Skip to content

Commit

Permalink
hwdef: Added FSO_POWER_STACK peripheral
Browse files Browse the repository at this point in the history
  • Loading branch information
lthall authored and tridge committed Feb 2, 2024
1 parent fc65fd4 commit ca0388c
Show file tree
Hide file tree
Showing 3 changed files with 277 additions and 0 deletions.
53 changes: 53 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/defaults.parm
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
BATT_MONITOR 4
BATT_VOLT_PIN 93
BATT_CURR_PIN 91
BATT_AMP_PERVLT 1
BATT_VOLT_MULT 1

BATT2_MONITOR 4
BATT2_VOLT_PIN 94
BATT2_CURR_PIN 92
BATT2_AMP_PERVLT 1
BATT2_VOLT_MULT 1

# Payload HV
BATT3_MONITOR 21
BATT3_I2C_BUS 0
BATT3_I2C_ADDR 65
BATT3_SHUNT 0.001
BATT3_MAX_AMPS 30

# Payload Out 1
BATT4_MONITOR 21
BATT4_I2C_BUS 1
BATT4_I2C_ADDR 64
BATT4_SHUNT 0.001
BATT4_MAX_AMPS 20

# Payload Out 2
BATT5_MONITOR 21
BATT5_I2C_BUS 1
BATT5_I2C_ADDR 69
BATT5_SHUNT 0.001
BATT5_MAX_AMPS 20

# High Power 5.3
BATT6_MONITOR 21
BATT6_I2C_BUS 1
BATT6_I2C_ADDR 65
BATT6_SHUNT 0.001
BATT6_MAX_AMPS 20

# 5.3 - 1
BATT7_MONITOR 21
BATT7_I2C_BUS 0
BATT7_I2C_ADDR 68
BATT7_SHUNT 0.001
BATT7_MAX_AMPS 5

# 5.3 - 2
BATT8_MONITOR 21
BATT8_I2C_BUS 0
BATT8_I2C_ADDR 69
BATT8_SHUNT 0.001
BATT8_MAX_AMPS 5
73 changes: 73 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef-bl.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# hw definition file for processing by chibios_pins.py

# MCU class and specific type
MCU STM32G4xx STM32G474xx

FLASH_RESERVE_START_KB 0
FLASH_BOOTLOADER_LOAD_KB 32

# reserve some space for params
APP_START_OFFSET_KB 4

# 512k flash part
FLASH_SIZE_KB 512

# board ID for firmware load
APJ_BOARD_ID AP_HW_FSO_POWER_STACK

# setup build for a peripheral firmware
env AP_PERIPH 1

# crystal frequency
OSCILLATOR_HZ 16000000

define CH_CFG_ST_FREQUENCY 1000000

# order of UARTs
SERIAL_ORDER USART2

# LED
PB2 LED_BOOTLOADER OUTPUT HIGH # change to PD2

define HAL_LED_ON 0

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

define HAL_USE_SERIAL TRUE

define STM32_SERIAL_USE_USART1 FALSE
define STM32_SERIAL_USE_USART2 TRUE
define STM32_SERIAL_USE_USART3 FALSE

define HAL_NO_GPIO_IRQ
define HAL_USE_EMPTY_IO TRUE

# avoid timer and RCIN threads to save memory
define HAL_NO_TIMER_THREAD
define HAL_NO_RCIN_THREAD

define DMA_RESERVE_SIZE 0

define HAL_DISABLE_LOOP_DELAY

# enable CAN support

PA11 CAN1_RX CAN1
PA12 CAN1_TX CAN1
PA5 GPIO_CAN1_SILENT OUTPUT PUSHPULL SPEED_LOW LOW

PB5 CAN2_RX CAN2
PB6 CAN2_TX CAN2
PA4 GPIO_CAN2_SILENT OUTPUT PUSHPULL SPEED_LOW LOW

define CAN_APP_NODE_NAME "org.ardupilot.FSO_Power_Stack"

# make bl baudrate match debug baudrate for easier debugging
define BOOTLOADER_BAUDRATE 57600

# use a smaller bootloader timeout
define HAL_BOOTLOADER_TIMEOUT 2500

# do I need to define pins as pull down so the bootloader doesn't blow things up?
151 changes: 151 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# hw definition file for processing by chibios_pins.py

# MCU class and specific type
MCU STM32G4xx STM32G474xx

FLASH_RESERVE_START_KB 36

STORAGE_FLASH_PAGE 16
define HAL_STORAGE_SIZE 800

# board ID for firmware load
APJ_BOARD_ID AP_HW_FSO_POWER_STACK

# setup build for a peripheral firmware
env AP_PERIPH 1

# crystal frequency
OSCILLATOR_HZ 16000000

define CH_CFG_ST_FREQUENCY 1000000

# assume 512k flash part
FLASH_SIZE_KB 512

# Enable Options
define AP_TEMPERATURE_SENSOR_ENABLED 1
define AP_TEMPERATURE_SENSOR_TSYS03_ENABLED 1
define HAL_PERIPH_ENABLE_BATTERY
define AP_BATTERY_INA2XX_ENABLED 1
define HAL_PERIPH_ENABLE_RC_OUT
define HAL_PERIPH_ENABLE_NOTIFY

