How robotpatient/manikin_sensor_node works
Project Type and Purpose
• This is an embedded-firmware project for the “Manikin Sensor Node,” running on an STM32F4 series MCU.
• It implements sensor sampling, storage (flash), communication over USB-CDC and CAN bus, and a command-line interface (CLI), all built on top of the ST HAL and FreeRTOS hooks.
High-Level Architectural Layers
• Hardware Layer
• STM32F405 microcontroller block
• On-chip peripherals: GPIO, I2C, SPI, timers, watchdog, USB FS, CAN, internal flash memory
• HAL / BSP Layer
• stm32f4xx_hal_conf.h, board_conf.h, usbd_conf.h
• manikin_software_hooks/hal_drivers providing platform-specific wrappers for I2C, SPI, timer, watchdog, error functions
• RTOS / System Hooks
• FreeRTOS integration: freertos_hooks.c
• interrupt handlers, syscalls, HAL MSP (msp.c), error handling hooks
• Middleware / Drivers
• CAN driver: can_wrapper.{c,h}
• USB CDC: usb_device.c, usbd_*.c
• Flash driver: flash.{c,h}
• CLI: cli.{c,h}, cli_setup.{c,h}
• Application Layer
• Sampling logic: sampling.c/h
• Main initialization & scheduler startup: main.cpp
• Configuration headers under config/
Components & Interactions
• MCU Hardware ⇄ HAL/BSP
• HAL config headers select which peripherals are enabled/configured
• HAL MSP routines handle low-level Init/DeInit
• HAL/BSP ⇄ Drivers
• Drivers call HAL API for peripheral operations
• manikin_software_hooks supply target-specific implementations
• Drivers ⇄ Application
• Sampling task triggers peripheral reads via I2C/SPI drivers
• CLI task sends and receives commands through USB/CAN wrappers
• Flash driver is used by sampling or CLI for non-volatile storage
• RTOS Scheduler
• Manages tasks: Sampling, CLI, USB/CAN handlers, flash tasks
• External Interfaces
• USB CDC to host PC for data logging / CLI
• CAN bus to manikin control network
Architectural Patterns
• Layered approach (hardware abstraction, middleware, application)
• Modular drivers each responsible for a single peripheral or protocol
• FreeRTOS hooks for portability and OS integration
• Separation of concerns: config vs. code, HAL vs. wrappers vs. application logic