void UART2_IRQHandler(void) { if(UART_GetITStatus(MDR_UART2,UART_IT_RX) == SET) { UART_ClearITPendingBit(MDR_UART2,UART_IT_RX); } }
void UART1_IRQHandler(void) { static uint8_t cnt_rx_byte=0; static bool start=false; uint8_t tmp=0; if(UART_GetITStatus(MDR_UART1,UART_IT_RX) == SET) { UART_ClearITPendingBit(MDR_UART1,UART_IT_RX); tmp=UART_ReceiveData(MDR_UART1); if((tmp==0xAA) && (!start)) { start=true; } else { if(start) { if(!RX_ok) ArrayRX_PKBA[cnt_rx_byte]=tmp; ++cnt_rx_byte; if(cnt_rx_byte==RX_FRAME_SIZE) { RX_ok=true; start=false; cnt_rx_byte=0; } } } } MDR_UART1->RSR_ECR = 0; }
/******************************************************************************* * Function Name : UART2_IRQHandler * Description : This function handles UART2 global interrupt request. * Input : None * Output : None * Return : None *******************************************************************************/ void UART2_IRQHandler(void) { if (UART_GetITStatusMasked(MDR_UART2, UART_IT_RX) == SET) { UART_ClearITPendingBit(MDR_UART2, UART_IT_RX); uart2_IT_RX_flag = SET; } }
void UART0_IRQHandler(void) { u8 c; // if receive irq (FIFO is over trigger level) or receive timeout irq (FIFO is not empty for longer times) has occured if((UART_GetITStatus(UART0, UART_IT_Receive) != RESET) || (UART_GetITStatus(UART0, UART_IT_ReceiveTimeOut) != RESET) ) { UART_ClearITPendingBit(UART0, UART_IT_Receive); // clear receive interrupt flag UART_ClearITPendingBit(UART0, UART_IT_ReceiveTimeOut); // clear receive timeout interrupt flag // if debug UART is UART0 if (DebugUART == UART0) { // forward received data to the UART1 tx buffer while(UART_GetFlagStatus(UART0, UART_FLAG_RxFIFOEmpty) != SET) { // wait for space in the tx buffer of the UART1 while(UART_GetFlagStatus(UART1, UART_FLAG_TxFIFOFull) == SET) {}; // move the byte from the rx buffer of UART0 to the tx buffer of UART1 UART_SendData(UART1, UART_ReceiveData(UART0)); } } else // UART0 is not the DebugUART (normal operation) { // repeat until no byte is in the RxFIFO while (UART_GetFlagStatus(UART0, UART_FLAG_RxFIFOEmpty) != SET) { c = UART_ReceiveData(UART0); // get byte from rx fifo switch(UART0_Muxer) { case UART0_MKGPS: UBX_RxParser(c); // if connected to GPS forward byte to ubx parser MKProtocol_CollectSerialFrame(&UART0_rx_buffer, c); // ckeck for MK-Frames also break; case UART0_MK3MAG: // ignore any byte send from MK3MAG break; case UART0_UNDEF: default: // ignore the byte from unknown source break; } // eof switch(UART0_Muxer) } // eof while } // eof UART0 is not the DebugUART } // eof receive irq or receive timeout irq }
void UART2_IRQHandler(void) { struct mm32_uart *uart; uart = &uart2; /* enter interrupt */ rt_interrupt_enter(); if (UART_GetITStatus(uart->uart_device, UART_IT_RXIEN) != RESET) { UART_ClearITPendingBit(uart->uart_device, UART_IT_RXIEN); rt_hw_serial_isr(&serial2, RT_SERIAL_EVENT_RX_IND); } if (UART_GetITStatus(uart->uart, UART_IT_TXIEN) != RESET) { /* clear interrupt */ UART_ClearITPendingBit(uart->uart, UART_IT_TXIEN); } /* leave interrupt */ rt_interrupt_leave(); }
//================================================================================== void UART1_send_byte(uint8_t byte) { UART_SendData(MDR_UART1,byte); //time_out_byte=0; //while(!UART_GetFlagStatus (MDR_UART1,UART_FLAG_RXFF)) //while(UART_GetFlagStatus (MDR_UART1,UART_FLAG_BUSY) || !UART_GetFlagStatus (MDR_UART1,UART_FLAG_RXFF)) while(UART_GetFlagStatus (MDR_UART1,UART_FLAG_BUSY)) { } UART_ReceiveData (MDR_UART1); UART_ClearITPendingBit(MDR_UART1,UART_IT_RX); }
__arm void vSerialISR( void ) { signed char cChar; portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; do { if( UART0->MIS & UART_IT_Transmit ) { /* The interrupt was caused by the THR becoming empty. Are there any more characters to transmit? */ if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE ) { /* A character was retrieved from the queue so can be sent to the THR now. */ UART0->DR = cChar; } else { xQueueEmpty = pdTRUE; } UART_ClearITPendingBit( UART0, UART_IT_Transmit ); } if( UART0->MIS & UART_IT_Receive ) { /* The interrupt was caused by a character being received. Grab the character from the RHR and place it in the queue of received characters. */ cChar = UART0->DR; xQueueSendFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken ); UART_ClearITPendingBit( UART0, UART_IT_Receive ); } } while( UART0->MIS ); /* If a task was woken by either a character being received or a character being transmitted then we may need to switch to another task. */ portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ); }
void UART1_Handler(void) { uint8_t ch; if(UART_GetITStatus(UART1,UART_IT_FLAG_RXI)) { ch = UART_ReceiveData(UART1); uart1_rx_cnt++; } else if(UART_GetITStatus(UART1,UART_IT_FLAG_TXI)) { UART_ClearITPendingBit(UART1,UART_IT_FLAG_TXI); uart1_tx_cnt++; } }
void INT_UART0_Handler(void) { uint32_t temp_1; if (UART_GetITStatusMasked(MDR_UART0, UART_IT_RX) == SET) { temp_1 = UART_ReceiveData(MDR_UART0); UART_ClearITPendingBit(MDR_UART0, UART_IT_RX); while (UART_GetFlagStatus (MDR_UART0, UART_FLAG_TXFE)!= SET) { } UART_SendData (MDR_UART0,temp_1); } }
void UART1_IRQHandler(void) { uint32_t temp_1; //UARTx_HandlerWork(MDR_UART2); if (UART_GetITStatusMasked(MDR_UART1, UART_IT_RX) == SET) { temp_1 = MDR_UART1->DR; UART_ClearITPendingBit(MDR_UART1, UART_IT_RX); while (UART_GetFlagStatus (MDR_UART1, UART_FLAG_TXFE)!= SET) { } UART_SendData (MDR_UART1,0x44); } }
void UART1_Handler(void) { if(UART_GetITStatus(UART1, UART_IT_FLAG_RXI)) { UART_ClearITPendingBit(UART1, UART_IT_FLAG_RXI); if( (u1rx_wr > u1rx_rd && u1rx_wr-u1rx_rd >= U1RX_BUF_SIZE-1) ||(u1rx_wr < u1rx_rd && u1rx_rd == u1rx_wr+1) ) // Buffer Overflow { UART_SendData(UART1, (uint8_t)'@'); return; } u1rx_buf[u1rx_wr] = (uint8_t)UART_ReceiveData(UART1); if(u1rx_wr < U1RX_BUF_SIZE-1) u1rx_wr++; else u1rx_wr = 0; } }
void UART1_send_byte(uint8_t byte) { UART_SendData(MDR_UART1,byte); time_out_byte = 0; /*while(!UART_GetFlagStatus (MDR_UART1,UART_FLAG_RXFF)) { if( time_out_byte>3) break; } UART_ReceiveData (MDR_UART1); */ while(UART_GetFlagStatus (MDR_UART1,UART_FLAG_BUSY) || !UART_GetFlagStatus (MDR_UART1,UART_FLAG_RXFF)) { // if(time_out_byte>3) // break; } UART_ReceiveData (MDR_UART1); UART_ClearITPendingBit(MDR_UART1,UART_IT_RX); }
// ----------------------------------------------------------------------------- void UBloxUARTHandler(void) { UART_ClearITPendingBit(UART0, UART_IT_Receive); ReceiveUBloxData(); }