0% found this document useful (0 votes)
61 views23 pages

FSM Generator

The document describes a finite state machine (FSM) with 4 states (E00, E10, E20, E2530, E35) and 4 events (BTN_10, BTN_25, BTN_RST, BTN_C). It shows the function and next state for each current state and event combination.

Uploaded by

P. Garcìa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views23 pages

FSM Generator

The document describes a finite state machine (FSM) with 4 states (E00, E10, E20, E2530, E35) and 4 events (BTN_10, BTN_25, BTN_RST, BTN_C). It shows the function and next state for each current state and event combination.

Uploaded by

P. Garcìa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
You are on page 1/ 23

Number of states: 5

Number of events: 4 Generate Code

BTN_10 BTN_25 BTN_RST BTN_C


Function Next State Function Next State Function Next State Function Next State
E00 inserta10 E10 inserta25 E2530 reinicia E00 comprar E00
E10 inserta10 E20 inserta25 E35 reinicia E00 comprar E10
E20 inserta10 E2530 inserta25 E35 reinicia E00 comprar E20
E2530 inserta10 E35 inserta25 E35 reinicia E00 comprar E2530
E35 inserta10 E35 inserta25 E35 reinicia E00 comprar E00
State5
State6
State7
State8
State9
State10
State11
State12
State13
State14
State15
State16
State17
State18
State19
State20
State21
State22
State23
State24
State25
State26
State27
State28
State29
State30
State31
de

Event4 Event5 Event6 Event7 Event8


Function Next State Function Next State Function Next State Function Next State Function
Event9 Event10 Event11 Event12
Next State Function Next State Function Next State Function Next State Function Next State
Event13 Event14 Event15 Event16 Event17
Function Next State Function Next State Function Next State Function Next State Function
nt17 Event18 Event19 Event20 Event21
Next State Function Next State Function Next State Function Next State Function Next State
Event22 Event23 Event24 Event25 Event26
Function Next State Function Next State Function Next State Function Next State Function
nt26 Event27 Event28 Event29 Event30
Next State Function Next State Function Next State Function Next State Function Next State
Event31
Function Next State
//****************************************************************************//
// MSP430 state machine
// fsm.c
//
// Describtion:
// A simple state machine for the MSP430
// Do not change code in here!!!
//
// Generated with Excel Table
// Date: 01/07/2023 Time: 21:51:25
//
//****************************************************************************//

#include <stdint.h>
#include <stdio.h>
#include "fsm.h"

//****************************************************************************//
// Global variables
//****************************************************************************//
uint8_t ActState;

const FSM_STATE_TABLE StateTable [NR_STATES][NR_EVENTS] =


{
NULL, EDO_A, FSM_gira_izquierda, EDO_B, FSM_gira_derecha, EDO_C, NULL, EDO_A, NULL, EDO_A, FSM_
FSM_avanza_frente, EDO_A, NULL, EDO_B, NULL, EDO_B, FSM_avanza_frente, EDO_A, NULL, EDO_B, FSM
FSM_avanza_frente, EDO_A, NULL, EDO_C, NULL, EDO_C, FSM_avanza_frente, EDO_A, NULL, EDO_C, FSM
NULL, EDO_D, NULL, EDO_D, NULL, EDO_D, NULL, EDO_D, FSM_avanza_frente, EDO_A, NULL, EDO_D, FS
};

//****************************************************************************//
// 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;

extern uint8_t ActState;

#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);

// Event function "S1_0_S2_0"


void FSM_S1_0_S2_0 (void);

// Event function "S1_0_S2_1"


void FSM_S1_0_S2_1 (void);

// Event function "S1_1_S2_0"


void FSM_S1_1_S2_0 (void);

// Event function "S1_1_S2_1"


void FSM_S1_1_S2_1 (void);

// Event function "Trig_0_Echo_0"


void FSM_Trig_0_Echo_0 (void);

// Event function "Trig_0_Echo_1"


void FSM_Trig_0_Echo_1 (void);

// Event function "Trig_1_Echo_0"


void FSM_Trig_1_Echo_0 (void);

// Event function "Trig_1_Echo_1"


void FSM_Trig_1_Echo_1 (void);

// Transition function "gira_izquierda"


void FSM_gira_izquierda (void);

// Transition function "gira_derecha"


void FSM_gira_derecha (void);

// Transition function "detenerse"


void FSM_detenerse (void);

// Transition function "avanza_frente"


void FSM_avanza_frente (void);

//****************************************************************************//

#endif /* FSM_H */

//****************************************************************************//

You might also like