Esempio n. 1
0
/**
 ****************************************************************************************
 * @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;
        }
    }
}
Esempio n. 2
0
/**
 ****************************************************************************************
 * @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);		
}
static void uart_rec_data_avail_isr(void)
{
    void (*callback) (uint8_t) = NULL;

    while (uart_data_rdy_getf())
    {
        // Read the received in the FIFO
        *uart_env.rx.bufptr = uart_rxdata_getf();

        // Update RX parameters
        uart_env.rx.size--;
        uart_env.rx.bufptr++;

        // Check if all expected data have been received
        if (uart_env.rx.size == 0)
        {
            // Reset RX parameters
            uart_env.rx.bufptr = NULL;

            // Disable Rx interrupt
            uart_rec_data_avail_setf(0);  //=SetBits16(UART_IER_DLH_REG, ETBEI_dlh0, 0); 

            // Retrieve callback pointer
            callback = uart_env.rx.callback;

            if(callback != NULL)
            {
                // Clear callback pointer
                uart_env.rx.callback = NULL;

                // Call handler
                callback(UART_STATUS_OK);
            }
            else
            {
                ASSERT_ERR(0);
            }

            // Exit loop
            break;
        }
    }
}
Esempio n. 4
0
/**
 ****************************************************************************************
 * @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) = NULL;
	
    while (uart_data_rdy_getf())
    {
        // Read the received in the FIFO
				readData = uart_rxdata_getf();
			
#if (UART_BYTESTUFFING_ENABLED && UART_SW_FLOW_ENABLED)
					if(stuffingByteReceived)
#endif /*bytestuffing enabled*/
					{
#if (UART_SW_FLOW_ENABLED)
							//reset flag
							stuffingByteReceived = 0;
						
							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;
									override_ble_xoff();

							}
							else if(readData == UART_STUFFING_BYTE)
							{
									//put data in buffer
									*uart_sps_env.rx.bufptr = readData; 
							
									//update RX parameters
									uart_sps_env.rx.size--;
									uart_sps_env.rx.bufptr++;
							}
#if (UART_BYTESTUFFING_ENABLED)							
							else
							{
									return;//this should never happen
							}	
					}
					else
					{		
						
							if(readData == UART_STUFFING_BYTE)
							{
									//set flag
									stuffingByteReceived = 1;
							}
#endif /*bytestuffing enabled*/
							else
#endif /*flow control enabled*/
							{
									//reset flag
									stuffingByteReceived = 0;
								
									//put data in buffer
									*uart_sps_env.rx.bufptr = readData;
									debug_uart_nb_bytes_received++;

									//update RX parameters
									uart_sps_env.rx.size--;
									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);
            }
            else
            {
                ASSERT_ERR(0);
            }

            // Exit loop
            break;
        }
		}
}
Esempio n. 5
0
/**
 ****************************************************************************************
 * @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);
	  
		//get remaining data
		while (uart_data_rdy_getf())
		{
			 // Read the received in the FIFO
				readData = uart_rxdata_getf();

#if (UART_BYTESTUFFING_ENABLED && UART_SW_FLOW_ENABLED)
				if(stuffingByteReceived)
#endif /*bytestuffing enabled*/
				{
#if (UART_SW_FLOW_ENABLED)
						//reset flag
						stuffingByteReceived = 0;
					
						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;
								override_ble_xoff();
						}
						else if(readData == UART_STUFFING_BYTE)
						{
								//put data in buffer
								*uart_sps_env.rx.bufptr = readData; 
								
								//update RX parameters
								uart_sps_env.rx.size--;
								uart_sps_env.rx.bufptr++;
						}
#if (UART_BYTESTUFFING_ENABLED)							
						else
						{
								return;//this should never happen
						}	
				}
				else
				{		
						if(readData == UART_STUFFING_BYTE)
						{
								//set flag
								stuffingByteReceived = 1;
						}
#endif /*bytestuffing enabled*/
						else
#endif /*flow control enabled*/
						{
								//reset flag
								stuffingByteReceived = 0;
							
								//put data in buffer
								*uart_sps_env.rx.bufptr = readData;
								debug_uart_nb_bytes_received++;						
								
								//update RX parameters
								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);		
}