PER Firmware
Loading...
Searching...
No Matches
vehicle_fsm.h
Go to the documentation of this file.
1#ifndef VEHICLE_FSM_H
2#define VEHICLE_FSM_H
3
11#include "amk.h"
12#include "can_library/generated/can_types.h"
13
14typedef struct {
15 car_state_t current_state;
16 car_state_t next_state;
17 AMK_t front_right; // INVA
18 AMK_t front_left; // INVB
19 AMK_t rear_left; // INVC
20 AMK_t rear_right; // INVD
21
22 // internal state variables
23 uint32_t buzzer_start_time;
24 bool last_start_button_state;
25 bool brake_light;
26 bool tsal_green_enable;
27 bool tsal_red_enable;
28 bool buzzer_enable;
29
30 bool is_precharge_complete; // AMKs are pointed to this variable
31} car_t;
32
33typedef struct {
34 int16_t front_right;
35 int16_t front_left;
36 int16_t rear_left;
37 int16_t rear_right;
39
40extern car_t g_car;
41extern torque_request_t g_torque_request;
42
43static constexpr uint32_t VEHICLE_FSM_PERIOD_MS = 15;
44
45// static assert that the FSM flushes the CAN messages it owns at least as fast as their defined periods
46static_assert(VEHICLE_FSM_PERIOD_MS == INVA_SET_PERIOD_MS);
47static_assert(VEHICLE_FSM_PERIOD_MS == INVB_SET_PERIOD_MS);
48static_assert(VEHICLE_FSM_PERIOD_MS == INVC_SET_PERIOD_MS);
49static_assert(VEHICLE_FSM_PERIOD_MS == INVD_SET_PERIOD_MS);
50
51void vehicle_fsm_periodic(void);
52
53#endif // VEHICLE_FSM_H
Definition amk.h:16
Definition vehicle_fsm.h:14
Definition vehicle_fsm.h:33