-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfsm.h
125 lines (98 loc) · 2.8 KB
/
fsm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//****************************************************************************//
// MSP430 state machine
// fsm.h
//
// Describtion:
// A simple state machine for the MSP430
//
// Generated with Excel Table
// Date: 06/10/2021 Time: 14:34:35
//
//****************************************************************************//
#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;
//BOTONES EN EL PUERTO 1
#define BTN_R BIT0
#define BTN_V BIT4
#define BTN_A BIT5
#define BTN_B BIT6
#define INICIO BIT3
extern uint8_t ActState;
//LEDS EN P2
#define LED1 BIT2//ROJO
#define LED0 BIT5//VERDE
#define LED3 BIT4//AMARILLO
#define LED2 BIT0//AZUL
//BOTON DE INICIO Y REINICIO EN P2
#define TAP_1 1
#define TAP_2 2
#define TAP_3 4
#define TAP_4 15
#define INTER 500000
//Semilla
#define seed 0xF9CD
#define NR_EVENTS 8
#define BTNR 0
#define BTNA 1
#define BTNV 2
#define BTNB 3
#define INICIO_RST 4
#define SEC_GOOD 5
#define SEC_BAD 6
#define SEC_WIN 7
#define NR_STATES 4
#define ESPERA 0
#define ESPERASEC 1
#define DIGITA_SEC 2
#define GAME_OVER 3
//****************************************************************************//
unsigned int RNG_LFSR(unsigned int LFSR);
void Asignar(long int LFSR0, int gen[10]);
void Decod(int sec[10]);
int generado[10];
//****************************************************************************//
// Initialize state machine
void FSM_Init (void);
// Event function "BTNR"
void FSM_BTNR (void);
// Event function "BTNA"
void FSM_BTNA (void);
// Event function "BTNV"
void FSM_BTNV (void);
// Event function "BTNB"
void FSM_BTNB (void);
// Event function "INICIO_RST"
void FSM_INICIO_RST (void);
// Event function "SEC_GOOD"
void FSM_SEC_GOOD (void);
// Event function "SEC_BAD"
void FSM_SEC_BAD (void);
// Event function "SEC_WIN"
void FSM_SEC_WIN (void);
// Transition function "SEC_ESPERA"
void FSM_SEC_ESPERA (void);
// Transition function "INICIA_JUEGO"
void FSM_INICIA_JUEGO (void);
// Transition function "REVISA"
void FSM_REVISA (void);
// Transition function "DESPLIEGA"
void FSM_DESPLIEGA (void);
// Transition function "PERDISTE"
void FSM_PERDISTE (void);
// Transition function "GANASTE"
void FSM_GANASTE (void);
// Transition function "LIMPIA"
void FSM_LIMPIA (void);
//****************************************************************************//
#endif /* FSM_H */
//****************************************************************************//