Could someone help me understand the purpose of the tx_computer_byte subroutine?
Code: Select all
uint8_t tx_computer_byte(uint8_t b) {
uint8_t v;
DDRA = 0x0; // outputs
DDRB = 0x5F; // input on MOSI/DI (for SPI), all others output
USICR = _BV(USIWM0) | _BV(USICS1);
USIDR = b; // transfer 0x0
USISR = _BV(USIOIF); // ready
while (! (USISR & _BV(USIOIF)) ) {
asm("wdr");
if (sensor_timer == 0xFFFF) {
stopcomputertx = 1;
}
if (stopcomputertx) {
break;
}
}
v = USIDR;
DDRB = 0xDF;
USICR = 0;
return v;
}
Thanks!