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 10, 2024
1 parent d0d9cdf commit dfec4b1
Show file tree
Hide file tree
Showing 3 changed files with 341 additions and 0 deletions.
74 changes: 74 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/defaults.parm
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
BATT_MONITOR 4
BATT_VOLT_PIN 93
BATT_CURR_PIN 92
BATT_AMP_PERVLT 66.6667
# BATT_AMP_PERVLT 1
BATT_VOLT_MULT 19

BATT2_MONITOR 4
BATT2_VOLT_PIN 94
BATT2_CURR_PIN 91
BATT2_AMP_PERVLT 66.6667
# BATT2_AMP_PERVLT 1
BATT2_VOLT_MULT 19

# 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.002
BATT4_MAX_AMPS 20

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

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

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

# 5.3 - 2
BATT8_MONITOR 21
BATT8_I2C_BUS 0
BATT8_I2C_ADDR 69
BATT8_SHUNT 0.01
BATT8_MAX_AMPS 5

# Main Out
BATT9_MONITOR 3
BATT9_VOLT_PIN 90
BATT9_VOLT_MULT 19

# LED setup
OUT1_FUNCTION 120

TEMP1_ADDR,64
TEMP1_BUS,0
TEMP1_SRC,3
TEMP1_SRC_ID,1
TEMP1_TYPE,4

# DAC setup
FSO_DAC1_TYPE 1
FSO_DAC1_BUS 1
FSO_DAC1_ADDR 72
87 changes: 87 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,87 @@
# 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

# pullup outputs to ensure they stay off
PB10 PAYLOAD_PC OUTPUT PULLDOWN LOW
PB11 PAYLOAD_EN OUTPUT PULLDOWN LOW
PC4 PAYLOAD_1_EN OUTPUT PULLDOWN LOW
PC5 PAYLOAD_2_EN OUTPUT PULLDOWN LOW
PC13 MAIN_PC OUTPUT PULLDOWN LOW
PC14 BAT_1_EN OUTPUT PULLDOWN LOW
PC15 BAT_2_EN OUTPUT PULLDOWN LOW
PA1 LED_RED OUTPUT PULLDOWN LOW
PA2 LED_GREEN OUTPUT PULLDOWN LOW
PA3 LED_BLUE OUTPUT PULLDOWN LOW
PB13 LED_MAIN OUTPUT PULLDOWN LOW
PB15 LED_PAYLOAD OUTPUT PULLDOWN 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?
180 changes: 180 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
# 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 HAL_PERIPH_ENABLE_FSO_POWER_STACK

define AP_BATT_MONITOR_MAX_INSTANCES 9
define AP_BATTERY_BACKEND_DEFAULT_ENABLED 0
define AP_BATTERY_INA2XX_ENABLED 1
define AP_BATTERY_ANALOG_ENABLED 1

# enable DAC
define AP_DAC_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

# enable serial LED
define AP_NOTIFY_NEOPIXEL_ENABLED 1
define AP_SERIALLED_ENABLED 1

# 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(0.9091) ANALOG(90)
PC0 ADC_BAT_1_CURRENT ADC1 SCALE(0.9091) ANALOG(91)
PC1 ADC_BAT_2_CURRENT ADC1 SCALE(0.9091) ANALOG(92)
PC2 ADC_BAT_1_VOLTAGE ADC1 SCALE(0.9091) ANALOG(93)
PC3 ADC_BAT_2_VOLTAGE ADC1 SCALE(0.9091) 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

define FSO_FAN_TACH1_PIN 60
define FSO_FAN_TACH2_PIN 61
define FSO_FAN_TACH3_PIN 62
define FSO_FAN_TACH4_PIN 63

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

define FSO_SWITCH_MAIN_PIN 64
define FSO_SWITCH_PAYLOAD_PIN 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

define FSO_PAYLOAD_HV_PC_PIN 70
define FSO_PAYLOAD_HV_EN_PIN 71
define FSO_PAYLOAD_1_EN_PIN 72
define FSO_PAYLOAD_2_EN_PIN 73
define FSO_MAIN_PC_PIN 74
define FSO_BAT_1_EN_PIN 75
define FSO_BAT_2_EN_PIN 76

# 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(1) 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

define FSO_LED_DEBUG_PIN 84
define FSO_LED_MAIN_PIN 85
define FSO_LED_PAYLOAD_PIN 86

# 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 DEFAULT_NTF_LED_TYPES 257

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 dfec4b1

Please sign in to comment.