view src/cs/drivers/drv_app/spi/spi_process.c @ 303:f76436d19a7a default tip

!GPRS config: fix long-standing AT+COPS chance hanging bug There has been a long-standing bug in FreeCalypso going back years: sometimes in the AT command bring-up sequence of an ACI-only MS, the AT+COPS command would produce only a power scan followed by cessation of protocol stack activity (only L1 ADC traces), instead of the expected network search sequence. This behaviour was seen in different FC firmware versions going back to Citrine, and seemed to follow some law of chance, not reliably repeatable. This bug has been tracked down and found to be specific to !GPRS configuration, stemming from our TCS2/TCS3 hybrid and reconstruction of !GPRS support that was bitrotten in TCS3.2/LoCosto version. ACI module psa_mms.c, needed only for !GPRS, was missing in the TCS3 version and had to be pulled from TCS2 - but as it turns out, there is a new field in the MMR_REG_REQ primitive that needs to be set correctly, and that psa_mms.c module is the place where this initialization needed to be added.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 08 Jun 2023 08:23:37 +0000
parents 34b7059b9337
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


/*******************************************************************************
** Function         spi_process
**
*******************************************************************************/
UINT8 spi_process(T_RV_HDR * msg_ptr)
{
   UINT16 data ;

   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);

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

            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;
}