Skip to content

Commit

Permalink
Merge branch 'dev' into 5-add-automations
Browse files Browse the repository at this point in the history
  • Loading branch information
Imeguras committed Mar 13, 2024
2 parents a90b27b + 9ee62f3 commit 9a85cdb
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 12 deletions.
3 changes: 2 additions & 1 deletion CAN_asdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
86 changes: 76 additions & 10 deletions CAN_datadb.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/**
* @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
* @author Guilherme Candido
* @version 0.0.1
**/
#ifndef CAN_DATADB_H
#define CAN_DATADB_H

Expand Down Expand Up @@ -67,36 +69,100 @@
#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
/**======================================================================**/

/**======================================================================**/
#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
Expand Down
5 changes: 4 additions & 1 deletion CAN_pwtdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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])

/**======================================================================**/
Expand Down

0 comments on commit 9a85cdb

Please sign in to comment.