Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions CANOPEN_db.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* CANOPEN_maxondb.h
*
* Created on: 26/06/2024
* Author: micron
*/

#ifndef CANOPEN_MAXONDB_H
#define CANOPEN_MAXONDB_H

/**================== Node IDS ==========================**/
#define NODE_ID_ACU 0x03
#define NODE_ID_STEERING 0x08
#define NODE_ID_BRAKE 0x06 //RESERVED DONT USE
#define NODE_ID_RES 0x11 // DO NOT CHANGE!! ENFORCED BY RULES!!!
/**======================================================================**/


#define NMT_ADDRESS_COBID() (0x000)

#define BOOTUP_ADDRESS_COBID(node_id) (node_id + 0x700)
//Maxon SDOs
#define SDO_REQUEST_ADDRESS_COBID(node_id) (node_id+0x600)
#define SDO_RESPONSE_ADDRESS_COBID(node_id) (node_id+0x580)


/**======================================================================**/

/**================== Receive from World ==========================**/
#define PDO_RXONE(node_id) (node_id+0x200)
/**======================================================================**/
#define MAP_DECODE_PDO_RXONE_CONTROL_WORD(x) (x[1] << 8 | x[0])
/**======================================================================**/
#define PDO_RXTWO(node_id) (node_id+0x300)
/**======================================================================**/
#define MAP_DECODE_PDO_RXTWO_MAXON_CONTROL_WORD(x) (x[1] << 8 | x[0])
#define MAP_DECODE_PDO_RXTWO_MAXON_MODES_OF_OPERATION(x) (x[2])
/**======================================================================**/
#define PDO_RXTHREE(node_id) (node_id+0x400)
/**======================================================================**/
#define MAP_DECODE_PDO_RXTHREE_MAXON_CONTROL_WORD(x) (x[1] << 8 | x[0])
#define MAP_DECODE_PDO_RXTHREE_MAXON_TARGET_POSITION(x) (x[5] << 24 | x[4] << 16 | x[3] << 8 | x[2])
/**======================================================================**/
#define PDO_RXFOUR(node_id) (node_id+0x500)
/**======================================================================**/
#define MAP_DECODE_PDO_RXFOUR_MAXON_CONTROL_WORD(x) (x[1] << 8 | x[0])
#define MAP_DECODE_PDO_RXFOUR_MAXON_TARGET_SPEED(x) (x[5] << 24 | x[4] << 16 | x[3] << 8 | x[2])

/**=================== Transmit to World ==========================**/
#define PDO_TXONE(node_id) (node_id+0x180)
/**======================================================================**/
#define MAP_DECODE_PDO_TXONE_MAXON_STATUSWORD(x) (x[1] << 8 | x[0])
#define MAP_DECODE_PDO_TXONE_MAXON_MODES_OF_OPERATION(x) (x[2])
#define MAP_DECODE_PDO_TXONE_MAXON_ERROR_CODE(x) (x[4] << 8 | x[3])

#define MAP_DECODE_PDO_TXONE_RES_STATUS(x) (x[0])


/**======================================================================**/
#define PDO_TXTWO(node_id) (node_id+0x280)
/**======================================================================**/
#define MAP_DECODE_PDO_TXTWO_MAXON_TARGET_POSITION(x) (x[3] << 24 | x[2] << 16 | x[1] << 8 | x[0])
#define MAP_DECODE_PDO_TXTWO_MAXON_TARGET_SPEED(x) (x[7] << 24 | x[6] << 16 | x[5] << 8 | x[4])

/**======================================================================**/
#define PDO_TXTHREE(node_id) (node_id+0x380)
/**======================================================================**/
#define MAP_DECODE_PDO_TXTHREE_MAXON_STATUSWORD(x) (x[1] << 8 | x[0])
#define MAP_DECODE_PDO_TXTHREE_MAXON_ACTUAL_POSITION(x) (x[5] << 24 | x[4] << 16 | x[3] << 8 | x[2])
#define MAP_DECODE_PDO_TXTHREE_MAXON_ACTUAL_MOMENT(x)(x[7] <<8 | x[6])
/**======================================================================**/
#define PDO_TXFOUR(node_id) (node_id+0x480)
/**======================================================================**/
#define MAP_DECODE_PDO_TXFOUR_MAXON_STATUSWORD(x) (x[1] << 8 | x[0])
#define MAP_DECODE_PDO_TXFOUR_MAXON_ACTUAL_SPEED(x) (x[5] << 24 | x[4] << 16 | x[3] << 8 | x[2])
#define MAP_DECODE_PDO_TXFOUR_MAXON_ACTUAL_PWM_DUTY(x) (x[7] << 8 | x[6])







#endif /* CANOPEN_MAXONDB_H */
71 changes: 0 additions & 71 deletions CANOPEN_maxondb.h

This file was deleted.

