Midnight Sun Firmware
Loading...
Searching...
No Matches
Steering

steering Firmware More...

Classes

struct  ButtonCallbacks
 Button Callbacks. More...
 
struct  ButtonConfig
 Button configuration structure. More...
 
struct  Button
 Button instance structure. More...
 
struct  LEDPixels
 
struct  ButtonLEDManager
 
struct  ButtonManager
 Button Manager structure. More...
 
struct  SteeringConfig
 Steering configuration data. More...
 
struct  SteeringStorage
 Steering storage. More...
 

Macros

#define BUTTON_LED_MANAGER_BITS_PER_LED   (24U)
 
#define BUTTON_LED_MANAGER_DMA_BUF_LEN   (512U)
 
#define BUTTON_MANAGER_DEBUG   0
 
#define STEERING_BUTTON_DEBOUNCE_PERIOD_MS   5U
 
#define STEERING_CAN_RX    { .port = GPIO_PORT_B, .pin = 8 }
 Steering CAN RX Port.
 
#define STEERING_CAN_TX    { .port = GPIO_PORT_B, .pin = 9 }
 Steering CAN TX Port.
 
#define STEERING_LEFT_TURN_BUTTON    { .port = GPIO_PORT_B, .pin = 3 }
 Steering left turn button.
 
#define STEERING_RIGHT_TURN_BUTTON    { .port = GPIO_PORT_B, .pin = 4 }
 Steering right turn button.
 
#define STEERING_HAZARDS_BUTTON    { .port = GPIO_PORT_B, .pin = 5 }
 Steering hazards button.
 
#define STEERING_NEUTRAL_BUTTON    { .port = GPIO_PORT_A, .pin = 5 }
 Steering neutral button.
 
#define STEERING_DRIVE_BUTTON    { .port = GPIO_PORT_A, .pin = 6 }
 Steering drive button.
 
#define STEERING_REVERSE_BUTTON    { .port = GPIO_PORT_A, .pin = 7 }
 Steering reverse button.
 
#define STEERING_HORN_BUTTON    { .port = GPIO_PORT_B, .pin = 6 }
 Steering horn button.
 
#define STEERING_DISPLAY_CTRL    { .port = GPIO_PORT_A, .pin = 0 }
 Display control (Push-pull to control display state)
 
#define STEERING_DISPLAY_CURRENT_CTRL    { .port = GPIO_PORT_A, .pin = 1 }
 Display current control (PWM to control % of current)
 
#define STEERING_RGB_LIGHTS_PWM_PIN    { .port = GPIO_PORT_A, .pin = 2 }
 PWM pin for RGB LED control.
 

Typedefs

typedef struct Button Button
 Button instance structure.
 
typedef struct ButtonLEDManager ButtonLEDManager
 
typedef struct ButtonManager ButtonManager
 Button Manager structure.
 

Enumerations

enum  ButtonState { BUTTON_IDLE , BUTTON_PRESSED }
 Button states representing current input. More...
 
enum  DriveState { DRIVE_STATE_INVALID = 0 , DRIVE_STATE_NEUTRAL , DRIVE_STATE_DRIVE , DRIVE_STATE_REVERSE }
 Drive states representing the current output. More...
 
enum  DriveStateRequest { DRIVE_STATE_REQUEST_NONE = 0 , DRIVE_STATE_REQUEST_D , DRIVE_STATE_REQUEST_N , DRIVE_STATE_REQUEST_R }
 Requests made to control the drive state. More...
 
enum  LightsSignalState { LIGHTS_SIGNAL_STATE_OFF = 0 , LIGHTS_SIGNAL_STATE_LEFT , LIGHTS_SIGNAL_STATE_RIGHT , LIGHTS_SIGNAL_STATE_HAZARD }
 Light signal states representing the current output. More...
 
enum  LightsSignalRequest { LIGHTS_SIGNAL_REQUEST_OFF = 0 , LIGHTS_SIGNAL_REQUEST_LEFT , LIGHTS_SIGNAL_REQUEST_RIGHT , LIGHTS_SIGNAL_REQUEST_HAZARD }
 Requests made to control the light signals. More...
 
