view src/cs/drivers/drv_app/fchg/fchg_env.c @ 629:3231dd9b38c1

armio.c: make GPIOs 8 & 13 outputs driving 1 on all "classic" targets Calypso GPIOs 8 & 13 are pinmuxed with MCUEN1 & MCUEN2, respectively, and on powerup these pins are MCUEN, i.e., outputs driving 1. TI's code for C-Sample and earlier turns them into GPIOs configured as outputs also driving 1 - so far, so good - but TI's code for BOARD 41 (which covers D-Sample, Leonardo and all real world Calypso devices derived from the latter) switches them from MCUEN to GPIOs, but then leaves them as inputs. Given that the hardware powerup state of these two pins is outputs driving 1, every Calypso board design MUST be compatible with such driving; typically these GPIO signals will be either unused and unconnected or connected as outputs driving some peripheral. Turning these pins into GPIO inputs will result in floating inputs on every reasonably-wired board, thus I am convinced that this configuration is nothing but a bug on the part of whoever wrote this code at TI. This floating input bug had already been fixed earlier for GTA modem and FCDEV3B targets; the present change makes the fix unconditional for all "classic" targets. The newly affected targets are D-Sample, Leonardo, Tango and GTM900.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 02 Jan 2020 05:38:26 +0000
parents ab47ade99fa9
children
line wrap: on
line source

/*
 * This module provides the glue to the RiViera environment
 * for our FCHG SWE.
 */

#include "fchg/fchg_env.h"
#include "rv/rv_general.h"
#include "rvf/rvf_api.h"
#include "rvm/rvm_priorities.h"
#include "rvm/rvm_api.h"
#include "rvm/rvm_use_id_list.h"
#include <string.h>

/* Define a pointer to the PWR environment control block */
T_PWR_CTRL_BLOCK *pwr_ctrl = 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);

T_RVM_RETURN fchg_get_info (T_RVM_INFO_SWE  *infoSWE)
{
   /* SWE info */

   infoSWE->swe_type = RVM_SWE_TYPE_4;
   infoSWE->type_info.type4.swe_use_id = FCHG_USE_ID;
   memcpy( infoSWE->type_info.type4.swe_name, "FCHG", 5 );

   infoSWE->type_info.type4.stack_size = FCHG_STACK_SIZE;
   infoSWE->type_info.type4.priority   = RVM_LCC_TASK_PRIORITY;

   /* memory bank info */
   infoSWE->type_info.type4.nb_mem_bank = 1;

   memcpy ((UINT8 *) infoSWE->type_info.type4.mem_bank[0].bank_name, "FCHG_PRIM", 10);
   infoSWE->type_info.type4.mem_bank[0].initial_params.size          = FCHG_MB_PRIM_SIZE;
   infoSWE->type_info.type4.mem_bank[0].initial_params.watermark     = FCHG_MB_PRIM_WATERMARK;

   /* linked SWE info: we use FFS */
   infoSWE->type_info.type4.nb_linked_swe    = 1;
   infoSWE->type_info.type4.linked_swe_id[0] = FFS_USE_ID;

   /* generic functions */
   infoSWE->type_info.type4.set_info = fchg_set_info;
   infoSWE->type_info.type4.init     = fchg_init;
   infoSWE->type_info.type4.core     = fchg_core;
   infoSWE->type_info.type4.stop     = fchg_stop;
   infoSWE->type_info.type4.kill     = fchg_kill;

   /* Set the return path */
   infoSWE->type_info.type4.return_path.callback_func	= NULL;
   infoSWE->type_info.type4.return_path.addr_id	      = 0;

   return RV_OK;
}

T_RVM_RETURN fchg_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;

    mb_status = rvf_get_buf(mbId[0],sizeof(T_PWR_CTRL_BLOCK),(void **) &pwr_ctrl);
    if (mb_status == RVF_RED) 
    {
        rvf_send_trace("fchg_set_info: rvf_get_buf() failed", 35,
                       NULL_PARAM,
                       RV_TRACE_LEVEL_ERROR,
                       FCHG_USE_ID);
        return (RVM_MEMORY_ERR);
    }
    memset(pwr_ctrl, 0, sizeof(T_PWR_CTRL_BLOCK));

    /* store the pointer to the error function */
    pwr_error_ft = callBackFct ;

    /* Store the addr id */
    pwr_ctrl->addr_id = addr_id;

    /* Store the memory bank id */
    pwr_ctrl->prim_id = mbId[0];

    return RV_OK;
}

T_RVM_RETURN fchg_init(void)
{
   return RV_OK;
}

T_RVM_RETURN fchg_stop(void)
{
   return RV_OK;
}

T_RVM_RETURN fchg_kill(void)
{
   /* free all memory buffer previously allocated */
   rvf_free_buf ((void *) pwr_ctrl);

   return RV_OK;
}