From bf06ad7f1b4962a2ddcf47eefee4427de83745f6 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sat, 28 Nov 2026 12:08:40 -0600 Subject: [PATCH] board: include guards instead of #pragma once (MISRA 1.2) (#2518) --- panda/board/boards/board_declarations.h | 5 ++++- panda/board/boards/cuatro.h | 5 ++++- panda/board/boards/red.h | 5 ++++- panda/board/boards/tres.h | 5 ++++- panda/board/boards/unused_funcs.h | 5 ++++- panda/board/body/boards/board_body.h | 5 ++++- panda/board/body/boards/board_declarations.h | 5 ++++- panda/board/body/body.h | 5 ++++- panda/board/body/can.h | 5 ++++- panda/board/body/dotstar.h | 5 ++++- panda/board/body/main_comms.h | 5 ++++- panda/board/body/stm32h7/board.h | 5 ++++- panda/board/bootstub_declarations.h | 5 ++++- panda/board/can.h | 5 ++++- panda/board/can_comms.h | 5 ++++- panda/board/comms_definitions.h | 5 ++++- panda/board/config.h | 5 ++++- panda/board/crc.h | 5 ++++- panda/board/drivers/bootkick.h | 5 ++++- panda/board/drivers/can_common.h | 5 ++++- panda/board/drivers/clock_source.h | 5 ++++- panda/board/drivers/debug.h | 5 ++++- panda/board/drivers/drivers.h | 5 ++++- panda/board/drivers/fake_siren.h | 5 ++++- panda/board/drivers/fan.h | 5 ++++- panda/board/drivers/fdcan.h | 5 ++++- panda/board/drivers/gpio.h | 5 ++++- panda/board/drivers/harness.h | 5 ++++- panda/board/drivers/interrupts.h | 5 ++++- panda/board/drivers/led.h | 5 ++++- panda/board/drivers/pwm.h | 5 ++++- panda/board/drivers/registers.h | 5 ++++- panda/board/drivers/self_test.h | 5 ++++- panda/board/drivers/simple_watchdog.h | 5 ++++- panda/board/drivers/spi.h | 5 ++++- panda/board/drivers/timers.h | 5 ++++- panda/board/drivers/usb.h | 5 ++++- panda/board/early_init.h | 5 ++++- panda/board/flasher.h | 5 ++++- panda/board/libc.h | 5 ++++- panda/board/main_comms.h | 5 ++++- panda/board/main_declarations.h | 5 ++++- panda/board/main_definitions.h | 5 ++++- panda/board/provision.h | 5 ++++- panda/board/stm32h7/board.h | 5 ++++- panda/board/stm32h7/clock.h | 5 ++++- panda/board/stm32h7/interrupt_handlers.h | 5 ++++- panda/board/stm32h7/lladc.h | 5 ++++- panda/board/stm32h7/lladc_declarations.h | 5 ++++- panda/board/stm32h7/lldts.h | 5 ++++- panda/board/stm32h7/llfan.h | 5 ++++- panda/board/stm32h7/llfdcan.h | 5 ++++- panda/board/stm32h7/llfdcan_declarations.h | 5 ++++- panda/board/stm32h7/llflash.h | 5 ++++- panda/board/stm32h7/lli2c.h | 5 ++++- panda/board/stm32h7/llmpu.h | 5 ++++- panda/board/stm32h7/llspi.h | 5 ++++- panda/board/stm32h7/llusb.h | 5 ++++- panda/board/stm32h7/llusb_declarations.h | 5 ++++- panda/board/stm32h7/peripherals.h | 5 ++++- panda/board/stm32h7/sound.h | 5 ++++- panda/board/stm32h7/stm32h7_config.h | 5 ++++- panda/board/sys/critical.h | 5 ++++- panda/board/sys/faults.h | 5 ++++- panda/board/sys/power_saving.h | 5 ++++- panda/board/sys/sys.h | 5 ++++- panda/board/utils.h | 5 ++++- 67 files changed, 268 insertions(+), 67 deletions(-) diff --git a/panda/board/boards/board_declarations.h b/panda/board/boards/board_declarations.h index 79fef491df..4e4c376d1d 100644 --- a/panda/board/boards/board_declarations.h +++ b/panda/board/boards/board_declarations.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_BOARDS_BOARD_DECLARATIONS_H +#define BOARD_BOARDS_BOARD_DECLARATIONS_H #include #include @@ -61,3 +62,5 @@ extern struct board board_dos; extern struct board board_tres; extern struct board board_cuatro; extern struct board board_red; + +#endif // BOARD_BOARDS_BOARD_DECLARATIONS_H diff --git a/panda/board/boards/cuatro.h b/panda/board/boards/cuatro.h index 7010fed008..ba54f0cd54 100644 --- a/panda/board/boards/cuatro.h +++ b/panda/board/boards/cuatro.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_BOARDS_CUATRO_H +#define BOARD_BOARDS_CUATRO_H #include "board_declarations.h" @@ -130,3 +131,5 @@ board board_cuatro = { .read_som_gpio = tres_read_som_gpio, .set_amp_enabled = cuatro_set_amp_enabled }; + +#endif // BOARD_BOARDS_CUATRO_H diff --git a/panda/board/boards/red.h b/panda/board/boards/red.h index aff0dc040c..9d048387c0 100644 --- a/panda/board/boards/red.h +++ b/panda/board/boards/red.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_BOARDS_RED_H +#define BOARD_BOARDS_RED_H #include "board_declarations.h" @@ -131,3 +132,5 @@ board board_red = { .read_som_gpio = unused_read_som_gpio, .set_amp_enabled = unused_set_amp_enabled }; + +#endif // BOARD_BOARDS_RED_H diff --git a/panda/board/boards/tres.h b/panda/board/boards/tres.h index 065df84774..5ef88bae44 100644 --- a/panda/board/boards/tres.h +++ b/panda/board/boards/tres.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_BOARDS_TRES_H +#define BOARD_BOARDS_TRES_H #include "board_declarations.h" @@ -168,3 +169,5 @@ board board_tres = { .read_som_gpio = tres_read_som_gpio, .set_amp_enabled = unused_set_amp_enabled }; + +#endif // BOARD_BOARDS_TRES_H diff --git a/panda/board/boards/unused_funcs.h b/panda/board/boards/unused_funcs.h index 53f0d704ff..3e3452b8b4 100644 --- a/panda/board/boards/unused_funcs.h +++ b/panda/board/boards/unused_funcs.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_BOARDS_UNUSED_FUNCS_H +#define BOARD_BOARDS_UNUSED_FUNCS_H void unused_set_ir_power(uint8_t percentage) { UNUSED(percentage); @@ -27,3 +28,5 @@ bool unused_read_som_gpio(void) { void unused_set_amp_enabled(bool enabled) { UNUSED(enabled); } + +#endif // BOARD_BOARDS_UNUSED_FUNCS_H diff --git a/panda/board/body/boards/board_body.h b/panda/board/body/boards/board_body.h index 1d483daf52..ea5cd822ab 100644 --- a/panda/board/body/boards/board_body.h +++ b/panda/board/body/boards/board_body.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_BODY_BOARDS_BOARD_BODY_H +#define BOARD_BODY_BOARDS_BOARD_BODY_H #include "board/config.h" #include "board/body/body.h" @@ -48,3 +49,5 @@ board board_body = { .led_pin = {10, 10, 10}, .init = board_body_init, }; + +#endif // BOARD_BODY_BOARDS_BOARD_BODY_H diff --git a/panda/board/body/boards/board_declarations.h b/panda/board/body/boards/board_declarations.h index 22f44627bd..64dea9c1d7 100644 --- a/panda/board/body/boards/board_declarations.h +++ b/panda/board/body/boards/board_declarations.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_BODY_BOARDS_BOARD_DECLARATIONS_H +#define BOARD_BODY_BOARDS_BOARD_DECLARATIONS_H #include "stm32h7xx.h" @@ -55,3 +56,5 @@ struct board { #define OBDC_IGNITION_ON_PIN 11 extern struct board board_body; + +#endif // BOARD_BODY_BOARDS_BOARD_DECLARATIONS_H diff --git a/panda/board/body/body.h b/panda/board/body/body.h index a2880082c8..f5c657b822 100644 --- a/panda/board/body/body.h +++ b/panda/board/body/body.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_BODY_BODY_H +#define BOARD_BODY_BODY_H #include #include @@ -38,3 +39,5 @@ void dotstar_apply_breathe(dotstar_rgb_t color, uint32_t now_us, uint32_t cycle_ #ifndef BOOTSTUB extern int _app_start[0xc000]; #endif + +#endif // BOARD_BODY_BODY_H diff --git a/panda/board/body/can.h b/panda/board/body/can.h index a620b80078..11d6e63471 100644 --- a/panda/board/body/can.h +++ b/panda/board/body/can.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_BODY_CAN_H +#define BOARD_BODY_CAN_H #include "board/config.h" #include "board/body/body.h" @@ -117,3 +118,5 @@ void body_can_periodic(uint32_t now, bool ignition, bool plug_charging) { last_motor_speed_tx_us = now; } } + +#endif // BOARD_BODY_CAN_H diff --git a/panda/board/body/dotstar.h b/panda/board/body/dotstar.h index 8d70a73ce9..1358e71787 100644 --- a/panda/board/body/dotstar.h +++ b/panda/board/body/dotstar.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_BODY_DOTSTAR_H +#define BOARD_BODY_DOTSTAR_H #include "board/config.h" #include "board/body/body.h" @@ -203,3 +204,5 @@ void dotstar_apply_breathe(dotstar_rgb_t color, uint32_t now_us, uint32_t cycle_ dotstar_set_global_brightness(DOTSTAR_GLOBAL_BRIGHTNESS_MAX); dotstar_fill(r, g, b); } + +#endif // BOARD_BODY_DOTSTAR_H diff --git a/panda/board/body/main_comms.h b/panda/board/body/main_comms.h index 680b7b4a8e..26b48f19e2 100644 --- a/panda/board/body/main_comms.h +++ b/panda/board/body/main_comms.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_BODY_MAIN_COMMS_H +#define BOARD_BODY_MAIN_COMMS_H #include "board/config.h" #include "board/body/body.h" @@ -94,3 +95,5 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) { } return resp_len; } + +#endif // BOARD_BODY_MAIN_COMMS_H diff --git a/panda/board/body/stm32h7/board.h b/panda/board/body/stm32h7/board.h index ec4b2cfd6b..459e331cdf 100644 --- a/panda/board/body/stm32h7/board.h +++ b/panda/board/body/stm32h7/board.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_BODY_STM32H7_BOARD_H +#define BOARD_BODY_STM32H7_BOARD_H #include "board/config.h" #include "board/body/body.h" @@ -8,3 +9,5 @@ void detect_board_type(void) { // Board type set explicitly in main() } + +#endif // BOARD_BODY_STM32H7_BOARD_H diff --git a/panda/board/bootstub_declarations.h b/panda/board/bootstub_declarations.h index d679487715..19f4f3605b 100644 --- a/panda/board/bootstub_declarations.h +++ b/panda/board/bootstub_declarations.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_BOOTSTUB_DECLARATIONS_H +#define BOARD_BOOTSTUB_DECLARATIONS_H // ******************** Prototypes ******************** void print(const char *a){ UNUSED(a); } @@ -13,3 +14,5 @@ void pwm_set(TIM_TypeDef *TIM, uint8_t channel, uint8_t percentage); // ********************* Globals ********************** uint8_t hw_type = 0; board *current_board; + +#endif // BOARD_BOOTSTUB_DECLARATIONS_H diff --git a/panda/board/can.h b/panda/board/can.h index d6e360a043..c1aea0a863 100644 --- a/panda/board/can.h +++ b/panda/board/can.h @@ -1,5 +1,8 @@ -#pragma once +#ifndef BOARD_CAN_H +#define BOARD_CAN_H #define PANDA_CAN_CNT 3U #include "opendbc/safety/can.h" + +#endif // BOARD_CAN_H diff --git a/panda/board/can_comms.h b/panda/board/can_comms.h index 8bcfe63d3d..2744496cfc 100644 --- a/panda/board/can_comms.h +++ b/panda/board/can_comms.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_CAN_COMMS_H +#define BOARD_CAN_COMMS_H /* CAN transactions to and from the host come in the form of @@ -144,3 +145,5 @@ void refresh_can_tx_slots_available(void) { can_tx_comms_resume_spi(); } } + +#endif // BOARD_CAN_COMMS_H diff --git a/panda/board/comms_definitions.h b/panda/board/comms_definitions.h index 8abc1f299a..9a7676b306 100644 --- a/panda/board/comms_definitions.h +++ b/panda/board/comms_definitions.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_COMMS_DEFINITIONS_H +#define BOARD_COMMS_DEFINITIONS_H typedef struct { uint8_t request; @@ -12,3 +13,5 @@ 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); + +#endif // BOARD_COMMS_DEFINITIONS_H diff --git a/panda/board/config.h b/panda/board/config.h index 18b376ef1d..be07bfecc1 100644 --- a/panda/board/config.h +++ b/panda/board/config.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_CONFIG_H +#define BOARD_CONFIG_H #include @@ -26,3 +27,5 @@ // building for tests //#include "fake_stm.h" #endif + +#endif // BOARD_CONFIG_H diff --git a/panda/board/crc.h b/panda/board/crc.h index 661435e0f0..4422be66d0 100644 --- a/panda/board/crc.h +++ b/panda/board/crc.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_CRC_H +#define BOARD_CRC_H // standard CRC-32, same as zlib's crc32() static uint32_t crc32_table[256]; @@ -24,3 +25,5 @@ static uint32_t crc32_update(uint32_t crc, const uint8_t *dat, uint32_t len) { uint32_t crc32(const uint8_t *dat, uint32_t len) { return crc32_update(0xFFFFFFFFU, dat, len) ^ 0xFFFFFFFFU; } + +#endif // BOARD_CRC_H diff --git a/panda/board/drivers/bootkick.h b/panda/board/drivers/bootkick.h index 62f0b6f5e7..89b19e6173 100644 --- a/panda/board/drivers/bootkick.h +++ b/panda/board/drivers/bootkick.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_DRIVERS_BOOTKICK_H +#define BOARD_DRIVERS_BOOTKICK_H #include "board/drivers/drivers.h" @@ -67,3 +68,5 @@ void bootkick_tick(bool ignition, bool recent_heartbeat, bool wake) { } current_board->set_bootkick(boot_state); } + +#endif // BOARD_DRIVERS_BOOTKICK_H diff --git a/panda/board/drivers/can_common.h b/panda/board/drivers/can_common.h index dd56b7678f..45b5c44b90 100644 --- a/panda/board/drivers/can_common.h +++ b/panda/board/drivers/can_common.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_DRIVERS_CAN_COMMON_H +#define BOARD_DRIVERS_CAN_COMMON_H #include "board/drivers/drivers.h" #include "opendbc/safety/ignition.h" @@ -222,3 +223,5 @@ bool is_speed_valid(uint32_t speed, const uint32_t *all_speeds, uint8_t len) { } return ret; } + +#endif // BOARD_DRIVERS_CAN_COMMON_H diff --git a/panda/board/drivers/clock_source.h b/panda/board/drivers/clock_source.h index 971b3d2555..a81ec11808 100644 --- a/panda/board/drivers/clock_source.h +++ b/panda/board/drivers/clock_source.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_DRIVERS_CLOCK_SOURCE_H +#define BOARD_DRIVERS_CLOCK_SOURCE_H #include "board/drivers/drivers.h" @@ -66,3 +67,5 @@ void clock_source_init(bool enable_channel1) { register_set(&(TIM1->CR1), TIM_CR1_CEN, 0x3FU); register_set(&(TIM8->CR1), TIM_CR1_CEN, 0x3FU); } + +#endif // BOARD_DRIVERS_CLOCK_SOURCE_H diff --git a/panda/board/drivers/debug.h b/panda/board/drivers/debug.h index 314919d780..84e559cf73 100644 --- a/panda/board/drivers/debug.h +++ b/panda/board/drivers/debug.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_DRIVERS_DEBUG_H +#define BOARD_DRIVERS_DEBUG_H #include "board/drivers/drivers.h" @@ -66,3 +67,5 @@ static void hexdump(const void *a, int l) { static inline void puth4(unsigned int i) { puthx(i, 4U); } + +#endif // BOARD_DRIVERS_DEBUG_H diff --git a/panda/board/drivers/drivers.h b/panda/board/drivers/drivers.h index a67bd64a64..4ab6620bb0 100644 --- a/panda/board/drivers/drivers.h +++ b/panda/board/drivers/drivers.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_DRIVERS_DRIVERS_H +#define BOARD_DRIVERS_DRIVERS_H #include "board/can.h" #include "board/health.h" @@ -259,3 +260,5 @@ static inline void puth4(unsigned int i); void usb_init(void); void refresh_can_tx_slots_available(void); void can_tx_comms_resume_usb(void); + +#endif // BOARD_DRIVERS_DRIVERS_H diff --git a/panda/board/drivers/fake_siren.h b/panda/board/drivers/fake_siren.h index 03d5d83408..9a25026039 100644 --- a/panda/board/drivers/fake_siren.h +++ b/panda/board/drivers/fake_siren.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_DRIVERS_FAKE_SIREN_H +#define BOARD_DRIVERS_FAKE_SIREN_H #include "board/stm32h7/lli2c.h" @@ -115,3 +116,5 @@ void fake_siren_set(bool enabled) { fake_siren_enabled = enabled; } } + +#endif // BOARD_DRIVERS_FAKE_SIREN_H diff --git a/panda/board/drivers/fan.h b/panda/board/drivers/fan.h index fe51511ed9..ebadf641e9 100644 --- a/panda/board/drivers/fan.h +++ b/panda/board/drivers/fan.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_DRIVERS_FAN_H +#define BOARD_DRIVERS_FAN_H #include "board/drivers/drivers.h" @@ -59,3 +60,5 @@ void fan_tick(void) { current_board->set_fan_enabled(!fan_stalled && ((fan_state.power > 0U) || (fan_state.cooldown_counter > 0U))); } } + +#endif // BOARD_DRIVERS_FAN_H diff --git a/panda/board/drivers/fdcan.h b/panda/board/drivers/fdcan.h index c01958c468..a5f249a6e0 100644 --- a/panda/board/drivers/fdcan.h +++ b/panda/board/drivers/fdcan.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_DRIVERS_FDCAN_H +#define BOARD_DRIVERS_FDCAN_H #include "board/drivers/drivers.h" @@ -311,3 +312,5 @@ bool can_init(uint8_t can_number) { } return ret; } + +#endif // BOARD_DRIVERS_FDCAN_H diff --git a/panda/board/drivers/gpio.h b/panda/board/drivers/gpio.h index 44af963391..da5e028999 100644 --- a/panda/board/drivers/gpio.h +++ b/panda/board/drivers/gpio.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_DRIVERS_GPIO_H +#define BOARD_DRIVERS_GPIO_H #define MODE_INPUT 0 #define MODE_OUTPUT 1 @@ -83,3 +84,5 @@ bool detect_with_pull(GPIO_TypeDef *GPIO, int pin, int mode) { set_gpio_pullup(GPIO, pin, PULL_NONE); return ret; } + +#endif // BOARD_DRIVERS_GPIO_H diff --git a/panda/board/drivers/harness.h b/panda/board/drivers/harness.h index be151e0381..cf9c43611b 100644 --- a/panda/board/drivers/harness.h +++ b/panda/board/drivers/harness.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_DRIVERS_HARNESS_H +#define BOARD_DRIVERS_HARNESS_H #include "board/drivers/drivers.h" @@ -157,3 +158,5 @@ void harness_init(void) { // keep buses connected by default set_intercept_relay(false, false); } + +#endif // BOARD_DRIVERS_HARNESS_H diff --git a/panda/board/drivers/interrupts.h b/panda/board/drivers/interrupts.h index b9e8ecd136..57aacc29c1 100644 --- a/panda/board/drivers/interrupts.h +++ b/panda/board/drivers/interrupts.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_DRIVERS_INTERRUPTS_H +#define BOARD_DRIVERS_INTERRUPTS_H #include "board/drivers/drivers.h" @@ -151,3 +152,5 @@ void init_interrupts(bool check_rate_limit){ // Init interrupt timer for a 1s interval interrupt_timer_init(); } + +#endif // BOARD_DRIVERS_INTERRUPTS_H diff --git a/panda/board/drivers/led.h b/panda/board/drivers/led.h index 6be08db93e..e953b99ece 100644 --- a/panda/board/drivers/led.h +++ b/panda/board/drivers/led.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_DRIVERS_LED_H +#define BOARD_DRIVERS_LED_H #define LED_RED 0U @@ -32,3 +33,5 @@ void led_init(void) { led_set(i, false); } } + +#endif // BOARD_DRIVERS_LED_H diff --git a/panda/board/drivers/pwm.h b/panda/board/drivers/pwm.h index ca8c2a7ada..8d60ba6a84 100644 --- a/panda/board/drivers/pwm.h +++ b/panda/board/drivers/pwm.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_DRIVERS_PWM_H +#define BOARD_DRIVERS_PWM_H #define PWM_COUNTER_OVERFLOW 4800U // To get ~25kHz @@ -56,3 +57,5 @@ void pwm_set(TIM_TypeDef *TIM, uint8_t channel, uint8_t percentage){ break; } } + +#endif // BOARD_DRIVERS_PWM_H diff --git a/panda/board/drivers/registers.h b/panda/board/drivers/registers.h index fcaae7e034..690299f068 100644 --- a/panda/board/drivers/registers.h +++ b/panda/board/drivers/registers.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_DRIVERS_REGISTERS_H +#define BOARD_DRIVERS_REGISTERS_H #include "board/drivers/drivers.h" @@ -84,3 +85,5 @@ void init_registers(void) { register_map[i].check_mask = 0U; } } + +#endif // BOARD_DRIVERS_REGISTERS_H diff --git a/panda/board/drivers/self_test.h b/panda/board/drivers/self_test.h index 10d399a9d2..b9d9a2db54 100644 --- a/panda/board/drivers/self_test.h +++ b/panda/board/drivers/self_test.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_DRIVERS_SELF_TEST_H +#define BOARD_DRIVERS_SELF_TEST_H #include "board/crc.h" #include "board/crypto/rsa.h" @@ -376,3 +377,5 @@ void self_test_tick(void) { fault_occurred_value(FAULT_DMA, dma_err); } } + +#endif // BOARD_DRIVERS_SELF_TEST_H diff --git a/panda/board/drivers/simple_watchdog.h b/panda/board/drivers/simple_watchdog.h index 54a83e476f..da5aeef8f7 100644 --- a/panda/board/drivers/simple_watchdog.h +++ b/panda/board/drivers/simple_watchdog.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_DRIVERS_SIMPLE_WATCHDOG_H +#define BOARD_DRIVERS_SIMPLE_WATCHDOG_H #include "board/drivers/drivers.h" @@ -21,3 +22,5 @@ void simple_watchdog_init(uint32_t fault, uint32_t threshold) { wd_state.threshold = threshold; wd_state.last_ts = microsecond_timer_get(); } + +#endif // BOARD_DRIVERS_SIMPLE_WATCHDOG_H diff --git a/panda/board/drivers/spi.h b/panda/board/drivers/spi.h index ccbbac8464..544c63013d 100644 --- a/panda/board/drivers/spi.h +++ b/panda/board/drivers/spi.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_DRIVERS_SPI_H +#define BOARD_DRIVERS_SPI_H #include "board/drivers/drivers.h" @@ -196,3 +197,5 @@ void spi_init(void) { void can_tx_comms_resume_spi(void) { spi_can_tx_ready = true; } + +#endif // BOARD_DRIVERS_SPI_H diff --git a/panda/board/drivers/timers.h b/panda/board/drivers/timers.h index a0de78c2eb..e879541926 100644 --- a/panda/board/drivers/timers.h +++ b/panda/board/drivers/timers.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_DRIVERS_TIMERS_H +#define BOARD_DRIVERS_TIMERS_H static void timer_init(TIM_TypeDef *TIM, int psc) { register_set(&(TIM->PSC), (psc-1), 0xFFFFU); @@ -57,3 +58,5 @@ void tick_timer_init(void) { timer_init(TICK_TIMER, (uint16_t)((15.25*APB2_TIMER_FREQ)/8U)); timer_irq_enable(TICK_TIMER, TICK_TIMER_IRQ); } + +#endif // BOARD_DRIVERS_TIMERS_H diff --git a/panda/board/drivers/usb.h b/panda/board/drivers/usb.h index f2a7b9c693..76d4350042 100644 --- a/panda/board/drivers/usb.h +++ b/panda/board/drivers/usb.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_DRIVERS_USB_H +#define BOARD_DRIVERS_USB_H #include "board/drivers/drivers.h" @@ -751,3 +752,5 @@ void can_tx_comms_resume_usb(void) { } EXIT_CRITICAL(); } + +#endif // BOARD_DRIVERS_USB_H diff --git a/panda/board/early_init.h b/panda/board/early_init.h index 8d94b6999f..86bd96d8d0 100644 --- a/panda/board/early_init.h +++ b/panda/board/early_init.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_EARLY_INIT_H +#define BOARD_EARLY_INIT_H // Early bringup #define ENTER_BOOTLOADER_MAGIC 0xdeadbeefU @@ -117,3 +118,5 @@ void HardFault_Handler(void) { } #endif + +#endif // BOARD_EARLY_INIT_H diff --git a/panda/board/flasher.h b/panda/board/flasher.h index 4c419bddd3..a85d9d79ab 100644 --- a/panda/board/flasher.h +++ b/panda/board/flasher.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_FLASHER_H +#define BOARD_FLASHER_H // from the linker script #ifdef STM32F4 @@ -154,3 +155,5 @@ void soft_flasher_start(void) { delay(500000); } } + +#endif // BOARD_FLASHER_H diff --git a/panda/board/libc.h b/panda/board/libc.h index 6a1d6344a7..7522bd1bae 100644 --- a/panda/board/libc.h +++ b/panda/board/libc.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_LIBC_H +#define BOARD_LIBC_H // **** libc **** @@ -79,3 +80,5 @@ int memcmp(const void * ptr1, const void * ptr2, unsigned int num) { } return ret; } + +#endif // BOARD_LIBC_H diff --git a/panda/board/main_comms.h b/panda/board/main_comms.h index 51d43c2c7e..848d623c7d 100644 --- a/panda/board/main_comms.h +++ b/panda/board/main_comms.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_MAIN_COMMS_H +#define BOARD_MAIN_COMMS_H #include "opendbc/safety/modes/tesla_preap_pedal_transport.h" static bool panda_ignition_line(void) { @@ -478,3 +479,5 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) { } return resp_len; } + +#endif // BOARD_MAIN_COMMS_H diff --git a/panda/board/main_declarations.h b/panda/board/main_declarations.h index 6f7c1cebb0..dbe1bed4bb 100644 --- a/panda/board/main_declarations.h +++ b/panda/board/main_declarations.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_MAIN_DECLARATIONS_H +#define BOARD_MAIN_DECLARATIONS_H #include "board/drivers/drivers.h" @@ -25,3 +26,5 @@ extern bool siren_enabled; // sound extern uint16_t sound_output_level; + +#endif // BOARD_MAIN_DECLARATIONS_H diff --git a/panda/board/main_definitions.h b/panda/board/main_definitions.h index 9a79ecdb56..878ada89cf 100644 --- a/panda/board/main_definitions.h +++ b/panda/board/main_definitions.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_MAIN_DEFINITIONS_H +#define BOARD_MAIN_DEFINITIONS_H #include "main_declarations.h" @@ -19,3 +20,5 @@ bool heartbeat_disabled = false; // set over USB // siren state bool siren_enabled = false; + +#endif // BOARD_MAIN_DEFINITIONS_H diff --git a/panda/board/provision.h b/panda/board/provision.h index 18c70c07b2..3f25f2c1e2 100644 --- a/panda/board/provision.h +++ b/panda/board/provision.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_PROVISION_H +#define BOARD_PROVISION_H // this is where we manage the dongle ID assigned during our // manufacturing. aside from this, there's a UID for the MCU @@ -13,3 +14,5 @@ void get_provision_chunk(uint8_t *resp) { (void)memcpy(resp, "unprovisioned\x00\x00\x00testing123\x00\x00\xa3\xa6\x99\xec", 0x20); } } + +#endif // BOARD_PROVISION_H diff --git a/panda/board/stm32h7/board.h b/panda/board/stm32h7/board.h index a09c16814a..fba05d2056 100644 --- a/panda/board/stm32h7/board.h +++ b/panda/board/stm32h7/board.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_STM32H7_BOARD_H +#define BOARD_STM32H7_BOARD_H // ///////////////////////////////////////////////////////////// // // Hardware abstraction layer for all different supported boards // @@ -53,3 +54,5 @@ void detect_board_type(void) { // check for non-supported board types assert_fatal(hw_type != HW_TYPE_UNKNOWN, "Unsupported board type\n"); } + +#endif // BOARD_STM32H7_BOARD_H diff --git a/panda/board/stm32h7/clock.h b/panda/board/stm32h7/clock.h index 80eedfe87f..30b037609b 100644 --- a/panda/board/stm32h7/clock.h +++ b/panda/board/stm32h7/clock.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_STM32H7_CLOCK_H +#define BOARD_STM32H7_CLOCK_H /* HSE: 25MHz @@ -156,3 +157,5 @@ void clock_check(void) { fault_occurred_value(FAULT_CLOCK, captured ? counts : 0U); } } + +#endif // BOARD_STM32H7_CLOCK_H diff --git a/panda/board/stm32h7/interrupt_handlers.h b/panda/board/stm32h7/interrupt_handlers.h index 15a44969f2..9440c90126 100644 --- a/panda/board/stm32h7/interrupt_handlers.h +++ b/panda/board/stm32h7/interrupt_handlers.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_STM32H7_INTERRUPT_HANDLERS_H +#define BOARD_STM32H7_INTERRUPT_HANDLERS_H // ********************* Bare interrupt handlers ********************* // Interrupts for STM32H7x5 @@ -143,3 +144,5 @@ void FDCAN3_IT0_IRQHandler(void) {handle_interrupt(FDCAN3_IT0_IRQn);} void FDCAN3_IT1_IRQHandler(void) {handle_interrupt(FDCAN3_IT1_IRQn);} void TIM23_IRQHandler(void) {handle_interrupt(TIM23_IRQn);} void TIM24_IRQHandler(void) {handle_interrupt(TIM24_IRQn);} + +#endif // BOARD_STM32H7_INTERRUPT_HANDLERS_H diff --git a/panda/board/stm32h7/lladc.h b/panda/board/stm32h7/lladc.h index f0c7a84797..d8b076ac07 100644 --- a/panda/board/stm32h7/lladc.h +++ b/panda/board/stm32h7/lladc.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_STM32H7_LLADC_H +#define BOARD_STM32H7_LLADC_H #include "lladc_declarations.h" @@ -99,3 +100,5 @@ uint16_t adc_get_mV(const adc_signal_t *signal) { } else {} return ret; } + +#endif // BOARD_STM32H7_LLADC_H diff --git a/panda/board/stm32h7/lladc_declarations.h b/panda/board/stm32h7/lladc_declarations.h index 979919c8c9..3b1a281ad3 100644 --- a/panda/board/stm32h7/lladc_declarations.h +++ b/panda/board/stm32h7/lladc_declarations.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_STM32H7_LLADC_DECLARATIONS_H +#define BOARD_STM32H7_LLADC_DECLARATIONS_H typedef enum { SAMPLETIME_1_CYCLE = 0, @@ -35,3 +36,5 @@ typedef struct { #define ADC_CHANNEL_DEFAULT(a, c) {.adc = (a), .channel = (c), .sample_time = SAMPLETIME_32_CYCLES, .oversampling = OVERSAMPLING_64} #define VREFINT_CAL_ADDR ((uint16_t *)0x1FF1E860UL) + +#endif // BOARD_STM32H7_LLADC_DECLARATIONS_H diff --git a/panda/board/stm32h7/lldts.h b/panda/board/stm32h7/lldts.h index 614a09f9a2..fe37dd1b81 100644 --- a/panda/board/stm32h7/lldts.h +++ b/panda/board/stm32h7/lldts.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_STM32H7_LLDTS_H +#define BOARD_STM32H7_LLDTS_H // Digital temperature sensor (DTS) @@ -30,3 +31,5 @@ float dts_get_temperature(void) { } return ret; } + +#endif // BOARD_STM32H7_LLDTS_H diff --git a/panda/board/stm32h7/llfan.h b/panda/board/stm32h7/llfan.h index c87e6e7888..cb81ed9f0d 100644 --- a/panda/board/stm32h7/llfan.h +++ b/panda/board/stm32h7/llfan.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_STM32H7_LLFAN_H +#define BOARD_STM32H7_LLFAN_H // TACH interrupt handler static void EXTI2_IRQ_Handler(void) { @@ -23,3 +24,5 @@ void llfan_init(void) { register_set_bits(&(EXTI->FTSR1), (1U << 2)); nvic_enable(EXTI2_IRQn); } + +#endif // BOARD_STM32H7_LLFAN_H diff --git a/panda/board/stm32h7/llfdcan.h b/panda/board/stm32h7/llfdcan.h index 38967df97a..68822770e9 100644 --- a/panda/board/stm32h7/llfdcan.h +++ b/panda/board/stm32h7/llfdcan.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_STM32H7_LLFDCAN_H +#define BOARD_STM32H7_LLFDCAN_H #include "llfdcan_declarations.h" @@ -239,3 +240,5 @@ void llcan_clear_send(FDCAN_GlobalTypeDef *FDCANx) { bool ret = llcan_init(FDCANx); UNUSED(ret); } + +#endif // BOARD_STM32H7_LLFDCAN_H diff --git a/panda/board/stm32h7/llfdcan_declarations.h b/panda/board/stm32h7/llfdcan_declarations.h index 860b20d9e0..bdd9280adc 100644 --- a/panda/board/stm32h7/llfdcan_declarations.h +++ b/panda/board/stm32h7/llfdcan_declarations.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_STM32H7_LLFDCAN_DECLARATIONS_H +#define BOARD_STM32H7_LLFDCAN_DECLARATIONS_H // SAE J2284-4 document specifies a bus-line network running at 2 Mbit/s // SAE J2284-5 document specifies a point-to-point communication running at 5 Mbit/s @@ -48,3 +49,5 @@ void llcan_irq_disable(const FDCAN_GlobalTypeDef *FDCANx); void llcan_irq_enable(const FDCAN_GlobalTypeDef *FDCANx); bool llcan_init(FDCAN_GlobalTypeDef *FDCANx); void llcan_clear_send(FDCAN_GlobalTypeDef *FDCANx); + +#endif // BOARD_STM32H7_LLFDCAN_DECLARATIONS_H diff --git a/panda/board/stm32h7/llflash.h b/panda/board/stm32h7/llflash.h index 40b772e8f7..1f3eb865c8 100644 --- a/panda/board/stm32h7/llflash.h +++ b/panda/board/stm32h7/llflash.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_STM32H7_LLFLASH_H +#define BOARD_STM32H7_LLFLASH_H bool flash_is_locked(void) { return (FLASH->CR1 & FLASH_CR_LOCK); @@ -33,3 +34,5 @@ void flush_write_buffer(void) { while (FLASH->SR1 & FLASH_SR_QW); } } + +#endif // BOARD_STM32H7_LLFLASH_H diff --git a/panda/board/stm32h7/lli2c.h b/panda/board/stm32h7/lli2c.h index 16b3ce5ecd..69b0d9ab38 100644 --- a/panda/board/stm32h7/lli2c.h +++ b/panda/board/stm32h7/lli2c.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_STM32H7_LLI2C_H +#define BOARD_STM32H7_LLI2C_H // TODO: this driver relies heavily on polling, // if we want it to be more async, we should use interrupts @@ -159,3 +160,5 @@ void i2c_init(I2C_TypeDef *I2C) { i2c_reset(I2C); } + +#endif // BOARD_STM32H7_LLI2C_H diff --git a/panda/board/stm32h7/llmpu.h b/panda/board/stm32h7/llmpu.h index 361fd164fc..2b419137be 100644 --- a/panda/board/stm32h7/llmpu.h +++ b/panda/board/stm32h7/llmpu.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_STM32H7_LLMPU_H +#define BOARD_STM32H7_LLMPU_H // linker symbols, see stm32h7x5_flash.ld extern uint32_t _ssafety[16]; @@ -101,3 +102,5 @@ void mpu_check(void) { fault_occurred_value(FAULT_MPU, mpu_safety_changed_addr); } } + +#endif // BOARD_STM32H7_LLMPU_H diff --git a/panda/board/stm32h7/llspi.h b/panda/board/stm32h7/llspi.h index 6b5b00964e..740bf79cb3 100644 --- a/panda/board/stm32h7/llspi.h +++ b/panda/board/stm32h7/llspi.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_STM32H7_LLSPI_H +#define BOARD_STM32H7_LLSPI_H // SPI4 NSS (chip select) is PE11 #define SPI_CS_PIN 11U @@ -95,3 +96,5 @@ void llspi_init(void) { EXTI->PR1 = (1UL << SPI_CS_PIN); nvic_enable(EXTI15_10_IRQn); } + +#endif // BOARD_STM32H7_LLSPI_H diff --git a/panda/board/stm32h7/llusb.h b/panda/board/stm32h7/llusb.h index fbc79d1f8c..6499f2017a 100644 --- a/panda/board/stm32h7/llusb.h +++ b/panda/board/stm32h7/llusb.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_STM32H7_LLUSB_H +#define BOARD_STM32H7_LLUSB_H #include "llusb_declarations.h" @@ -79,3 +80,5 @@ void usb_init(void) { // enable the IRQ nvic_enable(OTG_HS_IRQn); } + +#endif // BOARD_STM32H7_LLUSB_H diff --git a/panda/board/stm32h7/llusb_declarations.h b/panda/board/stm32h7/llusb_declarations.h index a11d3f52c6..fb8a5c3a2d 100644 --- a/panda/board/stm32h7/llusb_declarations.h +++ b/panda/board/stm32h7/llusb_declarations.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_STM32H7_LLUSB_DECLARATIONS_H +#define BOARD_STM32H7_LLUSB_DECLARATIONS_H extern USB_OTG_GlobalTypeDef *USBx; @@ -14,3 +15,5 @@ extern USB_OTG_GlobalTypeDef *USBx; void usb_irqhandler(void); void usb_init(void); + +#endif // BOARD_STM32H7_LLUSB_DECLARATIONS_H diff --git a/panda/board/stm32h7/peripherals.h b/panda/board/stm32h7/peripherals.h index b0eab86200..0389fde5e4 100644 --- a/panda/board/stm32h7/peripherals.h +++ b/panda/board/stm32h7/peripherals.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_STM32H7_PERIPHERALS_H +#define BOARD_STM32H7_PERIPHERALS_H #ifdef BOOTSTUB void gpio_usb_init(void) { @@ -150,3 +151,5 @@ void check_option_bytes(void) { fault_occurred_value(FAULT_REGISTER_DIVERGENT, (boot << 16) | optlock); } } + +#endif // BOARD_STM32H7_PERIPHERALS_H diff --git a/panda/board/stm32h7/sound.h b/panda/board/stm32h7/sound.h index 18938f11be..ec2b2c9f06 100644 --- a/panda/board/stm32h7/sound.h +++ b/panda/board/stm32h7/sound.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_STM32H7_SOUND_H +#define BOARD_STM32H7_SOUND_H #define SOUND_RX_BUF_SIZE 1000U #define SOUND_TX_BUF_SIZE (SOUND_RX_BUF_SIZE/2U) @@ -232,3 +233,5 @@ void sound_init(void) { nvic_enable(BDMA_Channel0_IRQn); nvic_enable(DMA1_Stream0_IRQn); } + +#endif // BOARD_STM32H7_SOUND_H diff --git a/panda/board/stm32h7/stm32h7_config.h b/panda/board/stm32h7/stm32h7_config.h index e72fc20605..985caa1c95 100644 --- a/panda/board/stm32h7/stm32h7_config.h +++ b/panda/board/stm32h7/stm32h7_config.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_STM32H7_STM32H7_CONFIG_H +#define BOARD_STM32H7_STM32H7_CONFIG_H #include "stm32h7xx.h" #include "stm32h7xx_hal_gpio_ex.h" @@ -96,3 +97,5 @@ void early_gpio_float(void) { GPIOA->ODR = 0; GPIOB->ODR = 0; GPIOC->ODR = 0; GPIOD->ODR = 0; GPIOE->ODR = 0; GPIOF->ODR = 0; GPIOG->ODR = 0; GPIOH->ODR = 0; GPIOA->PUPDR = 0; GPIOB->PUPDR = 0; GPIOC->PUPDR = 0; GPIOD->PUPDR = 0; GPIOE->PUPDR = 0; GPIOF->PUPDR = 0; GPIOG->PUPDR = 0; GPIOH->PUPDR = 0; } + +#endif // BOARD_STM32H7_STM32H7_CONFIG_H diff --git a/panda/board/sys/critical.h b/panda/board/sys/critical.h index 0b8ac20307..574ca9f784 100644 --- a/panda/board/sys/critical.h +++ b/panda/board/sys/critical.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_SYS_CRITICAL_H +#define BOARD_SYS_CRITICAL_H #include "board/sys/sys.h" @@ -16,3 +17,5 @@ void disable_interrupts(void) { interrupts_enabled = false; __disable_irq(); } + +#endif // BOARD_SYS_CRITICAL_H diff --git a/panda/board/sys/faults.h b/panda/board/sys/faults.h index 0e167bbf94..dd9ef64f64 100644 --- a/panda/board/sys/faults.h +++ b/panda/board/sys/faults.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_SYS_FAULTS_H +#define BOARD_SYS_FAULTS_H #include "board/sys/sys.h" @@ -44,3 +45,5 @@ void fault_recovered(uint32_t fault) { print("Cannot recover from a permanent fault!\n"); } } + +#endif // BOARD_SYS_FAULTS_H diff --git a/panda/board/sys/power_saving.h b/panda/board/sys/power_saving.h index eabea6c12d..809961e59e 100644 --- a/panda/board/sys/power_saving.h +++ b/panda/board/sys/power_saving.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_SYS_POWER_SAVING_H +#define BOARD_SYS_POWER_SAVING_H #include "board/sys/sys.h" @@ -168,3 +169,5 @@ static void enter_stop_mode(void) { NVIC_SystemReset(); } #endif + +#endif // BOARD_SYS_POWER_SAVING_H diff --git a/panda/board/sys/sys.h b/panda/board/sys/sys.h index ec2a901c55..55b1367ffc 100644 --- a/panda/board/sys/sys.h +++ b/panda/board/sys/sys.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_SYS_SYS_H +#define BOARD_SYS_SYS_H // ******************** critical ******************** @@ -81,3 +82,5 @@ extern volatile bool stop_mode_requested; #endif void set_power_save_state(bool enable); + +#endif // BOARD_SYS_SYS_H diff --git a/panda/board/utils.h b/panda/board/utils.h index 95b09cefbd..1a42b7166b 100644 --- a/panda/board/utils.h +++ b/panda/board/utils.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef BOARD_UTILS_H +#define BOARD_UTILS_H // cppcheck-suppress-macro [misra-c2012-1.2, misra-c2012-17.3]; allow __typeof__ extension #define MIN(a, b) ({ \ @@ -47,3 +48,5 @@ uint32_t get_ts_elapsed(uint32_t ts, uint32_t ts_last) { return ts - ts_last; } + +#endif // BOARD_UTILS_H