Created
November 21, 2016 08:04
-
-
Save AlexanderSavochkin/dc11bdefbcc63d7013777dbe75afa808 to your computer and use it in GitHub Desktop.
sam3x8e UART interrupt handler stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// IT handlers | |
void UART_Handler(void) | |
{ | |
uint32_t status = UART->UART_SR; | |
//Did we receive new byte? | |
if ((status & UART_SR_RXRDY) == UART_SR_RXRDY) | |
{ | |
//Read new byte from UART_RHR | |
uint8_t c = UART->UART_RHR; | |
//Do something else | |
.... | |
} | |
//Is transmitter is ready to send new data? | |
if ((status & UART_SR_TXRDY) == UART_SR_TXRDY) | |
{ | |
uint8_t c = ... // | |
UART->UART_THR = c; | |
... | |
} | |
// Acknowledge errors | |
if ((status & UART_SR_OVRE) == UART_SR_OVRE || (status & UART_SR_FRAME) == UART_SR_FRAME) | |
{ | |
//Process error | |
... | |
//Reset error | |
UART->UART_CR |= UART_CR_RSTSTA; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment