LED Blinker Circuit Design


Yes — that makes sense, and it will help the board fit.
Instead of building telemetry radios onto the PCB, we can make the board provide two telemetry connector ports for redundancy:
  • Telemetry Port 1
  • Telemetry Port 2
Each port can expose:
  • 3.3V or 5V power
  • GND
  • UART TX
  • UART RX
  • Optional enable/reset
  • Optional SPI pins if you want LoRa modules that use SPI instead of UART
That means I should remove the onboard telemetry modules and SMA antenna connectors, then replace them with two compact external telemetry headers. This will reduce board area a lot because the placement issue is driven mostly by the bulky modules/connectors, not by component count. The connector-replacement workflow requires preserving the old nets, replacing the parts, then rewiring the new connector pins to the same functions so the design stays electrically valid . For placement, the board should then be re-placed after resizing because the placement tool works inside the current board outline and cannot resize the board itself .
Recommended next move:
  1. Remove onboard telemetry radio modules and SMA antenna connectors.
  2. Add two compact telemetry connectors.
  3. Wire both connectors to the MCU for redundant telemetry.
  4. Re-place on the 70 × 100 mm board.
  5. Route after placement is clean.
Ready when you are.
yes
Thought for 14 sec
Thought for a moment
Add two compact telemetry connectors for UART redundancy.
I added the two compact external UART telemetry connectors and removed the onboard telemetry radios/antenna connectors. The schematic ERC is clean, the board is still 70 × 100 mm, includes the corner mounting holes and ZEN, and the placement now fits/routs cleanly enough to start routing.
Routing was started, but the job paused because the account ran out of credits. Remaining work: add credits, rerun routing, then review/fix any remaining airwires or layout issues.
Check layout issues
Rerun router help
Review connector pinout
Export current BOM

Firmware Starter — STM32F405RGT6 TVC Rocket Flight Controller
Status
Created from the live schematic after ERC cleanup. This is a bring-up starter for the functional-equivalent schematic, not flight-qualified firmware. Do not fly until the control laws, pyro arming logic, watchdog policy, sensor calibration, and failsafe behavior are fully implemented and tested.
Platform & Toolchain
  • MCU: STM32F405RGT6
  • Framework: STM32 HAL
  • Recommended IDE: STM32CubeIDE or PlatformIO with STM32Cube HAL
  • Main clocks: external HSE on PH0/PH1 and LSE 32.768 kHz on PC14/PC15
  • Debug: SWD on PA13/PA14, SWO on PB3
MCU Pin Mapping

Table


