/** **************************************************************************************** * @brief Serves the receive data available interrupt requests. It clears the requests and * executes the callback function. * * @return void **************************************************************************************** */ static void uart_sps_rec_data_avail_isr(void) { void (*callback) (uint8_t, uint32_t) = NULL; uint32_t sent_bytes = 0; while (uart_data_rdy_getf()) { // Read the received in the FIFO readData = uart_rxdata_getf(); #if (UART_SW_FLOW_ENABLED) if(readData == UART_XON_BYTE) { //callback function will tell application that XOFF is received *uart_sps_env.rx.state = UART_XON; } else if(readData == UART_XOFF_BYTE) { //callback function will tell application that XON is received *uart_sps_env.rx.state = UART_XOFF; app_override_ble_xoff(); } else #endif /*UART_SW_FLOW_ENABLED*/ { //put data in buffer *uart_sps_env.rx.bufptr = readData; //update RX parameters uart_sps_env.rx.size--; sent_bytes++; uart_sps_env.rx.bufptr++; } // Check if all expected data have been received if (uart_sps_env.rx.size == 0) { // Reset RX parameters uart_sps_env.rx.bufptr = NULL; // Retrieve callback pointer callback = uart_sps_env.rx.callback; if(callback != NULL) { // Clear callback pointer uart_sps_env.rx.callback = NULL; // Call handler callback(UART_STATUS_OK, sent_bytes); } else { ASSERT_ERR(0); } // Exit loop break; } } }
/** **************************************************************************************** * @brief Checks if there are available data in FIFO. It is called by uart timeout * interrupt. * * @return void **************************************************************************************** */ static void uart_sps_timeout_data_avail_isr(void) { void (*callback) (uint8_t, uint32_t); uint32_t sent_bytes = 0; //get remaining data while (uart_data_rdy_getf()) { // Read the received in the FIFO readData = uart_rxdata_getf(); #if (UART_SW_FLOW_ENABLED) if(readData == UART_XON_BYTE) { //callback function will return that a XON is received *uart_sps_env.rx.state = UART_XON; } else if(readData == UART_XOFF_BYTE) { //callback function will return that a XON is received *uart_sps_env.rx.state = UART_XOFF; app_override_ble_xoff(); } else #endif /*UART_SW_FLOW_ENABLED*/ { //put data in buffer *uart_sps_env.rx.bufptr = readData; //update RX parameters uart_sps_env.rx.size--; sent_bytes++; uart_sps_env.rx.bufptr++; } } *uart_sps_env.rx.bufptr = 0; //terminate pointer // Reset RX parameters uart_sps_env.rx.bufptr = NULL; uart_sps_env.rx.size = 0; // Retrieve callback pointer callback = uart_sps_env.rx.callback; // Clear callback pointer uart_sps_env.rx.callback = NULL; // Call callback callback(UART_STATUS_TIMEOUT, sent_bytes); }
void gpio0_callback(void) { NVIC_DisableIRQ(GPIO0_IRQn); // Disable this interrupt if(GPIO_GetPinStatus(UART1_CTS_PORT, UART1_CTS_PIN)==FALSE) { app_override_ble_xon(); //Set interrupt to detect rising edge of CTS GPIO_EnableIRQ(UART1_CTS_PORT, UART1_CTS_PIN, GPIO0_IRQn, 0, 1, 0); } else if(GPIO_GetPinStatus(UART1_CTS_PORT, UART1_CTS_PIN)==TRUE) { app_override_ble_xoff(); //Set interrupt to detect falling edge of CTS GPIO_EnableIRQ(UART1_CTS_PORT, UART1_CTS_PIN, GPIO0_IRQn, 1, 0, 0); } NVIC_ClearPendingIRQ(GPIO0_IRQn); NVIC_EnableIRQ(GPIO0_IRQn); // Enable this interrupt }