/** * @brief IRQ handler for USART2 */ void USART2_IRQHandler(void) { // If transmit buffer empty interrupt if(USART_GetITStatus(USART2, USART_IT_TXE) != RESET) { uint8_t c; if (FIFO_Pop(&txFifo,&c) == 0) { // If buffer not empty USART_SendData(USART2, c); // Send data } else { // Turn off TXE interrupt USART_ITConfig(USART2, USART_IT_TXE, DISABLE); } } // If RX buffer not empty interrupt if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) { uint8_t c = USART_ReceiveData(USART2); // Get data from UART uint8_t res = FIFO_Push(&rxFifo, c); // Put data in RX buffer // Checking res to ensure no buffer overflow occurred if ((c == UART2_TERMINATOR) && (res == 0)) { gotFrame++; } } }
void USART3_PrintBlock(uint8_t* pdata, uint8_t len) { uint32_t i = 0; for(i = 0; i < len; i++) { FIFO_Push(usart3_tx_fifo, pdata[i]); } USART_ITConfig(USART3, USART_IT_TXE, ENABLE); }
/** * @brief Callback for receiving data from PC. * @param c Data sent from lower layer software. */ void COMM_RxCallback(char c) { uint8_t res = FIFO_Push(&rxFifo, c); // Put data in RX buffer // Checking res to ensure no buffer overflow occurred if ((c == COMM_TERMINATOR) && (res == 0)) { gotFrame++; } }
/** * @brief Send a char to USART2. * @details This function can be called in stubs.c _write * function in order for printf to work * * @param c Char to send. */ void COMM_Putc(uint8_t c) { // disable IRQ so it doesn't screw up FIFO count - leads to errors in transmission COMM_HAL_IrqDisable; FIFO_Push(&txFifo,c); // Put data in TX buffer COMM_HAL_TxEnable(); // Enable low level transmitter // enable IRQ again COMM_HAL_IrqEnable; }
/** * @brief Send a char to PC. * @details This function can be called in stubs.c _write * function in order for printf to work * * @param c Char to send. */ void COMM_Putc(char c) { // disable IRQ so it doesn't screw up FIFO count - leads to errors in transmission COMM_HAL_IrqDisable(); FIFO_Push(&txFifo,c); // Put data in TX buffer // enable transmitter if inactive if (!COMM_HAL_IsTxActive()) { COMM_HAL_TxEnable(); } // enable IRQ again COMM_HAL_IrqEnable(); }
void USART3_Print(uint8_t ch) { FIFO_Push(usart3_tx_fifo, ch); USART_ITConfig(USART3, USART_IT_TXE, ENABLE); }
/** * @brief Send a char to USART2. * @param c Char to send. */ void USART2_Putc(uint8_t c) { FIFO_Push(&txFifo,c); // Put data in TX buffer USART_ITConfig(USART2, USART_IT_TXE, ENABLE); // Enable transmit buffer empty interrupt }