Skip to content

Instantly share code, notes, and snippets.

@AlexanderSavochkin
Created November 21, 2016 08:04
Show Gist options
  • Save AlexanderSavochkin/dc11bdefbcc63d7013777dbe75afa808 to your computer and use it in GitHub Desktop.
Save AlexanderSavochkin/dc11bdefbcc63d7013777dbe75afa808 to your computer and use it in GitHub Desktop.
sam3x8e UART interrupt handler stub
// 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