Skip to content

Commit

Permalink
AP_HAL_ChibiOS Add CBUnmanned CBU-H7-LC-Stamp
Browse files Browse the repository at this point in the history
  • Loading branch information
CBUnmanned committed Nov 21, 2024
1 parent dff0f6f commit 48f778f
Show file tree
Hide file tree
Showing 4 changed files with 459 additions and 0 deletions.
1 change: 1 addition & 0 deletions Tools/AP_Bootloader/board_types.txt
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ AP_HW_MicoAir743AIOv1 1176
AP_HW_CrazyF405 1177
AP_HW_FlywooF405HD_AIOv2 1180
AP_HW_FlywooH743Pro 1181
AP_HW_CBU_StampH743_LC 1182

AP_HW_ESP32_PERIPH 1205
AP_HW_ESP32S3_PERIPH 1206
Expand Down
80 changes: 80 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/CBU-H7-LC-Stamp/hwdef-bl.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# hw definition file for processing by chibios_hwdef.py
# for the CBUnmanned H743 Stamp Low Cost hardware

# MCU class and specific type
MCU STM32H7xx STM32H743xx

# crystal frequency
OSCILLATOR_HZ 16000000

# board ID for firmware load
APJ_BOARD_ID AP_HW_CBU_StampH743_LC

# bootloader is installed at zero offset
FLASH_RESERVE_START_KB 0

# the location where the bootloader will put the firmware
FLASH_BOOTLOADER_LOAD_KB 128

# flash size
FLASH_SIZE_KB 2048

env OPTIMIZE -Os

# order of UARTs (and USB)
SERIAL_ORDER OTG1 UART1 UART2

# USB
PA11 OTG_FS_DM OTG1
PA12 OTG_FS_DP OTG1
PA9 VBUS INPUT OPENDRAIN

# pins for SWD debugging
PA13 JTMS-SWDIO SWD
PA14 JTCK-SWCLK SWD

# CS pins
PE9 IMU1_CS CS
PE4 SP4_CS1 CS

PD6 USART2_RX USART2
PD5 USART2_TX USART2

PB6 USART1_TX USART1
PA10 USART1_RX USART1

PE3 LED_ACTIVITY OUTPUT HIGH
define HAL_LED_ON 1

define HAL_USE_EMPTY_STORAGE 1
define HAL_STORAGE_SIZE 16384

# enable DFU by default
ENABLE_DFU_BOOT 1

# support flashing from SD card

# FATFS support:
define CH_CFG_USE_MEMCORE 1
define CH_CFG_USE_HEAP 1
define CH_CFG_USE_SEMAPHORES 0
define CH_CFG_USE_MUTEXES 1
define CH_CFG_USE_DYNAMIC 1
define CH_CFG_USE_WAITEXIT 1
define CH_CFG_USE_REGISTRY 1

# microSD support
PC1 SDMMC2_CK SDMMC2
PD7 SDMMC2_CMD SDMMC2
PB14 SDMMC2_D0 SDMMC2
PB15 SDMMC2_D1 SDMMC2
PB3 SDMMC2_D2 SDMMC2
PB4 SDMMC2_D3 SDMMC2
define FATFS_HAL_DEVICE SDCD2

DMA_PRIORITY SDMMC* ADC* UART* USART* SPI* TIM*

# enable FAT filesystem support (needs a microSD defined via SDMMC)
define HAL_OS_FATFS_IO 1

define AP_BOOTLOADER_FLASH_FROM_SD_ENABLED 1
191 changes: 191 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/CBU-H7-LC-Stamp/hwdef.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
# hw definition file for processing by chibios_hwdef.py
# for the CBUnmanned H743 Stamp Low Cost hardware

# default to all pins low to avoid ESD issues
#DEFAULTGPIO OUTPUT LOW PULLDOWN

# MCU class and specific type
MCU STM32H7xx STM32H743xx

# crystal frequency
OSCILLATOR_HZ 16000000

# ChibiOS system timer
STM32_ST_USE_TIMER 12
define CH_CFG_ST_RESOLUTION 16

MCU_CLOCKRATE_MHZ 480

# board ID for firmware load
APJ_BOARD_ID AP_HW_CBU_StampH743_LC

FLASH_RESERVE_START_KB 128

# flash size
FLASH_SIZE_KB 2048

env OPTIMIZE -Os

# order of UARTs (and USB)
SERIAL_ORDER OTG1 USART1 USART2 USART3 UART4 UART5 USART6 UART7 UART8 OTG2

# USB
PA11 OTG_FS_DM OTG1
PA12 OTG_FS_DP OTG1
PA9 VBUS INPUT OPENDRAIN

# pins for SWD debugging
PA13 JTMS-SWDIO SWD
PA14 JTCK-SWCLK SWD

PB6 USART1_TX USART1 NODMA
PA10 USART1_RX USART1 NODMA

PD6 USART2_RX USART2
PD5 USART2_TX USART2

# GPS 1
PC10 USART3_TX USART3
PD9 USART3_RX USART3

# GPS 2
PD1 UART4_TX UART4
PC11 UART4_RX UART4

