Skip to content

Commit

Permalink
panda.cc: add functions to set can and data speed (#22920)
Browse files Browse the repository at this point in the history
  • Loading branch information
briskspirit authored Nov 16, 2021
1 parent ec66573 commit 04e1a25
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions selfdrive/boardd/panda.cc
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,14 @@ void Panda::send_heartbeat() {
usb_write(0xf3, 1, 0);
}

void Panda::set_can_speed_kbps(uint16_t bus, uint16_t speed) {
usb_write(0xde, bus, (speed * 10));
}

void Panda::set_data_speed_kbps(uint16_t bus, uint16_t speed) {
usb_write(0xf9, bus, (speed * 10));
}

uint8_t Panda::len_to_dlc(uint8_t len) {
if (len <= 8) {
return len;
Expand Down
2 changes: 2 additions & 0 deletions selfdrive/boardd/panda.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class Panda {
void set_power_saving(bool power_saving);
void set_usb_power_mode(cereal::PeripheralState::UsbPowerMode power_mode);
void send_heartbeat();
void set_can_speed_kbps(uint16_t bus, uint16_t speed);
void set_data_speed_kbps(uint16_t bus, uint16_t speed);
uint8_t len_to_dlc(uint8_t len);
void can_send(capnp::List<cereal::CanData>::Reader can_data_list);
bool can_receive(std::vector<can_frame>& out_vec);
Expand Down

0 comments on commit 04e1a25

Please sign in to comment.