From f6a7c440697ba2b60aee99d2338d6e9d831d035d Mon Sep 17 00:00:00 2001 From: perdo1305 Date: Mon, 11 Mar 2024 19:09:07 +0000 Subject: [PATCH 1/2] fixed shifting issue and add new dat to databus --- CAN_asdb.h | 3 +- CAN_datadb.h | 85 +++++++++++++++++++++++++++++++++++++++++++++------- CAN_pwtdb.h | 5 +++- 3 files changed, 81 insertions(+), 12 deletions(-) diff --git a/CAN_asdb.h b/CAN_asdb.h index a1cc443..69016f4 100644 --- a/CAN_asdb.h +++ b/CAN_asdb.h @@ -3,7 +3,8 @@ * @brief CAN database for autonomous driving header file * @details This file contains the mapping used to encode and decode CAN messages * @author João Vieira -* @version 0.0.0 +* @author Pedro Ferreira +* @version 0.0.1 **/ #ifndef CAN_ASDB_H #define CAN_ASDB_H diff --git a/CAN_datadb.h b/CAN_datadb.h index 6ed1cbf..8a0bf5f 100644 --- a/CAN_datadb.h +++ b/CAN_datadb.h @@ -1,11 +1,12 @@ /** -* @file CAN_datadb.h -* @brief CAN database header file for the data line -* @details This file contains the mapping used to encode and decode CAN messages -* @note This is being developed as of right now -* @author João Vieira -* @version 0.0.0 -**/ + * @file CAN_datadb.h + * @brief CAN database header file for the data line + * @details This file contains the mapping used to encode and decode CAN messages + * @note This is being developed as of right now + * @author João Vieira + * @author Pedro Ferreira + * @version 0.0.1 + **/ #ifndef CAN_DATADB_H #define CAN_DATADB_H @@ -67,21 +68,56 @@ #define CAN_PDM_ID_1 0x40 /**======================================================================**/ +#define MAP_DECODE_TOTAL_POWER(x) (x[7] << 8 | x[6]) +#define MAP_DECODE_LV_VOLTAGE(x) (x[4] << 8 | x[3]) +#define MAP_DECODE_INPUTS1(x) (x[2]) +#define MAP_DECODE_OUTPUTS1(x) (x[1]) + +#define MAP_ENCODE_DYNAMICS_FRONT_POWER(pnt, x) (pnt[7] = (x >> 8) & 0xFF, pnt[6] = x & 0xFF) +#define MAP_ENCODE_DYNAMICS_REAR_POWER(pnt, x) (pnt[5] = (x >> 8) & 0xFF, pnt[4] = x & 0xFF) +#define MAP_ENCODE_EXTRA_POWER(pnt, x) (pnt[3] = (x >> 8) & 0xFF, pnt[2] = x & 0xFF) +#define MAP_ENCODE_PDM_HEARTBEAT(pnt, x) (pnt[1] = x) + /**======================================================================**/ #define CAN_PDM_ID_2 0x41 /**======================================================================**/ +#define MAP_DECODE_TCU_POWER(x) ((x[7] << 8 | x[6]) / 10) +#define MAP_DECODE_VCU_POWER(x) ((x[5] << 8 | x[4]) / 10) +#define MAP_DECODE_ACU_POWER(x) ((x[3] << 8 | x[2]) / 10) +#define MAP_DECODE_DATALOGGER_POWER(x) ((x[1] << 8 | x[0]) / 10) + +#define MAP_ENCODE_TCU_POWER(pnt, x) (pnt[7] = (x >> 8) & 0xFF, pnt[6] = x & 0xFF) +#define MAP_ENCODE_VCU_POWER(pnt, x) (pnt[5] = (x >> 8) & 0xFF, pnt[4] = x & 0xFF) +#define MAP_ENCODE_ACU_POWER(pnt, x) (pnt[3] = (x >> 8) & 0xFF, pnt[2] = x & 0xFF) +#define MAP_ENCODE_DATALOGGER_POWER(pnt, x) (pnt[1] = (x >> 8) & 0xFF, pnt[0] = x & 0xFF) + /**======================================================================**/ #define CAN_PDM_ID_3 0x42 /**======================================================================**/ +#define MAP_DECODE_DYNAMICS_FRONT_POWER(x) (x[7] << 8 | x[6]) +#define MAP_DECODE_DYNAMICS_REAR_POWER(x) (x[5] << 8 | x[4]) +#define MAP_DECODE_EXTRA_POWER(x) (x[3] << 8 | x[2]) + +#define MAP_ENCODE_TOTAL_POWER(pnt, x) (pnt[7] = (x >> 8) & 0xFF, pnt[6] = x & 0xFF) +#define MAP_ENCODE_LV_VOLTAGE(pnt, x) (pnt[4] = (x >> 8) & 0xFF, pnt[3] = x & 0xFF) +#define MAP_ENCODE_INPUTS1(pnt, x) (pnt[2] = x) + /**======================================================================**/ #define CAN_PDM_ID_4 0x43 /**======================================================================**/ +#define MAP_DECODE_PDM_HEARTBEAT(x) (x[1]) +#define MAP_DECODE_SDC_STATE(x) (x[0]) + +#define MAP_ENCODE_PDM_HEARTBEAT(pnt, x) (pnt[1] = x) +#define MAP_ENCODE_SDC_STATE(pnt, x) (pnt[0] = x) + /**======================================================================**/ #define CAN_IMU_ID_1 0x60 /**======================================================================**/ + /**======================================================================**/ #define CAN_IMU_ID_2 0x61 /**======================================================================**/ @@ -89,14 +125,43 @@ /**======================================================================**/ #define CAN_DYNAMICS_REAR_ID_1 0x80 /**======================================================================**/ + +#define MAP_DECODE_WHEEL_SPEED_RL(x) (x[7]) +#define MAP_DECODE_WHEEL_SPEED_RR(x) (x[6]) +#define MAP_DECODE_SUSPOS_RL(x) (x[5]) +#define MAP_DECODE_SUSPOS_RR(x) (x[4]) +#define MAP_DECODE_BRK_STATE(x) (x[3]) +#define MAP_DECODE_DY_REAR_STATE(x) (x[2]) + +#define MAP_ENCODE_WHEEL_SPEED_RL(pnt, x) (pnt[7] = x) +#define MAP_ENCODE_WHEEL_SPEED_RR(pnt, x) (pnt[6] = x) +#define MAP_ENCODE_SUSPOS_RL(pnt, x) (pnt[5] = x) +#define MAP_ENCODE_SUSPOS_RR(pnt, x) (pnt[4] = x) +#define MAP_ENCODE_BRK_STATE(pnt, x) (pnt[3] = x) +#define MAP_ENCODE_DY_REAR_STATE(pnt, x) (pnt[2] = x) + /**======================================================================**/ -#define CAN_DYNAMICS_REAR_ID_2 0xA0 +#define CAN_DYNAMICS_REAR_ID_2 0x81 /**======================================================================**/ + /**======================================================================**/ -// #define CAN_DYNAMICS_FRONT_ID_1 0x80 //definir id +#define CAN_DYNAMICS_FRONT_ID_1 0xA0 // definir id /**======================================================================**/ + +#define MAP_DECODE_WHEEL_SPEED_FL(x) (x[7]) +#define MAP_DECODE_WHEEL_SPEED_FR(x) (x[6]) +#define MAP_DECODE_SUSPOS_FL(x) (x[5]) +#define MAP_DECODE_SUSPOS_FR(x) (x[4]) +#define MAP_DECODE_DY_FRONT_STATE(x) (x[2]) + +#define MAP_ENCODE_WHEEL_SPEED_FL(pnt, x) (pnt[7] = x) +#define MAP_ENCODE_WHEEL_SPEED_FR(pnt, x) (pnt[6] = x) +#define MAP_ENCODE_SUSPOS_FL(pnt, x) (pnt[5] = x) +#define MAP_ENCODE_SUSPOS_FR(pnt, x) (pnt[4] = x) +#define MAP_ENCODE_DY_FRONT_STATE(pnt, x) (pnt[2] = x) + /**======================================================================**/ -// #define CAN_DYNAMICS_FRONT_ID_2 0xA0 //definir id +#define CAN_DYNAMICS_FRONT_ID_2 0xA1 // definir id /**======================================================================**/ // #endif diff --git a/CAN_pwtdb.h b/CAN_pwtdb.h index e3d9619..7b30366 100644 --- a/CAN_pwtdb.h +++ b/CAN_pwtdb.h @@ -4,6 +4,8 @@ * @details This file contains the mapping used to encode and decode CAN messages * @note THIS IS OBSOLETE/NEEDS TO BE UPDATED * @author João Vieira + * @author Pedro Ferreira + * @version 0.0.1 **/ #ifndef CAN_PWTDB_H #define CAN_PWTDB_H @@ -16,8 +18,9 @@ /**======================================================================**/ #define CAN_HV500_ERPM_DUTY_VOLTAGE_ID 0x14 /**======================================================================**/ + #define MAP_DECODE_Actual_ERPM(x) (x[0] << 24 | x[1] << 16 | x[2] << 8 | x[3]) -#define MAP_DECODE_Actual_Duty(x) (x[4] << 10 | x[5]) +#define MAP_DECODE_Actual_Duty(x) (x[4] << 8 | x[5]) #define MAP_DECODE_Actual_InputVoltage(x) (x[6] << 8 | x[7]) /**======================================================================**/ From 9ee62f343380888bc76a49452c497ce274150f08 Mon Sep 17 00:00:00 2001 From: Candido Date: Mon, 11 Mar 2024 19:19:59 +0000 Subject: [PATCH 2/2] Author Added --- CAN_datadb.h | 1 + 1 file changed, 1 insertion(+) diff --git a/CAN_datadb.h b/CAN_datadb.h index 8a0bf5f..d270e95 100644 --- a/CAN_datadb.h +++ b/CAN_datadb.h @@ -5,6 +5,7 @@ * @note This is being developed as of right now * @author João Vieira * @author Pedro Ferreira + * @author Guilherme Candido * @version 0.0.1 **/ #ifndef CAN_DATADB_H