![]() |
ACwing Flow bridge firmware
STM32C011: PMW3901 optical flow over SPI, I2C target 0x3B
|
ACwing Flow rev A bridge firmware (STM32C011F4U6). More...
Go to the source code of this file.
Macros | |
| #define | SYSCLK_HZ 48000000u |
| #define | LOOP_MS 10u |
| #define | REINIT_MS 1000u |
Functions | |
| void | SysTick_Handler (void) |
| static void | iwdg_feed (void) |
| static void | clock_init (void) |
| static void | gpio_mode (GPIO_TypeDef *g, uint32_t pin, uint32_t mode, uint32_t af) |
| static void | board_init (void) |
| static void | iwdg_start (void) |
| void | I2C1_IRQHandler (void) |
| static void | delay_us (uint32_t us) |
| static uint8_t | spi_xfer (uint8_t b) |
| static void | pin_cs (uint8_t l) |
| static void | pin_reset (uint8_t l) |
| static void | led (uint8_t on) |
| int | main (void) |
Variables | |
| static volatile uint32_t | s_ms |
| static const pmw_bus_t | k_bus = { spi_xfer, pin_cs, pin_reset, delay_us } |
ACwing Flow rev A bridge firmware (STM32C011F4U6).
PMW3901 –SPI1 (mode 3, 1.5 MHz)--> STM32C011 –I2C1 target 0x3B--> Qwiic --> ACwing FC
Pins (ACwing_Flow_A schematic, checked against ST open pin data): PA0 TOF_XSHUT left in its reset state (analog, high impedance): the 10 k pull-up keeps the VL53L1X running. Never drive it low. PA1 TOF_INT not used (the FC polls the ToF), high impedance PA2 PMW_NRESET output, high = running PA3 PMW_MOTION not used (motion burst polled at 100 Hz) PA4 PMW_NCS output, high = deselected PA5/6/7 SPI1 SCK / MISO / MOSI (AF0) PA8 LED_K output, low = LED on PA13/PA14 SWD (untouched) PB6/PB7 I2C1 SCL / SDA (AF6, open drain, pull-ups on the FC)
Main loop: every 10 ms a motion burst; the deltas of good samples are added to the accumulators with the time they cover (bridge.c). The I2C interrupt serves the register map and latches a frame when the FC reads from 0x02. The independent watchdog (~0.5 s) is fed by the main loop only.
LED: on = sensor OK and the FC reading frames; slow blink (1 Hz) = sensor OK, no reads from the FC; fast blink (5 Hz) = PMW3901 not found (retried every second); short flash every 2 s = sensor OK but no surface features.
Definition in file main.c.
|
static |
Definition at line 42 of file main.c.
Referenced by delay_us(), iwdg_start(), and main().
|
static |
|
static |
Definition at line 54 of file main.c.
Referenced by board_init().
|
static |
Definition at line 62 of file main.c.
References FLOW_I2C_ADDR, gpio_mode(), and SYSCLK_HZ.
Referenced by main().
|
static |
Definition at line 109 of file main.c.
References iwdg_feed().
Referenced by main().
| void I2C1_IRQHandler | ( | void | ) |
Definition at line 121 of file main.c.
References bridge_i2c_addr_read(), bridge_i2c_addr_write(), bridge_i2c_rx(), bridge_i2c_stop(), and bridge_i2c_tx().
|
static |
Definition at line 146 of file main.c.
References iwdg_feed().
|
static |
| int main | ( | void | ) |
Definition at line 172 of file main.c.
References board_init(), bridge_add_sample(), bridge_init(), bridge_reads(), bridge_set_sensor_ok(), bridge_take_ctrl(), clock_init(), pmw_burst_t::dx, pmw_burst_t::dy, FLOW_CTRL_REINIT, FLOW_CTRL_RESET, iwdg_feed(), iwdg_start(), k_bus, led(), LOOP_MS, pmw_burst(), pmw_init(), pmw_valid(), REINIT_MS, s_ms, pmw_burst_t::shutter, and pmw_burst_t::squal.
|
static |
Definition at line 37 of file main.c.
Referenced by main(), and SysTick_Handler().