add kartculator

This commit is contained in:
2023-08-31 13:42:31 +02:00
parent 00130b03ee
commit dc6e4ec65a
8 changed files with 267 additions and 178 deletions

View File

@@ -9,6 +9,7 @@
#include "car.h"
#include "../app/factory/factory.h"
#include "../middleware/can_interface.h"
#include "kartculator.h"
typedef union {
struct {
@@ -20,6 +21,14 @@ typedef union {
uint32_t full;
} BYTES_4;
typedef union {
struct {
uint8_t byte0;
uint8_t byte1;
} separate;
uint16_t full;
} BYTES_2;
void CM_processIncome(uint8_t idSender, uint8_t idMsg, uint32_t data){
switch(idSender){
@@ -145,6 +154,11 @@ void CM_processIncome(uint8_t idSender, uint8_t idMsg, uint32_t data){
case 2:
if(idMsg == 0x1) { // JOY_MESURE
// posX posY button -
BYTES_4 tmpData;
tmpData.full = data;
calcTorque(tmpData.separate.byte1);
calcPosition(tmpData.separate.byte0);
}
@@ -182,7 +196,14 @@ void CM_processIncome(uint8_t idSender, uint8_t idMsg, uint32_t data){
case 4:
if(idMsg == 0x0) { // DRIVE_SPEED
// speedHH speedH speedL speedLL
BYTES_4 tmpData;
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);
}
if(idMsg == 0xF) { // DRIVE_ALIVE
@@ -199,7 +220,14 @@ void CM_processIncome(uint8_t idSender, uint8_t idMsg, uint32_t data){
case 5:
if(idMsg == 0x1) { // STEERING_GET_CENTER
// valHH valH valL valLL
BYTES_4 tmpData;
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
@@ -291,7 +319,12 @@ void CM_DRIVE_SETUP(void* p) {
void CM_DRIVE_POWER(void* p) {
// valH valL - -
// TODO
BYTES_2 torque;
BYTES_4 tmpData;
torque.full = *((int16_t*) p);
tmpData.separate.byte0 = torque.separate.byte1;
tmpData.separate.byte1 = torque.separate.byte0;
CAN_Send(4, 1, tmpData.full);
}
void CM_STEERING_SETUP(void* p) {