Removed 10.1 violations (#217)
parent
c066c7838c
commit
3601212ec5
|
@ -103,8 +103,8 @@ uint32_t get_ts_elapsed(uint32_t ts, uint32_t ts_last) {
|
|||
// convert a trimmed integer to signed 32 bit int
|
||||
int to_signed(int d, int bits) {
|
||||
int d_signed = d;
|
||||
if (d >= (1 << (bits - 1))) {
|
||||
d_signed = d - (1 << bits);
|
||||
if (d >= (1 << max((bits - 1), 0))) {
|
||||
d_signed = d - (1 << max(bits, 0));
|
||||
}
|
||||
return d_signed;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@ static void chrysler_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
|
|||
|
||||
// Measured eps torque
|
||||
if (addr == 544U) {
|
||||
int rdhr = to_push->RDHR;
|
||||
int torque_meas_new = ((rdhr & 0x7) << 8) + ((rdhr & 0xFF00) >> 8) - 1024;
|
||||
uint32_t rdhr = to_push->RDHR;
|
||||
int torque_meas_new = ((rdhr & 0x7U) << 8) + ((rdhr & 0xFF00U) >> 8) - 1024U;
|
||||
|
||||
// update array of samples
|
||||
update_sample(&chrysler_torque_meas, torque_meas_new);
|
||||
|
@ -73,8 +73,8 @@ static int chrysler_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
|
|||
|
||||
// LKA STEER
|
||||
if (addr == 0x292U) {
|
||||
int rdlr = to_send->RDLR;
|
||||
int desired_torque = ((rdlr & 0x7) << 8) + ((rdlr & 0xFF00) >> 8) - 1024;
|
||||
uint32_t rdlr = to_send->RDLR;
|
||||
int desired_torque = ((rdlr & 0x7U) << 8) + ((rdlr & 0xFF00U) >> 8) - 1024U;
|
||||
uint32_t ts = TIM2->CNT;
|
||||
bool violation = 0;
|
||||
|
||||
|
|
|
@ -147,8 +147,8 @@ static int gm_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
|
|||
|
||||
// BRAKE: safety check
|
||||
if (addr == 789U) {
|
||||
int rdlr = to_send->RDLR;
|
||||
int brake = ((rdlr & 0xF) << 8) + ((rdlr & 0xFF00) >> 8);
|
||||
uint32_t rdlr = to_send->RDLR;
|
||||
int brake = ((rdlr & 0xFU) << 8) + ((rdlr & 0xFF00U) >> 8);
|
||||
brake = (0x1000 - brake) & 0xFFF;
|
||||
if (current_controls_allowed && long_controls_allowed) {
|
||||
if (brake > GM_MAX_BRAKE) {
|
||||
|
@ -163,8 +163,8 @@ static int gm_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
|
|||
|
||||
// LKA STEER: safety check
|
||||
if (addr == 384U) {
|
||||
int rdlr = to_send->RDLR;
|
||||
int desired_torque = ((rdlr & 0x7) << 8) + ((rdlr & 0xFF00) >> 8);
|
||||
uint32_t rdlr = to_send->RDLR;
|
||||
int desired_torque = ((rdlr & 0x7U) << 8) + ((rdlr & 0xFF00U) >> 8);
|
||||
uint32_t ts = TIM2->CNT;
|
||||
bool violation = 0;
|
||||
desired_torque = to_signed(desired_torque, 11);
|
||||
|
|
|
@ -217,7 +217,7 @@ static int tesla_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
|
|||
}
|
||||
if (addr == 0x101) {
|
||||
to_fwd->RDLR = to_fwd->RDLR | 0x4000; // 0x4000: WITH_ANGLE, 0xC000: WITH_BOTH (angle and torque)
|
||||
int checksum = (((to_fwd->RDLR & 0xFF00) >> 8) + (to_fwd->RDLR & 0xFF) + 2) & 0xFF;
|
||||
uint32_t checksum = (((to_fwd->RDLR & 0xFF00) >> 8) + (to_fwd->RDLR & 0xFF) + 2) & 0xFF;
|
||||
to_fwd->RDLR = to_fwd->RDLR & 0xFFFF;
|
||||
to_fwd->RDLR = to_fwd->RDLR + (checksum << 16);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue