uint8_t sendByte(uint8_t data, uint8_t channel) { cli(); uint8_t tries = 1 ; #ifdef USE_UART if (channel == 2) { sei(); return FALSE; } #endif while (1) { if (tx_parity_error || tries) { if (txChar(data, channel)) { sei(); return TRUE; } else if (tries > 0) { tries--; } } else { sei(); return FALSE; } } }
void serialRegsPoll( void ) { StructUSART *usart = DEFUART ; unsigned short csr = usart->US_CSR ; while( ( 0 != (csr & US_TXRDY) ) && ( txAdd != txTake ) ) { usart->US_THR = txBuf[txTake++]; csr = usart->US_CSR ; } if( txAdd == txTake ){ txAdd = txTake = 0 ; } // reset to beginning while( 0 != (csr & US_RXRDY ) ){ unsigned char inChar = usart->US_RHR ; if( '\r' == inChar ){ // process data here rxBuf[rxAdd] = 0 ; process(); tx( prompt ); } else if( '\b' == inChar ){ if( rxAdd >= 1 ){ --rxAdd ; tx( "\b \b" ); } } else if( ('U'-'@') == inChar ){ if( rxAdd >= 1 ){ rxAdd = 0 ; tx( "^U\r\n" ); } } else { txChar(inChar); rxBuf[rxAdd++] = inChar ; rxAdd &= RXBUFMASK ; } csr = usart->US_CSR ; } }
uint8_t sendByte(uint8_t data, uint8_t channel) { // signed int tries = TX_TRIES; signed int tries = 1 ; #ifdef USE_UART if (channel == 2) return FALSE; #endif while (1) { if (tx_parity_error || tries) { if (txChar(data, channel)) { return TRUE; } else if (tries > 0) { tries--; } } else { return FALSE; } } }