35 changes: 33 additions & 2 deletions CAN_asdb.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
/**
* @file CAN_asdb.h
1* @file CAN_asdb.h
* @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
* @author Pedro Ferreira
* @author Bruno Vicente
* @version 0.0.1
**/
#ifndef CAN_ASDB_H
#define CAN_ASDB_H
#define __LART_AXANATO_VCU_GATEWAY__
//#ifdef __LART_T24__
/**
* @brief T24 uses a little endian architecture when it comes to CAN messages
Expand Down Expand Up @@ -53,7 +55,36 @@
#define MAP_ENCODE_AS_MISSION(pnt, x)(pnt[0]=(pnt[0]&0x1F) | (x&0xE0) )
#define MAP_ENCODE_AS_EBS(pnt, x)(pnt[0]=(pnt[0]&0xE7) | (x&0x18) )
#define MAP_ENCODE_AS_STATE(pnt, x)(pnt[0]=(pnt[0]&0xF8)| (x&0x07) )


#define CAN_AS_ACU_HEARTBEAT 0x703
/**======================================================================**/
#define MAP_DECODE_AS_ACU_HEARTBEAT(x) (x[0])
#define MAP_ENCODE_AS_ACU_HEARTBEAT(pnt, x) (pnt[0] = x)

#define CAN_AS_ACU_PNEU 0x183
/**======================================================================**/
#define MAP_DECODE_AS_ACU_PNEUMATIC_BRAKING_EBS_FRONT(x) (x[1] << 8 | x[0])
#define MAP_DECODE_AS_ACU_PNEUMATIC_BRAKING_BRAKE_FRONT(x) (x[3] << 8 | x[2])
#define MAP_DECODE_AS_ACU_PNEUMATIC_BRAKING_EBS_REAR(x) (x[5] << 8 | x[4])
#define MAP_DECODE_AS_ACU_PNEUMATIC_BRAKING_BRAKE_REAR(x) (x[7] << 8 | x[6])


#ifdef __LART_AXANATO_VCU_GATEWAY__
#define CAN_TOJAL_TEST 0x499
/**======================================================================**/
#define MAP_DECODE_TOJAL_RPM(x) ((x[1] << 8) | x[0])

#define CAN_TOJAL_SEND_RPM 0x509
/**======================================================================**/
#define MAP_ENCODE_TOJAL_RPM(pnt, x) (pnt[1] = (x >> 8), pnt[0] = x)
#endif



/**======================================================================**/
#define ALC_MS 0x050
/**======================================================================**/
#define MAP_DECODE_AS_EMERGENCY_STATE(x) (x[0])
#define MAP_DECODE_MS_STATE(x) (x[1])
//#endif
#endif // CAN_ASDB_H
97 changes: 49 additions & 48 deletions CAN_datadb.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#define MAP_DECODE_BRAKE_PRESSURE (x)(x[1])
#define MAP_DECODE_THROTTLE_POSITION (x)(x[0])

#define MAP_DECODE_APPS (x) MAP_DECODE_THROTTLE_POSITION(x)
#define MAP_DECODE_APPS (x) MAP_DECODE_THROTTLE_POSITION(x)

#define MAP_ENCODE_CONSUMED_POWER(pnt, x) (pnt[7] = (x >> 16) & 0xFF, pnt[6] = (x >> 8) & 0xFF, pnt[5] = x & 0xFF)
#define MAP_ENCODE_TARGET_POWER(pnt, x) (pnt[4] = (x >> 16) & 0xFF, pnt[3] = (x >> 8) & 0xFF, pnt[2] = x & 0xFF)
Expand All @@ -38,9 +38,13 @@

#define MAP_DECODE_MOTOR_TEMPERATURE(x) ((x[3] << 8 | x[2]) + 40)
#define MAP_DECODE_INVERTER_TEMPERATURE(x) ((x[1] << 8 | x[0]) + 40)
#define MAP_DECODE_HV_VOLTAGE(x) (x[6] << 8 | x[5])
#define MAP_DECODE_HV_SOC(x) (x[7])

#define MAP_ENCODE_MOTOR_TEMPERATURE(pnt, x) (pnt[3] = (x - 40) >> 8, pnt[2] = (x - 40) & 0xFF)
#define MAP_ENCODE_INVERTER_TEMPERATURE(pnt, x) (pnt[1] = (x - 40) >> 8, pnt[0] = (x - 40) & 0xFF)
#define MAP_ENCODE_HV_VOLTAGE(pnt, x) (pnt[6] = (x >> 8) & 0xFF, pnt[5] = x & 0xFF)
#define MAP_ENCODE_HV_SOC(pnt, x) (pnt[7] = x)

/**======================================================================**/
#define CAN_VCU_ID_3 0x022
Expand All @@ -49,71 +53,45 @@
#define MAP_DECODE_LMT2(x) (x[3])
#define MAP_DECODE_LMT1(x) (x[2])
#define MAP_DECODE_INVERTER_ERROR(x) (x[1] << 8 | x[0])
#define MAP_DECODE_APPS_ERROR(x) (x[5])
#define MAP_DECODE_POWER_PLAN(x) (x[6])


