-
Notifications
You must be signed in to change notification settings - Fork 3
/
I2C.h
executable file
·32 lines (23 loc) · 1007 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
#ifndef I2C_H
#define I2C_H
struct I2C;
struct CardData;
struct I2C_bit_ops {
void (*Start)(struct CardData *card);
void (*Stop)(struct CardData *card);
void (*SetDir_CLK_SDA)(struct CardData *card, int clock, int data); /* set line direction (0 = write, 1 = read) */
void (*Write_CLK_SDA)(struct CardData *card, int clock, int data);
int (*GetClock)(struct CardData *card);
int (*GetData)(struct CardData *card, int ack);
};
struct I2C {
unsigned short flags; // some private data
unsigned short addr;
struct I2C_bit_ops *bit; // with a pointer, the specific card information can be put in a struct and assigned to this attribute
};
struct I2C *AllocI2C(unsigned char addr);
void FreeI2C(struct I2C *device);
int WriteBytesI2C(struct CardData *card, struct I2C *device, unsigned char *bytes, int count);
int ReadBytesI2C(struct CardData *card, struct I2C *device, unsigned char *bytes, int count);
int ProbeAddressI2C(struct CardData *card, unsigned short addr);
#endif /* I2C_H */