frac32.positive input
None
// FOUR 74HC595 SHIFT REGISTERS
// by paul
int32_t in1;
uint8_t *txbuf;
void setup(void) {
static uint8_t _txbuf[32] __attribute__((section(".sram2")));
txbuf = _txbuf;
}
void loop(void) {
spiSelect(&SPID1);
txbuf[0] = (in1 >> 24); // SHIFTREGISTER 1
txbuf[1] = (in1 >> 16); // SHIFTREGISTER 2
txbuf[2] = (in1 >> 8); // SHIFTREGISTER 3
txbuf[3] = (in1); // SHIFTREGISTER 4
spiSend(&SPID1, 4, txbuf);
spiUnselect(&SPID1);
chThdSleepMilliseconds(1);
}
msg_t ThreadX2() {
setup();
while (!chThdShouldTerminate()) {
loop();
chThdSleepMilliseconds(1);
}
chThdExit((msg_t)0);
}
static msg_t ThreadX(void *arg) { ((attr_parent *)arg)->ThreadX2(); }
WORKING_AREA(waThreadX, 1024);
Thread *Thd;
in1 = 0;
Thd = chThdCreateStatic(waThreadX, sizeof(waThreadX), NORMALPRIO, ThreadX,
(void *)this);
this->in1 = inlet_in;
chThdTerminate(Thd);
chThdWait(Thd);