This repository has been archived on 2024-01-25. You can view files and clone it, but cannot push or open issues or pull requests.
SummerSchool2-Controller/306-controller_interface.X/app/can_message.h
2023-08-31 13:42:31 +02:00

107 lines
2.8 KiB
C

/**
* @author Rémi Heredero
* @version 1.0.0
* @date August 2023
* @file can_message.h
*/
#ifndef CAN_MESSAGE_H
#define CAN_MESSAGE_H
#include <stdint.h> // usage of standard types
#include <stdbool.h> // usage of boolean types
#include "../mcc_generated_files/mcc.h"
/*
S R M
1 0 F CONTROL_ALIVE - - - -
1 2 0 JOY_SETUP Mode Param1 Param2 aliveTime
1 3 0 DISPLAY_SETUP reset - - aliveTime
1 3 2 DISPLAY_SPEED valH valL - -
1 3 3 DISPLAY_DIRECTION direction - - -
1 4 0 DRIVE_SETUP Reset/init speedTime stopTime aliveTime
1 4 1 DRIVE_POWER valH valL - -
1 5 0 STEERING_SETUP Reset/init homing setCenter aliveTime
1 5 1 STEERING_SET valHH valH valL valLL
1 6 0 SETUP_CONTROL batteryVoltTime batteryCurrentTime batteryEnergyTime aliveTime
*/
/**
* Process an incoming message
* @param idSender id of the sender
* @param idMsg is of the message
* @param data data of the message
*/
void CM_processIncome(uint8_t idSender, uint8_t idMsg, uint32_t data);
/**
* Send alive message from controller
* @param p have to be NULL
*/
void CM_CONTROLLER_ALIVE(void* p);
/**
* Send setup to the joystick (settings from memory)
* @param p have to be NULL
*/
void CM_JOY_SETUP(void* p);
/**
* Send setup to the display (settings from memory)
* @param p have to be NULL
*/
void CM_DISPLAY_SETUP(void* p);
/**
* Send speed to display
* @param p the speed in 100m/h (max 255 m/h)
*/
void CM_DISPLAY_SPEED(void* p);
/**
* Send direction of the steering wheel
* 0 is straight forward
* positive value is going right
* negative value is going left
* @param p the direction (int 8)
*/
void CM_DISPLAY_DIRECTION(void* p);
/**
* Send setup to the drive
* use with reset in parameter
* other settings from memory
* @param p 1 if reset/init 0 else
*/
void CM_DRIVE_SETUP(void* p);
/**
* Send power to the drive
* @param p the torque (int16_t*)
*/
void CM_DRIVE_POWER(void* p);
/**
* Send setup to the steering
* can be use for reset (1), homing (2) and setCenter (3)
* @param p 0 for setup, 1 for reset, 2 for homing, 3 for setCenter
*/
void CM_STEERING_SETUP(void* p);
/**
* Send position for steering
* no negative value because 0 is home (sensor)
* @param p the position (uint32_t*)
*/
void CM_STEERING_SET(void* p);
/**
* Send setup to the supply (settings from memory)
* @param p have to be NULL
*/
void CM_SUPPLY_SETUP(void* p);
#endif /* CAN_MESSAGE_H */