Add LSFTCAN and SWCAN support

This commit is contained in:
Paul Hollinsky
2019-01-22 13:14:28 -05:00
parent c313801a21
commit ae78122cbe
10 changed files with 107 additions and 14 deletions
+29
View File
@@ -242,6 +242,9 @@ bool IDeviceSettings::applyDefaults(bool temporary) {
return false;
}
// This short wait helps on FIRE devices, otherwise the checksum might be wrong!
std::this_thread::sleep_for(std::chrono::milliseconds(3));
refresh(true); // Refresh ignoring checksum
// The device might modify the settings once they are applied, however in this case it does not update the checksum
// We refresh to get these updates, update the checksum, and send it back so it's all in sync
@@ -315,6 +318,32 @@ bool IDeviceSettings::setBaudrateFor(Network net, int64_t baudrate) {
cfg->SetBaudrate = AUTO; // Device will use the baudrate value to set the TQ values
return true;
}
case Network::Type::LSFTCAN: {
CAN_SETTINGS* cfg = getMutableLSFTCANSettingsFor(net);
if(cfg == nullptr)
return false;
CANBaudrate newBaud = GetEnumValueForBaudrate(baudrate);
if(newBaud == (CANBaudrate)-1)
return false;
cfg->Baudrate = (uint8_t)newBaud;
cfg->auto_baud = false;
cfg->SetBaudrate = AUTO; // Device will use the baudrate value to set the TQ values
return true;
}
case Network::Type::SWCAN: {
SWCAN_SETTINGS* cfg = getMutableSWCANSettingsFor(net);
if(cfg == nullptr)
return false;
CANBaudrate newBaud = GetEnumValueForBaudrate(baudrate);
if(newBaud == (CANBaudrate)-1)
return false;
cfg->Baudrate = (uint8_t)newBaud;
cfg->auto_baud = false;
cfg->SetBaudrate = AUTO; // Device will use the baudrate value to set the TQ values
return true;
}
default:
return false;
}