-
Notifications
You must be signed in to change notification settings - Fork 0
/
i2c_esp32_static.h
52 lines (43 loc) · 1.45 KB
/
i2c_esp32_static.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef _STATIC_ESP_I2C_H_
#define _STATIC_ESP_I2C_H_
#include "driver/i2c.h"
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef union {
struct {
uint32_t byte_num: 8,
ack_en: 1,
ack_exp: 1,
ack_val: 1,
op_code: 3,
reserved14: 17,
done: 1;
};
uint32_t val;
} i2c_hw_cmd_t;
typedef struct {
i2c_hw_cmd_t hw_cmd;
uint8_t *data;
uint8_t byte_cmd;
} i2c_cmd_t;
typedef struct i2c_cmd_link {
i2c_cmd_t cmd;
struct i2c_cmd_link *next;
} i2c_cmd_link_t;
typedef struct {
i2c_cmd_link_t *head;
i2c_cmd_link_t *cur;
i2c_cmd_link_t *free;
} i2c_cmd_desc_t;
void static_i2c_master_start(i2c_cmd_handle_t cmd_handle, i2c_cmd_link_t* lnk);
void static_i2c_master_read_byte(i2c_cmd_handle_t cmd_handle, i2c_cmd_link_t* lnk, uint8_t* data, i2c_ack_type_t ack);
void static_i2c_master_read(i2c_cmd_handle_t cmd_handle, i2c_cmd_link_t* lnk, uint8_t* data, size_t data_len, i2c_ack_type_t ack);
void static_i2c_master_write_byte(i2c_cmd_handle_t cmd_handle, i2c_cmd_link_t* lnk, uint8_t data, bool ack_en);
void static_i2c_master_write(i2c_cmd_handle_t cmd_handle, i2c_cmd_link_t* lnk, uint8_t* data, size_t data_len, bool ack_en);
void static_i2c_master_stop(i2c_cmd_handle_t cmd_handle, i2c_cmd_link_t* lnk);
#ifdef __cplusplus
}
#endif
#endif