snickerdoodle Platform Controller
firmware for STM32F0 platform controller
sd_i2c.h
Go to the documentation of this file.
1 
46 #ifndef __SD_I2C_H
47 #define __SD_I2C_H
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
61 #define SD_I2C_SWITCH_ADDR 0xE0
63 #define SD_I2C_CHANNEL_NONE 0x00
64 #define SD_I2C_CHANNEL_0 0x01
65 #define SD_I2C_CHANNEL_1 0x02
66 #define SD_I2C_CHANNEL_2 0x04
67 #define SD_I2C_CHANNEL_3 0x08
68 #define SD_I2C_CHANNEL_4 0x10
69 #define SD_I2C_CHANNEL_5 0x20
70 #define SD_I2C_CHANNEL_6 0x40
71 #define SD_I2C_CHANNEL_7 0x80
73 #define SD_I2C_JA1 SD_I2C_CHANNEL_0
74 #define SD_I2C_JA2 SD_I2C_CHANNEL_1
75 #define SD_I2C_JB1 SD_I2C_CHANNEL_2
76 #define SD_I2C_JB2 SD_I2C_CHANNEL_3
77 #define SD_I2C_JC1 SD_I2C_CHANNEL_4
78 #define SD_I2C_J3 SD_I2C_CHANNEL_5
79 #define SD_I2C_J2 SD_I2C_CHANNEL_7
89 extern struct sd_i2c_dev i2c1_dev;
90 extern struct sd_i2c_dev i2c2_dev;
106  SD_I2C_SUCCESS = 0x4A0D,
108  SD_I2C_LOCKED,
110  SD_I2C_ERROR
111 };
112 
118  SD_I2C_INITIALIZED = 0x0E60,
119  SD_I2C_READY,
120  SD_I2C_BUSY,
121 };
122 
123 
128 struct sd_i2c_dev {
129  I2C_HandleTypeDef *i2c;
130  struct sd_cbuf *rx_buff;
131  enum sd_i2c_state state;
132  uint8_t error;
133 };
143 void sd_i2c1_init (void);
144 void sd_i2c2_init (void);
145 enum sd_i2c_err sd_i2C_set_chan (struct sd_i2c_dev *dev,
146  uint8_t chan);
155 #ifdef __cplusplus
156 }
157 #endif
158 #else
159 #error "Multiple inclusion of sd_i2c.h"
160 #endif /* __SD_I2C_H */
161 
162 /*
163  * END OF FILE [sd_i2c.h]
164  */
I2C_HandleTypeDef * i2c
Definition: sd_i2c.h:126
sd_i2c_err
I2C error enumeration.
Definition: sd_i2c.h:102
enum sd_i2c_state state
Definition: sd_i2c.h:128
Character buffer structure.
Definition: sd_buffer.h:102
uint8_t error
Definition: sd_i2c.h:129
Definition: sd_i2c.h:117
struct sd_i2c_dev i2c2_dev
Definition: sd_i2c.c:79
Definition: sd_i2c.h:106
struct sd_cbuf * rx_buff
Definition: sd_i2c.h:127
void sd_i2c1_init(void)
I2C1 Initialization Initialize low-level hardware peripheral and set device handle.
Definition: sd_i2c.c:96
Definition: sd_i2c.h:104
Definition: sd_i2c.h:116
Definition: sd_i2c.h:115
Definition: sd_i2c.h:103
Definition: sd_i2c.h:105
Definition: sd_i2c.h:107
void sd_i2c2_init(void)
I2C2 Initialization Initialize low-level hardware peripheral and set device handle.
Definition: sd_i2c.c:123
I2C device structure.
Definition: sd_i2c.h:125
enum sd_i2c_err sd_i2C_set_chan(struct sd_i2c_dev *dev, uint8_t chan)
Set I2C channel Set I2C channel (more than one channel may be specified) to broadcast messages...
Definition: sd_i2c.c:235
sd_i2c_state
I2C state enumeration.
Definition: sd_i2c.h:114