TWD/MacServices/PowerSrvSM.h
changeset 0 10c42ec6c05f
equal deleted inserted replaced
-1:000000000000 0:10c42ec6c05f
       
     1 /*
       
     2  * PowerSrvSM.h
       
     3  *
       
     4  * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved.      
       
     5  * All rights reserved.      
       
     6  * 
       
     7  * This program and the accompanying materials are made available under the 
       
     8  * terms of the Eclipse Public License v1.0 or BSD License which accompanies
       
     9  * this distribution. The Eclipse Public License is available at
       
    10  * http://www.eclipse.org/legal/epl-v10.html and the BSD License is as below.                                   
       
    11  *                                                                       
       
    12  * Redistribution and use in source and binary forms, with or without    
       
    13  * modification, are permitted provided that the following conditions    
       
    14  * are met:                                                              
       
    15  *                                                                       
       
    16  *  * Redistributions of source code must retain the above copyright     
       
    17  *    notice, this list of conditions and the following disclaimer.      
       
    18  *  * Redistributions in binary form must reproduce the above copyright  
       
    19  *    notice, this list of conditions and the following disclaimer in    
       
    20  *    the documentation and/or other materials provided with the         
       
    21  *    distribution.                                                      
       
    22  *  * Neither the name Texas Instruments nor the names of its            
       
    23  *    contributors may be used to endorse or promote products derived    
       
    24  *    from this software without specific prior written permission.      
       
    25  *                                                                       
       
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   
       
    27  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     
       
    28  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
       
    29  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  
       
    30  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
       
    31  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      
       
    32  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
       
    33  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
       
    34  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   
       
    35  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
       
    36  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    37  */
       
    38 
       
    39 /** \file PowerSrvSM.h
       
    40  *  \brief This is the PowerSrv module API.
       
    41  *  \author Assaf Azulay
       
    42  *  \date 6-Oct-2005
       
    43  */
       
    44 
       
    45 /****************************************************************************
       
    46  *                                                                                                        *
       
    47  *   MODULE:  PowerSrv                                                                              *
       
    48  *   PURPOSE: Power Server State machine API                                                    *
       
    49  *                                                                                                              *
       
    50  ****************************************************************************/
       
    51 
       
    52 #ifndef _POWER_SRV_SM_H_
       
    53 #define _POWER_SRV_SM_H_
       
    54 
       
    55 #include "PowerSrv_API.h"
       
    56 #include "PowerSrv.h"
       
    57 
       
    58 
       
    59 
       
    60 /*****************************************************************************
       
    61  **         Constants                                                       **
       
    62  *****************************************************************************/
       
    63 
       
    64 #define POWER_SAVE_GUARD_TIME_MS            5000       /* The gaurd time used to protect from FW stuck */
       
    65 
       
    66 /*****************************************************************************
       
    67  **         Enumerations                                                    **
       
    68  *****************************************************************************/
       
    69 
       
    70 /** \enum PowerSrvSMEvents_e */
       
    71 typedef enum 
       
    72 {
       
    73         POWER_SRV_EVENT_REQUEST_ACTIVE , 
       
    74     POWER_SRV_EVENT_REQUEST_PS ,
       
    75     POWER_SRV_EVENT_SUCCESS,
       
    76     POWER_SRV_EVENT_FAIL ,
       
    77     POWER_SRV_SM_EVENT_NUM
       
    78 }PowerSrvSMEvents_e;
       
    79 
       
    80 /** \enum PowerSrvSMStates_e */
       
    81 typedef enum 
       
    82 {
       
    83     POWER_SRV_STATE_ACTIVE = 0,
       
    84     POWER_SRV_STATE_PEND_PS ,
       
    85     POWER_SRV_STATE_PS ,
       
    86     POWER_SRV_STATE_PEND_ACTIVE ,
       
    87     POWER_SRV_STATE_ERROR_ACTIVE,
       
    88     POWER_SRV_SM_STATE_NUM
       
    89 }PowerSrvSMStates_e;
       
    90 
       
    91 
       
    92 
       
    93 /*****************************************************************************
       
    94  **         Structures                                                      **
       
    95  *****************************************************************************/
       
    96 
       
    97 /** \struct PowerSrvSM_t */
       
    98 typedef struct
       
    99 {
       
   100     TI_HANDLE               hCmdBld;                    /**< 
       
   101                                                          * Handle to the power controller object via the command builder.
       
   102                                                          * Need for configure the desired power mode policy in the system.
       
   103                                                          */
       
   104 
       
   105     TI_HANDLE               hOS;                        /**< Handle to the OS object. */
       
   106 
       
   107     TI_HANDLE               hReport;                    /**< Handle to the Report module. */
       
   108 
       
   109     TI_HANDLE               hFSM;                       /**< Handle to the State machine module. */
       
   110 
       
   111     TI_HANDLE               hTimer;                     /**< Handle to the Timer module. */
       
   112 
       
   113     TI_HANDLE               hPwrSrvSmTimer;             /**< Guard timer for PS commands sent to the FW */
       
   114 
       
   115     PowerSrvSMStates_e      currentState;               /**< the current state of the state machine. */
       
   116 
       
   117     powerSrvRequest_t*      pSmRequest;                 /**< pointer to the relevant request in the power server. */
       
   118 
       
   119     TI_UINT8                hangOverPeriod;             /**< parameter for the FW */
       
   120 
       
   121     TI_UINT8                numNullPktRetries;          /**< parameter for the FW */
       
   122     
       
   123     EHwRateBitFiled         NullPktRateModulation;      /**< parameter for the FW */
       
   124 
       
   125     TFailureEventCb         failureEventCB;             /**< Failure event callback */
       
   126 
       
   127     TI_HANDLE               hFailureEventObj;           /**< Failure event object (supplied to the above callback) */
       
   128 } PowerSrvSM_t;
       
   129 
       
   130 
       
   131 
       
   132 
       
   133 
       
   134 
       
   135 
       
   136 /*****************************************************************************
       
   137  **         External data definitions                                       **
       
   138  *****************************************************************************/
       
   139 
       
   140 
       
   141 /*****************************************************************************
       
   142  **         External functions definitions                                  **
       
   143  *****************************************************************************/
       
   144 
       
   145 
       
   146 /*****************************************************************************
       
   147  **         Public Function prototypes                                      **
       
   148  *****************************************************************************/
       
   149 
       
   150 /**
       
   151  * \author Assaf Azulay
       
   152  * \date 6-Oct-2005\n
       
   153  * \brief Creates the object of the PowerSrv.
       
   154  *
       
   155  * Function Scope \e Public.\n
       
   156  * Parameters:\n
       
   157  * 1) TI_HANDLE - handle to the OS.\n
       
   158  * Return Value: TI_HANDLE - handle to the PowerSrv object.\n
       
   159  */
       
   160 TI_HANDLE powerSrvSM_create(TI_HANDLE hOsHandle);
       
   161 
       
   162 /**
       
   163  * \author Assaf Azulay
       
   164  * \date 6-Oct-2005\n
       
   165  * \brief Destroy the object of the PowerSrvSM.
       
   166  *
       
   167  * Function Scope \e Public.\n
       
   168  * Parameters:\n
       
   169  * 1) TI_HANDLE - handle to the PowerSrv object.\n
       
   170  * Return Value: TI_STATUS - TI_OK on success else TI_NOK.\n
       
   171  */
       
   172 TI_STATUS powerSrvSM_destroy(TI_HANDLE thePowerSrvSMHandle);
       
   173 
       
   174 /**
       
   175  * \author Assaf Azulay
       
   176  * \date 6-Oct-2005\n
       
   177  * \brief Initialize the PowerSrvSM module.
       
   178  *
       
   179  * Function Scope \e Public.\n
       
   180  * Parameters:\n
       
   181  * 1) TI_HANDLE - handle to the PowerSrvSM object.\n
       
   182  * 2) TI_HANDLE - handle to the Report object.
       
   183  * 3) TI_HANDLE - handle to the Command Builder object.
       
   184  * 4) TI_HANDLE - handle to the Timer module object.
       
   185  * Return Value: TI_STATUS - TI_OK on success else TI_NOK.\n
       
   186  */
       
   187 TI_STATUS powerSrvSM_init (TI_HANDLE hPowerSrvSM,
       
   188                            TI_HANDLE hReport,
       
   189                            TI_HANDLE hCmdBld,
       
   190                            TI_HANDLE hTimer);
       
   191 
       
   192 TI_STATUS powerSrvSM_config(TI_HANDLE hPowerSrvSM,
       
   193                             TPowerSrvInitParams *pPowerSrvInitParams);
       
   194 /**
       
   195  * \author Assaf Azulay
       
   196  * \date 6-Oct-2005\n
       
   197  * \brief return the component version.
       
   198  *
       
   199  * Function Scope \e Public.\n
       
   200  * Parameters:\n
       
   201  * 1) TI_HANDLE - handle to the PowerSrvSM object.\n
       
   202  * Return Value: TI_UINT32 - component version code.\n
       
   203  */
       
   204 
       
   205 TI_STATUS powerSrvSM_SMApi(TI_HANDLE hPowerSrvSM,
       
   206                                             PowerSrvSMEvents_e theSMEvent);
       
   207 
       
   208 
       
   209 /**
       
   210  * \author Assaf Azulay
       
   211  * \date 020-Oct-2005\n
       
   212  * \brief This function sets the current SM working request.\n
       
   213  *
       
   214  * Function Scope \e Public.\n
       
   215  * Parameters:\n
       
   216  * 1) TI_HANDLE - handle to the PowerSrvSM object.\n
       
   217  * 2) powerSrvRequest_t* pSmRequest - desierd request./n
       
   218  * Return Value: TI_STATUS -  TI_OK.\n
       
   219  */
       
   220 TI_STATUS powerSrvSm_setSmRequest(TI_HANDLE hPowerSrvSM,powerSrvRequest_t* pSmRequest);
       
   221 
       
   222 
       
   223 
       
   224 /**
       
   225  * \author Assaf Azulay
       
   226  * \date 09-Jun-2004\n
       
   227  * \brief get the current state of the state machine.
       
   228  *
       
   229  * Function Scope \e Public.\n
       
   230  * Parameters:\n
       
   231  * 1) TI_HANDLE - handle to the PowerSrvSM object.\n
       
   232  * Return Value: PowerCtrlSMStates_e.\n
       
   233  */
       
   234 PowerSrvSMStates_e powerSrvSM_getCurrentState(TI_HANDLE hPowerSrvSM);
       
   235 
       
   236 
       
   237 /**
       
   238  * \author Assaf Azulay
       
   239  * \date 20-July-2004\n
       
   240  * \brief sets rate modulation
       
   241  *
       
   242  * Function Scope \e Public.\n
       
   243  * Parameters:\n
       
   244  * 1) TI_HANDLE - handle to the PowerSrvSM object.\n
       
   245  * 2) rate_e rate modulation
       
   246  * Return Value: void.\n
       
   247  */
       
   248 void powerSrvSM_setRateModulation(TI_HANDLE hPowerSrvSM, TI_UINT16 rateModulation);
       
   249 
       
   250 /**
       
   251  * \brief sets rate modulation
       
   252  *
       
   253  * Function Scope \e Public.\n
       
   254  * Parameters:\n
       
   255  * 1) TI_HANDLE - handle to the PowerSrvSM object.\n* 
       
   256  * Return Value: TI_UINT16 Rate.\n
       
   257  */
       
   258 TI_UINT32 powerSrvSM_getRateModulation(TI_HANDLE hPowerSrvSM);
       
   259 
       
   260 /**
       
   261  * \author Assaf Azulay
       
   262  * \date 20-July-2004\n
       
   263  * \brief print configuration of the PowerSrvSM object - use for debug!
       
   264  *
       
   265  * Function Scope \e Public.\n
       
   266  * Parameters:\n
       
   267  * 1) TI_HANDLE - handle to the PowerSrvSM object.\n
       
   268  * Return Value: void.\n
       
   269  */
       
   270 void powerSrvSM_printObject(TI_HANDLE hPowerSrvSM);
       
   271 
       
   272 /**
       
   273  * \author Ronen Kalish
       
   274  * \date 21-August-2006\n
       
   275  * \brief Registers a failure event callback for power save error notifications (timer expiry).\n
       
   276  *
       
   277  * Function Scope \e Public.\n
       
   278  * Parameters:\n
       
   279  * - hPowerSrvSM      - handle to the PowerSrv object.        
       
   280  * - failureEventCB     - the failure event callback function.
       
   281  * - hFailureEventObj   - handle to the object passed to the failure event callback function.
       
   282 */
       
   283 void powerSrvSM_RegisterFailureEventCB( TI_HANDLE hPowerSrvSM, 
       
   284                                         void* failureEventCB, TI_HANDLE hFailureEventObj );
       
   285 #endif /*  _POWER_SRV_SM_H_  */
       
   286