define AP_BATT_MONITOR_MAX_INSTANCES 8
define AP_BATTERY_BACKEND_DEFAULT_ENABLED 0
define AP_BATTERY_INA2XX_ENABLED 1
define AP_BATTERY_ANALOG_ENABLED 1

# Disable Options
define HAL_NO_RCIN_THREAD
define HAL_NO_RCOUT_THREAD
define HAL_USE_RTC FALSE
define DISABLE_SERIAL_ESC_COMM TRUE
define HAL_NO_GPIO_IRQ
define HAL_DISABLE_LOOP_DELAY

# Set Options
define DMA_RESERVE_SIZE 0

env DISABLE_SCRIPTING 1

# order of UARTs
SERIAL_ORDER UART4 UART5

# UARTs

# UART4, External Serial Port
PC10 UART4_TX UART4
Pc11 UART4_RX UART4
PB7 UART4_CTS UART4
PA15 UART4_RTS UART4

# UART5, External Serial Port
PC12 UART5_TX UART5
PD2 UART5_RX UART5

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

# enable CAN support
PA11 CAN1_RX CAN1
PA12 CAN1_TX CAN1
PA5 GPIO_CAN1_SILENT OUTPUT PUSHPULL SPEED_LOW LOW
PB5 CAN2_RX CAN2
PB6 CAN2_TX CAN2
PA4 GPIO_CAN2_SILENT OUTPUT PUSHPULL SPEED_LOW LOW

# I2C2 is Control and Power Distribution Board
PA8 I2C2_SDA I2C2
PA9 I2C2_SCL I2C2

# I2C3 is Auxiliary Power Board
PC8 I2C3_SCL I2C3
PC9 I2C3_SDA I2C3

# I2C4 is External I2C Port
PC6 I2C4_SCL I2C4
PC7 I2C4_SDA I2C4

# order of I2C buses
I2C_ORDER I2C2 I2C3 I2C4

define HAL_USE_ADC TRUE
define STM32_ADC_USE_ADC1 TRUE

# analog in
PA0 ADC_MAIN_VOLTAGE ADC1 SCALE(1) ANALOG(90)
PC0 ADC_BAT_1_CURRENT ADC1 SCALE(1) ANALOG(91)
PC1 ADC_BAT_2_CURRENT ADC1 SCALE(1) ANALOG(92)
PC2 ADC_BAT_1_VOLTAGE ADC1 SCALE(1) ANALOG(93)
PC3 ADC_BAT_2_VOLTAGE ADC1 SCALE(1) ANALOG(94)
# VBat channel should be here somewhere too

# Fan Tachometer Inputs
PA6 TACH_1 INPUT OPENDRAIN GPIO(60) # Input Fan1 Tach
PA7 TACH_2 INPUT OPENDRAIN GPIO(61) # Input Fan2 Tach
PB0 TACH_3 INPUT OPENDRAIN GPIO(62) # Input Fan3 Tach
PB1 TACH_4 INPUT OPENDRAIN GPIO(63) # Input Fan4 Tach

# PDB input switches
PB12 SWITCH_MAIN INPUT OPENDRAIN GPIO(64)
PB14 SWITCH_PAYLOAD INPUT OPENDRAIN GPIO(65)

# PDB controls
PB10 PAYLOAD_PC OUTPUT PULLDOWN GPIO(70) LOW
PB11 PAYLOAD_EN OUTPUT PULLDOWN GPIO(71) LOW
PC4 PAYLOAD_1_EN OUTPUT PULLDOWN GPIO(72) LOW
PC5 PAYLOAD_2_EN OUTPUT PULLDOWN GPIO(73) LOW
PC13 MAIN_PC OUTPUT PULLDOWN GPIO(74) LOW
PC14 BAT_1_EN OUTPUT PULLDOWN GPIO(75) LOW
PC15 BAT_2_EN OUTPUT PULLDOWN GPIO(76) LOW

# LEDs
PA1 LED_RED OUTPUT PULLDOWN GPIO(80) LOW
PA2 LED_GREEN OUTPUT PULLDOWN GPIO(81) LOW
PA3 LED_BLUE OUTPUT PULLDOWN GPIO(82) LOW
PA10 TIM1_CH3 TIM1 PWM(3) GPIO(83) LOW # Status NTF_LED LED
PB2 LED_BOOT OUTPUT PULLDOWN GPIO(84) LOW
PB13 LED_MAIN OUTPUT PULLDOWN GPIO(85) LOW
PB15 LED_PAYLOAD OUTPUT PULLDOWN GPIO(86) LOW

# setup for "pixracer" RGB LEDs
define HAL_GPIO_A_LED_PIN 80
define HAL_GPIO_B_LED_PIN 81
define HAL_GPIO_C_LED_PIN 82
define HAL_GPIO_LED_ON 1
define HAL_GPIO_LED_OFF 0

define HAL_HAVE_PIXRACER_LED

define HAL_NO_LOGGING
define HAL_NO_MONITOR_THREAD

define HAL_DEVICE_THREAD_STACK 768

# we setup a small defaults.parm
define AP_PARAM_MAX_EMBEDDED_PARAM 256

# keep ROMFS uncompressed as we don't have enough RAM
# to uncompress the bootloader at runtime
env ROMFS_UNCOMPRESSED True

0 comments on commit ca0388c

Please sign in to comment.