fix compiler

This commit is contained in:
Rémi Heredero 2023-09-01 10:40:11 +02:00
parent 296575a4b9
commit 26ea7d0870
2 changed files with 35 additions and 53 deletions

View File

@ -21,6 +21,8 @@ typedef union {
uint32_t full; uint32_t full;
} BYTES_4; } BYTES_4;
//BYTES_4 foobar;
typedef union { typedef union {
struct { struct {
uint8_t byte0; uint8_t byte0;
@ -30,7 +32,16 @@ typedef union {
} BYTES_2; } BYTES_2;
void CM_processIncome(uint8_t idSender, uint8_t idMsg, uint32_t data){ void CM_processIncome(uint8_t idSender, uint8_t idMsg, uint32_t data){
BYTES_4 incomeData;
incomeData.full = data;
BYTES_4 revertData;
revertData.separate.byte0 = incomeData.separate.byte3;
revertData.separate.byte1 = incomeData.separate.byte2;
revertData.separate.byte2 = incomeData.separate.byte1;
revertData.separate.byte3 = incomeData.separate.byte0;
switch(idSender){ switch(idSender){
//foobar.full = data;
/********************* /*********************
* BROADCAST / DEBUG * * BROADCAST / DEBUG *
@ -38,13 +49,11 @@ void CM_processIncome(uint8_t idSender, uint8_t idMsg, uint32_t data){
case 0: case 0:
if(idMsg == 0x0) { // CONTROL_SETUP if(idMsg == 0x0) { // CONTROL_SETUP
// steeringMode eraseMemory - controlAliveTime // steeringMode eraseMemory - controlAliveTime
BYTES_4 tmpData; if (incomeData.separate.byte1) {
tmpData.full = data;
if (tmpData.separate.byte1) {
MEM_reset(); MEM_reset();
} }
KART_CST.CONTROL_STEERING_MODE = tmpData.separate.byte0; KART_CST.CONTROL_STEERING_MODE = incomeData.separate.byte0;
KART_CST.CONTROL_ALIVE_TIME = tmpData.separate.byte3; KART_CST.CONTROL_ALIVE_TIME = incomeData.separate.byte3;
MEM_write_1_byte(MEMADD_CONTROL_STEERING_MODE, KART_CST.CONTROL_STEERING_MODE); MEM_write_1_byte(MEMADD_CONTROL_STEERING_MODE, KART_CST.CONTROL_STEERING_MODE);
MEM_write_1_byte(MEMADD_CONTROL_ALIVE_TIME, KART_CST.CONTROL_ALIVE_TIME); MEM_write_1_byte(MEMADD_CONTROL_ALIVE_TIME, KART_CST.CONTROL_ALIVE_TIME);
ALIVE_setAliveTime(ALcontroller(), KART_CST.CONTROL_ALIVE_TIME); ALIVE_setAliveTime(ALcontroller(), KART_CST.CONTROL_ALIVE_TIME);
@ -73,10 +82,8 @@ void CM_processIncome(uint8_t idSender, uint8_t idMsg, uint32_t data){
if(idMsg == 0x4) { // CONTROL_SECURITY_PARAM if(idMsg == 0x4) { // CONTROL_SECURITY_PARAM
// maxSpeedFw maxSpeedBw - - // maxSpeedFw maxSpeedBw - -
BYTES_4 tmpData; KART_CST.CONTROL_MAX_SPEED_FW = incomeData.separate.byte0;
tmpData.full = data; KART_CST.CONTROL_MAX_SPEED_BW = incomeData.separate.byte1;
KART_CST.CONTROL_MAX_SPEED_FW = tmpData.separate.byte0;
KART_CST.CONTROL_MAX_SPEED_BW = tmpData.separate.byte1;
MEM_write_1_byte(MEMADD_CONTROL_MAX_SPEED_FW, KART_CST.CONTROL_MAX_SPEED_FW); MEM_write_1_byte(MEMADD_CONTROL_MAX_SPEED_FW, KART_CST.CONTROL_MAX_SPEED_FW);
MEM_write_1_byte(MEMADD_CONTROL_MAX_SPEED_BW, KART_CST.CONTROL_MAX_SPEED_BW); MEM_write_1_byte(MEMADD_CONTROL_MAX_SPEED_BW, KART_CST.CONTROL_MAX_SPEED_BW);
@ -84,10 +91,8 @@ void CM_processIncome(uint8_t idSender, uint8_t idMsg, uint32_t data){
if(idMsg == 0x5) { // CONTROL_SETUP_PARAM if(idMsg == 0x5) { // CONTROL_SETUP_PARAM
// displayAliveTime steeringAliveTime - - // displayAliveTime steeringAliveTime - -
BYTES_4 tmpData; KART_CST.DISPLAY_ALIVE_TIME = incomeData.separate.byte0;
tmpData.full = data; KART_CST.STEERING_ALIVE_TIME = incomeData.separate.byte1;
KART_CST.DISPLAY_ALIVE_TIME = tmpData.separate.byte0;
KART_CST.STEERING_ALIVE_TIME = tmpData.separate.byte1;
MEM_write_1_byte(MEMADD_DISPLAY_ALIVE_TIME, KART_CST.DISPLAY_ALIVE_TIME); MEM_write_1_byte(MEMADD_DISPLAY_ALIVE_TIME, KART_CST.DISPLAY_ALIVE_TIME);
MEM_write_1_byte(MEMADD_STEERING_ALIVE_TIME, KART_CST.STEERING_ALIVE_TIME); MEM_write_1_byte(MEMADD_STEERING_ALIVE_TIME, KART_CST.STEERING_ALIVE_TIME);
// TODO set alive times // TODO set alive times
@ -97,12 +102,10 @@ void CM_processIncome(uint8_t idSender, uint8_t idMsg, uint32_t data){
if(idMsg == 0x6) { // CONTROL_SETUP_PARAM_JOY if(idMsg == 0x6) { // CONTROL_SETUP_PARAM_JOY
// joystickMode joystickParam1 joystickParam2 joystickAliveTime // joystickMode joystickParam1 joystickParam2 joystickAliveTime
BYTES_4 tmpData; KART_CST.JOYSTICK_MODE = incomeData.separate.byte0;
tmpData.full = data; KART_CST.JOYSTICK_PARAM1 = incomeData.separate.byte1;
KART_CST.JOYSTICK_MODE = tmpData.separate.byte0; KART_CST.JOYSTICK_PARAM2 = incomeData.separate.byte2;
KART_CST.JOYSTICK_PARAM1 = tmpData.separate.byte1; KART_CST.JOYSTICK_ALIVE_TIME = incomeData.separate.byte3;
KART_CST.JOYSTICK_PARAM2 = tmpData.separate.byte2;
KART_CST.JOYSTICK_ALIVE_TIME = tmpData.separate.byte3;
MEM_write_1_byte(MEMADD_JOYSTICK_MODE, KART_CST.JOYSTICK_MODE); MEM_write_1_byte(MEMADD_JOYSTICK_MODE, KART_CST.JOYSTICK_MODE);
MEM_write_1_byte(MEMADD_JOYSTICK_PARAM1, KART_CST.JOYSTICK_PARAM1); MEM_write_1_byte(MEMADD_JOYSTICK_PARAM1, KART_CST.JOYSTICK_PARAM1);
MEM_write_1_byte(MEMADD_JOYSTICK_PARAM2, KART_CST.JOYSTICK_PARAM2); MEM_write_1_byte(MEMADD_JOYSTICK_PARAM2, KART_CST.JOYSTICK_PARAM2);
@ -115,11 +118,9 @@ void CM_processIncome(uint8_t idSender, uint8_t idMsg, uint32_t data){
if(idMsg == 0x7) { // CONTROL_SETUP_PARAM_DRIVE if(idMsg == 0x7) { // CONTROL_SETUP_PARAM_DRIVE
// driveAliveTime driveSpeedTime driveStopTime - // driveAliveTime driveSpeedTime driveStopTime -
BYTES_4 tmpData; KART_CST.DRIVE_ALIVE_TIME = incomeData.separate.byte0;
tmpData.full = data; KART_CST.DRIVE_SPEED_TIME = incomeData.separate.byte1;
KART_CST.DRIVE_ALIVE_TIME = tmpData.separate.byte0; KART_CST.DRIVE_STOP_TIME = incomeData.separate.byte2;
KART_CST.DRIVE_SPEED_TIME = tmpData.separate.byte1;
KART_CST.DRIVE_STOP_TIME = tmpData.separate.byte2;
MEM_write_1_byte(MEMADD_DRIVE_ALIVE_TIME, KART_CST.DRIVE_ALIVE_TIME); MEM_write_1_byte(MEMADD_DRIVE_ALIVE_TIME, KART_CST.DRIVE_ALIVE_TIME);
MEM_write_1_byte(MEMADD_DRIVE_SPEED_TIME, KART_CST.DRIVE_SPEED_TIME); MEM_write_1_byte(MEMADD_DRIVE_SPEED_TIME, KART_CST.DRIVE_SPEED_TIME);
MEM_write_1_byte(MEMADD_DRIVE_STOP_TIME, KART_CST.DRIVE_STOP_TIME); MEM_write_1_byte(MEMADD_DRIVE_STOP_TIME, KART_CST.DRIVE_STOP_TIME);
@ -130,12 +131,10 @@ void CM_processIncome(uint8_t idSender, uint8_t idMsg, uint32_t data){
if(idMsg == 0x8) { // CONTROL_SETUP_PARAM_BATTERY if(idMsg == 0x8) { // CONTROL_SETUP_PARAM_BATTERY
// batteryVoltTime batteryCurrentTime batteryEnergyTime batteryAliveTime // batteryVoltTime batteryCurrentTime batteryEnergyTime batteryAliveTime
BYTES_4 tmpData; KART_CST.BATTERY_VOLT_TIME = incomeData.separate.byte0;
tmpData.full = data; KART_CST.BATTERY_CURRENT_TIME = incomeData.separate.byte1;
KART_CST.BATTERY_VOLT_TIME = tmpData.separate.byte0; KART_CST.BATTERY_ENERGY_TIME = incomeData.separate.byte2;
KART_CST.BATTERY_CURRENT_TIME = tmpData.separate.byte1; KART_CST.BATTERY_ALIVE_TIME = incomeData.separate.byte3;
KART_CST.BATTERY_ENERGY_TIME = tmpData.separate.byte2;
KART_CST.BATTERY_ALIVE_TIME = tmpData.separate.byte3;
MEM_write_1_byte(MEMADD_BATTERY_VOLT_TIME, KART_CST.BATTERY_VOLT_TIME); MEM_write_1_byte(MEMADD_BATTERY_VOLT_TIME, KART_CST.BATTERY_VOLT_TIME);
MEM_write_1_byte(MEMADD_BATTERY_CURRENT_TIME, KART_CST.BATTERY_CURRENT_TIME); MEM_write_1_byte(MEMADD_BATTERY_CURRENT_TIME, KART_CST.BATTERY_CURRENT_TIME);
MEM_write_1_byte(MEMADD_BATTERY_ENERGY_TIME, KART_CST.BATTERY_ENERGY_TIME); MEM_write_1_byte(MEMADD_BATTERY_ENERGY_TIME, KART_CST.BATTERY_ENERGY_TIME);
@ -154,11 +153,8 @@ void CM_processIncome(uint8_t idSender, uint8_t idMsg, uint32_t data){
case 2: case 2:
if(idMsg == 0x1) { // JOY_MESURE if(idMsg == 0x1) { // JOY_MESURE
// posX posY button - // posX posY button -
BYTES_4 tmpData; calcTorque(incomeData.separate.byte1);
tmpData.full = data; calcPosition(incomeData.separate.byte0);
calcTorque(tmpData.separate.byte1);
calcPosition(tmpData.separate.byte0);
} }
@ -197,14 +193,7 @@ void CM_processIncome(uint8_t idSender, uint8_t idMsg, uint32_t data){
case 4: case 4:
if(idMsg == 0x0) { // DRIVE_SPEED if(idMsg == 0x0) { // DRIVE_SPEED
// speedHH speedH speedL speedLL // speedHH speedH speedL speedLL
BYTES_4 tmpData; calcSpeed(revertData.full);
tmpData.full = data;
BYTES_4 rpm;
rpm.separate.byte0 = tmpData.separate.byte3;
rpm.separate.byte1 = tmpData.separate.byte2;
rpm.separate.byte2 = tmpData.separate.byte1;
rpm.separate.byte3 = tmpData.separate.byte0;
calcSpeed(rpm.full);
DRIVE_emitPollSpeed(drive()); DRIVE_emitPollSpeed(drive());
} }
@ -230,14 +219,7 @@ void CM_processIncome(uint8_t idSender, uint8_t idMsg, uint32_t data){
case 5: case 5:
if(idMsg == 0x1) { // STEERING_GET_CENTER if(idMsg == 0x1) { // STEERING_GET_CENTER
// valHH valH valL valLL // valHH valH valL valLL
BYTES_4 tmpData; eKart.center = revertData.full;
tmpData.full = data;
BYTES_4 center;
center.separate.byte0 = tmpData.separate.byte3;
center.separate.byte1 = tmpData.separate.byte2;
center.separate.byte2 = tmpData.separate.byte1;
center.separate.byte3 = tmpData.separate.byte0;
eKart.center = center.full;
} }
if(idMsg == 0x2) { // STEERING_GET_POSITION if(idMsg == 0x2) { // STEERING_GET_POSITION

View File

@ -9,7 +9,7 @@
void calcTorque(uint8_t joy_pos) { void calcTorque(uint8_t joy_pos) {
int32_t calcTorque; int32_t calcTorque;
calcTorque = joy_pos; // joystick position calcTorque = (int8_t) joy_pos; // joystick position
calcTorque *= KART_CST.CONTROL_POWER_FACTOR; // convert by power factor calcTorque *= KART_CST.CONTROL_POWER_FACTOR; // convert by power factor
calcTorque /= 1000; // torque define by joystick calcTorque /= 1000; // torque define by joystick
eKart.torque = (int16_t) calcTorque; eKart.torque = (int16_t) calcTorque;
@ -17,7 +17,7 @@ void calcTorque(uint8_t joy_pos) {
void calcPosition(uint8_t joy_pos){ void calcPosition(uint8_t joy_pos){
int32_t calcPosition; int32_t calcPosition;
calcPosition = joy_pos; calcPosition = (int8_t) joy_pos;
} }
void calcSpeed(int32_t rpm) { void calcSpeed(int32_t rpm) {