CARME-M4 BSP
V1.5
Main Page
Related Pages
Modules
Data Structures
Files
Examples
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_Cmd
(
CARME_UART0
, DISABLE);
USART_ITConfig
(
CARME_UART0
, USART_IT_RXNE, ENABLE);
USART_Cmd
(
CARME_UART0
, 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) {
c =
USART_ReceiveData
(
CARME_UART0
);
USART_SendData
(
CARME_UART0
, c);
}
}
Generated on Fri Aug 12 2016 17:42:38 for CARME-M4 BSP by
1.8.10