FunctionMCU PinNet / PeripheralDirectionNotes
VBAT / power monitor senseVBAT3V3 / INA226 VS domainPowerVBAT tied to logic rail in this revision
Status LEDPC13LED_STATUS_DRVOutputActive level depends on LED orientation
LSE inputPC14LSE_INAnalog clock32.768 kHz crystal
LSE outputPC15LSE_OUTAnalog clock32.768 kHz crystal
HSE inputPH0HSE_INAnalog clock8 MHz resonator/crystal input
HSE outputPH1HSE_OUTAnalog clock8 MHz resonator/crystal output
ResetNRSTMCU_NRSTInputSWD and TPS3430 watchdog reset output share this net
LoRa1 TX enablePC0LORA1_TXENOutputPrimary telemetry module enable/control
LoRa1 RX enablePC1LORA1_RXENOutputPrimary telemetry module enable/control
Watchdog inputPC2WATCHDOG_WDIOutputToggle periodically after system health checks
Radio resetPC3RADIO_RESETOutputShared reset for LoRa modules
LoRa1 DIO2PC4LORA1_DIO2InputInterrupt-capable telemetry signal
LoRa2 DIO0PC5LORA2_DIO0InputBackup RFM96 interrupt
LoRa2 DIO1PC6LORA2_DIO1InputBackup RFM96 interrupt
LoRa2 DIO2PC7LORA2_DIO2InputBackup RFM96 interrupt
SD DAT0PC8SD_DAT0SDIOmicroSD data 0
SD DAT1PC9SD_DAT1SDIOmicroSD data 1
SD DAT2PC10SD_DAT2SDIOmicroSD data 2
SD DAT3/CDPC11SD_DAT3SDIOmicroSD data 3/card-detect per socket wiring
SD CLKPC12SD_CLKSDIO clockmicroSD clock
GPS RX to MCUPA1GPS_TX_TO_MCU_RXUART RXNEO-M8N TXD into MCU
MCU TX to GPSPA0MCU_TX_TO_GPS_RXUART TXNEO-M8N RXD from MCU
LoRa1 DIO0PA2LORA1_DIO0InputPrimary LoRa IRQ
LoRa1 DIO1PA3LORA1_DIO1InputPrimary LoRa IRQ
LoRa1 NSSPA4SPI1_NSS_LORA1OutputPrimary LoRa chip select
SPI1 SCKPA5SPI1_SCKSPI clockShared telemetry SPI clock
SPI1 MISOPA6SPI1_MISOSPI inputShared telemetry MISO
SPI1 MOSIPA7SPI1_MOSISPI outputShared telemetry MOSI
Servo 1 PWMPA8SERVO1_PWMTimer PWMPitch servo
Servo 2 PWMPA9SERVO2_PWMTimer PWMYaw servo
Servo 3 PWMPA10SERVO3_PWMTimer PWMAux servo
USB D-PA11USB_D-USB FSControlled-impedance layout required
USB D+PA12USB_D+USB FSControlled-impedance layout required
SWDIOPA13SWDIODebugSWD programming/debug
SWCLKPA14SWCLKDebugSWD programming/debug
Servo 4 PWMPA15SERVO4_PWMTimer PWMAux servo
IMU1 INT1PB0IMU1_INT1InputPrimary IIM-42652 interrupt
IMU1 INT2PB1IMU1_INT2InputPrimary IIM-42652 interrupt
Fault LEDPB2LED_FAULT_DRVOutputFault/status indication
SWOPB3SWODebugTrace output
GPS PPSPB4GPS_PPSInputNEO-M8N timepulse
I2C expansion INTPB5I2C_EXP_INTInputExternal I2C connector interrupt/GPIO
I2C1 SCLPB6I2C1_SCLI2C clockINA226, IMUs, MS5611s, expansion connector
I2C1 SDAPB7I2C1_SDAI2C dataINA226, IMUs, MS5611s, expansion connector
Pyro 1 drivePB8PYRO1_DRVOutputMust be software-armed; never default high
Pyro 2 drivePB9PYRO2_DRVOutputMust be software-armed; never default high
IMU2 INT1PB10IMU2_INT1InputBackup IIM-42652 interrupt
IMU2 INT2PB11IMU2_INT2InputBackup IIM-42652 interrupt
LoRa2 NSSPB12SPI1_NSS_LORA2OutputBackup RFM96 chip select
UnusedPB13NCNo connectReserved for future SPI2/I/O
UnusedPB14NCNo connectReserved for future SPI2/I/O
UnusedPB15NCNo connectReserved for future SPI2/I/O
SD CMDPD2SD_CMDSDIO commandmicroSD command
BOOT0BOOT0BOOT0Strap inputPulled low for normal boot
Bring-Up Order
  1. Keep pyro GPIOs as inputs with pulldowns until arming logic is proven.
  2. Initialize clocks from HSE and LSE.
  3. Initialize GPIO defaults: chip selects high, resets inactive, LEDs off, servos disabled.
  4. Initialize I2C1 and verify INA226, two IIM-42652 IMUs, and two MS5611 barometers respond.
  5. Initialize SPI1 and verify both LoRa modules independently using separate NSS pins.
  6. Initialize GPS UART and verify NMEA/UBX data plus PPS edge capture.
  7. Initialize SDIO and mount the SD card.
  8. Start watchdog service only after health checks pass.
  9. Enable servo PWM and pyro outputs only through explicit arming state machine.
Minimal STM32 HAL Starter Code

C


#include "stm32f4xx_hal.h"
#include <string.h>
#include <stdbool.h>

I2C_HandleTypeDef hi2c1;
SPI_HandleTypeDef hspi1;
UART_HandleTypeDef huart2;
SD_HandleTypeDef hsd;
TIM_HandleTypeDef htim1;

#define PIN_LED_STATUS      GPIO_PIN_13
#define PORT_LED_STATUS     GPIOC
#define PIN_LED_FAULT       GPIO_PIN_2
#define PORT_LED_FAULT      GPIOB
#define PIN_WATCHDOG_WDI    GPIO_PIN_2
#define PORT_WATCHDOG_WDI   GPIOC
#define PIN_RADIO_RESET     GPIO_PIN_3
#define PORT_RADIO_RESET    GPIOC
#define PIN_LORA1_NSS       GPIO_PIN_4
#define PORT_LORA1_NSS      GPIOA
#define PIN_LORA2_NSS       GPIO_PIN_12
#define PORT_LORA2_NSS      GPIOB
#define PIN_LORA1_TXEN      GPIO_PIN_0
#define PORT_LORA1_TXEN     GPIOC
#define PIN_LORA1_RXEN      GPIO_PIN_1
#define PORT_LORA1_RXEN     GPIOC
#define PIN_PYRO1           GPIO_PIN_8
#define PORT_PYRO1          GPIOB
#define PIN_PYRO2           GPIO_PIN_9
#define PORT_PYRO2          GPIOB

