CARME-M4 BSP  V1.5
usart_interrupt.c

This example shows how to receive bytes over the USART with interrupts.

/*
* This example shows how to receive bytes over the USART with interrupts.
* As UART the CARME_UART0 is used with the configuration 115200 8n1.
* The received bytes will be sent back to the CARME_UART0 (echo).
*/
#include <stm32f4xx.h>
#include <carme.h>
#include <uart.h>
uint8_t x = 0, y = 1;
int main(void) {
USART_InitTypeDef USART_InitStruct;
NVIC_InitTypeDef NVIC_InitStruct;
USART_StructInit(&USART_InitStruct);
USART_InitStruct.USART_BaudRate = 115200;
CARME_UART_Init(CARME_UART0, &USART_InitStruct);
USART_ITConfig(CARME_UART0, USART_IT_RXNE, ENABLE);
NVIC_InitStruct.NVIC_IRQChannel = USART1_IRQn;
NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0x0F;
NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0x0F;
NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStruct);
for (;;) {
}
return 0U;
}
void USART1_IRQHandler(void) {
uint8_t c;
while (USART_GetITStatus(CARME_UART0, USART_IT_RXNE) != RESET) {
}
}