1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
uint8_t var;
extern "C" void USART1_IRQHandler(void)
{
var = 1;
if(USART_GetITStatus(USART1, USART_IT_RXNE) == SET)
{
if ((USART1->SR & (USART_FLAG_NE|USART_FLAG_FE|USART_FLAG_PE|USART_FLAG_ORE)) == 0) // check for errors
{
rx1_buffer[rx1_wr_index++]= (uint8_t) (USART_ReceiveData(USART2)& 0xFF);
if (rx1_wr_index == RX_BUFFER_SIZE) rx1_wr_index=0;
if (++rx1_counter == RX_BUFFER_SIZE)
{
//rx1_counter=0;
rx1_buffer_overflow=1;
}
}
else USART_ReceiveData(USART2); // read data even if there is an error
//DrawChar(100, 100, TFT_BLUE, TFT_BLACK, (const uint8_t*) font8x8, '1', 10);
}
}
void read_msg()
{
uint8_t data;
if(var == 1)
{
USART_ITConfig(USART2, USART_IT_RXNE, DISABLE);
data=rx1_buffer[rx1_rd_index++];
DrawChar(100, 100, TFT_BLUE, TFT_BLACK, (const uint8_t*) font8x8, 'g', 10);
USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
}
}
|