LibJuno 1.0.1
LibJuno is a lightweight C11 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
example_state_machine.c File Reference
#include "juno/macros.h"
#include "juno/module.h"
#include "juno/sm/sm_api.h"
#include "juno/status.h"
#include "unistd.h"
#include <stdio.h>
Include dependency graph for example_state_machine.c:

Typedefs

typedef enum TRAFFIC_LIGHT_T TRAFFIC_LIGHT_T
 

Enumerations

enum  TRAFFIC_LIGHT_T { TRAFFIC_RED , TRAFFIC_YELLOW , TRAFFIC_GREEN , TRAFFIC_COUNT }
 

Functions

struct TRAFFIC_LIGHT_STATE_T JUNO_MODULE_DERIVE (union JUNO_SM_STATE_T JUNO_MODULE(JUNO_SM_STATE_ROOT_T, int iCounter;TRAFFIC_LIGHT_T tNextLight;TRAFFIC_LIGHT_T tThisLight;)
 The action that should be executed in this state.
 
static JUNO_RESULT_BOOL_T ShouldExit (JUNO_SM_STATE_ROOT_T *ptJunoSm)
 Returns a bool result whether the current state should exit.
 
static JUNO_STATUS_T ResetState (JUNO_SM_STATE_ROOT_T *ptJunoSm)
 
struct TRAFFIC_LIGHT_SM_T JUNO_MODULE_DERIVE (union JUNO_SM_T JUNO_MODULE(JUNO_SM_ROOT_T, TRAFFIC_LIGHT_STATE_T tStates;[TRAFFIC_COUNT])
 
int main (void)
 

Variables

static const JUNO_SM_STATE_API_T tSmStateApi
 

Typedef Documentation

◆ TRAFFIC_LIGHT_T

Enumeration Type Documentation

◆ TRAFFIC_LIGHT_T

Enumerator
TRAFFIC_RED 
TRAFFIC_YELLOW 
TRAFFIC_GREEN 
TRAFFIC_COUNT 

Function Documentation

◆ JUNO_MODULE_DERIVE() [1/2]

struct TRAFFIC_LIGHT_STATE_T JUNO_MODULE_DERIVE ( union JUNO_SM_STATE_T JUNO_MODULE JUNO_SM_STATE_ROOT_T,
int iCounter;TRAFFIC_LIGHT_T tNextLight;TRAFFIC_LIGHT_T tThisLight;   
)

The action that should be executed in this state.

◆ JUNO_MODULE_DERIVE() [2/2]

struct TRAFFIC_LIGHT_SM_T JUNO_MODULE_DERIVE ( union JUNO_SM_T JUNO_MODULE JUNO_SM_ROOT_T,
TRAFFIC_LIGHT_STATE_T tStates;  [TRAFFIC_COUNT] 
)

◆ main()

int main ( void  )

◆ ResetState()

static JUNO_STATUS_T ResetState ( JUNO_SM_STATE_ROOT_T ptJunoSm)
static

◆ ShouldExit()

static JUNO_RESULT_BOOL_T ShouldExit ( JUNO_SM_STATE_ROOT_T ptJunoSm)
static

Returns a bool result whether the current state should exit.

Variable Documentation

◆ tSmStateApi

const JUNO_SM_STATE_API_T tSmStateApi
static
Initial value:
= {
.StateAction = StateAction,
.ShouldExit = ShouldExit,
.ResetState = ResetState
}
static JUNO_STATUS_T ResetState(JUNO_SM_STATE_ROOT_T *ptJunoSm)
Definition example_state_machine.c:67
static JUNO_RESULT_BOOL_T ShouldExit(JUNO_SM_STATE_ROOT_T *ptJunoSm)
Returns a bool result whether the current state should exit.
Definition example_state_machine.c:55