view src/cs/services/lls/lls_functions.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

/**
 * @file   lls_functions.c
 *
 * Implementation of LLS functions.
 *
 * @author   Laurent Sollier (l-sollier@ti.com)
 * @version 0.1
 */

/*
 * History:
 *
 *   Date          Author       Modification
 *  ----------------------------------------
 *  03/12/2002     L Sollier    Create
 *
 *
 * (C) Copyright 2002 by Texas Instruments Incorporated, All Rights Reserved
 */

#ifndef _WINDOWS
   #include "l1sw.cfg"
   #include "chipset.cfg"
#endif

#include "lls/lls_i.h"
#include "lls/lls_api.h"

#include "spi/spi_api.h"
#include "rvf/rvf_api.h"


/* Number of available equipment's */
#define NUMBER_OF_EQUIPMENT 3

/* Parameters for each EQUIPMENT */
typedef struct
{
   T_LLS_EQUIPMENT  equipment_sort;
   UINT16			page;
   UINT16			address;
   UINT8            bit;
} T_EQUIPMENT_PARAM;

/* Table of parameters for all the equipment's */
typedef T_EQUIPMENT_PARAM T_EQUIPMENT_PARAM_TABLE[NUMBER_OF_EQUIPMENT];

/* Definition of the parameters for the equipment */
#if (ANLG_FAM == 2)
   static T_EQUIPMENT_PARAM_TABLE equipment_param_table = 
   {  {LLS_LED_A,         PAGE1, AUXLED,  0},
      {LLS_BACKLIGHT,     PAGE1, AUXLED,  1},
      {LLS_PRECHARGE_LED, PAGE0, BCICTL2, 5}
   };
#else
   static T_EQUIPMENT_PARAM_TABLE equipment_param_table = {0};
#endif

/* Save of the action to perform */
typedef struct
{
   T_LLS_EQUIPMENT   equipment_index;
   UINT8             action;
} T_ACTION;

static T_ACTION action_to_perform = {0};

/* Mutex used to protect perform only one action simultaneously */
static T_RVF_MUTEX mutex;


/**
 * @name Functions implementation
 *
 */
/*@{*/

/**
 * function: lls_initialize
 */
T_RV_RET lls_initialize(void)
{
   T_RV_RET ret = RV_OK;
   UINT8 i;

   /* Mutex initialization */
   ret = rvf_initialize_mutex(&mutex);
   if (ret != RVF_OK)
      return RV_INTERNAL_ERR;

   /* Initialisation of the equipment at SWITCH_OFF */
   for (i = 0; i < NUMBER_OF_EQUIPMENT; i++)
   {
      ret = lls_switch_off(equipment_param_table[i].equipment_sort);
      if (ret != RV_OK)
         return RV_INTERNAL_ERR;
   }

   return RV_OK;
}


/**
 * function: lls_kill_service
 */
T_RV_RET lls_kill_service(void)
{
   T_RV_RET ret = RV_OK;
   ret = rvf_delete_mutex(&mutex);
   if (ret != RVF_OK)
      return RV_INTERNAL_ERR;

   return ret;
}


/**
 * function: lls_callback_equipment_status
 */
void lls_callback_equipment_status(UINT16* equipment_status)
{
   T_RV_RET ret = RV_OK;
   UINT16 new_equipment_status = *equipment_status;

   LLS_SEND_TRACE_PARAM("LLS: Received equipment status", (UINT32) new_equipment_status, RV_TRACE_LEVEL_DEBUG_LOW);

   if (action_to_perform.action == SWITCH_ON)
      new_equipment_status |= 1 << equipment_param_table[action_to_perform.equipment_index].bit;
   else
      new_equipment_status &= ~(1 << equipment_param_table[action_to_perform.equipment_index].bit);

   LLS_SEND_TRACE_PARAM("LLS: New equipment status", (UINT32) new_equipment_status, RV_TRACE_LEVEL_DEBUG_LOW);

   ret = spi_abb_write(equipment_param_table[action_to_perform.equipment_index].page,
                 equipment_param_table[action_to_perform.equipment_index].address,
                 new_equipment_status);

   if (ret != RV_OK)
      LLS_SEND_TRACE("LLS: Error on SPI read",  RV_TRACE_LEVEL_ERROR);


   rvf_unlock_mutex(&mutex);
}

/**
 * function: lls_manage_equipment
 */
T_RV_RET lls_manage_equipment(UINT8 equipment_index, UINT8 action)
{
   T_RV_RET ret = RV_OK;

   /* Lock mutex until response from SPI is received */
   rvf_lock_mutex(&mutex);

   /* Save action to do */
   action_to_perform.equipment_index = equipment_index;
   action_to_perform.action = action;

   ret = spi_abb_read(equipment_param_table[equipment_index].page,
                equipment_param_table[equipment_index].address,
                lls_callback_equipment_status);

   if (ret != RV_OK)
      LLS_SEND_TRACE("LLS: Error on SPI read",  RV_TRACE_LEVEL_ERROR);

   return ret;
}

/**
 * function: lls_search_index
 */
T_RV_RET lls_search_index(T_LLS_EQUIPMENT equipment, UINT8* equipment_index)
{
   T_RV_RET ret = RV_OK;
   UINT8 i;

   for (i = 0; i < NUMBER_OF_EQUIPMENT; i++)
      if (equipment == equipment_param_table[i].equipment_sort)
      {
         *equipment_index = i;
         return RV_OK;
      }

   return RV_INVALID_PARAMETER;
}



/*@}*/