Bladeren bron

Add initial files for PC98

core
tmk 11 jaren geleden
bovenliggende
commit
6f55cbee1d
1 gewijzigde bestanden met toevoegingen van 17 en 1 verwijderingen
  1. 17
    1
      protocol/serial_soft.c

+ 17
- 1
protocol/serial_soft.c Bestand weergeven

SERIAL_RXD_INT_ENTER() SERIAL_RXD_INT_ENTER()


uint8_t data = 0; uint8_t data = 0;

#ifdef SERIAL_BIT_ORDER_MSB #ifdef SERIAL_BIT_ORDER_MSB
uint8_t mask = 0x80; uint8_t mask = 0x80;
#else #else
uint8_t mask = 0x01; uint8_t mask = 0x01;
#endif #endif

#ifdef SERIAL_PARITY_ODD
uint8_t parity = 0;
#else
uint8_t parity = 1;
#endif

/* to center of start bit */ /* to center of start bit */
_delay_us(WAIT_US/2); _delay_us(WAIT_US/2);
do { do {


if (SERIAL_RXD_READ()) { if (SERIAL_RXD_READ()) {
data |= mask; data |= mask;
parity ^= 1;
} }
#ifdef SERIAL_BIT_ORDER_MSB #ifdef SERIAL_BIT_ORDER_MSB
mask >>= 1; mask >>= 1;
mask <<= 1; mask <<= 1;
#endif #endif
} while (mask); } while (mask);

/* to center of parity bit */
_delay_us(WAIT_US);
parity ^= SERIAL_RXD_READ();

/* to center of stop bit */ /* to center of stop bit */
_delay_us(WAIT_US); _delay_us(WAIT_US);
_delay_us(WAIT_US/2);


parity = 1;
uint8_t next = (rbuf_head + 1) % RBUF_SIZE; uint8_t next = (rbuf_head + 1) % RBUF_SIZE;
if (next != rbuf_tail) {
if (parity && next != rbuf_tail) {
rbuf[rbuf_head] = data; rbuf[rbuf_head] = data;
rbuf_head = next; rbuf_head = next;
} }