enum  SteeringButtons {
  STEERING_BUTTON_LEFT_LIGHT , STEERING_BUTTON_RIGHT_LIGHT , STEERING_BUTTON_HAZARDS , STEERING_BUTTON_DRIVE ,
  STEERING_BUTTON_REVERSE , STEERING_BUTTON_NEUTRAL , STEERING_BUTTON_HORN , STEERING_BUTTON_REGEN ,
  STEERING_BUTTON_PUSH_TO_TALK , STEERING_BUTTON_CRUISE_CONTROL_UP , STEERING_BUTTON_CRUISE_CONTROL_DOWN , NUM_STEERING_BUTTONS
}
 Steering buttons.
 

Functions

StatusCode button_init (Button *button, ButtonConfig *config)
 Initialize a button instance. More...
 
StatusCode button_update (Button *button)
 Update the Button state based on the given GPIO state. More...
 
StatusCode button_led_manager_init (SteeringStorage *storage)
 Initialize the button LED manager. More...
 
StatusCode button_led_manager_set_color (SteeringButtons button, LEDPixels color_code)
 Update a button's LED color (marks for update but doesn't transmit immediately) More...
 
StatusCode button_led_manager_update (void)
 Force immediate update of all LEDs (call after setting colors) More...
 
bool button_led_manager_is_busy (void)
 Check if the LED manager is currently transmitting data. More...
 
StatusCode button_led_manager_clear_all (void)
 Set all LEDs to off (black) More...
 
StatusCode button_manager_init (SteeringStorage *storage)
 Initialize the button manager. More...
 
StatusCode button_manager_update (void)
 Update the button manager. More...
 
void drive_state_manager_init (void)
 Initialize the drive state manager.
 
void drive_state_manager_request (DriveStateRequest req)
 Make a request to change the drive state. More...
 
void drive_state_manager_update (void)
 Update the drive state based on the current request.
 
DriveState drive_state_manager_get_state (void)
 Get the current state of the drive controller. More...
 
void lights_signal_manager_init (void)
 Initialize the light signal manager.
 
void lights_signal_manager_request (LightsSignalRequest req)
 Make a request to change the signal state. More...
 
void lights_signal_manager_update (void)
 Update the signal state based on the current request.
 
LightsSignalState lights_signal_manager_get_state (void)
 Get the current state of the signal lights. More...
 
StatusCode steering_init (SteeringStorage *storage, SteeringConfig *config)
 Initialize the steering interface. More...
 

Detailed Description

steering Firmware

Macro Definition Documentation

◆ BUTTON_MANAGER_DEBUG

#define BUTTON_MANAGER_DEBUG   0

Set to 1 to enable debug prints

Enumeration Type Documentation

◆ ButtonState

Button states representing current input.

Enumerator
BUTTON_IDLE 

Button is not pressed

BUTTON_PRESSED 

Button is pressed

◆ DriveState

enum DriveState

Drive states representing the current output.

Enumerator
DRIVE_STATE_INVALID 

Wrong State

DRIVE_STATE_NEUTRAL 

Car Not Actively Moving in Neutral

DRIVE_STATE_DRIVE 

Car Drive Forward

DRIVE_STATE_REVERSE 

Car Drive Reverse

◆ DriveStateRequest

Requests made to control the drive state.

Enumerator
DRIVE_STATE_REQUEST_NONE 

No Request

DRIVE_STATE_REQUEST_D 

Request to switch to drive

DRIVE_STATE_REQUEST_N 

Request to switch to neutral

DRIVE_STATE_REQUEST_R 

Request to switch to reverse

◆ LightsSignalRequest

Requests made to control the light signals.

Enumerator
LIGHTS_SIGNAL_REQUEST_OFF 

Request to turn off signals

LIGHTS_SIGNAL_REQUEST_LEFT 

Request to turn on left signal

LIGHTS_SIGNAL_REQUEST_RIGHT 

Request to turn on right signal

LIGHTS_SIGNAL_REQUEST_HAZARD 

Request to turn on hazard signal

◆ LightsSignalState

Light signal states representing the current output.

Enumerator
LIGHTS_SIGNAL_STATE_OFF 

All lights off

LIGHTS_SIGNAL_STATE_LEFT 

Left signal active

LIGHTS_SIGNAL_STATE_RIGHT 

Right signal active

LIGHTS_SIGNAL_STATE_HAZARD 

Hazard signal active

Function Documentation

◆ button_init()

StatusCode button_init ( Button button,
ButtonConfig config 
)

Initialize a button instance.

Parameters
buttonPointer to the Button instance to initialize
configPointer to the ButtonConfig structure
Returns
STATUS_CODE_OK if initialized successfully STATUS_CODE_INVALID_ARGS if an invalid parameter is passed in

◆ button_led_manager_clear_all()

StatusCode button_led_manager_clear_all ( void  )

Set all LEDs to off (black)

Returns
STATUS_CODE_OK if successful

◆ button_led_manager_init()

StatusCode button_led_manager_init ( SteeringStorage storage)

Initialize the button LED manager.

Parameters
storagePointer to the SteeringStorage instance
Returns
STATUS_CODE_OK if initialized successfully STATUS_CODE_INVALID_ARGS if an invalid parameter is passed in

◆ button_led_manager_is_busy()

bool button_led_manager_is_busy ( void  )

Check if the LED manager is currently transmitting data.

Returns
true if DMA transmission is in progress, false otherwise

◆ button_led_manager_set_color()

StatusCode button_led_manager_set_color ( SteeringButtons  button,
LEDPixels  color_code 
)

Update a button's LED color (marks for update but doesn't transmit immediately)

Parameters
buttonButton selector for modification
color_codeRGB color code for the button LED
Returns
STATUS_CODE_OK if set successfully STATUS_CODE_UNINITIALIZED if the system has not already been initialized STATUS_CODE_INVALID_ARGS if the button is invalid

◆ button_led_manager_update()

StatusCode button_led_manager_update ( void  )

Force immediate update of all LEDs (call after setting colors)

Returns
STATUS_CODE_OK if transmission started successfully STATUS_CODE_UNINITIALIZED if the system has not been initialized STATUS_CODE_RESOURCE_EXHAUSTED if DMA is busy

◆ button_manager_init()

StatusCode button_manager_init ( SteeringStorage storage)

Initialize the button manager.

Parameters
storagePointer to the SteeringStorage instance
Returns
STATUS_CODE_OK if initialized successfully STATUS_CODE_INVALID_ARGS if an invalid parameter is passed in

◆ button_manager_update()

StatusCode button_manager_update ( void  )

Update the button manager.

Parameters
managerPointer to the ButtonManager instance
Returns
STATUS_CODE_OK if updated successfully STATUS_CODE_UNINITIALIZED if the system has not already been initialized

◆ button_update()

StatusCode button_update ( Button button)

Update the Button state based on the given GPIO state.

Parameters
buttonPointer to the Button instance
Returns
STATUS_CODE_OK if initialized successfully STATUS_CODE_INVALID_ARGS if an invalid parameter is passed in

◆ drive_state_manager_get_state()

DriveState drive_state_manager_get_state ( void  )

Get the current state of the drive controller.

Returns
Current drive state

◆ drive_state_manager_request()

void drive_state_manager_request ( DriveStateRequest  req)

Make a request to change the drive state.

Parameters
reqThe requested drive state

◆ lights_signal_manager_get_state()

LightsSignalState lights_signal_manager_get_state ( void  )

Get the current state of the signal lights.

Returns
The current light signal state

◆ lights_signal_manager_request()

void lights_signal_manager_request ( LightsSignalRequest  req)

Make a request to change the signal state.

Parameters
reqThe requested light signal state

◆ steering_init()

StatusCode steering_init ( SteeringStorage storage,
SteeringConfig config 
)

Initialize the steering interface.

Parameters
storagePointer to the steering storage
configPointer to the steering config
Returns
STATUS_CODE_OK if steering initialization succeeded STATUS_CODE_INVALID_ARGS if one of the parameters are incorrect