FSM Generator
FSM Generator
#include <stdint.h>
#include <stdio.h>
#include "fsm.h"
//****************************************************************************//
// Global variables
//****************************************************************************//
uint8_t ActState;
//****************************************************************************//
// Initialize state machine
//****************************************************************************//
void FSM_Init (void)
{
ActState = EDO_A;
}
//****************************************************************************//
// Event function "S1_0_S2_0"
//****************************************************************************//
void FSM_S1_0_S2_0 (void)
{
if (StateTable[ActState][S1_0_S2_0].ptrFunct != NULL)
StateTable[ActState][S1_0_S2_0].ptrFunct();
ActState = StateTable[ActState][S1_0_S2_0].NextState;
}
//****************************************************************************//
// Event function "S1_0_S2_1"
//****************************************************************************//
void FSM_S1_0_S2_1 (void)
{
if (StateTable[ActState][S1_0_S2_1].ptrFunct != NULL)
StateTable[ActState][S1_0_S2_1].ptrFunct();
ActState = StateTable[ActState][S1_0_S2_1].NextState;
}
//****************************************************************************//
// Event function "S1_1_S2_0"
//****************************************************************************//
void FSM_S1_1_S2_0 (void)
{
if (StateTable[ActState][S1_1_S2_0].ptrFunct != NULL)
StateTable[ActState][S1_1_S2_0].ptrFunct();
ActState = StateTable[ActState][S1_1_S2_0].NextState;
}
//****************************************************************************//
// Event function "S1_1_S2_1"
//****************************************************************************//
void FSM_S1_1_S2_1 (void)
{
if (StateTable[ActState][S1_1_S2_1].ptrFunct != NULL)
StateTable[ActState][S1_1_S2_1].ptrFunct();
ActState = StateTable[ActState][S1_1_S2_1].NextState;
}
//****************************************************************************//
// Event function "Trig_0_Echo_0"
//****************************************************************************//
void FSM_Trig_0_Echo_0 (void)
{
if (StateTable[ActState][TRIG_0_ECHO_0].ptrFunct != NULL)
StateTable[ActState][TRIG_0_ECHO_0].ptrFunct();
ActState = StateTable[ActState][TRIG_0_ECHO_0].NextState;
}
//****************************************************************************//
// Event function "Trig_0_Echo_1"
//****************************************************************************//
void FSM_Trig_0_Echo_1 (void)
{
if (StateTable[ActState][TRIG_0_ECHO_1].ptrFunct != NULL)
StateTable[ActState][TRIG_0_ECHO_1].ptrFunct();
ActState = StateTable[ActState][TRIG_0_ECHO_1].NextState;
}
//****************************************************************************//
// Event function "Trig_1_Echo_0"
//****************************************************************************//
void FSM_Trig_1_Echo_0 (void)
{
if (StateTable[ActState][TRIG_1_ECHO_0].ptrFunct != NULL)
StateTable[ActState][TRIG_1_ECHO_0].ptrFunct();
ActState = StateTable[ActState][TRIG_1_ECHO_0].NextState;
}
//****************************************************************************//
// Event function "Trig_1_Echo_1"
//****************************************************************************//
void FSM_Trig_1_Echo_1 (void)
{
if (StateTable[ActState][TRIG_1_ECHO_1].ptrFunct != NULL)
StateTable[ActState][TRIG_1_ECHO_1].ptrFunct();
ActState = StateTable[ActState][TRIG_1_ECHO_1].NextState;
}
//****************************************************************************//
O_A, NULL, EDO_A, FSM_detenerse, EDO_D, NULL, EDO_A, FSM_detenerse, EDO_D,
DO_A, NULL, EDO_B, FSM_detenerse, EDO_D, NULL, EDO_B, FSM_detenerse, EDO_D,
DO_A, NULL, EDO_C, FSM_detenerse, EDO_D, NULL, EDO_C, FSM_detenerse, EDO_D,
EDO_A, NULL, EDO_D, FSM_avanza_frente, EDO_A, NULL, EDO_D
//****************************************************************************//
// MSP430 state machine
// fsm_transition.c
//
// Describtion:
// A simple state machine for the MSP430
// You can add your own code in here!!!
//
// Generated with Excel Table
// Date: 01/07/2023 Time: 21:51:25
//
//****************************************************************************//
#include "fsm.h"
//****************************************************************************//
// Transition function "gira_izquierda"
//****************************************************************************//
void FSM_gira_izquierda (void)
{
// You can add your code here
}
//****************************************************************************//
// Transition function "gira_derecha"
//****************************************************************************//
void FSM_gira_derecha (void)
{
// You can add your code here
}
//****************************************************************************//
// Transition function "detenerse"
//****************************************************************************//
void FSM_detenerse (void)
{
// You can add your code here
}
//****************************************************************************//
// Transition function "avanza_frente"
//****************************************************************************//
void FSM_avanza_frente (void)
{
// You can add your code here
}
//****************************************************************************//
//****************************************************************************//
// MSP430 state machine
// fsm.h
//
// Describtion:
// A simple state machine for the MSP430
//
// Generated with Excel Table
// Date: 01/07/2023 Time: 21:51:25
//
//****************************************************************************//
#ifndef FSM_H
#define FSM_H
#include <stdint.h>
#include <stdio.h>
//****************************************************************************//
// State table typedef
//****************************************************************************//
typedef struct
{
void (*ptrFunct) (void);
uint8_t NextState;
} FSM_STATE_TABLE;
#define NR_EVENTS 8
#define S1_0_S2_0 0
#define S1_0_S2_1 1
#define S1_1_S2_0 2
#define S1_1_S2_1 3
#define TRIG_0_ECHO_0 4
#define TRIG_0_ECHO_1 5
#define TRIG_1_ECHO_0 6
#define TRIG_1_ECHO_1 7
#define NR_STATES 4
#define EDO_A 0
#define EDO_B 1
#define EDO_C 2
#define EDO_D 3
//****************************************************************************//
// Function prototypes
//****************************************************************************//
// Initialize state machine
void FSM_Init (void);
//****************************************************************************//
#endif /* FSM_H */
//****************************************************************************//