view src/cs/drivers/drv_core/spi/spi_drv.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 4e78acac3d88
children
line wrap: on
line source

/**********************************************************************************/
/*            TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION              */
/*                                                                                */
/*   Property of Texas Instruments -- For  Unrestricted  Internal  Use  Only      */
/*   Unauthorized reproduction and/or distribution is strictly prohibited.  This  */
/*   product  is  protected  under  copyright  law  and  trade  secret law as an  */
/*   unpublished work.  Created 1987, (C) Copyright 1997 Texas Instruments.  All  */
/*   rights reserved.                                                             */
/*                                                                                */
/*                                                                                */
/*   Filename          : spi_drv.c                                                */
/*                                                                                */
/*   Description       : Functions to drive the SPI module.                       */
/*                       The Serial Port Interface is a bidirectional 3 lines 	  */
/*                       interface dedicated to the transfer of data to and 	  */
/*                       from up to 5 external devices offering a 3 lines 		  */
/*                       serial interface.										  */
/*						 In this project, it is only used to connect the TI 	  */
/*						 Analog BaseBand (ABB).				    				  */
/*						 It is assumed that the ABB is connected as the SPI       */																				  
/*                       device 0.                                                */																				  
/*																				  */
/*                       This interface is specified to be compatible with 		  */
/*                       the UMA1018M Philips, the FUJITSU MB15F02, the 		  */
/*                       SIEMENS PMB2306T synthesizers and the TI ABB.			  */
/*																				  */
/*                       This serial port is based on a looped shift-register 	  */
/*                       thus allowing both transmit (PISO) and receive (SIPO) 	  */
/*                       modes.													  */
/*																				  */
/*                                                                                */
/*   Author            : Pascal PUEL                                              */
/*                                                                                */
/*   Version number   : 1.45                                                       */
/*                                                                                */
/*   Date and time    : 07/01/03                                                       */
/*                                                                                */
/*   Previous delta   : Rework                                                    */
/*                                                                                */
/**********************************************************************************/

#include "spi/spi_drv.h"



/*-----------------------------------------------------------------------*/
/* SPI_InitDev()                                                         */
/*                                                                       */
/* This function initializes the SPI registers for an external device    */
/* connected to the serial port.                                         */
/*                                                                       */
/*-----------------------------------------------------------------------*/    
void SPI_InitDev(T_SPI_DEV *Device)
{
  unsigned short Param,Gate,Shiftval;
  unsigned short Mask = 0x7bde;

  /* Clock enable, mask ITs and pre scale setting */
  * (volatile SYS_UWORD16 *) SPI_REG_SET1 = (SPI_CLK_ON | Device->PrescVal | SPI_IT_MASK_0 | SPI_IT_MASK_1);

  /* Building the parameter for REG_SET2 initialization */
  Shiftval = Device->DevId >> 7;
  Param = (Device->ClkEdge | Device->TspEnLevel | Device->TspEnForm)<<Shiftval ;
  Gate = Mask<<Shiftval;   
  
  * (volatile SYS_UWORD16 *) SPI_REG_SET2 = (* (volatile SYS_UWORD16 *) SPI_REG_SET2 & Gate) | Param;


  /* Configuring CTRL_REG : this writting erases the previous one */
  * (volatile SYS_UWORD16 *) SPI_REG_CTRL = (Device->DataTrLength | Device->DevId);

  /* Stop the SPI clock */
  #ifdef SPI_CLK_LOW_POWER    
    SPI_CLK_DISABLE
  #endif
}