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.c
2023-08-25 22:53:04 +02:00

104 lines
1.9 KiB
C

/**
* @author Rémi Heredero
* @version 1.0.0
* @date August 2023
* @file can_message.c
*/
#include "../middleware/can_interface.h"
#include "car.h"
#include "../app/factory/factory.h"
typedef union {
struct {
uint8_t byte0;
uint8_t byte1;
uint8_t byte2;
uint8_t byte3;
} separate;
struct {
uint32_t bytes;
} full;
} BYTES_4;
void CM_processIncome(uint8_t idSender, uint8_t idMsg, uint32_t data){
switch(idSender){
case 0: // Broadcast / Debug
break;
case 2: // Joystick
if(idMsg == 0x1) { // JOY_MESURE
}
if(idMsg == 0xF) { // JOY_ALIVE
ALIVE_CHECKER_ISALIVE(ACjoy());
if(ACjoy()->state == STAC_DEAD){
ALIVE_CHECKER_emitBorn(ACjoy(), 0, 0);
ALIVE_CHECKER_emitReady(ACjoy(), 100, 0);
}
}
break;
case 3: // Display
break;
case 4: // Drive
break;
case 5: // Steering
break;
case 6: // Supply
break;
case 7: // Undefined
break;
}
}
void CM_CONTROLLER_ALIVE(void* p) {
CAN_Send(0x0, 0xF, 0);
}
void CM_JOY_SETUP(void* p) {
BYTES_4 joy;
joy.separate.byte0 = CAR_CST.JOYSTICK_MODE;
joy.separate.byte1 = CAR_CST.JOYSTICK_PARAM1;
joy.separate.byte2 = CAR_CST.JOYSTICK_PARAM2;
joy.separate.byte3 = CAR_CST.JOYSTICK_ALIVE_TIME;
CAN_Send(2, 0, joy.full.bytes);
}
void CM_DISPLAY_SETUP(void* p) {
}
void CM_DISPLAY_SPEED(void* p) {
}
void CM_DISPLAY_DIRECTION(void* p) {
}
void CM_DRIVE_SETUP(void* p) {
}
void CM_DRIVE_POWER(void* p) {
}
void CM_STEERING_SETUP(void* p) {
}
void CM_STEERING_SET(void* p) {
}
void CM_SETUP_CONTROL(void* p) {
}