Skip to content

Commit

Permalink
board struct: add has_canfd (commaai#1072)
Browse files Browse the repository at this point in the history
* add

* gate this

* and this

* forgot white
  • Loading branch information
briskspirit authored Sep 17, 2022
1 parent 59ede3f commit fd226de
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions board/boards/black.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ const board board_black = {
.has_hw_gmlan = false,
.has_obd = true,
.has_lin = false,
.has_canfd = false,
.has_rtc_battery = false,
.fan_max_rpm = 0U,
.init = black_init,
Expand Down
1 change: 1 addition & 0 deletions board/boards/board_declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ struct board {
const bool has_hw_gmlan;
const bool has_obd;
const bool has_lin;
const bool has_canfd;
const bool has_rtc_battery;
const uint16_t fan_max_rpm;
board_init init;
Expand Down
1 change: 1 addition & 0 deletions board/boards/dos.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ const board board_dos = {
.has_hw_gmlan = false,
.has_obd = true,
.has_lin = false,
.has_canfd = false,
.has_rtc_battery = true,
.fan_max_rpm = 6500U,
.init = dos_init,
Expand Down
1 change: 1 addition & 0 deletions board/boards/grey.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const board board_grey = {
.has_hw_gmlan = true,
.has_obd = false,
.has_lin = true,
.has_canfd = false,
.has_rtc_battery = false,
.fan_max_rpm = 0U,
.init = grey_init,
Expand Down
1 change: 1 addition & 0 deletions board/boards/pedal.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const board board_pedal = {
.has_hw_gmlan = false,
.has_obd = false,
.has_lin = false,
.has_canfd = false,
.has_rtc_battery = false,
.fan_max_rpm = 0U,
.init = pedal_init,
Expand Down
1 change: 1 addition & 0 deletions board/boards/red.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ const board board_red = {
.has_hw_gmlan = false,
.has_obd = true,
.has_lin = false,
.has_canfd = true,
.has_rtc_battery = false,
.fan_max_rpm = 0U,
.init = red_init,
Expand Down
1 change: 1 addition & 0 deletions board/boards/red_v2.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ const board board_red_v2 = {
.has_hw_gmlan = false,
.has_obd = true,
.has_lin = false,
.has_canfd = true,
.has_rtc_battery = true,
.fan_max_rpm = 0U,
.init = red_v2_init,
Expand Down
1 change: 1 addition & 0 deletions board/boards/uno.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ const board board_uno = {
.has_hw_gmlan = false,
.has_obd = true,
.has_lin = false,
.has_canfd = false,
.has_rtc_battery = true,
.fan_max_rpm = 5100U,
.init = uno_init,
Expand Down
1 change: 1 addition & 0 deletions board/boards/white.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ const board board_white = {
.has_hw_gmlan = true,
.has_obd = false,
.has_lin = true,
.has_canfd = false,
.has_rtc_battery = false,
.fan_max_rpm = 0U,
.init = white_init,
Expand Down
3 changes: 3 additions & 0 deletions board/drivers/can_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ bus_config_t bus_config[] = {
void can_init_all(void) {
bool ret = true;
for (uint8_t i=0U; i < CAN_CNT; i++) {
if (!current_board->has_canfd) {
bus_config[i].can_data_speed = 0U;
}
can_clear(can_queues[i]);
ret &= can_init(i);
}
Expand Down
2 changes: 1 addition & 1 deletion board/main_comms.h
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) {
break;
// **** 0xde: set CAN FD data bitrate
case 0xf9:
if (req->param1 < CAN_CNT) {
if ((req->param1 < CAN_CNT) && current_board->has_canfd) {
// TODO: add sanity check, ideally check if value is correct (from array of correct values)
bus_config[req->param1].can_data_speed = req->param2;
bus_config[req->param1].canfd_enabled = (req->param2 >= bus_config[req->param1].can_speed);
Expand Down

0 comments on commit fd226de

Please sign in to comment.