Skip to content

Commit

Permalink
wonder how MISRA feels about this
Browse files Browse the repository at this point in the history
  • Loading branch information
jyoung8607 committed Feb 17, 2024
1 parent 561a325 commit 79a8b18
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions board/safety/safety_chrysler_cusw.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static void chrysler_cusw_rx_hook(const CANPacket_t *to_push) {

// exit controls on rising edge of brake press
if ((bus == 0) && (addr == chrysler_cusw_addrs->BRAKE_2)) {
brake_pressed = GET_BIT(to_push, 9U);
brake_pressed = GET_BIT(to_push, 9);
}

generic_rx_checks((bus == 0) && (addr == chrysler_cusw_addrs->LKAS_COMMAND));
Expand All @@ -141,16 +141,16 @@ static bool chrysler_cusw_tx_hook(const CANPacket_t *to_send) {

const SteeringLimits limits = CHRYSLER_CUSW_STEERING_LIMITS;

const bool steer_req = GET_BIT(to_send, 12U) != 0U;
const bool steer_req = GET_BIT(to_send, 12);
if (steer_torque_cmd_checks(desired_torque, steer_req, limits)) {
tx = false;
}
}

// FORCE CANCEL: only the cancel button press is allowed
if (addr == chrysler_cusw_addrs->CRUISE_BUTTONS) {
const bool is_cancel = GET_BIT(to_send, 0U) != 0U;
const bool is_resume = GET_BIT(to_send, 4U) != 0U;
const bool is_cancel = GET_BIT(to_send, 0);
const bool is_resume = GET_BIT(to_send, 4);
const bool allowed = is_cancel || (is_resume && controls_allowed);
if (!allowed) {
tx = false;
Expand Down
2 changes: 1 addition & 1 deletion board/safety_declarations.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#define GET_BIT(msg, b) (((msg)->data[((b) / 8U)] >> ((b) % 8U)) & 0x1U)
#define GET_BIT(msg, b) (bool)(((msg)->data[((b) / 8U)] >> ((b) % 8U)) & 0x1U)
#define GET_BYTE(msg, b) ((msg)->data[(b)])
#define GET_FLAG(value, mask) (((__typeof__(mask))(value) & (mask)) == (mask))

Expand Down

0 comments on commit 79a8b18

Please sign in to comment.