static int __getc(void) { uint8_t bit; uint8_t ch; half_bit_delay(); if (rx_pin() != STARTBIT) return -1; /* Glitch */ bit_delay(); for (bit = 0; bit < 8; bit++) { ch = ch >> 1; if (rx_pin()) ch |= 1 << 7; bit_delay(); } if (rx_pin() != STOPBIT) return -2; /* Frame error */ return (int) ch; }
void get_char(volatile unsigned char *pins, unsigned char pin, char *rxbyte) { // // read character into rxbyte on pins pin // assumes line driver (inverts bits) // *rxbyte = 0; while (pin_test(*pins,pin)) // // wait for start bit // ; // // delay to middle of first data bit // half_bit_delay(); bit_delay(); // // unrolled loop to read data bits // if pin_test(*pins,pin) *rxbyte |= (1 << 0); else