CAN errors : comment some funcs + defines

This commit is contained in:
fenugrec 2020-12-06 11:58:45 -05:00
parent ceeac236c4
commit 7f9a0ea331
2 changed files with 12 additions and 2 deletions

View File

@ -50,5 +50,15 @@ bool can_is_rx_pending(can_data_t *hcan);
bool can_send(can_data_t *hcan, struct gs_host_frame *frame); bool can_send(can_data_t *hcan, struct gs_host_frame *frame);
/** return CAN->ESR register which contains tx/rx error counters and
* LEC (last error code).
*/
uint32_t can_get_error_status(can_data_t *hcan); uint32_t can_get_error_status(can_data_t *hcan);
#define CAN_ERRCOUNT_THRESHOLD 15 /* send an error frame if tx/rx counters increase by more than this amount */
/** parse status value returned by can_get_error_status().
* @param frame : will hold the generated error frame
* @return 1 when status changes (if any) need a new error frame sent
*/
bool can_parse_error_status(uint32_t err, uint32_t last_err, can_data_t *hcan, struct gs_host_frame *frame); bool can_parse_error_status(uint32_t err, uint32_t last_err, can_data_t *hcan, struct gs_host_frame *frame);

View File

@ -290,10 +290,10 @@ bool can_parse_error_status(uint32_t err, uint32_t last_err, can_data_t *hcan, s
should_send = true; should_send = true;
} }
/* If either error counter increased by 15. */ /* If either error counter increased by 15. */
if (((int)last_tx_error_cnt + 15) < tx_error_cnt) { if (((int)last_tx_error_cnt + CAN_ERRCOUNT_THRESHOLD) < tx_error_cnt) {
should_send = true; should_send = true;
} }
if (((int)last_rx_error_cnt + 15) < rx_error_cnt) { if (((int)last_rx_error_cnt + CAN_ERRCOUNT_THRESHOLD) < rx_error_cnt) {
should_send = true; should_send = true;
} }