DevLab_ICM20948 1.0.0
Driver para sensor ICM-20948
Loading...
Searching...
No Matches
ICM20948_platform.h
Go to the documentation of this file.
1#ifndef ICM20948_PLATFORM_H
2#define ICM20948_PLATFORM_H
3
4// #include <stdint.h>
5// #include <stddef.h>
6
7/**
8 * 7Semi comment style
9 * - Platform glue for bus IO, delays, and timing
10 * - Implement these for your system (I2C or SPI)
11 */
12
13typedef struct {
14 /**
15 * - Bus read: read `len` bytes from `reg` into `buf`
16 * - Return 0 on success, nonzero on error
17 */
18 int (*read)(uint8_t reg, uint8_t *buf, size_t len, void *user);
19 /**
20 * - Bus write: write `len` bytes from `buf` to `reg`
21 * - Return 0 on success, nonzero on error
22 */
23 int (*write)(uint8_t reg, const uint8_t *buf, size_t len, void *user);
24 /**
25 * - Optional: SPI transfers may need register R/W bit mangling
26 * - For I2C, leave as NULL
27 */
28 uint8_t (*spi_reg_rw_bits)(uint8_t reg, int is_write);
29 /**
30 * - Millisecond delay
31 */
32 void (*delay_ms)(uint32_t ms);
33 /**
34 * - User context pointer passed to read/write
35 */
36 void *user;
37 /**
38 * - If using SPI: set chip select active (1) or inactive (0)
39 * - For I2C: leave as NULL
40 */
41 void (*spi_cs)(int level, void *user);
42 /**
43 * - Device address (I2C) or ignored for SPI if you wrap inside user
44 */
45 uint8_t i2c_addr;
47
48#endif
void(* delay_ms)(uint32_t ms)
void(* spi_cs)(int level, void *user)
int(* read)(uint8_t reg, uint8_t *buf, size_t len, void *user)
int(* write)(uint8_t reg, const uint8_t *buf, size_t len, void *user)
uint8_t(* spi_reg_rw_bits)(uint8_t reg, int is_write)