#define INA226_ADDR_GND_GND     (0x40 << 1)
#define IIM42652_ADDR_LOW       (0x68 << 1)
#define IIM42652_ADDR_HIGH      (0x69 << 1)
#define MS5611_ADDR_LOW         (0x76 << 1)
#define MS5611_ADDR_HIGH        (0x77 << 1)
#define IIM42652_WHO_AM_I       0x75
#define SX127X_REG_VERSION      0x42

static void Error_Handler(void) {
    HAL_GPIO_WritePin(PORT_LED_FAULT, PIN_LED_FAULT, GPIO_PIN_SET);
    while (1) { }
}

static void SystemClock_Config(void) {
    /* Generate this in STM32CubeMX for STM32F405RGT6 using HSE and LSE.
       Target typical F405 system clock: 168 MHz, USB clock: 48 MHz. */
}

static void MX_GPIO_Init(void) {
    __HAL_RCC_GPIOA_CLK_ENABLE();
    __HAL_RCC_GPIOB_CLK_ENABLE();
    __HAL_RCC_GPIOC_CLK_ENABLE();

    GPIO_InitTypeDef g = {0};

    HAL_GPIO_WritePin(PORT_PYRO1, PIN_PYRO1, GPIO_PIN_RESET);
    HAL_GPIO_WritePin(PORT_PYRO2, PIN_PYRO2, GPIO_PIN_RESET);
    HAL_GPIO_WritePin(PORT_LORA1_NSS, PIN_LORA1_NSS, GPIO_PIN_SET);
    HAL_GPIO_WritePin(PORT_LORA2_NSS, PIN_LORA2_NSS, GPIO_PIN_SET);
    HAL_GPIO_WritePin(PORT_RADIO_RESET, PIN_RADIO_RESET, GPIO_PIN_SET);

    g.Mode = GPIO_MODE_OUTPUT_PP;
    g.Pull = GPIO_NOPULL;
    g.Speed = GPIO_SPEED_FREQ_LOW;

    g.Pin = PIN_LED_STATUS;
    HAL_GPIO_Init(PORT_LED_STATUS, &g);

    g.Pin = PIN_LED_FAULT | PIN_WATCHDOG_WDI | PIN_RADIO_RESET | PIN_LORA1_TXEN | PIN_LORA1_RXEN;
    HAL_GPIO_Init(GPIOC, &g);

    g.Pin = PIN_LORA1_NSS;
    HAL_GPIO_Init(PORT_LORA1_NSS, &g);

    g.Pin = PIN_LORA2_NSS | PIN_PYRO1 | PIN_PYRO2;
    HAL_GPIO_Init(GPIOB, &g);

    g.Mode = GPIO_MODE_INPUT;
    g.Pull = GPIO_NOPULL;
    g.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_10 | GPIO_PIN_11;
    HAL_GPIO_Init(GPIOB, &g); /* IMU interrupts */

    g.Pin = GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7;
    HAL_GPIO_Init(GPIOC, &g); /* LoRa2 DIO0..2 */

    g.Pin = GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4;
    HAL_GPIO_Init(GPIOA, &g); /* LoRa1 DIO0..1 and GPS PPS if remapped by CubeMX */
}

static void MX_I2C1_Init(void) {
    hi2c1.Instance = I2C1;
    hi2c1.Init.ClockSpeed = 400000;
    hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
    hi2c1.Init.OwnAddress1 = 0;
    hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
    hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
    hi2c1.Init.OwnAddress2 = 0;
    hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
    hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
    if (HAL_I2C_Init(&hi2c1) != HAL_OK) Error_Handler();
}

static void MX_SPI1_Init(void) {
    hspi1.Instance = SPI1;
    hspi1.Init.Mode = SPI_MODE_MASTER;
    hspi1.Init.Direction = SPI_DIRECTION_2LINES;
    hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
    hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
    hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
    hspi1.Init.NSS = SPI_NSS_SOFT;
    hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;
    hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
    hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
    hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
    if (HAL_SPI_Init(&hspi1) != HAL_OK) Error_Handler();
}

static void MX_UART_GPS_Init(void) {
    huart2.Instance = USART2; /* Adjust in CubeMX if GPS UART is assigned differently. */
    huart2.Init.BaudRate = 9600;
    huart2.Init.WordLength = UART_WORDLENGTH_8B;
    huart2.Init.StopBits = UART_STOPBITS_1;
    huart2.Init.Parity = UART_PARITY_NONE;
    huart2.Init.Mode = UART_MODE_TX_RX;
    huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
    huart2.Init.OverSampling = UART_OVERSAMPLING_16;
    if (HAL_UART_Init(&huart2) != HAL_OK) Error_Handler();
}

static HAL_StatusTypeDef i2c_read_u8(uint16_t addr, uint8_t reg, uint8_t *value) {
    return HAL_I2C_Mem_Read(&hi2c1, addr, reg, I2C_MEMADD_SIZE_8BIT, value, 1, 100);
}

