ACwing Flow bridge firmware
STM32C011: PMW3901 optical flow over SPI, I2C target 0x3B
Loading...
Searching...
No Matches
bridge.h File Reference

Register file of the flow bridge and the I2C target protocol. More...

#include <stdint.h>
Include dependency graph for bridge.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void bridge_init (void)
 
void bridge_set_sensor_ok (uint8_t ok)
 
void bridge_add_sample (int16_t dx, int16_t dy, uint8_t squal, uint16_t shutter, uint8_t valid, uint32_t dt_us)
 one motion burst: deltas since the previous burst, dt_us = time between the two bursts; valid = 0 for a sample without surface features
 
void bridge_i2c_addr_write (void)
 address matched, master writes
 
void bridge_i2c_rx (uint8_t b)
 first byte = register pointer
 
void bridge_i2c_addr_read (void)
 address matched, master reads: snapshot
 
uint8_t bridge_i2c_tx (void)
 next byte to send
 
void bridge_i2c_stop (void)
 
uint8_t bridge_take_ctrl (void)
 CTRL bits written by the master, cleared.
 
uint8_t bridge_reads (void)
 FRAME reads since boot (LED activity), wraps.
 

Detailed Description

Register file of the flow bridge and the I2C target protocol.

Pure C (no registers): the main loop adds PMW3901 samples, the I2C interrupt calls the bridge_i2c_* functions. The two sides share the accumulators: bridge_add_sample() must run with the I2C interrupt masked (the main loop wraps it in a short critical section).

Definition in file bridge.h.

Function Documentation

◆ bridge_init()

void bridge_init ( void  )

Definition at line 19 of file bridge.c.

References s_count, s_ctrl, s_dt_us, s_dx, s_dy, s_first, s_ptr, s_rd, s_reads, s_shutter, s_squal, s_status, and s_wr.

Referenced by main().

Here is the caller graph for this function:

◆ bridge_set_sensor_ok()

void bridge_set_sensor_ok ( uint8_t  ok)

Definition at line 26 of file bridge.c.

References FLOW_S_SENSOR_OK, and s_status.

Referenced by main().

Here is the caller graph for this function:

◆ bridge_add_sample()

void bridge_add_sample ( int16_t  dx,
int16_t  dy,
uint8_t  squal,
uint16_t  shutter,
uint8_t  valid,
uint32_t  dt_us 
)

one motion burst: deltas since the previous burst, dt_us = time between the two bursts; valid = 0 for a sample without surface features

Definition at line 32 of file bridge.c.

References FLOW_S_NEW, FLOW_S_REJECTED, s_count, s_dt_us, s_dx, s_dy, s_shutter, s_squal, and s_status.

Referenced by main().

Here is the caller graph for this function:

◆ bridge_i2c_addr_write()

void bridge_i2c_addr_write ( void  )

address matched, master writes

Definition at line 82 of file bridge.c.

References s_first, and s_wr.

Referenced by I2C1_IRQHandler().

Here is the caller graph for this function:

◆ bridge_i2c_rx()

void bridge_i2c_rx ( uint8_t  b)

first byte = register pointer

Definition at line 84 of file bridge.c.

References FLOW_R_CTRL, s_ctrl, s_first, s_ptr, and s_wr.

Referenced by I2C1_IRQHandler().

Here is the caller graph for this function:

◆ bridge_i2c_addr_read()

void bridge_i2c_addr_read ( void  )

address matched, master reads: snapshot

Definition at line 92 of file bridge.c.

References FLOW_R_FRAME, s_ptr, s_rd, and snapshot().

Referenced by I2C1_IRQHandler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bridge_i2c_tx()

uint8_t bridge_i2c_tx ( void  )

next byte to send

Definition at line 98 of file bridge.c.

References FLOW_REG_SPACE, s_img, and s_rd.

Referenced by I2C1_IRQHandler().

Here is the caller graph for this function:

◆ bridge_i2c_stop()

void bridge_i2c_stop ( void  )

Definition at line 105 of file bridge.c.

References s_first.

Referenced by I2C1_IRQHandler().

Here is the caller graph for this function:

◆ bridge_take_ctrl()

uint8_t bridge_take_ctrl ( void  )

CTRL bits written by the master, cleared.

Definition at line 107 of file bridge.c.

References s_ctrl.

Referenced by main().

Here is the caller graph for this function:

◆ bridge_reads()

uint8_t bridge_reads ( void  )

FRAME reads since boot (LED activity), wraps.

Definition at line 114 of file bridge.c.

References s_reads.

Referenced by main().

Here is the caller graph for this function: