-
Notifications
You must be signed in to change notification settings - Fork 0
/
i2c.h
47 lines (39 loc) · 965 Bytes
/
i2c.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
#ifndef _I2C_H_
#define _I2C_H_
#include <pico/i2c_slave.h>
#define I2C_IF i2c0
#define I2C_BAUDRATE 100000 // 100 kHz
typedef enum
{
I2C_COMMAND_SET_RTC,
I2C_COMMAND_READ_RTC,
I2C_COMMAND_READ_WIND_SPEED,
I2C_COMMAND_READ_WIND_DIRECTION,
I2C_COMMAND_READ_RAIN_RATE,
I2C_COMMAND_READ_RAIN_DAILY
} i2c_command_t;
typedef enum
{
I2C_STATE_IDLE,
I2C_STATE_SET_RTC,
I2C_STATE_READ_RTC_CMD,
I2C_STATE_READ_RTC,
I2C_STATE_READ_WIND_SPEED_CMD,
I2C_STATE_READ_WIND_SPEED,
I2C_STATE_READ_WIND_DIRECTION_CMD,
I2C_STATE_READ_WIND_DIRECTION,
I2C_STATE_READ_RAIN_RATE_CMD,
I2C_STATE_READ_RAIN_RATE,
I2C_STATE_READ_RAIN_DAILY_CMD,
I2C_STATE_READ_RAIN_DAILY
} i2c_state_machine_t;
#ifdef __cplusplus
extern "C"
{
#endif
extern void start_i2c_slave(const uint address, const uint sda_pin, const uint scl_pin);
extern void setup_i2c_slave(const uint address, const uint sda_pin, const uint scl_pin);
#ifdef __cplusplus
}
#endif
#endif