static HAL_StatusTypeDef i2c_write_u8(uint16_t addr, uint8_t reg, uint8_t value) {
    return HAL_I2C_Mem_Write(&hi2c1, addr, reg, I2C_MEMADD_SIZE_8BIT, &value, 1, 100);
}

static uint8_t sx127x_read(GPIO_TypeDef *cs_port, uint16_t cs_pin, uint8_t reg) {
    uint8_t tx[2] = { (uint8_t)(reg & 0x7F), 0x00 };
    uint8_t rx[2] = {0};
    HAL_GPIO_WritePin(cs_port, cs_pin, GPIO_PIN_RESET);
    HAL_SPI_TransmitReceive(&hspi1, tx, rx, 2, 100);
    HAL_GPIO_WritePin(cs_port, cs_pin, GPIO_PIN_SET);
    return rx[1];
}

static void radio_reset_pulse(void) {
    HAL_GPIO_WritePin(PORT_RADIO_RESET, PIN_RADIO_RESET, GPIO_PIN_RESET);
    HAL_Delay(5);
    HAL_GPIO_WritePin(PORT_RADIO_RESET, PIN_RADIO_RESET, GPIO_PIN_SET);
    HAL_Delay(10);
}

static bool sensors_present(void) {
    uint8_t who = 0;
    bool ok = true;
    ok &= (HAL_I2C_IsDeviceReady(&hi2c1, INA226_ADDR_GND_GND, 2, 100) == HAL_OK);
    ok &= (i2c_read_u8(IIM42652_ADDR_LOW, IIM42652_WHO_AM_I, &who) == HAL_OK);
    ok &= (i2c_read_u8(IIM42652_ADDR_HIGH, IIM42652_WHO_AM_I, &who) == HAL_OK);
    ok &= (HAL_I2C_IsDeviceReady(&hi2c1, MS5611_ADDR_LOW, 2, 100) == HAL_OK ||
           HAL_I2C_IsDeviceReady(&hi2c1, MS5611_ADDR_HIGH, 2, 100) == HAL_OK);
    return ok;
}

static void watchdog_feed_if_healthy(bool healthy) {
    if (!healthy) return;
    HAL_GPIO_TogglePin(PORT_WATCHDOG_WDI, PIN_WATCHDOG_WDI);
}

static void pyro_safe_defaults(void) {
    HAL_GPIO_WritePin(PORT_PYRO1, PIN_PYRO1, GPIO_PIN_RESET);
    HAL_GPIO_WritePin(PORT_PYRO2, PIN_PYRO2, GPIO_PIN_RESET);
}

int main(void) {
    HAL_Init();
    SystemClock_Config();
    MX_GPIO_Init();
    pyro_safe_defaults();
    MX_I2C1_Init();
    MX_SPI1_Init();
    MX_UART_GPS_Init();

    radio_reset_pulse();
    uint8_t lora1_ver = sx127x_read(PORT_LORA1_NSS, PIN_LORA1_NSS, SX127X_REG_VERSION);
    uint8_t lora2_ver = sx127x_read(PORT_LORA2_NSS, PIN_LORA2_NSS, SX127X_REG_VERSION);
    (void)lora1_ver;
    (void)lora2_ver;

    while (1) {
        bool healthy = sensors_present();
        HAL_GPIO_WritePin(PORT_LED_STATUS, PIN_LED_STATUS, healthy ? GPIO_PIN_SET : GPIO_PIN_RESET);
        watchdog_feed_if_healthy(healthy);
        HAL_Delay(250);
    }
}
Build Notes
  • Use CubeMX to generate the exact alternate-function GPIO initialization for I2C1, SPI1, SDIO, USB FS, timers, and GPS UART.
  • Keep pyro pins forced low until the arming state machine is implemented and tested.
  • RFM96W/RC-SM1276 LoRa register initialization is not complete here; this file only includes SPI presence checks.
  • MP1584 COMP/FREQ values were added to clear regulator support pins, but the compensation values must be finalized against the MP1584 datasheet before fabrication.
Next Firmware Tasks
  1. Generate CubeMX project for STM32F405RGT6 with the mapped pins.
  2. Add IIM-42652 register initialization and calibration.
  3. Add MS5611 PROM read and pressure/temperature conversion flow.
  4. Add INA226 calibration based on the 0.01 ohm shunt.
  5. Add LoRa packet protocol and dual-radio failover.
  6. Add SD logging with brownout-safe file handling.
  7. Add full TVC control loop, arming logic, watchdog policy, and hardware-in-the-loop tests.
  • Status

  • Platform & Toolchain

  • MCU Pin Mapping

  • Bring-Up Order

  • Minimal STM32 HAL Starter Code

  • Build Notes

  • Next Firmware Tasks