void UART0_IRQHandler(void) {
// handles tx - same as default handler
if ((Chip_UART_GetStatus(_uart_ptr) & UART_STAT_TXRDY) != 0) {
Chip_UART_TXIntHandlerRB(_uart_ptr, &_txring);
if (RingBuffer_IsEmpty(&_txring)) {
Chip_UART_IntDisable(_uart_ptr, UART_INTEN_TXRDY);
}
}
// handles rx
while ((Chip_UART_GetStatus(_uart_ptr) & UART_STAT_RXRDY) != 0) {
uint8_t current_char = Chip_UART_ReadByte(_uart_ptr);
Chip_UART_IntDisable(_uart_ptr, UART_INTEN_RXRDY);
if(current_char == YOUR_CHAR) {
// do something
} else {
// otherwise, store it in the ring buffer
RingBuffer_Insert(&_rxring, ¤t_char );
}
Chip_UART_IntEnable(_uart_ptr, UART_INTEN_RXRDY);
}
}
|
void UART0_IRQHandler(void) {
// handles tx - same as default handler
if ((Chip_UART_GetStatus(_uart_ptr) & UART_STAT_TXRDY) != 0) {
Chip_UART_TXIntHandlerRB(_uart_ptr, &_txring);
if (RingBuffer_IsEmpty(&_txring)) {
Chip_UART_IntDisable(_uart_ptr, UART_INTEN_TXRDY);
}
}
// handles rx
while ((Chip_UART_GetStatus(_uart_ptr) & UART_STAT_RXRDY) != 0) {
uint8_t current_char = Chip_UART_ReadByte(_uart_ptr);
Chip_UART_IntDisable(_uart_ptr, UART_INTEN_RXRDY);
if(current_char == YOUR_CHAR) {
// do something
} else {
// otherwise, store it in the ring buffer
RingBuffer_Insert(&_rxring, ¤t_char );
}
Chip_UART_IntEnable(_uart_ptr, UART_INTEN_RXRDY);
}
}
|