Midnight Sun Firmware
Loading...
Searching...
No Matches
steering.h
1#pragma once
2
3/************************************************************************************************
4 * @file steering.h
5 *
6 * @brief Header file for steering
7 *
8 * @date 2025-07-09
9 * @author Midnight Sun Team #24 - MSXVI
10 ************************************************************************************************/
11
12/* Standard library Headers */
13#include <stdbool.h>
14#include <stdint.h>
15
16/* Inter-component Headers */
17#include "global_enums.h"
18#include "ws22_motor_can.h"
19
20/* Intra-component Headers */
21#include "status.h"
22
29/* Forward declarations */
30struct ButtonManager;
31struct ButtonLEDManager;
33
35#define STEERING_BUTTON_DEBOUNCE_PERIOD_MS 5U
36
38#define STEERING_CRUISE_MAX_SPEED_KMH 1000U // 80
39
41#define STEERING_CRUISE_MIN_SPEED_KMH 0U // 40
42
46typedef enum {
47 STEERING_BUTTON_HAZARDS,
48 STEERING_BUTTON_DRIVE,
49 STEERING_BUTTON_NEUTRAL,
50 STEERING_BUTTON_REVERSE,
51
52 STEERING_BUTTON_REGEN,
53
54 STEERING_BUTTON_LEFT_LIGHT,
55 STEERING_BUTTON_RIGHT_LIGHT,
56
57 STEERING_BUTTON_HORN,
58
59 STEERING_BUTTON_CRUISE_CONTROL_UP,
60 STEERING_BUTTON_CRUISE_CONTROL_DOWN,
61
62 NUM_STEERING_BUTTONS,
64
68typedef struct {
72
76typedef struct {
78 uint8_t brake_percentage;
79
80 // int16_t motor_heatsink_temp; /**< Temperature of the motor heatsink */
81 // int16_t motor_temp; /**< Temperature of the motor */
82
84 // int16_t motor_velocity; /**< Angular velocity of the motor in ??? */
85
86 uint16_t bps_fault;
88 // uint16_t ws22_flags; /**< Error and limit flags from the WS22 */
89 float state_of_charge;
91 int16_t dcdc_voltage;
92 int16_t dcdc_current;
93 int16_t aux_voltage;
94 int16_t aux_current;
96 uint16_t pack_voltage;
97 uint16_t cell_voltages[36];
98 // uint16_t motor_bus_voltage; /**< Motor bus voltage reading (V) */
99 uint16_t pack_current;
102 uint16_t max_cell_temp;
104 VehicleDriveState drive_state;
105 uint8_t brake_enabled;
106 uint8_t regen_enabled;
107 uint8_t precharge_complete;
109
113typedef struct {
118 uint8_t drive_state;
119 uint8_t light_signal;
131
139StatusCode steering_init(SteeringStorage *storage, SteeringConfig *config, Ws22MotorCanConfig *motor_can_config);
140
VehicleDriveState
Vehicle drive states.
Definition: global_enums.h:32
StatusCode
StatusCodes for various errors.
Definition: status.h:27
StatusCode steering_init(SteeringStorage *storage, SteeringConfig *config, Ws22MotorCanConfig *motor_can_config)
Initialize the steering interface.
Definition: steering.c:57
SteeringButtons
Steering buttons.
Definition: steering.h:46
Definition: button_led_manager.h:57
Button Manager structure.
Definition: button_manager.h:32
Data for the display, CAN RX or internal.
Definition: steering.h:76
int16_t vehicle_velocity
Definition: steering.h:83
int16_t dcdc_current
Definition: steering.h:92
uint8_t pedal_percentage
Definition: steering.h:77
int16_t aux_voltage
Definition: steering.h:93
uint16_t max_cell_voltage_mv
Definition: steering.h:101
int16_t dcdc_voltage
Definition: steering.h:91
uint8_t bps_fault_cell
Definition: steering.h:87
uint16_t bps_fault
Definition: steering.h:86
uint16_t min_cell_voltage_mv
Definition: steering.h:100
uint16_t pack_current
Definition: steering.h:99
int16_t aux_current
Definition: steering.h:94
uint16_t pack_voltage
Definition: steering.h:96
uint16_t max_cell_temp
Definition: steering.h:102
Steering configuration data.
Definition: steering.h:68
uint16_t cruise_min_speed_kmh
Definition: steering.h:69
uint16_t cruise_max_speed_kmh
Definition: steering.h:70
Steering storage.
Definition: steering.h:113
float estimated_km_remaining
Definition: steering.h:126
uint8_t drive_state
Definition: steering.h:118
bool cruise_control_enabled
Definition: steering.h:115
struct Ws22MotorCanStorage * ws22_motor_can_storage
Definition: steering.h:123
uint16_t cruise_control_target_speed_kmh
Definition: steering.h:117
uint8_t light_signal
Definition: steering.h:119
struct ButtonLEDManager * button_led_manager
Definition: steering.h:122
Ws22MotorCanConfig * ws22_motor_can_config
Definition: steering.h:129
struct ButtonManager * button_manager
Definition: steering.h:121
DisplayData display_data
Definition: steering.h:124
SteeringConfig * config
Definition: steering.h:128
bool horn_enabled
Definition: steering.h:114
Definition: ws22_motor_can.h:94
WS22 motor CAN interface storage structure.
Definition: ws22_motor_can.h:109