Questa FwSmDesc_t createMainStateMachine(void* smData) è la funzione che inizializza la macchina a stati ti posto l'intero codice.
FwSmDesc_t createMainStateMachine(void* smData)
{
const FwSmCounterU2_t STATE_IDLE = 1; ///< The identifier of state
const FwSmCounterU2_t N_OUT_OF_STATE_IDLE = 2; ///< The number of transitions out of state
const FwSmCounterU2_t STATE_CONNECTING = 2; ///< The identifier of state
const FwSmCounterU2_t N_OUT_OF_STATE_CONNECTING = 2; ///< The number of transitions out of state
const FwSmCounterU2_t STATE_PROGRAMMING = 3; ///< The identifier of state
const FwSmCounterU2_t N_OUT_OF_STATE_PROGRAMMING = 1; ///< The number of transitions out of state
/** Create state machine smDesc */
FW_SM_INST(smDesc,
3, ///< NSTATES - The number of states
0, ///< NCPS - The number of choice pseudo-states
6, ///< NTRANS - The number of transitions
9, ///< NACTIONS - The number of state and transition actions
0 ///< NGUARDS - The number of transition guards
);
FwSmInit(&smDesc);
/** Configure the state machine smDesc */
FwSmSetData(&smDesc, smData);
FwSmAddState(&smDesc, STATE_IDLE, N_OUT_OF_STATE_IDLE, &enter_StateIdle, &exit_StateIdle, &do_StateIdle, NULL);
FwSmAddState(&smDesc, STATE_CONNECTING, N_OUT_OF_STATE_CONNECTING, &enter_StateConnecting, &exit_StateConnecting, NULL, NULL);
FwSmAddState(&smDesc, STATE_PROGRAMMING, N_OUT_OF_STATE_PROGRAMMING, &enter_StateProgramming, &exit_StateProgramming, &do_StateProgramming, NULL);
FwSmAddTransIpsToSta(&smDesc, STATE_IDLE, NULL);
FwSmAddTransStaToSta(&smDesc, TriggerEnterProgrammingMode, STATE_IDLE, STATE_PROGRAMMING, NULL, NULL);
FwSmAddTransStaToSta(&smDesc, TriggerTimeIsUp, STATE_IDLE, STATE_CONNECTING, NULL, NULL);
FwSmAddTransStaToSta(&smDesc, TriggerConnectionSucceded, STATE_CONNECTING, STATE_IDLE, NULL, NULL);
FwSmAddTransStaToSta(&smDesc, TriggerConnectionFailed, STATE_CONNECTING, STATE_IDLE, NULL, NULL);
FwSmAddTransStaToSta(&smDesc, TriggerExitProgrammingMode, STATE_PROGRAMMING, STATE_IDLE, NULL, NULL);
return &smDesc;
}