Home | History | Annotate | Download | only in utils
      1 /** \file fsm.h
      2  *  \brief non-recursive finite state machine header file
      3  *
      4  *  \see fsm.c
      5  */
      6 
      7 /****************************************************************************
      8 **+-----------------------------------------------------------------------+**
      9 **|                                                                       |**
     10 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved.      |**
     11 **| All rights reserved.                                                  |**
     12 **|                                                                       |**
     13 **| Redistribution and use in source and binary forms, with or without    |**
     14 **| modification, are permitted provided that the following conditions    |**
     15 **| are met:                                                              |**
     16 **|                                                                       |**
     17 **|  * Redistributions of source code must retain the above copyright     |**
     18 **|    notice, this list of conditions and the following disclaimer.      |**
     19 **|  * Redistributions in binary form must reproduce the above copyright  |**
     20 **|    notice, this list of conditions and the following disclaimer in    |**
     21 **|    the documentation and/or other materials provided with the         |**
     22 **|    distribution.                                                      |**
     23 **|  * Neither the name Texas Instruments nor the names of its            |**
     24 **|    contributors may be used to endorse or promote products derived    |**
     25 **|    from this software without specific prior written permission.      |**
     26 **|                                                                       |**
     27 **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |**
     28 **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |**
     29 **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
     30 **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |**
     31 **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
     32 **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |**
     33 **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
     34 **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
     35 **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |**
     36 **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
     37 **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |**
     38 **|                                                                       |**
     39 **+-----------------------------------------------------------------------+**
     40 ****************************************************************************/
     41 
     42 /***************************************************************************/
     43 /*                                                                         */
     44 /*      MODULE: fsm.h                                                      */
     45 /*    PURPOSE:  Finite State Machine API                                   */
     46 /*                                                                         */
     47 /***************************************************************************/
     48 
     49 #ifndef __NRFSM_H__
     50 #define __NRFSM_H__
     51 
     52 
     53 /* Constants */
     54 
     55 /* Enumerations */
     56 
     57 /* Typedefs */
     58 
     59 /** action function type definition */
     60 typedef TI_STATUS (*nrfsm_action_t) (void* pData);
     61 
     62 /* Structures */
     63 
     64 /* State\Event cell */
     65 typedef  struct
     66 {
     67     UINT32          nState;      /**< next state in transition */
     68     nrfsm_action_t  fAction;     /**< action function */
     69 } nrfsm_action_cell_t;
     70 
     71 /** matrix type */
     72 typedef nrfsm_action_cell_t*  nrfsm_matrix_t;
     73 
     74 
     75 /* External data definitions */
     76 
     77 /* External functions definitions */
     78 
     79 /* Function prototypes */
     80 
     81 TI_STATUS nrfsm_Create       (TI_HANDLE       hOs,
     82                               TI_HANDLE      *hFsm,
     83                               UINT32          uMaxNoOfStates,
     84                               UINT32          uMaxNoOfEvents);
     85 
     86 TI_STATUS nrfsm_Unload       (TI_HANDLE       hFsm);
     87 
     88 TI_STATUS nrfsm_Config       (TI_HANDLE       hFsm,
     89                               nrfsm_matrix_t  pMatrix,
     90                               UINT32          uActNoOfStates,
     91                               UINT32          uActNoOfEvents);
     92 
     93 TI_STATUS nrfsm_Event        (TI_HANDLE       hFsm,
     94                               UINT32          event,
     95                               void           *pData);
     96 
     97 TI_STATUS nrfsm_GetState     (TI_HANDLE       hFsm,
     98                               UINT32         *state);
     99 
    100 TI_STATUS nrfsm_SetState     (TI_HANDLE       hFsm,
    101                               UINT32          state);
    102 
    103 TI_STATUS nrfsm_GetNextState (TI_HANDLE       hFsm,
    104                               UINT32          event,
    105                               UINT32         *state);
    106 
    107 #endif /* __NRFSM_H__ */
    108