1 /*------------------------------------------------------------------------------------------------*/
2 /* UNICENS V2.1.0-3491 */
3 /* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
5 /* This program is free software: you can redistribute it and/or modify */
6 /* it under the terms of the GNU General Public License as published by */
7 /* the Free Software Foundation, either version 2 of the License, or */
8 /* (at your option) any later version. */
10 /* This program is distributed in the hope that it will be useful, */
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
13 /* GNU General Public License for more details. */
15 /* You should have received a copy of the GNU General Public License */
16 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 /* You may also obtain this software under a propriety license from Microchip. */
19 /* Please contact Microchip for further information. */
20 /*------------------------------------------------------------------------------------------------*/
24 * \brief Internal header file of the Finite State Machine.
26 * \cond UCS_INTERNAL_DOC
34 /*------------------------------------------------------------------------------------------------*/
36 /*------------------------------------------------------------------------------------------------*/
37 #include "ucs_types_cfg.h"
44 /*------------------------------------------------------------------------------------------------*/
46 /*------------------------------------------------------------------------------------------------*/
47 /*! \brief Internal state machine states which are also used as return values for method
50 typedef enum Fsm_State_
52 FSM_STATE_IDLE, /*!< \brief The state machine is in idle mode */
53 FSM_STATE_SERVICE, /*!< \brief An event is pending and the state machine must be serviced */
54 FSM_STATE_WAIT, /*!< \brief Waiting for asynchronous data/signal/event */
55 FSM_STATE_END, /*!< \brief The state machine is finished */
56 FSM_STATE_ERROR /*!< \brief An error occurred while processing the state machine */
60 /*------------------------------------------------------------------------------------------------*/
62 /*------------------------------------------------------------------------------------------------*/
63 /*! \brief Function signature used for state machine actions */
64 typedef void (*Fsm_Act_t)(void *self);
66 /*! \brief Structure is used to define state elements */
67 typedef struct Fsm_StateElem_
69 /*! \brief Function pointer to the action that shall be executed */
70 Fsm_Act_t action_fptr;
71 /*! \brief Next state */
76 /*! \brief Class structure of the finite state machine */
79 /*! \brief Reference to transition table */
80 const Fsm_StateElem_t *transition_table_ptr;
81 /*! \brief Instance pointer used for actions */
83 /*! \brief Current event */
85 /*! \brief Current state */
87 /*! \brief Maximum number of events */
89 /*! \brief Internal state of the state machine */
90 Fsm_State_t internal_state;
94 /*------------------------------------------------------------------------------------------------*/
96 /*------------------------------------------------------------------------------------------------*/
97 extern void Fsm_Ctor(CFsm *self, void *inst_ptr, const Fsm_StateElem_t *trans_table_ptr,
98 uint8_t num_events, int8_t init_state);
99 extern Fsm_State_t Fsm_Service(CFsm *self);
100 extern void Fsm_SetEvent(CFsm *self, int8_t e);
101 extern void Fsm_Wait(CFsm *self);
102 extern void Fsm_End(CFsm *self);
108 #endif /* #ifndef UCS_FSM_H */
115 /*------------------------------------------------------------------------------------------------*/
117 /*------------------------------------------------------------------------------------------------*/