FreeCalypso > hg > fc-magnetite
view src/cs/drivers/drv_app/pwr/pwr_api.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 | c93a236e0d50 |
children |
line wrap: on
line source
/******************************************************************************* * * pwr_api.c * * Purpose: This file contains functions that can be accessed by any SWE * to use power management services. * * Author Candice Bazanegue (c-brille@ti.com) * * * (C) Texas Instruments 2001 * ******************************************************************************/ #include "rv/rv_defined_swe.h" // for RVM_PWR_SWE #ifdef RVM_PWR_SWE #include "rvm/rvm_use_id_list.h" #include "spi/spi_api.h" #include "spi/spi_env.h" #include "pwr/pwr_env.h" #include "pwr/pwr_cust.h" #include "pwr/pwr_messages.h" #include "pwr/pwr_messages_i.h" /* Define a pointer to the PWR Environment control block. */ extern T_PWR_ENV_CTRL_BLK *pwr_env_ctrl_blk; /******************************************************************************* ** ** Function power_info_register ** ** Description Function called by the MMI to enable (or disable) the receipt ** of several events related to the charging process or the ** discharge levels. ** ** *******************************************************************************/ T_POWER_RET power_info_register(BOOLEAN info_enable, T_RV_RETURN return_path) { if (((pwr_env_ctrl_blk->power_info.return_path.callback_func)!= NULL) || (pwr_env_ctrl_blk->power_info.return_path.addr_id != RVF_INVALID_ADDR_ID)) { rvf_send_trace("power_info_register : info already registered, performs another registration", 76, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, PWR_USE_ID); } pwr_env_ctrl_blk->power_info.info_enable = info_enable; pwr_env_ctrl_blk->power_info.return_path.addr_id = return_path.addr_id; pwr_env_ctrl_blk->power_info.return_path.callback_func = return_path.callback_func; return (POWER_OK); } /******************************************************************************* ** ** Function power_alert_register ** ** Description Function called by the MMI to configure the threshold of ** remaining energy in the battery, under which the MMI will ** receive low battery alerts. ** ** *******************************************************************************/ T_POWER_RET power_alert_register(T_PWR_PERCENT remain_capa_threshold, T_RV_RETURN return_path) { if (((pwr_env_ctrl_blk->power_alert.return_path.callback_func)!= NULL) || (pwr_env_ctrl_blk->power_alert.return_path.addr_id != RVF_INVALID_ADDR_ID)) { rvf_send_trace("power_alert_register : info already registered, performs another registration", 77, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, PWR_USE_ID); } pwr_env_ctrl_blk->power_alert.remain_capa_threshold = remain_capa_threshold; pwr_env_ctrl_blk->power_alert.return_path.addr_id = return_path.addr_id; pwr_env_ctrl_blk->power_alert.return_path.callback_func = return_path.callback_func; return (POWER_OK); } /******************************************************************************* ** ** Function power_emergency_register ** ** Description Function called by the MMI to define the call-back function ** which will be called in case of emergency switch OFF. ** ** *******************************************************************************/ T_POWER_RET power_emergency_register(T_RV_RETURN return_path) { if (((pwr_env_ctrl_blk->power_emergency.callback_func)!= NULL) || (pwr_env_ctrl_blk->power_emergency.addr_id != RVF_INVALID_ADDR_ID)) { rvf_send_trace("power_emergency_register : info already registered, performs another registration", 80, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, PWR_USE_ID); } pwr_env_ctrl_blk->power_emergency.addr_id = return_path.addr_id; pwr_env_ctrl_blk->power_emergency.callback_func = return_path.callback_func; return (POWER_OK); } /******************************************************************************* ** ** Function pwr_callback_func ** ** Description ** ** ** *******************************************************************************/ void pwr_callback_func(void *ptr) { T_PWR_CHARGING_STATE charge_started; /* Charge started? */ charge_started = pwr_env_ctrl_blk->charging_state; if (charge_started == CHARGE_STOPPED) { /* Ask for battery temperature measurement */ pwr_get_battery_temperature(); } else if ((charge_started == CI_CHARGE_STARTED) || (charge_started == CV_CHARGE_STARTED)) { /* The battery temperature has been measured during the charge */ pwr_get_bat_info(); } } /******************************************************************************* ** ** Function pwr_get_bat_info ** ** Description ** ** *******************************************************************************/ void pwr_get_bat_info(void) { UINT16 bat_voltage, bat_madc_voltage; UINT16 charger_current, bat_madc_current; UINT16 status; BOOLEAN charger_plugged; T_PWR_CHARGING_STATE charge_started; T_PWR_PERCENT remain_capacity; INT16 bat_temperature; /* Voltage and current */ /* Read the conversion results in the analog device registers */ bat_madc_voltage = ABB_Read_Register_on_page(PAGE0, VBATREG); bat_madc_current = ABB_Read_Register_on_page(PAGE0, ICHGREG); bat_voltage = pwr_adc_to_mvolt(bat_madc_voltage); charger_current = pwr_adc_to_mA(bat_madc_current); /* Remaining capacity in the battery */ remain_capacity = pwr_get_capacity_vs_voltage(bat_voltage); /* Charger plugged? */ status = ABB_Read_Status(); if (status & CHGPRES) { charger_plugged = TRUE; } else { charger_plugged = FALSE; } /* Charge started? */ charge_started = pwr_env_ctrl_blk->charging_state; /* The battery temperature is already measured during the charge */ /* Use the last result */ bat_temperature = pwr_env_ctrl_blk->bat_celsius_temp; /* Send the results to the upper layer */ pwr_send_battery_info(bat_voltage, bat_temperature, charger_current, charger_plugged, charge_started, remain_capacity); } /******************************************************************************* ** ** Function power_battery_information ** ** Description Function called by the MMI to get information concerning ** the battery. ** ** *******************************************************************************/ T_POWER_RET power_battery_information(void) { T_RV_RET spi_return; spi_return = pwr_spi_battery_info(pwr_callback_func); if (spi_return != RV_OK) { return (POWER_ERROR); } return (POWER_OK); } #endif /* #ifdef RVM_PWR_SWE */