Midnight Sun Firmware
Loading...
Searching...
No Matches
motor can

WS22 motor can library. More...

Classes

struct  Ws22MotorControlData
 Motor control command data structure. More...
 
struct  Ws22MotorTelemetryData
 Motor status and telemetry data structure. More...
 
struct  Ws22MotorCanConfig
 
struct  Ws22MotorCanStorage
 WS22 motor CAN interface storage structure. More...
 

Macros

#define WS22_CAN_BASE_CONTROL   0x500U
 
#define WS22_CAN_BASE_STATUS   0x80U
 
#define VEHICLE_RPM_TO_KPH   0.10367f
 
#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 Ws22MotorCanStorage Ws22MotorCanStorage
 WS22 motor CAN interface storage structure.
 

Functions

StatusCode ws22_motor_can_init (Ws22MotorCanStorage *storage, Ws22MotorCanConfig *config)
 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 (float velocity)
 Set motor control velocity command. More...
 
StatusCode ws22_motor_can_process_rx (uint8_t *msg_data_u8, uint32_t msg_id_raw, uint8_t msg_dlc)
 Process received CAN message for motor controller. More...
 
Ws22MotorControlDataws22_motor_can_get_control_data (void)
 Get current motor control data. More...
 
Ws22MotorTelemetryDataws22_motor_can_get_telemetry_data (void)
 Get current motor telemetry data. More...
 

Detailed Description

WS22 motor can library.

Macro Definition Documentation

◆ WS22_CAN_BASE_CONTROL

#define WS22_CAN_BASE_CONTROL   0x500U

Base address for control messages

◆ WS22_CAN_BASE_STATUS

#define WS22_CAN_BASE_STATUS   0x80U

Base address for status messages

Function Documentation

◆ ws22_motor_can_get_control_data()

Ws22MotorControlData * ws22_motor_can_get_control_data ( void  )

Get current motor control data.

Returns
Pointer to motor control data (read-only)

◆ ws22_motor_can_get_telemetry_data()

Ws22MotorTelemetryData * ws22_motor_can_get_telemetry_data ( void  )

Get current motor telemetry data.

Returns
Pointer to motor telemetry data (read-only)

◆ ws22_motor_can_init()

StatusCode ws22_motor_can_init ( Ws22MotorCanStorage storage,
Ws22MotorCanConfig config 
)

Initialize the WS22 motor CAN interface.

Parameters
storagePointer to Front controller storage structure
Returns
STATUS_CODE_OK on success, error code otherwise

◆ ws22_motor_can_process_rx()

StatusCode ws22_motor_can_process_rx ( uint8_t *  msg_data_u8,
uint32_t  msg_id_raw,
uint8_t  msg_dlc 
)

Process received CAN message for motor controller.

Parameters
msgPointer to received CAN message
Returns
STATUS_CODE_OK on success, STATUS_CODE_UNIMPLEMENTED for unknown message IDs

◆ ws22_motor_can_set_current()

StatusCode ws22_motor_can_set_current ( float  current)

Set motor control current command.

Parameters
currentMotor current command (0.0 to 1.0)
Returns
STATUS_CODE_OK on success, STATUS_CODE_INVALID_ARGS if out of range

◆ ws22_motor_can_set_velocity()

StatusCode ws22_motor_can_set_velocity ( float  velocity)

Set motor control velocity command.

Parameters
velocityMotor velocity command (rpm)
Returns
STATUS_CODE_OK on success, STATUS_CODE_INVALID_ARGS if out of range