FreeCalypso > hg > fc-magnetite
view src/cs/drivers/drv_app/pwr/pwr_env.c @ 339:2990f590d368
configs/l1reconst-chg created
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 14 Dec 2017 23:09:56 +0000 |
parents | c93a236e0d50 |
children |
line wrap: on
line source
/*****************************************************************************/ /* */ /* File Name: pwr_env.c */ /* */ /* Purpose: This file contains definitions for RV manager related */ /* functions used to get info, start and stop the PWR SWE. */ /* */ /* Version 0.1 */ /* */ /* Date Modification */ /* ------------------------------------ */ /* 20/08/2000 Create */ /* */ /* Author Candice Bazanegue (c-brille@ti.com) */ /* */ /* (C) Copyright 2000 by Texas Instruments Incorporated, All Rights Reserved */ /*****************************************************************************/ #include "rv/rv_defined_swe.h" // for RVM_PWR_SWE #ifdef RVM_PWR_SWE #include "rvm/rvm_priorities.h" #include "rvm/rvm_api.h" #include "pwr/pwr_env.h" #include "spi/spi_env.h" #include "pwr/pwr_cust.h" #include "pwr/pwr_analog_dev.h" #include "rvm/rvm_use_id_list.h" #include <string.h> /* Define a pointer to the PWR environment control block */ T_PWR_ENV_CTRL_BLK *pwr_env_ctrl_blk = NULL; /* Define global pointer to the error function */ static T_RVM_RETURN (*pwr_error_ft) (T_RVM_NAME swe_name, T_RVM_RETURN error_cause, T_RVM_ERROR_TYPE error_type, T_RVM_STRING error_msg); /****************************************************************************** * Function name: pwr_get_info * * Description : Generic PWR get info function : provide general information * regarding the PWR SWE to the Riviera Manager * For more details, see Riviera Manager documentation * * Parameters : Pointer on the info structure * * Return : Always OK * * History : * ******************************************************************************/ T_RVM_RETURN pwr_get_info (T_RVM_INFO_SWE *infoSWE) { /* SWE info */ infoSWE->swe_type = RVM_SWE_TYPE_1; infoSWE->type_info.type1.swe_use_id = PWR_USE_ID; memcpy( infoSWE->type_info.type1.swe_name, "PWR", sizeof("PWR") ); /* Set the return path */ infoSWE->type_info.type1.return_path.callback_func = NULL; infoSWE->type_info.type1.return_path.addr_id = 0; /* memory bank info */ infoSWE->type_info.type1.nb_mem_bank = 1; memcpy ((UINT8 *) infoSWE->type_info.type1.mem_bank[0].bank_name, "PWR_PRIM", 9); infoSWE->type_info.type1.mem_bank[0].initial_params.size = PWR_MB_PRIM_SIZE; infoSWE->type_info.type1.mem_bank[0].initial_params.watermark = PWR_MB_PRIM_WATERMARK; /* Linked SW entities : PWR needs SPI */ infoSWE->type_info.type1.nb_linked_swe = 1; infoSWE->type_info.type1.linked_swe_id[0] = SPI_USE_ID; /* generic functions */ infoSWE->type_info.type1.set_info = pwr_set_info; infoSWE->type_info.type1.init = pwr_init; infoSWE->type_info.type1.start = pwr_start; infoSWE->type_info.type1.stop = pwr_stop; infoSWE->type_info.type1.kill = pwr_kill; return RV_OK; } /****************************************************************************** * Function : pwr_set_info * * Description : This function is called by the RV manager to inform * the pwr SWE about task_id, mb_id and error function. * * Parameters : - T_RVM_TASK_ID taskId[]: array of task_id. * taskId[0] contains pwr task_id. * - T_RVF_MB_ID mbId[]: array of memory bank ids. * - callback function to call in case of unrecoverable error. * * Return : T_RVM_RETURN * * History : * * ******************************************************************************/ T_RVM_RETURN pwr_set_info(T_RVF_ADDR_ID addr_id, T_RV_RETURN return_path[], T_RVF_MB_ID mbId[], T_RVM_RETURN (*callBackFct) (T_RVM_NAME SWEntName, T_RVM_RETURN errorCause, T_RVM_ERROR_TYPE errorType, T_RVM_STRING errorMsg)) { T_RVF_MB_STATUS mb_status; rvf_send_trace("PWR: pwr_set_info: try to init GLOBAL INFO PWR structure ...",60, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, PWR_USE_ID); mb_status = rvf_get_buf(mbId[0],sizeof(T_PWR_ENV_CTRL_BLK),(void **) &pwr_env_ctrl_blk); if (mb_status == RVF_RED) { rvf_send_trace("PWR : pwr_set_info: Not enough memory to initiate GLOBAL INFO PWR structure ... ",86, NULL_PARAM, RV_TRACE_LEVEL_ERROR, PWR_USE_ID); return (RVM_MEMORY_ERR); } /* store the pointer to the error function */ pwr_error_ft = callBackFct ; /* Store the addr id */ /* Same task id than SPI but different mailbox */ pwr_env_ctrl_blk->addr_id = SPI_GBL_INFO_PTR->addr_id; pwr_env_ctrl_blk->prim_id = mbId[0]; pwr_env_ctrl_blk->charging_state = CHARGE_STOPPED; pwr_env_ctrl_blk->madc_eoc_current_code = (UINT16)(1000 * END_OF_CHARGE_I / MADC_CURRENT_STEP); /* modified after i2v calibration */ pwr_env_ctrl_blk->max_voltage_code = (UINT16)(1000 * ((END_OF_CHARGE_V + MADC_OFFSET)/4) / MADC_VOLTAGE_STEP); pwr_env_ctrl_blk->power_info.info_enable = FALSE; /* initalize the return path */ pwr_env_ctrl_blk->power_info.return_path.addr_id = RVF_INVALID_ADDR_ID; pwr_env_ctrl_blk->power_info.return_path.callback_func = NULL; pwr_env_ctrl_blk->power_alert.remain_capa_threshold =0x0A; /* initalize the return path */ pwr_env_ctrl_blk->power_alert.return_path.addr_id = RVF_INVALID_ADDR_ID; pwr_env_ctrl_blk->power_alert.return_path.callback_func = NULL; /* initalize the return path */ pwr_env_ctrl_blk->power_emergency.addr_id = RVF_INVALID_ADDR_ID; pwr_env_ctrl_blk->power_emergency.callback_func = NULL; pwr_env_ctrl_blk->bat_celsius_temp = 0; pwr_env_ctrl_blk->timer0_state = BATTERY_SHORT_TEST; return RV_OK; } /****************************************************************************** * Function : pwr_init * * Description : This function is called by the RV manager to initialize the * pwr SWE before creating the task and calling pwr_start. * * Parameters : None * * Return : T_RVM_RETURN * * History : * * ******************************************************************************/ T_RVM_RETURN pwr_init(void) { return RV_OK; } /****************************************************************************** * Function : pwr_start * * Description : This function is called by the RV manager to start the pwr * SWE, it is the body of the task. * * Parameters : None * * Return : T_RVM_RETURN * * History : * * ******************************************************************************/ T_RVM_RETURN pwr_start(void) { return RV_OK; } /****************************************************************************** * Function : pwr_stop * * Description : This function is called by the RV manager to stop the pwr SWE. * * Parameters : None * * Return : T_RVM_RETURN * * History : * * ******************************************************************************/ T_RVM_RETURN pwr_stop(void) { return RV_OK; } /****************************************************************************** * Function : pwr_kill * * Description : This function is called by the RV manager to kill the pwr * SWE, after the pwr_stop function has been called. * * Parameters : None * * Return : T_RVM_RETURN * * History : * * ******************************************************************************/ T_RVM_RETURN pwr_kill (void) { /* free all memory buffer previously allocated */ rvf_free_buf ((void *) pwr_env_ctrl_blk); return RV_OK; } #endif /* #ifdef RVM_PWR_SWE */