-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathI2C.h
77 lines (59 loc) · 1.76 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef I2C_H
#define I2C_H
#include "stm32f10x.h"
#define ADXLADDR 0xA6
#define REG_POWER_ADDR 0x2D
#define REG_DATA_FORMAT 0x31
#define REG_DATA_X_LOW 0x32
#define REG_DATA_X_HIGH 0x33
#define REG_DATA_Y_LOW 0x34
#define REG_DATA_Y_HIGH 0x35
#define REG_DATA_Z_LOW 0x36
#define REG_DATA_Z_HIGH 0x37
#define PIN_SCL GPIO_Pin_5
#define PIN_SDA GPIO_Pin_4
#define PIN_SCL1 GPIO_Pin_3
#define PIN_SDA1 GPIO_Pin_2
#define PIN_SCL2 GPIO_Pin_1
#define PIN_SDA2 GPIO_Pin_0
#define I2C_PORT GPIOE
void Init_ADXL345(void);
void Init_ADXL3451(void);
void Init_ADXL3452(void);
void SDA_IN(void);
void SDA1_IN(void);
void SDA2_IN(void);
void SDA_OUT(void);
void SDA1_OUT(void);
void SDA2_OUT(void);
void I2C_Initi(void);
void I2C_Initi1(void);
void I2C_Initi2(void);
void I2C_Start(void);
void I2C_Start1(void);
void I2C_Start2(void);
void I2C_Stop(void);
void I2C_Stop1(void);
void I2C_Stop2(void);
void I2C_Send_Byte(u8 txd);
void I2C_Send_Byte1(u8 txd);
void I2C_Send_Byte2(u8 txd);
u8 I2C_Read_Byte(unsigned char ack);
u8 I2C_Read_Byte1(unsigned char ack);
u8 I2C_Read_Byte2(unsigned char ack);
u8 I2C_Wait_Ack(void);
u8 I2C_Wait_Ack1(void);
u8 I2C_Wait_Ack2(void);
u8 I2C_Wait_Ack(void);
u8 I2C_Wait_Ack1(void);
u8 I2C_Wait_Ack2(void);
void I2C_NAck(void);
void I2C_NAck1(void);
void I2C_NAck2(void);
void SingleWrite(u8 daddr,u8 addr,u8 data);
void SingleWrite1(u8 daddr,u8 addr,u8 data);
void SingleWrite2(u8 daddr,u8 addr,u8 data);
u8 SingleRead(u8 daddr,u8 addr);
u8 SingleRead1(u8 daddr,u8 addr);
u8 SingleRead2(u8 daddr,u8 addr);
#endif