Skip to content

Commit

Permalink
Bug/anand89/main general fixes (#109)
Browse files Browse the repository at this point in the history
* bruh

* WS Init Untested

* Conflicts:
*	source/main_module/main.c

* throttle map

* fixes

* stale checks

* more stale fix

* CAN fixes

* CAN priority tx queues

* turnoff bootloader build

* can priority queue tested

* Update can tx for bootloader (untested)

* remove imd from bms line

* bump stale thresh to 250% of period

---------

Co-authored-by: AdityaAsGithub <[email protected]>
Co-authored-by: DEMETRIUS GULEWICZ <[email protected]>
  • Loading branch information
3 people authored Apr 3, 2024
1 parent 790472f commit 184c31d
Show file tree
Hide file tree
Showing 87 changed files with 6,981 additions and 1,322 deletions.
256 changes: 98 additions & 158 deletions common/daq/can_config.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions common/daq/generation/gen_embedded_can.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,16 @@ def gen_send_macro(lines, msg_config, peripheral):
""" generates a send macro to add a message to the tx queue """
cap = msg_config['msg_name'].upper()
sig_args = ", ".join([sig['sig_name']+'_' for sig in msg_config['signals']])
lines.append(f"#define SEND_{cap}(queue, {sig_args}) do {{\\\n")
lines.append(f"#define SEND_{cap}({sig_args}) do {{\\\n")
lines.append(f" CanMsgTypeDef_t msg = {{.Bus={peripheral}, .ExtId=ID_{cap}, .DLC=DLC_{cap}, .IDE=1}};\\\n")
lines.append(f" CanParsedData_t* data_a = (CanParsedData_t *) &msg.Data;\\\n")
for sig in msg_config['signals']:
# if float, cannot simply cast to uint32, have to use union
convert_str = f"FLOAT_TO_UINT32({sig['sig_name']}_)" if 'float' in sig['type'] else f"{sig['sig_name']}_"
# conversion not necessary for signed integers (source: testing)
lines.append(f" data_a->{msg_config['msg_name']}.{sig['sig_name']} = {convert_str};\\\n")
lines.append(f" qSendToBack(&queue, &msg);\\\n")
#lines.append(f" qSendToBack(&queue, &msg);\\\n")
lines.append(f" canTxSendToBack(&msg);\\\n")
lines.append(f" }} while(0)\n")

def gen_filter_lines(lines, rx_msg_configs, peripheral):
Expand Down
394 changes: 170 additions & 224 deletions common/daq/per_dbc.dbc

Large diffs are not rendered by default.

42 changes: 37 additions & 5 deletions common/faults/fault_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
"fault_name": "BSPD_latched",
"max": 1,
"min": 0,
"priority": "fatal",
"priority": "error",
"time_to_latch": 400,
"time_to_unlatch": 10000,
"lcd_message": "BSPD Latched. Restart Car"
Expand Down Expand Up @@ -367,17 +367,17 @@
"faults": [
{
"fault_name": "APPS_wiring_t1",
"max": 3000,
"min": 200,
"max": 4000,
"min": 100,
"priority": "error",
"time_to_latch": 10,
"time_to_unlatch": 1000,
"lcd_message": "APPS Wiring Fail T1"
},
{
"fault_name": "APPS_wiring_t2",
"max": 3000,
"min": 200,
"max": 4000,
"min": 100,
"priority": "error",
"time_to_latch": 10,
"time_to_unlatch": 1000,
Expand Down Expand Up @@ -688,6 +688,38 @@

]
},
{
"node_name":"torque_vector",
"faults": [
{
"fault_name": "TV_Disabled",
"max": 1,
"min": 0,
"priority": "warning",
"time_to_latch": 10,
"time_to_unlatch": 10,
"lcd_message": "TV Disabled"
},
{
"fault_name": "TV_uncalibrated",
"max": 1,
"min": 0,
"priority": "warning",
"time_to_latch": 10,
"time_to_unlatch": 10,
"lcd_message": "TV Uncalibrated"
},
{
"fault_name": "No_GPS_Fix",
"max": 1,
"min": 0,
"priority": "warning",
"time_to_latch": 10,
"time_to_unlatch": 10,
"lcd_message": "No GPS Fix"
}
]
},
{
"node_name": "test",
"can_name": "test_node",
Expand Down
3 changes: 2 additions & 1 deletion common/faults/fault_nodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#define NODE_MAIN_MODULE 1
#define NODE_DASHBOARD 2
#define NODE_A_BOX 3
#define NODE_TEST 4
#define NODE_TORQUE_VECTOR 4
#define NODE_TEST 5
//END AUTO NODE DEFS


Expand Down
22 changes: 14 additions & 8 deletions common/faults/faults.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ uint16_t faultLatchTime[TOTAL_NUM_FAULTS] = { PDU_MCU_TEMP_HIGH_LATCH_TIME, DASH
HEATSINK_THERMISTOR_LATCH_TIME, SOFTWARE_LATCH_TIME, MAX_CELLV_HIGH_LATCH_TIME, MIN_CELLV_LOW_LATCH_TIME, PACK_OVERHEAT_ORION_LATCH_TIME, INTERNAL_COMMS_LATCH_TIME, CELL_BALANCING_FOFF_LATCH_TIME,
WEAK_CELL_LATCH_TIME, LOW_CELLV_LATCH_TIME, OPEN_WIRE_LATCH_TIME, CURRENT_SENSOR_LATCH_TIME, MAX_CELLV_O5V_LATCH_TIME, CELL_ASIC_LATCH_TIME, WEAK_PACK_LATCH_TIME,
FAN_MONITOR_LATCH_TIME, THERMISTOR_LATCH_TIME, EXTERNAL_COMMS_LATCH_TIME, REDUNDANT_PSU_LATCH_TIME, HV_ISOLATION_LATCH_TIME, INPUT_PSU_LATCH_TIME, CHARGE_LIMIT_ENFORCE_LATCH_TIME,
PACK_TEMP_LATCH_TIME, PACK_TEMP_EXCEEDED_LATCH_TIME, MIN_PACK_TEMP_LATCH_TIME, IMD_LATCH_TIME, TMU_POWER_LOST_LATCH_TIME, TEST_FAULT_1_LATCH_TIME, TEST_FAULT_2_LATCH_TIME,
TEST_FAULT_3_LATCH_TIME, TEST_FAULT_4_LATCH_TIME,};
PACK_TEMP_LATCH_TIME, PACK_TEMP_EXCEEDED_LATCH_TIME, MIN_PACK_TEMP_LATCH_TIME, IMD_LATCH_TIME, TMU_POWER_LOST_LATCH_TIME, TV_DISABLED_LATCH_TIME, TV_UNCALIBRATED_LATCH_TIME,
NO_GPS_FIX_LATCH_TIME, TEST_FAULT_1_LATCH_TIME, TEST_FAULT_2_LATCH_TIME, TEST_FAULT_3_LATCH_TIME, TEST_FAULT_4_LATCH_TIME,};
uint16_t faultULatchTime[TOTAL_NUM_FAULTS] = { PDU_MCU_TEMP_HIGH_UNLATCH_TIME, DASH_RAIL_UNLATCH_TIME, ABOX_RAIL_UNLATCH_TIME, MAIN_RAIL_UNLATCH_TIME, DAQ_RAIL_UNLATCH_TIME, V_CRIT_UNLATCH_TIME,
V_NONCRIT_UNLATCH_TIME, FAN1_UNLATCH_TIME, BULLET_RAIL_UNLATCH_TIME, FAN2_UNLATCH_TIME, PCHG_IMPLAUS_UNLATCH_TIME, RTD_EXIT_UNLATCH_TIME, LEFT_MC_CONN_UNLATCH_TIME,
RIGHT_MC_CONN_UNLATCH_TIME, MCU_TEMP_HIGH_UNLATCH_TIME, DT_L_TEMP_OT_UNLATCH_TIME, DT_R_TEMP_OT_UNLATCH_TIME, DT_L_TEMP_HIGH_UNLATCH_TIME, DT_R_TEMP_HIGH_UNLATCH_TIME, BAT_COOL_LOOP_HIGH_UNLATCH_TIME,
Expand All @@ -41,8 +41,8 @@ uint16_t faultULatchTime[TOTAL_NUM_FAULTS] = { PDU_MCU_TEMP_HIGH_UNLATCH_TIME, D
HEATSINK_THERMISTOR_UNLATCH_TIME, SOFTWARE_UNLATCH_TIME, MAX_CELLV_HIGH_UNLATCH_TIME, MIN_CELLV_LOW_UNLATCH_TIME, PACK_OVERHEAT_ORION_UNLATCH_TIME, INTERNAL_COMMS_UNLATCH_TIME, CELL_BALANCING_FOFF_UNLATCH_TIME,
WEAK_CELL_UNLATCH_TIME, LOW_CELLV_UNLATCH_TIME, OPEN_WIRE_UNLATCH_TIME, CURRENT_SENSOR_UNLATCH_TIME, MAX_CELLV_O5V_UNLATCH_TIME, CELL_ASIC_UNLATCH_TIME, WEAK_PACK_UNLATCH_TIME,
FAN_MONITOR_UNLATCH_TIME, THERMISTOR_UNLATCH_TIME, EXTERNAL_COMMS_UNLATCH_TIME, REDUNDANT_PSU_UNLATCH_TIME, HV_ISOLATION_UNLATCH_TIME, INPUT_PSU_UNLATCH_TIME, CHARGE_LIMIT_ENFORCE_UNLATCH_TIME,
PACK_TEMP_UNLATCH_TIME, PACK_TEMP_EXCEEDED_UNLATCH_TIME, MIN_PACK_TEMP_UNLATCH_TIME, IMD_UNLATCH_TIME, TMU_POWER_LOST_UNLATCH_TIME, TEST_FAULT_1_UNLATCH_TIME, TEST_FAULT_2_UNLATCH_TIME,
TEST_FAULT_3_UNLATCH_TIME, TEST_FAULT_4_UNLATCH_TIME,};
PACK_TEMP_UNLATCH_TIME, PACK_TEMP_EXCEEDED_UNLATCH_TIME, MIN_PACK_TEMP_UNLATCH_TIME, IMD_UNLATCH_TIME, TMU_POWER_LOST_UNLATCH_TIME, TV_DISABLED_UNLATCH_TIME, TV_UNCALIBRATED_UNLATCH_TIME,
NO_GPS_FIX_UNLATCH_TIME, TEST_FAULT_1_UNLATCH_TIME, TEST_FAULT_2_UNLATCH_TIME, TEST_FAULT_3_UNLATCH_TIME, TEST_FAULT_4_UNLATCH_TIME,};
//Global arrays with all faults
fault_status_t statusArray[TOTAL_NUM_FAULTS] = {
(fault_status_t){false, ID_PDU_MCU_TEMP_HIGH_FAULT},
Expand Down Expand Up @@ -119,6 +119,9 @@ fault_status_t statusArray[TOTAL_NUM_FAULTS] = {
(fault_status_t){false, ID_MIN_PACK_TEMP_FAULT},
(fault_status_t){false, ID_IMD_FAULT},
(fault_status_t){false, ID_TMU_POWER_LOST_FAULT},
(fault_status_t){false, ID_TV_DISABLED_FAULT},
(fault_status_t){false, ID_TV_UNCALIBRATED_FAULT},
(fault_status_t){false, ID_NO_GPS_FIX_FAULT},
(fault_status_t){false, ID_TEST_FAULT_1_FAULT},
(fault_status_t){false, ID_TEST_FAULT_2_FAULT},
(fault_status_t){false, ID_TEST_FAULT_3_FAULT},
Expand Down Expand Up @@ -199,10 +202,13 @@ fault_attributes_t faultArray[TOTAL_NUM_FAULTS] = {
(fault_attributes_t){false, false, MIN_PACK_TEMP_PRIORITY, 0, 0, MIN_PACK_TEMP_MAX, MIN_PACK_TEMP_MIN, &statusArray[71], 0, MIN_PACK_TEMP_MSG},
(fault_attributes_t){false, false, IMD_PRIORITY, 0, 0, IMD_MAX, IMD_MIN, &statusArray[72], 0, IMD_MSG},
(fault_attributes_t){false, false, TMU_POWER_LOST_PRIORITY, 0, 0, TMU_POWER_LOST_MAX, TMU_POWER_LOST_MIN, &statusArray[73], 0, TMU_POWER_LOST_MSG},
(fault_attributes_t){false, false, TEST_FAULT_1_PRIORITY, 0, 0, TEST_FAULT_1_MAX, TEST_FAULT_1_MIN, &statusArray[74], 0, TEST_FAULT_1_MSG},
(fault_attributes_t){false, false, TEST_FAULT_2_PRIORITY, 0, 0, TEST_FAULT_2_MAX, TEST_FAULT_2_MIN, &statusArray[75], 0, TEST_FAULT_2_MSG},
(fault_attributes_t){false, false, TEST_FAULT_3_PRIORITY, 0, 0, TEST_FAULT_3_MAX, TEST_FAULT_3_MIN, &statusArray[76], 0, TEST_FAULT_3_MSG},
(fault_attributes_t){false, false, TEST_FAULT_4_PRIORITY, 0, 0, TEST_FAULT_4_MAX, TEST_FAULT_4_MIN, &statusArray[77], 0, TEST_FAULT_4_MSG},
(fault_attributes_t){false, false, TV_DISABLED_PRIORITY, 0, 0, TV_DISABLED_MAX, TV_DISABLED_MIN, &statusArray[74], 0, TV_DISABLED_MSG},
(fault_attributes_t){false, false, TV_UNCALIBRATED_PRIORITY, 0, 0, TV_UNCALIBRATED_MAX, TV_UNCALIBRATED_MIN, &statusArray[75], 0, TV_UNCALIBRATED_MSG},
(fault_attributes_t){false, false, NO_GPS_FIX_PRIORITY, 0, 0, NO_GPS_FIX_MAX, NO_GPS_FIX_MIN, &statusArray[76], 0, NO_GPS_FIX_MSG},
(fault_attributes_t){false, false, TEST_FAULT_1_PRIORITY, 0, 0, TEST_FAULT_1_MAX, TEST_FAULT_1_MIN, &statusArray[77], 0, TEST_FAULT_1_MSG},
(fault_attributes_t){false, false, TEST_FAULT_2_PRIORITY, 0, 0, TEST_FAULT_2_MAX, TEST_FAULT_2_MIN, &statusArray[78], 0, TEST_FAULT_2_MSG},
(fault_attributes_t){false, false, TEST_FAULT_3_PRIORITY, 0, 0, TEST_FAULT_3_MAX, TEST_FAULT_3_MIN, &statusArray[79], 0, TEST_FAULT_3_MSG},
(fault_attributes_t){false, false, TEST_FAULT_4_PRIORITY, 0, 0, TEST_FAULT_4_MAX, TEST_FAULT_4_MIN, &statusArray[80], 0, TEST_FAULT_4_MSG},
};
//END AUTO FAULT INFO ARRAY DEFS

Expand Down
44 changes: 33 additions & 11 deletions common/faults/faults.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
#define TOTAL_MAIN_MODULE_FAULTS 29
#define TOTAL_DASHBOARD_FAULTS 6
#define TOTAL_A_BOX_FAULTS 29
#define TOTAL_TORQUE_VECTOR_FAULTS 3
#define TOTAL_TEST_FAULTS 4
#define TOTAL_MCU_NUM 5
#define TOTAL_NUM_FAULTS 78
#define TOTAL_MCU_NUM 6
#define TOTAL_NUM_FAULTS 81
//END AUTO TOTAL DEFS

//BEGIN AUTO ID DEFS
Expand Down Expand Up @@ -104,10 +105,13 @@
#define ID_MIN_PACK_TEMP_FAULT 0x3047
#define ID_IMD_FAULT 0x3048
#define ID_TMU_POWER_LOST_FAULT 0x3049
#define ID_TEST_FAULT_1_FAULT 0x404a
#define ID_TEST_FAULT_2_FAULT 0x404b
#define ID_TEST_FAULT_3_FAULT 0x404c
#define ID_TEST_FAULT_4_FAULT 0x404d
#define ID_TV_DISABLED_FAULT 0x404a
#define ID_TV_UNCALIBRATED_FAULT 0x404b
#define ID_NO_GPS_FIX_FAULT 0x404c
#define ID_TEST_FAULT_1_FAULT 0x504d
#define ID_TEST_FAULT_2_FAULT 0x504e
#define ID_TEST_FAULT_3_FAULT 0x504f
#define ID_TEST_FAULT_4_FAULT 0x5050
//END AUTO ID DEFS

//Macro defs for accessing aspects of id
Expand Down Expand Up @@ -144,7 +148,7 @@
#define DT_L_THERM_DISC_PRIORITY 0
#define BATT_CL_DISC_PRIORITY 0
#define DT_CL_DISC_PRIORITY 0
#define BSPD_LATCHED_PRIORITY 2
#define BSPD_LATCHED_PRIORITY 1
#define BOTS_FAIL_PRIORITY 1
#define INERTIA_FAIL_PRIORITY 1
#define COCKPIT_ESTOP_PRIORITY 1
Expand Down Expand Up @@ -193,6 +197,9 @@
#define MIN_PACK_TEMP_PRIORITY 1
#define IMD_PRIORITY 2
#define TMU_POWER_LOST_PRIORITY 1
#define TV_DISABLED_PRIORITY 0
#define TV_UNCALIBRATED_PRIORITY 0
#define NO_GPS_FIX_PRIORITY 0
#define TEST_FAULT_1_PRIORITY 0
#define TEST_FAULT_2_PRIORITY 1
#define TEST_FAULT_3_PRIORITY 2
Expand Down Expand Up @@ -239,8 +246,8 @@
#define MOTOR_L_HEAT_MAX 80
#define MOTOR_R_OT_MAX 80
#define MOTOR_L_OT_MAX 80
#define APPS_WIRING_T1_MAX 3000
#define APPS_WIRING_T2_MAX 3000
#define APPS_WIRING_T1_MAX 4000
#define APPS_WIRING_T2_MAX 4000
#define BSE_MAX 1
#define BSPD_MAX 182
#define IMPLAUS_DETECTED_MAX 700
Expand Down Expand Up @@ -274,6 +281,9 @@
#define MIN_PACK_TEMP_MAX 10000
#define IMD_MAX 1
#define TMU_POWER_LOST_MAX 5
#define TV_DISABLED_MAX 1
#define TV_UNCALIBRATED_MAX 1
#define NO_GPS_FIX_MAX 1
#define TEST_FAULT_1_MAX 1
#define TEST_FAULT_2_MAX 1
#define TEST_FAULT_3_MAX 1
Expand Down Expand Up @@ -320,8 +330,8 @@
#define MOTOR_L_HEAT_MIN -80
#define MOTOR_R_OT_MIN -80
#define MOTOR_L_OT_MIN -80
#define APPS_WIRING_T1_MIN 200
#define APPS_WIRING_T2_MIN 200
#define APPS_WIRING_T1_MIN 100
#define APPS_WIRING_T2_MIN 100
#define BSE_MIN 0
#define BSPD_MIN 0
#define IMPLAUS_DETECTED_MIN 0
Expand Down Expand Up @@ -355,6 +365,9 @@
#define MIN_PACK_TEMP_MIN 10
#define IMD_MIN 0
#define TMU_POWER_LOST_MIN 3
#define TV_DISABLED_MIN 0
#define TV_UNCALIBRATED_MIN 0
#define NO_GPS_FIX_MIN 0
#define TEST_FAULT_1_MIN 0
#define TEST_FAULT_2_MIN 0
#define TEST_FAULT_3_MIN 0
Expand Down Expand Up @@ -436,6 +449,9 @@
#define MIN_PACK_TEMP_LATCH_TIME 2000
#define IMD_LATCH_TIME 100
#define TMU_POWER_LOST_LATCH_TIME 100
#define TV_DISABLED_LATCH_TIME 10
#define TV_UNCALIBRATED_LATCH_TIME 10
#define NO_GPS_FIX_LATCH_TIME 10
#define TEST_FAULT_1_LATCH_TIME 10
#define TEST_FAULT_2_LATCH_TIME 10
#define TEST_FAULT_3_LATCH_TIME 10
Expand Down Expand Up @@ -517,6 +533,9 @@
#define MIN_PACK_TEMP_UNLATCH_TIME 10000
#define IMD_UNLATCH_TIME 5000
#define TMU_POWER_LOST_UNLATCH_TIME 5000
#define TV_DISABLED_UNLATCH_TIME 10
#define TV_UNCALIBRATED_UNLATCH_TIME 10
#define NO_GPS_FIX_UNLATCH_TIME 10
#define TEST_FAULT_1_UNLATCH_TIME 10
#define TEST_FAULT_2_UNLATCH_TIME 10
#define TEST_FAULT_3_UNLATCH_TIME 10
Expand Down Expand Up @@ -598,6 +617,9 @@
#define MIN_PACK_TEMP_MSG "Pack Minimum temp < 10\0"
#define IMD_MSG "IMD Isolation Fault\0"
#define TMU_POWER_LOST_MSG "Poopy! TMU Power Lost!\0"
#define TV_DISABLED_MSG "TV Disabled\0"
#define TV_UNCALIBRATED_MSG "TV Uncalibrated\0"
#define NO_GPS_FIX_MSG "No GPS Fix\0"
#define TEST_FAULT_1_MSG "Test fault 1\0"
#define TEST_FAULT_2_MSG "Test fault 2\0"
#define TEST_FAULT_3_MSG "Test fault 3\0"
Expand Down
67 changes: 47 additions & 20 deletions common/phal_F4_F7/can/can.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

extern uint32_t APB1ClockRateHz;


bool PHAL_initCAN(CAN_TypeDef* bus, bool test_mode)
{
uint32_t timeout = 0;
Expand Down Expand Up @@ -116,30 +117,40 @@ bool PHAL_deinitCAN(CAN_TypeDef* bus)
return true;
}

bool PHAL_txCANMessage(CanMsgTypeDef_t* msg)
bool PHAL_txCANMessage(CanMsgTypeDef_t* msg, uint8_t txMbox)
{
uint8_t txMbox = 0;
uint32_t timeout = 0;
uint32_t txOkay = 0;

if (msg->Bus->TSR & CAN_TSR_TME0)
{
txMbox = 0;
txOkay = CAN_TSR_TXOK0;
}
else if (msg->Bus->TSR & CAN_TSR_TME1)
{
txMbox = 1;
txOkay = CAN_TSR_TXOK1;
}
else if (msg->Bus->TSR & CAN_TSR_TME2)
if (txMbox > 2) return false; // invalid box

switch (txMbox)
{
txMbox = 2;
txOkay = CAN_TSR_TXOK2;
case 0: if (!(msg->Bus->TSR & CAN_TSR_TME0)) return false; // mbx full
break;
case 1: if (!(msg->Bus->TSR & CAN_TSR_TME1)) return false;
break;
case 2: if (!(msg->Bus->TSR & CAN_TSR_TME2)) return false;
break;
}
else
return false; // Unable to find Mailbox

// if (msg->Bus->TSR & CAN_TSR_TME0)
// {
// txMbox = 0;
// txOkay = CAN_TSR_TXOK0;
// }
// else if (msg->Bus->TSR & CAN_TSR_TME1)
// {
// txMbox = 1;
// txOkay = CAN_TSR_TXOK1;
// }
// else if (msg->Bus->TSR & CAN_TSR_TME2)
// {
// txMbox = 2;
// txOkay = CAN_TSR_TXOK2;
// }
// else
// return false; // Unable to find Mailbox
if (msg->IDE == 0)
{
msg->Bus->sTxMailBox[txMbox].TIR = (msg->StdId << CAN_TI0R_STID_Pos); // Standard ID
Expand All @@ -160,10 +171,26 @@ bool PHAL_txCANMessage(CanMsgTypeDef_t* msg)

msg->Bus->sTxMailBox[txMbox].TIR |= (0b1 << CAN_TI0R_TXRQ_Pos); // Request TX

while(!(msg->Bus->TSR & txOkay) && ++timeout < PHAL_CAN_TX_TIMEOUT) // Wait for message to be sent within specified timeout
;
// while(!(msg->Bus->TSR & txOkay) && ++timeout < PHAL_CAN_TX_TIMEOUT) // Wait for message to be sent within specified timeout
// ;

return timeout != PHAL_CAN_TX_TIMEOUT;
// return timeout != PHAL_CAN_TX_TIMEOUT;
return true;
}

bool PHAL_txMailboxFree(CAN_TypeDef* bus, uint8_t mbx)
{
switch(mbx)
{
case 0:
return bus->TSR & CAN_TSR_TME0;
case 1:
return bus->TSR & CAN_TSR_TME1;
case 2:
return bus->TSR & CAN_TSR_TME2;
default:
return false;
}
}

void __attribute__((weak)) CAN1_RX0_IRQHandler()
Expand Down
5 changes: 4 additions & 1 deletion common/phal_F4_F7/can/can.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#define PHAL_CAN_40MHz_500k (0x001c0004)
#define PHAL_CAN_80MHz_500k (0x001c0009)



typedef struct
{
CAN_TypeDef* Bus; /*!< Specifies the bus. */
Expand Down Expand Up @@ -65,6 +67,7 @@ bool PHAL_deinitCAN(CAN_TypeDef* bus);
* @return true Sucessful TX of message.
* @return false Unable to find empty message or transmit took too long.
*/
bool PHAL_txCANMessage(CanMsgTypeDef_t* msg);
bool PHAL_txCANMessage(CanMsgTypeDef_t* msg, uint8_t mbx);
bool PHAL_txMailboxFree(CAN_TypeDef* bus, uint8_t mbx);

#endif // _PHAL_CAN_H
Loading

0 comments on commit 184c31d

Please sign in to comment.