mirror of
https://github.com/infiniteCable2/panda.git
synced 2026-02-18 09:13:52 +08:00
enable misra-constParameterPointer (#1826)
This commit is contained in:
@@ -56,7 +56,7 @@ int comms_can_read(uint8_t *data, uint32_t max_len) {
|
||||
asm_buffer can_write_buffer = {.ptr = 0U, .tail_size = 0U};
|
||||
|
||||
// send on CAN
|
||||
void comms_can_write(uint8_t *data, uint32_t len) {
|
||||
void comms_can_write(const uint8_t *data, uint32_t len) {
|
||||
uint32_t pos = 0U;
|
||||
|
||||
// Assembling can message with data from buffer
|
||||
|
||||
@@ -6,7 +6,7 @@ typedef struct {
|
||||
} __attribute__((packed)) ControlPacket_t;
|
||||
|
||||
int comms_control_handler(ControlPacket_t *req, uint8_t *resp);
|
||||
void comms_endpoint2_write(uint8_t *data, uint32_t len);
|
||||
void comms_can_write(uint8_t *data, uint32_t len);
|
||||
void comms_endpoint2_write(const uint8_t *data, uint32_t len);
|
||||
void comms_can_write(const uint8_t *data, uint32_t len);
|
||||
int comms_can_read(uint8_t *data, uint32_t max_len);
|
||||
void comms_can_reset(void);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
uint8_t crc_checksum(uint8_t *dat, int len, const uint8_t poly) {
|
||||
uint8_t crc_checksum(const uint8_t *dat, int len, const uint8_t poly) {
|
||||
uint8_t crc = 0xFFU;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
@@ -95,7 +95,7 @@ bool can_pop(can_ring *q, CANPacket_t *elem) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool can_push(can_ring *q, CANPacket_t *elem) {
|
||||
bool can_push(can_ring *q, const CANPacket_t *elem) {
|
||||
bool ret = false;
|
||||
uint32_t next_w_ptr;
|
||||
|
||||
@@ -133,7 +133,7 @@ bool can_push(can_ring *q, CANPacket_t *elem) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t can_slots_empty(can_ring *q) {
|
||||
uint32_t can_slots_empty(const can_ring *q) {
|
||||
uint32_t ret = 0;
|
||||
|
||||
ENTER_CRITICAL();
|
||||
@@ -238,7 +238,7 @@ bool can_tx_check_min_slots_free(uint32_t min) {
|
||||
(can_slots_empty(&can_txgmlan_q) >= min);
|
||||
}
|
||||
|
||||
uint8_t calculate_checksum(uint8_t *dat, uint32_t len) {
|
||||
uint8_t calculate_checksum(const uint8_t *dat, uint32_t len) {
|
||||
uint8_t checksum = 0U;
|
||||
for (uint32_t i = 0U; i < len; i++) {
|
||||
checksum ^= dat[i];
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
int gmlan_alt_mode = DISABLED;
|
||||
|
||||
// returns out_len
|
||||
int do_bitstuff(char *out, char *in, int in_len) {
|
||||
int do_bitstuff(char *out, const char *in, int in_len) {
|
||||
int last_bit = -1;
|
||||
int bit_cnt = 0;
|
||||
int j = 0;
|
||||
@@ -57,7 +57,7 @@ int append_crc(char *in, int in_len) {
|
||||
return in_len_copy;
|
||||
}
|
||||
|
||||
int append_bits(char *in, int in_len, char *app, int app_len) {
|
||||
int append_bits(char *in, int in_len, const char *app, int app_len) {
|
||||
int in_len_copy = in_len;
|
||||
for (int i = 0; i < app_len; i++) {
|
||||
in[in_len_copy] = app[i];
|
||||
@@ -75,7 +75,7 @@ int append_int(char *in, int in_len, int val, int val_len) {
|
||||
return in_len_copy;
|
||||
}
|
||||
|
||||
int get_bit_message(char *out, CANPacket_t *to_bang) {
|
||||
int get_bit_message(char *out, const CANPacket_t *to_bang) {
|
||||
char pkt[MAX_BITS_CAN_PACKET];
|
||||
char footer[] = {
|
||||
1, // CRC delimiter
|
||||
@@ -268,7 +268,7 @@ void TIM12_IRQ_Handler(void) {
|
||||
TIM12->SR = 0;
|
||||
}
|
||||
|
||||
bool bitbang_gmlan(CANPacket_t *to_bang) {
|
||||
bool bitbang_gmlan(const CANPacket_t *to_bang) {
|
||||
gmlan_send_ok = true;
|
||||
gmlan_alt_mode = BITBANG;
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ void set_gpio_pullup(GPIO_TypeDef *GPIO, unsigned int pin, unsigned int mode) {
|
||||
EXIT_CRITICAL();
|
||||
}
|
||||
|
||||
int get_gpio_input(GPIO_TypeDef *GPIO, unsigned int pin) {
|
||||
int get_gpio_input(const GPIO_TypeDef *GPIO, unsigned int pin) {
|
||||
return (GPIO->IDR & (1UL << pin)) == (1UL << pin);
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ void spi_init(void) {
|
||||
llspi_mosi_dma(spi_buf_rx, SPI_HEADER_SIZE);
|
||||
}
|
||||
|
||||
bool validate_checksum(uint8_t *data, uint16_t len) {
|
||||
bool validate_checksum(const uint8_t *data, uint16_t len) {
|
||||
// TODO: can speed this up by casting the bulk to uint32_t and xor-ing the bytes afterwards
|
||||
uint8_t checksum = SPI_CHECKSUM_START;
|
||||
for(uint16_t i = 0U; i < len; i++){
|
||||
|
||||
@@ -131,7 +131,7 @@ bool put_char(uart_ring *q, char elem) {
|
||||
|
||||
// Seems dangerous to use (might lock CPU if called with interrupts disabled f.e.)
|
||||
// TODO: Remove? Not used anyways
|
||||
void uart_flush(uart_ring *q) {
|
||||
void uart_flush(const uart_ring *q) {
|
||||
while (q->w_ptr_tx != q->r_ptr_tx) {
|
||||
__WFI();
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) {
|
||||
return resp_len;
|
||||
}
|
||||
|
||||
void comms_can_write(uint8_t *data, uint32_t len) {
|
||||
void comms_can_write(const uint8_t *data, uint32_t len) {
|
||||
UNUSED(data);
|
||||
UNUSED(len);
|
||||
}
|
||||
@@ -112,7 +112,7 @@ int comms_can_read(uint8_t *data, uint32_t max_len) {
|
||||
|
||||
void refresh_can_tx_slots_available(void) {}
|
||||
|
||||
void comms_endpoint2_write(uint8_t *data, uint32_t len) {
|
||||
void comms_endpoint2_write(const uint8_t *data, uint32_t len) {
|
||||
current_board->set_led(LED_RED, 0);
|
||||
for (uint32_t i = 0; i < len/4; i++) {
|
||||
flash_write_word(prog_ptr, *(uint32_t*)(data+(i*4)));
|
||||
|
||||
@@ -29,7 +29,7 @@ int get_jungle_health_pkt(void *dat) {
|
||||
}
|
||||
|
||||
// send on serial, first byte to select the ring
|
||||
void comms_endpoint2_write(uint8_t *data, uint32_t len) {
|
||||
void comms_endpoint2_write(const uint8_t *data, uint32_t len) {
|
||||
UNUSED(data);
|
||||
UNUSED(len);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ int get_rtc_pkt(void *dat) {
|
||||
}
|
||||
|
||||
// send on serial, first byte to select the ring
|
||||
void comms_endpoint2_write(uint8_t *data, uint32_t len) {
|
||||
void comms_endpoint2_write(const uint8_t *data, uint32_t len) {
|
||||
uart_ring *ur = get_ring_by_number(data[0]);
|
||||
if ((len != 0U) && (ur != NULL)) {
|
||||
if ((data[0] < 2U) || (data[0] >= 4U)) {
|
||||
|
||||
@@ -46,11 +46,11 @@ int comms_can_read(uint8_t *data, uint32_t max_len) {
|
||||
UNUSED(max_len);
|
||||
return 0;
|
||||
}
|
||||
void comms_can_write(uint8_t *data, uint32_t len) {
|
||||
void comms_can_write(const uint8_t *data, uint32_t len) {
|
||||
UNUSED(data);
|
||||
UNUSED(len);
|
||||
}
|
||||
void comms_endpoint2_write(uint8_t *data, uint32_t len) {
|
||||
void comms_endpoint2_write(const uint8_t *data, uint32_t len) {
|
||||
UNUSED(data);
|
||||
UNUSED(len);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ void gen_crc_lookup_table_16(uint16_t poly, uint16_t crc_lut[]) {
|
||||
}
|
||||
}
|
||||
|
||||
bool msg_allowed(CANPacket_t *to_send, const CanMsg msg_list[], int len) {
|
||||
bool msg_allowed(const CANPacket_t *to_send, const CanMsg msg_list[], int len) {
|
||||
int addr = GET_ADDR(to_send);
|
||||
int bus = GET_BUS(to_send);
|
||||
int length = GET_LEN(to_send);
|
||||
@@ -138,7 +138,7 @@ bool msg_allowed(CANPacket_t *to_send, const CanMsg msg_list[], int len) {
|
||||
return allowed;
|
||||
}
|
||||
|
||||
int get_addr_check_index(CANPacket_t *to_push, RxCheck addr_list[], const int len) {
|
||||
int get_addr_check_index(const CANPacket_t *to_push, RxCheck addr_list[], const int len) {
|
||||
int bus = GET_BUS(to_push);
|
||||
int addr = GET_ADDR(to_push);
|
||||
int length = GET_LEN(to_push);
|
||||
@@ -450,7 +450,7 @@ bool dist_to_meas_check(int val, int val_last, struct sample_t *val_meas,
|
||||
}
|
||||
|
||||
// check that commanded value isn't fighting against driver
|
||||
bool driver_limit_check(int val, int val_last, struct sample_t *val_driver,
|
||||
bool driver_limit_check(int val, int val_last, const struct sample_t *val_driver,
|
||||
const int MAX_VAL, const int MAX_RATE_UP, const int MAX_RATE_DOWN,
|
||||
const int MAX_ALLOWANCE, const int DRIVER_FACTOR) {
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ bool angle_dist_to_meas_check(int val, struct sample_t *val_meas,
|
||||
const int MAX_ERROR, const int MAX_VAL);
|
||||
bool dist_to_meas_check(int val, int val_last, struct sample_t *val_meas,
|
||||
const int MAX_RATE_UP, const int MAX_RATE_DOWN, const int MAX_ERROR);
|
||||
bool driver_limit_check(int val, int val_last, struct sample_t *val_driver,
|
||||
bool driver_limit_check(int val, int val_last, const struct sample_t *val_driver,
|
||||
const int MAX, const int MAX_RATE_UP, const int MAX_RATE_DOWN,
|
||||
const int MAX_ALLOWANCE, const int DRIVER_FACTOR);
|
||||
bool get_longitudinal_allowed(void);
|
||||
@@ -169,8 +169,8 @@ float interpolate(struct lookup_t xy, float x);
|
||||
int ROUND(float val);
|
||||
void gen_crc_lookup_table_8(uint8_t poly, uint8_t crc_lut[]);
|
||||
void gen_crc_lookup_table_16(uint16_t poly, uint16_t crc_lut[]);
|
||||
bool msg_allowed(CANPacket_t *to_send, const CanMsg msg_list[], int len);
|
||||
int get_addr_check_index(CANPacket_t *to_push, RxCheck addr_list[], const int len);
|
||||
bool msg_allowed(const CANPacket_t *to_send, const CanMsg msg_list[], int len);
|
||||
int get_addr_check_index(const CANPacket_t *to_push, RxCheck addr_list[], const int len);
|
||||
void update_counter(RxCheck addr_list[], int index, uint8_t counter);
|
||||
void update_addr_timestamp(RxCheck addr_list[], int index);
|
||||
bool is_msg_valid(RxCheck addr_list[], int index);
|
||||
|
||||
@@ -75,7 +75,7 @@ bool llcan_set_speed(CAN_TypeDef *CANx, uint32_t speed, bool loopback, bool sile
|
||||
return ret;
|
||||
}
|
||||
|
||||
void llcan_irq_disable(CAN_TypeDef *CANx) {
|
||||
void llcan_irq_disable(const CAN_TypeDef *CANx) {
|
||||
if (CANx == CAN1) {
|
||||
NVIC_DisableIRQ(CAN1_TX_IRQn);
|
||||
NVIC_DisableIRQ(CAN1_RX0_IRQn);
|
||||
@@ -94,7 +94,7 @@ void llcan_irq_disable(CAN_TypeDef *CANx) {
|
||||
}
|
||||
}
|
||||
|
||||
void llcan_irq_enable(CAN_TypeDef *CANx) {
|
||||
void llcan_irq_enable(const CAN_TypeDef *CANx) {
|
||||
if (CANx == CAN1) {
|
||||
NVIC_EnableIRQ(CAN1_TX_IRQn);
|
||||
NVIC_EnableIRQ(CAN1_RX0_IRQn);
|
||||
|
||||
@@ -158,7 +158,7 @@ bool llcan_set_speed(FDCAN_GlobalTypeDef *FDCANx, uint32_t speed, uint32_t data_
|
||||
return ret;
|
||||
}
|
||||
|
||||
void llcan_irq_disable(FDCAN_GlobalTypeDef *FDCANx) {
|
||||
void llcan_irq_disable(const FDCAN_GlobalTypeDef *FDCANx) {
|
||||
if (FDCANx == FDCAN1) {
|
||||
NVIC_DisableIRQ(FDCAN1_IT0_IRQn);
|
||||
NVIC_DisableIRQ(FDCAN1_IT1_IRQn);
|
||||
@@ -172,7 +172,7 @@ void llcan_irq_disable(FDCAN_GlobalTypeDef *FDCANx) {
|
||||
}
|
||||
}
|
||||
|
||||
void llcan_irq_enable(FDCAN_GlobalTypeDef *FDCANx) {
|
||||
void llcan_irq_enable(const FDCAN_GlobalTypeDef *FDCANx) {
|
||||
if (FDCANx == FDCAN1) {
|
||||
NVIC_EnableIRQ(FDCAN1_IT0_IRQn);
|
||||
NVIC_EnableIRQ(FDCAN1_IT1_IRQn);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#define I2C_TIMEOUT_US 100000U
|
||||
|
||||
// cppcheck-suppress misra-c2012-2.7; not sure why it triggers here?
|
||||
bool i2c_status_wait(volatile uint32_t *reg, uint32_t mask, uint32_t val) {
|
||||
bool i2c_status_wait(const volatile uint32_t *reg, uint32_t mask, uint32_t val) {
|
||||
uint32_t start_time = microsecond_timer_get();
|
||||
while(((*reg & mask) != val) && (get_ts_elapsed(microsecond_timer_get(), start_time) < I2C_TIMEOUT_US));
|
||||
return ((*reg & mask) == val);
|
||||
|
||||
@@ -17,7 +17,6 @@ unmatchedSuppression
|
||||
# fixing the violations and all are intended to be removed soon after
|
||||
|
||||
unusedFunction
|
||||
constParameterPointer
|
||||
constParameterCallback
|
||||
|
||||
misra-config
|
||||
|
||||
Reference in New Issue
Block a user