本人初学CYBLE,求大神指导
这里的UART中断要怎么使用呢?
是指外面的MCU串口发给蓝牙芯片的UART中断吗?还是蓝牙天线接收数据后的中断?
函数在BLE_HAL_INT.C源文件里面
/*******************************************************************************
* Function Name: CyBLE_Uart_Interrupt
********************************************************************************
*
* Summary:
* Handles the Interrupt Service Routine for the UART.
*
* Parameters:
* None
*
* Return:
* None
*
*******************************************************************************/
CY_ISR(CyBLE_Uart_Interrupt)
{
uint8 uartTxStatus = CyBLE_INTR_TX_SUCCESS;
uint32 srcInterrupt = 0u;
uint8 length = 0u;
uint8 srcCount = 0u;
uint8 uartRxStatus = CyBLE_INTR_RX_SUCCESS;
uint8 receivedData[BLE_HAL_Uart_FIFO_SIZE] = {0u};
/* Evaluate RX interrupt event */
srcInterrupt = BLE_HAL_Uart_GetRxInterruptSourceMasked();
if(0u != (srcInterrupt & BLE_HAL_Uart_INTR_RX_NOT_EMPTY))
{
if(0u != (srcInterrupt & BLE_HAL_Uart_INTR_RX_PARITY_ERROR))
{
uartRxStatus |= CyBLE_INTR_RX_PARITY_ERROR;
}
if(0u != (srcInterrupt & BLE_HAL_Uart_INTR_RX_FRAME_ERROR))
{
uartRxStatus |= CyBLE_INTR_RX_FRAME_ERROR;
}
if(0u != (srcInterrupt & BLE_HAL_Uart_INTR_RX_OVERFLOW))
{
uartRxStatus |= CyBLE_INTR_RX_OVERFLOW;
}
if(uartRxStatus == CyBLE_INTR_RX_SUCCESS)
{
length = (uint8)BLE_HAL_Uart_SpiUartGetRxBufferSize();
for(srcCount = 0u; srcCount < length; srcCount++)
{
receivedData[srcCount] = (uint8)BLE_HAL_Uart_SpiUartReadRxData();
}
}
else
{
BLE_HAL_Uart_SpiUartClearRxBuffer();
}
for(uartTxStatus = 0u; uartTxStatus < length; uartTxStatus++)
{
CyBLE_pf_handle_uart_rx_data(receivedData[uartTxStatus]);
}
BLE_HAL_Uart_ClearRxInterruptSource(srcInterrupt);
}
else
{
/* No RX interrupt. Do nothing. */
}
/* Evaluate TX interrupt event in sequence */
srcInterrupt = BLE_HAL_Uart_GetTxInterruptSourceMasked();
/* Stack manager TX uart complete */
if(0u != (srcInterrupt & BLE_HAL_Uart_INTR_TX_UART_DONE))
{
if(0u != (srcInterrupt & BLE_HAL_Uart_INTR_TX_OVERFLOW))
{
/*Stack manager TX uart error */
uartTxStatus |= CyBLE_INTR_TX_OVERFLOW;
}
CyBLE_pf_handle_uart_tx_complt();
BLE_HAL_Uart_ClearTxInterruptSource(srcInterrupt);
}
else
{
/* No TX interrupt. Do nothing. */
}
} |