# TerraHawk charge node: AP_Periph DroneCAN node for the hangar charge path. # Reads the pack's balance lead (six cells), charge current, shoe-side voltage # and pack temperature; drives the charge-enable and balancer switches; one # status LED strip. STM32F405RGT6, 8 MHz crystal. See docs/charge-node.md. MCU STM32F4xx STM32F405xx # bootloader in the first 64k, parameters in the next two 16k sectors FLASH_RESERVE_START_KB 64 FLASH_SIZE_KB 1024 STORAGE_FLASH_PAGE 2 define HAL_STORAGE_SIZE 15360 # Private board id. It only has to agree between hwdef.dat and hwdef-bl.dat. # IDs 1000 to 19999 are allocated upstream by PR; this board is not registered. APJ_BOARD_ID 20401 env AP_PERIPH 1 define STM32_ST_USE_TIMER 5 define CH_CFG_ST_RESOLUTION 32 OSCILLATOR_HZ 8000000 STDOUT_SERIAL SD1 STDOUT_BAUDRATE 57600 define SERIAL_BUFFERS_SIZE 512 define PORT_INT_REQUIRED_STACK 64 define DMA_RESERVE_SIZE 0 define HAL_DEVICE_THREAD_STACK 768 define AP_PARAM_MAX_EMBEDDED_PARAM 512 env ROMFS_UNCOMPRESSED True # activity LED PC12 LED OUTPUT LOW define HAL_LED_ON 0 # SWD stays available: this is a home-made board PA13 JTMS-SWDIO SWD PA14 JTCK-SWCLK SWD # ---------------------- CAN bus ------------------------- PB8 CAN1_RX CAN1 PB9 CAN1_TX CAN1 PC13 GPIO_CAN1_SILENT OUTPUT PUSHPULL SPEED_LOW LOW # ---------------------- UARTs --------------------------- # USART1: debug console on a 3-pin header SERIAL_ORDER USART1 PA9 USART1_TX USART1 SPEED_HIGH NODMA PA10 USART1_RX USART1 SPEED_HIGH NODMA # ---------------------- I2C1 ---------------------------- # spare header for a digital current monitor or temperature sensor later I2C_ORDER I2C1 PB6 I2C1_SCL I2C1 PB7 I2C1_SDA I2C1 define HAL_I2C_CLEAR_ON_TIMEOUT 0 define HAL_I2C_INTERNAL_MASK 0 # ---------------------- ADC ----------------------------- define HAL_USE_ADC TRUE define STM32_ADC_USE_ADC1 TRUE # Balance lead taps, cumulative from pack negative, through 10.1:1 dividers # (910k over 100k, 0.1 %, Viking ARG03BTC9103, high so the permanently plugged # balance lead does not drain the pack unevenly; terrahawk-eda a1d96ca, Ryan # 2026-10-01). SCALE(10.1) is fixed in firmware, so the dividers must be # accurate; there is no per-cell calibration parameter. Never fit 900k parts # with SCALE(10.1), or 910k with SCALE(10): each reads 1 % wrong, 0.04 V a cell. PC0 CELL1 ADC1 SCALE(10.1) ANALOG(1) PC1 CELL2 ADC1 SCALE(10.1) ANALOG(2) PC2 CELL3 ADC1 SCALE(10.1) ANALOG(3) PC3 CELL4 ADC1 SCALE(10.1) ANALOG(4) PA0 CELL5 ADC1 SCALE(10.1) ANALOG(5) PA1 CELL6 ADC1 SCALE(10.1) ANALOG(6) # Pack voltage (1M over 100k from the balance lead top tap), charge current # (INA180A2 on a 5 mOhm shunt, 0.25 V/A, over the link from the power stage), # shoe-side voltage at the bridge input (11:1 after a BAV70 diode-OR, over the # link), pack thermistor (10k NTC, 10k pull-up to 3V3) PA6 BATT_VOLTAGE_SENS ADC1 SCALE(1) ANALOG(10) PA5 BATT_CURRENT_SENS ADC1 SCALE(1) ANALOG(11) PA4 BATT2_VOLTAGE_SENS ADC1 SCALE(1) ANALOG(12) PA7 PACK_TEMP ADC1 SCALE(1) ANALOG(13) # ---------------------- Battery ------------------------- define AP_PERIPH_BATTERY_ENABLED 1 define AP_BATT_MONITOR_MAX_INSTANCES 2 # BATT: the pack, voltage and charge current define HAL_BATT_MONITOR_DEFAULT 4 define HAL_BATT_VOLT_PIN 10 define HAL_BATT_CURR_PIN 11 define HAL_BATT_VOLT_SCALE 11.0 define HAL_BATT_CURR_SCALE 4.0 # BATT2: shoe-side voltage, voltage only. Reports contact before any current flows. define HAL_BATT2_MONITOR_DEFAULT 3 define HAL_BATT2_VOLT_PIN 12 define HAL_BATT2_VOLT_SCALE 11.0 # per-cell voltages from the balance lead define AP_PERIPH_BATTERY_BALANCE_ENABLED 1 define AP_PERIPH_BATTERY_BALANCE_NUMCELLS_DEFAULT 6 define AP_PERIPH_BATTERY_BALANCE_RATE_DEFAULT 2 define AP_PERIPH_BATTERY_BALANCE_CELL1_PIN_DEFAULT 1 define AP_PERIPH_BATTERY_BALANCE_ID_DEFAULT 10 # pack temperature: analog NTC, attached to BATT by TEMP1_SRC in defaults.parm define AP_PERIPH_DEVICE_TEMPERATURE_ENABLED 1 define AP_TEMPERATURE_SENSOR_ENABLED 1 define AP_TEMPERATURE_SENSOR_ANALOG_ENABLED 1 # ---------------------- Relays -------------------------- # RELAY1 = charge-enable P-MOSFET gate driver, RELAY2 = balancer power. # Both default off. Driven from the FC by DroneCAN hardpoint 0 and 1. PB0 CHARGE_EN OUTPUT LOW GPIO(50) PB1 BAL_EN OUTPUT LOW GPIO(51) define AP_PERIPH_RELAY_ENABLED 1 define AP_RELAY_ENABLED 1 define AP_RELAY_NUM_RELAYS 2 define RELAY1_PIN_DEFAULT 50 define RELAY2_PIN_DEFAULT 51 # ---------------------- Status LEDs --------------------- # WS2812 strip visible through the hatch, on OUT1 PA15 TIM2_CH1 TIM2 PWM(1) GPIO(58) define AP_PERIPH_RC_OUT_ENABLED 1 define AP_PERIPH_NOTIFY_ENABLED 1 # built-in LED plus NeoPixel define DEFAULT_NTF_LED_TYPES 257