view src/cs/drivers/drv_app/spi/spi_process.c @ 600:8f50b202e81f

board preprocessor conditionals: prep for more FC hw in the future This change eliminates the CONFIG_TARGET_FCDEV3B preprocessor symbol and all preprocessor conditionals throughout the code base that tested for it, replacing them with CONFIG_TARGET_FCFAM or CONFIG_TARGET_FCMODEM. These new symbols are specified as follows: CONFIG_TARGET_FCFAM is intended to cover all hardware designs created by Mother Mychaela under the FreeCalypso trademark. This family will include modem products (repackagings of the FCDEV3B, possibly with RFFE or even RF transceiver changes), and also my desired FreeCalypso handset product. CONFIG_TARGET_FCMODEM is intended to cover all FreeCalypso modem products (which will be firmware-compatible with the FCDEV3B if they use TI Rita transceiver, or will require a different fw build if we switch to one of Silabs Aero transceivers), but not the handset product. Right now this CONFIG_TARGET_FCMODEM preprocessor symbol is used to conditionalize everything dealing with MCSI. At the present moment the future of FC hardware evolution is still unknown: it is not known whether we will ever have any beyond-FCDEV3B hardware at all (contingent on uncertain funding), and if we do produce further FC hardware designs, it is not known whether they will retain the same FIC modem core (triband), if we are going to have a quadband design that still retains the classic Rita transceiver, or if we are going to switch to Silabs Aero II or some other transceiver. If we produce a quadband modem that still uses Rita, it will run exactly the same fw as the FCDEV3B thanks to the way we define TSPACT signals for the RF_FAM=12 && CONFIG_TARGET_FCFAM combination, and the current fcdev3b build target will be renamed to fcmodem. OTOH, if that putative quadband modem will be Aero-based, then it will require a different fw build target, the fcdev3b target will stay as it is, and the two targets will both define CONFIG_TARGET_FCFAM and CONFIG_TARGET_FCMODEM, but will have different RF_FAM numbers. But no matter which way we are going to evolve, it is not right to have conditionals on CONFIG_TARGET_FCDEV3B in places like ACI, and the present change clears the way for future evolution.
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 01 Apr 2019 01:05:24 +0000
parents 945cf7f506b2
children
line wrap: on
line source

/*****************************************************************************/
/*                                                                           */
/*  Name       spi_process.c                                                 */
/*                                                                           */
/*  Function    this file contains the spi_process function, used to         */
/*				handle messages received in the SPI mailbox, and used to 	 */
/*              access the ABB. It is called by the spi task core.           */
/*                                                                           */
/*  Version    0.1                                                           */
/*                                                                           */
/*  Date       Modification                                                  */
/*  ------------------------------------                                     */
/*  20/08/2000 Create                                                        */
/*                                                                           */
/* Author                                                                    */
/*                                                                           */
/* (C) Copyright 2000 by Texas Instruments Incorporated, All Rights Reserved */
/*****************************************************************************/

#include "rvf/rvf_api.h"
#include "spi/spi_api.h"
#include "rvm/rvm_use_id_list.h"
#include "spi/spi_process.h"
#include "rv/rv_defined_swe.h"	   // for RVM_PWR_SWE



//#ifndef _WINDOWS
//#include "iq.h"
//#endif

/*******************************************************************************
** Function         spi_process
**
*******************************************************************************/
UINT8 spi_process(T_RV_HDR * msg_ptr)
{
   UINT16 data ;
//   static UINT8 int_nb = 0;

   if(msg_ptr != NULL)
   {
      switch (msg_ptr->msg_id)
      {
         case ABB_EXT_IRQ_EVT:
		 {
            /* Call to the low-level driver function : interrupt status register reading */
            data = ABB_Read_Register_on_page(PAGE0, ITSTATREG);

//#ifndef _WINDOWS
            // SW workaround to avoid an ABB interrupt occuring to early after the application start.
			// The first ABB interrupt is skipped.

//            if((int_nb == 0) && (data == ADCEND_IT_STS))
//            {
//              int_nb++;

              /* Unmask keypad interrupt */
//              IQ_Unmask(IQ_EXT);
//            }
//            else
//            {

			/* Callback function */
//            if(msg_ptr->callback_func != NULL)
//            {
//               msg_ptr->callback_func(&data);
//            }
//          }
//#else

            /* Callback function */
            if(msg_ptr->callback_func != NULL)
            {
               msg_ptr->callback_func(&data);
            }
//#endif

            rvf_free_buf ((void *) msg_ptr);

		   break;
		 }

         case SPI_ABB_READ_EVT:
		 {
           rvf_send_trace("SPI_task: SPI_READ_ABB_EVT received", 35, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);

           /* Call to the low-level driver function */
           data = ABB_Read_Register_on_page(((T_SPI_READ *)msg_ptr)->page, ((T_SPI_READ *)msg_ptr)->address);

           /*  Callback function */
           if(((T_SPI_READ *)msg_ptr)->os_hdr.callback_func != NULL)
           {
              ((T_SPI_READ *)msg_ptr)->os_hdr.callback_func(&data);
           }

           rvf_free_buf ((void *) msg_ptr);

           return 0;
		 }

         case SPI_ABB_WRITE_EVT:
		 {
           rvf_send_trace("SPI_task: SPI_WRITE_ABB_EVT received", 36, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);

           /* Call to the low-level driver function */
           ABB_Write_Register_on_page(((T_SPI_WRITE *)msg_ptr)->page, ((T_SPI_WRITE *)msg_ptr)->address, ((T_SPI_WRITE *)msg_ptr)->data);

           rvf_free_buf ((void *) msg_ptr);

           return 0;
		 }

         case SPI_ABB_CONF_ADC_EVT:
		 {
           rvf_send_trace("SPI_task: SPI_ABB_CONF_ADC_EVT received", 39, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);

           /* Call to the low-level driver function */
           ABB_Conf_ADC(((T_SPI_ABB_CONF_ADC *)msg_ptr)->channels, ((T_SPI_ABB_CONF_ADC *)msg_ptr)->itval);                              

           rvf_free_buf ((void *) msg_ptr);

           return 0;
		 }

         case SPI_ABB_READ_ADC_EVT:
		 {
           rvf_send_trace("SPI_task: SPI_ABB_READ_ADC_EVT received", 39, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);

           /* Call to the low-level driver function */
           ABB_Read_ADC(((T_SPI_ABB_READ_ADC *)msg_ptr)->Buff);

           /* Callback function */
           if(((T_SPI_ABB_READ_ADC *)msg_ptr)->callback_func != NULL)
           {
              ((T_SPI_ABB_READ_ADC *)msg_ptr)->callback_func();
           }

           rvf_free_buf ((void *) msg_ptr);

           return 0;
		 }

         default:
		 {
           /* Unknown message has been received */
           #ifdef RVM_PWR_SWE
           rvf_send_trace("SPI_task : Received an unknown or a PWR message",47, NULL_PARAM ,
                           RV_TRACE_LEVEL_DEBUG_HIGH, SPI_USE_ID);
           #else
           rvf_send_trace("SPI_task : Received an unknown message",38, NULL_PARAM ,
                           RV_TRACE_LEVEL_DEBUG_HIGH, SPI_USE_ID);

           rvf_free_buf ((void *) msg_ptr);
           #endif
		   
           return 1; 
		 }
      }	   // end of switch
   }	// end of if (msg_ptr != NULL)
   return 0;
}