/****************************************************************************** * @fn HalUARTPollISR * * @brief Poll a USART module implemented by ISR. * * @param none * * @return none *****************************************************************************/ static void HalUARTPollISR(void) { if (isrCfg.uartCB != NULL) { uint16 cnt = HAL_UART_ISR_RX_AVAIL(); uint8 evt = 0; if (isrCfg.rxTick) { // Use the LSB of the sleep timer (ST0 must be read first anyway). uint8 decr = ST0 - isrCfg.rxShdw; if (isrCfg.rxTick > decr) { isrCfg.rxTick -= decr; } else { isrCfg.rxTick = 0; } } isrCfg.rxShdw = ST0; if (cnt >= HAL_UART_ISR_RX_MAX-1) { evt = HAL_UART_RX_FULL; } else if (cnt >= HAL_UART_ISR_HIGH) { evt = HAL_UART_RX_ABOUT_FULL; } else if (cnt && !isrCfg.rxTick) { evt = HAL_UART_RX_TIMEOUT; } if (isrCfg.txMT) { isrCfg.txMT = 0; evt |= HAL_UART_TX_EMPTY; } if (evt) { isrCfg.uartCB(HAL_UART_ISR-1, evt); } } }
/************************************************************************************************** * @fn HalUARTRxAvailISR() * * @brief Calculate Rx Buffer length - the number of bytes in the buffer. * * @param none * * @return length of current Rx Buffer **************************************************************************************************/ static uint16 HalUARTRxAvailISR(void) { return HAL_UART_ISR_RX_AVAIL(); }