PC12 UART5_TX UART5
PD2 UART5_RX UART5

# RCIN
PC6 USART6_TX USART6
PC7 USART6_RX USART6
define DEFAULT_SERIAL6_PROTOCOL SerialProtocol_RCIN
define DEFAULT_SERIAL6_BAUD 115

PA15 UART7_TX UART7
PE7 UART7_RX UART7

PE1 UART8_TX UART8 NODMA
PE0 UART8_RX UART8 NODMA


# ADC
PC4 BATT_CURRENT_SENS ADC1 SCALE(1) # Current INP4
PA4 BATT_VOLTAGE_SENS ADC1 SCALE(1) # Voltage
# PB1 SPARE_SENS ADC1 SCALE(1) # Spare

# define default battery setup
define HAL_BATT_MONITOR_DEFAULT 4
define HAL_BATT_VOLT_PIN 18
define HAL_BATT_CURR_PIN 4
define HAL_BATT_VOLT_SCALE 11.1
define HAL_BATT_CURR_SCALE 64

# IMU1 ICM-42760-P
PE9 IMU1_CS CS
PB0 IMU1_DRDY INPUT

# SPI4 - External
PE2 SPI4_SCK SPI4
PE5 SPI4_MISO SPI4
PE6 SPI4_MOSI SPI4
PD4 SP4_DRDY INPUT
PE4 SP4_CS1 CS

# SPI6 - IMUs
PA5 SPI6_SCK SPI6
PA6 SPI6_MISO SPI6
PB5 SPI6_MOSI SPI6

# PWM output pins
PA0 TIM5_CH1 TIM5 PWM(1) GPIO(50) BIDIR
PA1 TIM5_CH2 TIM5 PWM(2) GPIO(51)
PA2 TIM5_CH3 TIM5 PWM(3) GPIO(52) BIDIR
PA3 TIM5_CH4 TIM5 PWM(4) GPIO(53)

PD12 TIM4_CH1 TIM4 PWM(5) GPIO(54) BIDIR
PB7 TIM4_CH2 TIM4 PWM(6) GPIO(55)
PD14 TIM4_CH3 TIM4 PWM(7) GPIO(56) BIDIR
PD15 TIM4_CH4 TIM4 PWM(8) GPIO(57)

PC8 TIM3_CH3 TIM3 PWM(9) GPIO(58)
PB1 TIM3_CH4 TIM3 PWM(10) GPIO(59)

PA7 TIM14_CH1 TIM14 GPIO(61) ALARM

# CAN bus
PD0 CAN1_RX CAN1
PB9 CAN1_TX CAN1

PB12 CAN2_RX CAN2
PB13 CAN2_TX CAN2

# I2C buses
# I2C2 - BMP280
PB10 I2C2_SCL I2C2
PB11 I2C2_SDA I2C2

# I2C3 - GPS1 external compass
PA8 I2C3_SCL I2C3
PC9 I2C3_SDA I2C3

# I2C4 - GPS2 external compass
PB8 I2C4_SCL I2C4
PD13 I2C4_SDA I2C4

# order of I2C buses
I2C_ORDER I2C2 I2C3 I2C4
define HAL_I2C_INTERNAL_MASK 1


# microSD support
PC1 SDMMC2_CK SDMMC2
PD7 SDMMC2_CMD SDMMC2
PB14 SDMMC2_D0 SDMMC2
PB15 SDMMC2_D1 SDMMC2
PB3 SDMMC2_D2 SDMMC2
PB4 SDMMC2_D3 SDMMC2
define FATFS_HAL_DEVICE SDCD2

# safety
PD3 SAFETY_IN INPUT PULLDOWN

# LED
PE3 LED_RED OUTPUT HIGH GPIO(90)

define AP_NOTIFY_GPIO_LED_1_ENABLED 1
define AP_NOTIFY_GPIO_LED_1_PIN 90
define HAL_GPIO_LED_ON 1

# barometers
BARO BMP280 I2C:0:0x76

# compass
define HAL_PROBE_EXTERNAL_I2C_COMPASSES

# IMUs
SPIDEV icm42670 SPI6 DEVID3 IMU1_CS MODE3 2*MHZ 8*MHZ
IMU Invensensev3 SPI:icm42670 ROTATION_PITCH_180_YAW_270

define HAL_DEFAULT_INS_FAST_SAMPLE 7

# use last 2 pages for flash storage
# H743 has 16 pages of 128k each
define HAL_STORAGE_SIZE 32768
STORAGE_FLASH_PAGE 14

DMA_PRIORITY SDMMC* TIM* SPI6*
DMA_NOSHARE TIM2* TIM4* TIM5*

# enable FAT filesystem support (needs a microSD defined via SDMMC)
define HAL_OS_FATFS_IO 1

# enable DFU reboot for installing bootloader
# note that if firmware is build with --secure-bl then DFU is
# disabled
ENABLE_DFU_BOOT 1

# build ABIN for flash-from-bootloader support:
env BUILD_ABIN True

# ethernet consumes a big chunk of flash
define AP_BATTERY_SCRIPTING_ENABLED 1
Loading

0 comments on commit 48f778f

Please sign in to comment.