board: include guards instead of #pragma once (MISRA 1.2) (#2518)

This commit is contained in:
Adeeb Shihadeh
2026-11-28 12:08:40 -06:00
committed by firestar5683
parent b46cde70a1
commit bf06ad7f1b
67 changed files with 268 additions and 67 deletions
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef BOARD_BOARDS_BOARD_DECLARATIONS_H
#define BOARD_BOARDS_BOARD_DECLARATIONS_H
#include <stdint.h>
#include <stdbool.h>
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef BOARD_BODY_BODY_H
#define BOARD_BODY_BODY_H
#include <stdbool.h>
#include <stdint.h>
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H
#include <stdbool.h>
@@ -26,3 +27,5 @@
// building for tests
//#include "fake_stm.h"
#endif
#endif // BOARD_CONFIG_H
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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
+4 -1
View File
@@ -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