#define MAP_ENCODE_VCU_STATE(pnt, x) (pnt[4] = x)
#define MAP_ENCODE_LMT2(pnt, x) (pnt[3] = x)
#define MAP_ENCODE_LMT1(pnt, x) (pnt[2] = x)
#define MAP_ENCODE_INVERTER_ERROR(pnt, x) (pnt[1] = (x >> 8) & 0xFF, pnt[0] = x & 0xFF)
#define MAP_ENCODE_APPS_ERROR(pnt, x) (pnt[5] = x)
#define MAP_ENCODE_POWER_PLAN(pnt, x) (pnt[6] = x)

/**======================================================================**/
#define CAN_VCU_ID_4 0x023
/**======================================================================**/

#define MAP_DECODE_RPM(x) (x[3] << 8 | x[2])
#define MAP_DECODE_INVERTER_VOLTAGE(x) (x[1] << 8 | x[0])
#define MAP_DECODE_IGNITION_STATE(x) (x[4])
#define MAP_DECODE_Ready2Drive_STATE(x) (x[5])

#define MAP_ENCODE_RPM(pnt, x) (pnt[3] = (x >> 8) & 0xFF, pnt[2] = x & 0xFF)
#define MAP_ENCODE_INVERTER_VOLTAGE(pnt, x) (pnt[1] = (x >> 8) & 0xFF, pnt[0] = x & 0xFF)
#define MAP_ENCODE_IGNITION_STATE(pnt, x) (pnt[4] = x)
#define MAP_ENCODE_Ready2Drive_STATE(pnt, x) (pnt[5] = x)

/**======================================================================**/
#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 CAN_VCU_ID_5 0x024

#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_DECODE_VCU_TCU_STATE(x) (x[0])
#define MAP_DECODE_VCU_ACU_STATE(x) (x[1])
#define MAP_DECODE_VCU_ALC_STATE(x) (x[2])
#define MAP_DECODE_LV_SOC(x) ((x[3] << 8 | x[4]) /10)
#define MAP_DECODE_LV_VOLTAGE(x) (x[5] << 8 | x[6])

#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 MAP_ENCODE_VCU_TCU_STATE(pnt, x) (pnt[0] = x)
#define MAP_ENCODE_VCU_ACU_STATE(pnt, x) (pnt[1] = x)
#define MAP_ENCODE_VCU_ALC_STATE(pnt, x) (pnt[2] = x)
#define MAP_ENCODE_LV_SOC(pnt, x) (pnt[3] = (x >> 8) & 0xFF, pnt[4] = x & 0xFF) // 0-1000
#define MAP_ENCODE_LV_VOLTAGE(pnt, x) (pnt[5] = (x >> 8) & 0xFF, pnt[6] = x & 0xFF)

/**======================================================================**/
#define CAN_IMU_ID_1 0x60
Expand Down Expand Up @@ -165,6 +143,29 @@
#define CAN_DYNAMICS_FRONT_ID_2 0xA1 // definir id
/**======================================================================**/

/**======================================================================**/
#define CAN_DATA_LOGGER_ID 0x180

#define MAP_DECODE_DATA_LOGGER_STATE(x) (x[0])
#define MAP_DECODE_DATA_LOGGER_RECORD_STATE(x) (x[1])

#define MAP_ENCODE_DATA_LOGGER_STATE(pnt, x) (pnt[0] = x)
#define MAP_ENCODE_DATA_LOGGER_RECORD_STATE(pnt, x) (pnt[1] = x)


/**======================================================================**/
#define CAN_BRAKE_LIGHT 0x253 // definir id
/**======================================================================**/


/**======================================================================**/
#define CAN_STEERING_WHEEL 0x254 // definir id
/**======================================================================**/

#define MAP_DECODE_VCU_POWER_LIMIT(x) (x[0])

#define MAP_ENCODE_VCU_POWER_LIMIT(pnt, x) (pnt[0] = x)

// #endif

#endif // CAN_DB_H
#endif // CAN_DB_H
26 changes: 26 additions & 0 deletions CAN_icupdb.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @file CAN_icupdb.h
* @brief CAN database header file for the inter control unit 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.1
**/
#ifndef CAN_ICUPDB_H
#define CAN_ICUPDB_H

// #ifdef __LART_T24__
/**
* @brief T24 uses a little endian architecture when it comes to CAN messages
**/



#define GENERIC_MSG_CONVERSION_ENCODE_DATABUS(x) (x | 0x04000000)
#define GENERIC_MSG_CONVERSION_DECODE_DATABUS(x) (x & 0x1BFFFFFF)
#define GENERIC_MSG_CONVERSION_ENCODE_POWERTRAIN(x) (x | 0x08000000)
#define GENERIC_MSG_CONVERSION_DECODE_POWERTRAIN(x) (x & 0x17FFFFFF)
#define GENERIC_MSG_CONVERSION_ENCODE_AUTONOMOUSBUS(x) (x | 0x0C000000)
#define GENERIC_MSG_CONVERSION_DECODE_AUTONOMOUSBUS(x) (x & 0x13FFFFFF)

#endif // CAN_DB_H
Loading