TMF8829 Universal Driver 0.1.0
Loading...
Searching...
No Matches
tmf8829_ops.h File Reference

Platform callback table (tmf8829_ops_t) for bus, time, and GPIO. More...

#include "tmf8829_types.h"
Include dependency graph for tmf8829_ops.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  tmf8829_ops
 Set of platform callbacks required by tmf8829_init. More...

Typedefs

typedef int(* tmf8829_read_fn) (tmf8829_driver_t *drv, uint8_t reg, uint8_t *buf, uint16_t len)
 Read len bytes from register reg into buf.
typedef int(* tmf8829_write_fn) (tmf8829_driver_t *drv, uint8_t reg, const uint8_t *buf, uint16_t len)
 Write len bytes from buf starting at register reg.
typedef void(* tmf8829_delay_us_fn) (uint32_t us)
 Busy-wait for at least us microseconds (resolution is host-defined).
typedef uint32_t(* tmf8829_systick_us_fn) (void)
 Free-running microsecond tick (32-bit wrap allowed; only differences are used).
typedef void(* tmf8829_write_pin_enable_fn) (tmf8829_driver_t *drv, int high)
 Drive the sensor enable pin: low if high is zero, else high.
typedef int(* tmf8829_read_pin_int_fn) (tmf8829_driver_t *drv)
 Optional: read the IRQ GPIO level for this instance.

Detailed Description

Platform callback table (tmf8829_ops_t) for bus, time, and GPIO.

One table is typically static const and shared by all tmf8829_driver_t instances on the same board.

Typedef Documentation

◆ tmf8829_delay_us_fn

typedef void(* tmf8829_delay_us_fn) (uint32_t us)

Busy-wait for at least us microseconds (resolution is host-defined).

◆ tmf8829_read_fn

typedef int(* tmf8829_read_fn) (tmf8829_driver_t *drv, uint8_t reg, uint8_t *buf, uint16_t len)

Read len bytes from register reg into buf.

Implementations map drv->bus, drv->i2c_addr, and drv->user_ctx to the underlying transfer (e.g. I2C memory read at sub-address reg).

Note
For SPI, the TMF8829 protocol returns one stuff/dummy byte after the read command and register address. This library expects buf to contain only the requested payload bytes, so platform tmf8829_read_fn implementations must consume/discard that first byte. If the platform does not strip it, all register reads will be shifted by one byte (garbage data). Refer to datasheet section 7.11.2 "SPI read transaction" for more details.
Parameters
[in]regFirst register address on the device.
[out]bufDestination buffer.
[in]lenBytes to read.
Returns
0 on success, negative on failure.

◆ tmf8829_read_pin_int_fn

typedef int(* tmf8829_read_pin_int_fn) (tmf8829_driver_t *drv)

Optional: read the IRQ GPIO level for this instance.

May be NULL if the host polls TMF8829_REG_INT_STATUS only.

Returns
1 if the interrupt line is asserted, 0 if deasserted, negative on error.

◆ tmf8829_systick_us_fn

typedef uint32_t(* tmf8829_systick_us_fn) (void)

Free-running microsecond tick (32-bit wrap allowed; only differences are used).

◆ tmf8829_write_fn

typedef int(* tmf8829_write_fn) (tmf8829_driver_t *drv, uint8_t reg, const uint8_t *buf, uint16_t len)

Write len bytes from buf starting at register reg.

Returns
0 on success, negative on failure.

◆ tmf8829_write_pin_enable_fn

typedef void(* tmf8829_write_pin_enable_fn) (tmf8829_driver_t *drv, int high)

Drive the sensor enable pin: low if high is zero, else high.

Pin mux / mode must be configured before tmf8829_init.

May be NULL if the enable pin is permanently tied high in hardware (not controllable via GPIO). When NULL, tmf8829_enable skips the power-on toggle and only polls for CPU readiness, and tmf8829_disable becomes a no-op returning TMF8829_E_NOT_IMPLEMENTED.