May 2020
Intermediate to advanced
496 pages
13h 54m
English
The startReceiveInt function is very similar to the one used for the queue-based driver:
static bool rxInProgress = false;static uint_fast16_t rxLen = 0;static uint8_t* rxBuff = NULL;static uint_fast16_t rxItr = 0;int32_t startReceiveInt( uint8_t* Buffer, uint_fast16_t Len ){ if(!rxInProgress && (Buffer != NULL)) { rxInProgress = true; rxLen = Len; rxBuff = Buffer; rxItr = 0; USART2->CR3 |= USART_CR3_EIE; //enable error interrupts USART2->CR1 |= (USART_CR1_UE | USART_CR1_RXNEIE); NVIC_SetPriority(USART2_IRQn, 6); NVIC_EnableIRQ(USART2_IRQn); return 0; } return -1;}
Here are the notable differences in this setup: