![]() |
Midnight Sun Firmware
|
Front Controller Board Firmware. More...
Classes | |
| struct | AccelPedalCalibrationData |
| struct | AccelPedalStorage |
| struct | BrakePedalCalibrationData |
| struct | BrakePedalStorage |
| struct | FrontControllerConfig |
| Front Controller configuration data. More... | |
| struct | FrontControllerStorage |
| Front Controller storage. More... | |
| struct | OpdCalibrationStorage |
| struct | OpdStorage |
| struct | Ws22MotorControlData |
| Motor control command data structure. More... | |
| struct | Ws22MotorTelemetryData |
| Motor status and telemetry data structure. More... | |
| struct | Ws22MotorCanStorage |
| WS22 motor CAN interface storage structure. More... | |
Macros | |
| #define | FRONT_CONTROLLER_ACCEL_INPUT_DEADZONE 0.02f |
| Front controller pedal set to 2% deadzone | |
| #define | FRONT_CONTROLLER_ACCEL_REMAP_MIN 0.10f |
| Front controller pedal is remapped from 0 - 1 to 0.1 to 1. | |
| #define | FRONT_CONTROLLER_ACCEL_CURVE_EXPONENT 2.0f |
| Front controller pedal exponent for non-linear feel. | |
| #define | FRONT_CONTROLLER_ACCEL_LPF_ALPHA 0.25f |
| Front controller pedal alpha value for low-pass filtering. | |
| #define | FRONT_CONTROLLER_CAN_RX { .port = GPIO_PORT_B, .pin = 8 } |
| Front Controller CAN RX Port. | |
| #define | FRONT_CONTROLLER_CAN_TX { .port = GPIO_PORT_B, .pin = 9 } |
| Front Controller CAN TX Port. | |
| #define | FRONT_CONTROLLER_HEADLIGHT_LS_ENABLE { .port = GPIO_PORT_A, .pin = 1 } |
| Front Controller headlight load switch enable. | |
| #define | FRONT_CONTROLLER_LEFT_SIG_LS_ENABLE { .port = GPIO_PORT_A, .pin = 8 } |
| Front Controller left signal load switch enable. | |
| #define | FRONT_CONTROLLER_RIGHT_SIG_LS_ENABLE { .port = GPIO_PORT_A, .pin = 9 } |
| Front Controller right signal load switch enable. | |
| #define | FRONT_CONTROLLER_BRAKE_LIGHT_LS_ENABLE { .port = GPIO_PORT_A, .pin = 10 } |
| Front Controller brake light load switch enable. | |
| #define | FRONT_CONTROLLER_BPS_LIGHT_LS_ENABLE { .port = GPIO_PORT_A, .pin = 11 } |
| Front Controller battery-protection-system light load switch enable. | |
| #define | FRONT_CONTROLLER_DRIVER_FAN_LS_ENABLE { .port = GPIO_PORT_A, .pin = 12 } |
| Front Controller driver fan load switch enable. | |
| #define | FRONT_CONTROLLER_REV_CAM_LS_ENABLE { .port = GPIO_PORT_A, .pin = 15 } |
| Front Controller reverse camera load switch enable. | |
| #define | FRONT_CONTROLLER_TELEM_LS_ENABLE { .port = GPIO_PORT_B, .pin = 2 } |
| Front Controller telemetry load switch enable. | |
| #define | FRONT_CONTROLLER_STEERING_LS_ENABLE { .port = GPIO_PORT_B, .pin = 3 } |
| Front Controller steering load switch enable. | |
| #define | FRONT_CONTROLLER_HORN_LS_ENABLE { .port = GPIO_PORT_B, .pin = 4 } |
| Front Controller horn load switch enable. | |
| #define | FRONT_CONTROLLER_SPARE_1_LS_ENABLE { .port = GPIO_PORT_B, .pin = 10 } |
| Front Controller spare 12V load switch enable. | |
| #define | FRONT_CONTROLLER_SPARE_2_LS_ENABLE { .port = GPIO_PORT_B, .pin = 11 } |
| Front Controller spare 12V load switch enable. | |
| #define | FRONT_CONTROLLER_MUX_SEL_0 { .port = GPIO_PORT_B, .pin = 12 } |
| Front Controller current sense mux select 0. | |
| #define | FRONT_CONTROLLER_MUX_SEL_1 { .port = GPIO_PORT_B, .pin = 13 } |
| Front Controller current sense mux select 1. | |
| #define | FRONT_CONTROLLER_MUX_SEL_2 { .port = GPIO_PORT_B, .pin = 14 } |
| Front Controller current sense mux select 2. | |
| #define | FRONT_CONTROLLER_MUX_SEL_3 { .port = GPIO_PORT_B, .pin = 15 } |
| Front Controller current sense mux select 3. | |
| #define | FRONT_CONTROLLER_MUX_OUTPUT { .port = GPIO_PORT_A, .pin = 2 } |
| Front Controller current sense mux input. | |
| #define | FRONT_CONTROLLER_ACCEL_PEDAL { .port = GPIO_PORT_A, .pin = 3 } |
| Front Controller accelerator pedal input. | |
| #define | FRONT_CONTROLLER_BRAKE_PEDAL { .port = GPIO_PORT_A, .pin = 5 } |
| Front Controller brake pedal input. | |
| #define | WS22_CAN_BASE_CONTROL 0x500U |
| #define | WS22_CAN_BASE_STATUS 0x400U |
| #define | WS22_CAN_ID_DRIVE_CMD (WS22_CAN_BASE_CONTROL + 0x01U) |
| #define | WS22_CAN_ID_STATUS_INFO (WS22_CAN_BASE_STATUS + 0x01U) |
| #define | WS22_CAN_ID_BUS_MEASUREMENT (WS22_CAN_BASE_STATUS + 0x02U) |
| #define | WS22_CAN_ID_VELOCITY_MEASUREMENT (WS22_CAN_BASE_STATUS + 0x03U) |
| #define | WS22_CAN_ID_PHASE_CURRENT (WS22_CAN_BASE_STATUS + 0x04U) |
| #define | WS22_CAN_ID_MOTOR_VOLTAGE (WS22_CAN_BASE_STATUS + 0x05U) |
| #define | WS22_CAN_ID_MOTOR_CURRENT (WS22_CAN_BASE_STATUS + 0x06U) |
| #define | WS22_CAN_ID_MOTOR_BACK_EMF (WS22_CAN_BASE_STATUS + 0x07U) |
| #define | WS22_CAN_ID_RAIL_15V (WS22_CAN_BASE_STATUS + 0x08U) |
| #define | WS22_CAN_ID_TEMPERATURE (WS22_CAN_BASE_STATUS + 0x0BU) |
Typedefs | |
| typedef struct AccelPedalStorage | AccelPedalStorage |
| typedef struct BrakePedalStorage | BrakePedalStorage |
| typedef struct OpdStorage | OpdStorage |
| typedef struct Ws22MotorCanStorage | Ws22MotorCanStorage |
| WS22 motor CAN interface storage structure. | |
Functions | |
| StatusCode | accel_pedal_run () |
| Reads the pedal percentage and applies deadzone and filtering before updating the storage. More... | |
| StatusCode | accel_pedal_init (FrontControllerStorage *storage) |
| Initializes the acceleration pedal hardware interface loads calibration data from memory. More... | |
| StatusCode | brake_pedal_run () |
| Reads the pedal percentage and applies deadzone and filtering before updating the brake state. More... | |
| StatusCode | brake_pedal_init (FrontControllerStorage *storage) |
| Initializes the brake pedal hardware interface loads calibration data from memory. More... | |
| StatusCode | front_controller_init (FrontControllerStorage *storage, FrontControllerConfig *config) |
| Initialize the front controller interface. More... | |
| StatusCode | opd_run () |
| StatusCode | opd_init (FrontControllerStorage *storage) |
| StatusCode | opd_calculate_handler (float pedal_percentage, PtsRelationType relation_type, float *calculated_reading, curveType curve_type) |
| StatusCode | opd_linear_calculate (float pedal_percentage, PtsRelationType relation_type, float *calculated_reading) |
| StatusCode | opd_quadratic_calculate (float pedal_percentage, PtsRelationType relation_type, float *calculated_reading) |
| StatusCode | ws22_motor_can_init (FrontControllerStorage *storage) |
| Initialize the WS22 motor CAN interface. More... | |
| StatusCode | ws22_motor_can_set_current (float current) |
| Set motor control current command. More... | |
| StatusCode | ws22_motor_can_set_velocity (uint32_t velocity) |
| Set motor control velocity command. More... | |
| StatusCode | ws22_motor_can_transmit_drive_command (void) |
| Build and transmit motor drive command. More... | |
| StatusCode | ws22_motor_can_process_rx (CanMessage *msg) |
| Process received CAN message for motor controller. More... | |
| Ws22MotorControlData * | ws22_motor_can_get_control_data (void) |
| Get current motor control data. More... | |
| Ws22MotorTelemetryData * | ws22_motor_can_get_telemetry_data (void) |
| Get current motor telemetry data. More... | |
Front Controller Board Firmware.
| #define WS22_CAN_BASE_CONTROL 0x500U |
Base address for control messages
| #define WS22_CAN_BASE_STATUS 0x400U |
Base address for status messages
| StatusCode accel_pedal_init | ( | FrontControllerStorage * | storage | ) |
Initializes the acceleration pedal hardware interface loads calibration data from memory.
| StatusCode accel_pedal_run | ( | ) |
Reads the pedal percentage and applies deadzone and filtering before updating the storage.
Convert ADC Reading to readable voltage by normalizing with calibration data and dividing to get percentage press. Negatives and > 100 values will be clamped
| StatusCode brake_pedal_init | ( | FrontControllerStorage * | storage | ) |
Initializes the brake pedal hardware interface loads calibration data from memory.
| StatusCode brake_pedal_run | ( | ) |
Reads the pedal percentage and applies deadzone and filtering before updating the brake state.
| StatusCode front_controller_init | ( | FrontControllerStorage * | storage, |
| FrontControllerConfig * | config | ||
| ) |
Initialize the front controller interface.
| storage | Pointer to the front controller storage |
| config | Pointer to the front controller config |
| Ws22MotorControlData * ws22_motor_can_get_control_data | ( | void | ) |
Get current motor control data.
| Ws22MotorTelemetryData * ws22_motor_can_get_telemetry_data | ( | void | ) |
Get current motor telemetry data.
| StatusCode ws22_motor_can_init | ( | FrontControllerStorage * | storage | ) |
Initialize the WS22 motor CAN interface.
| storage | Pointer to Front controller storage structure |
| StatusCode ws22_motor_can_process_rx | ( | CanMessage * | msg | ) |
Process received CAN message for motor controller.
| msg | Pointer to received CAN message |
| StatusCode ws22_motor_can_set_current | ( | float | current | ) |
Set motor control current command.
| current | Motor current command (0.0 to 1.0) |
| StatusCode ws22_motor_can_set_velocity | ( | uint32_t | velocity | ) |
Set motor control velocity command.
| velocity | Motor velocity command (rpm) |
| StatusCode ws22_motor_can_transmit_drive_command | ( | void | ) |
Build and transmit motor drive command.