/** * USART interrupt handler. */ void usart1_isr(void) { //TOGGLE(GREEN); /* input (RX) handler */ if ((USART_SR(USART1) & USART_SR_RXNE) != 0) { data_buf = usart_recv(USART1); if (gpc_handle_byte((u8)data_buf) != 0) { //LED_GREEN_TOGGLE(); } else { //LED_RED_ON(); } } /* output (TX) handler */ if ((USART_SR(USART1) & USART_SR_TXE) != 0) { if ((data_buf = gpc_pickup_byte()) >= 0) { usart_send(USART1, (uint16_t)data_buf); //LED_GREEN_TOGGLE(); } else { usart_disable_send(); } } }
void usart3_irq_handler(void) { /* input (RX) handler */ if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET){ data_buf = USART_ReceiveData(USART3); if(!gpc_handle_byte(data_buf)){ LED_GREEN_TOGGLE(); }else{ LED_RED_ON(); } } /* output (TX) handler */ if(USART_GetITStatus(USART3, USART_IT_TXE) != RESET){ if((data_buf = gpc_pickup_byte()) >= 0){ USART_SendData(USART3, data_buf); LED_GREEN_TOGGLE(); }else{ usart_disable_send(); } } }