Rev 19 | Rev 23 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 19 | Rev 22 | ||
---|---|---|---|
1 | #ifndef _TWI_SLAVE_H_ |
1 | #ifndef _TWI_SLAVE_H_ |
2 | #define _TWI_SLAVE_H_ |
2 | #define _TWI_SLAVE_H_ |
3 | 3 | ||
4 | #include <inttypes.h> |
4 | #include <inttypes.h> |
5 | 5 | ||
6 | #define I2C_SLAVE_ADDRESS 0x50 |
6 | #define I2C_SLAVE_ADDRESS 0x50 |
7 | #define I2C_PROTOCOL_COMP 1 |
7 | #define I2C_PROTOCOL_COMP 1 |
8 | 8 | ||
9 | #define I2C_CMD_VERSION 0x01 |
9 | #define I2C_CMD_VERSION 0x01 |
10 | #define I2C_CMD_READ_MAG 0x02 |
10 | #define I2C_CMD_READ_MAG 0x02 |
11 | #define I2C_CMD_READ_HEADING 0x03 |
11 | #define I2C_CMD_READ_HEADING 0x03 |
12 | #define I2C_CMD_WRITE_CAL 0x04 |
12 | #define I2C_CMD_WRITE_CAL 0x04 |
13 | #define I2C_CMD_WRITE_EEPROM 0x0A |
13 | #define I2C_CMD_WRITE_EEPROM 0x0A |
14 | #define I2C_CMD_READ_EEPROM 0x0B |
14 | #define I2C_CMD_READ_EEPROM 0x0B |
15 | 15 | ||
16 | 16 | ||
17 | typedef struct |
17 | typedef struct |
18 | { |
18 | { |
19 | uint8_t Major; |
19 | uint8_t Major; |
20 | uint8_t Minor; |
20 | uint8_t Minor; |
21 | uint8_t Compatible; |
21 | uint8_t Compatible; |
22 | } I2C_Version_t; |
22 | } I2C_Version_t; |
23 | 23 | ||
24 | 24 | ||
25 | typedef struct |
25 | typedef struct |
26 | { |
26 | { |
27 | uint8_t Adress; |
27 | uint8_t Adress; |
28 | uint16_t Content; |
28 | uint16_t Content; |
29 | } I2C_EEPROM_t; |
29 | } I2C_EEPROM_t; |
30 | 30 | ||
31 | 31 | ||
32 | typedef struct |
32 | typedef struct |
33 | { |
33 | { |
34 | int16_t MagX; |
34 | int16_t MagX; |
35 | int16_t MagY; |
35 | int16_t MagY; |
36 | int16_t MagZ; |
36 | int16_t MagZ; |
37 | } I2C_Mag_t; |
37 | } I2C_Mag_t; |
38 | 38 | ||
39 | 39 | ||
40 | typedef struct |
40 | typedef struct |
41 | { |
41 | { |
42 | int16_t Nick; |
42 | int16_t Nick; |
43 | int16_t Roll; |
43 | int16_t Roll; |
44 | } I2C_WriteAttitude_t; |
44 | } I2C_WriteAttitude_t; |
45 | 45 | ||
46 | 46 | ||
47 | typedef struct |
47 | typedef struct |
48 | { |
48 | { |
49 | uint8_t CalByte; |
49 | uint8_t CalByte; |
50 | uint8_t Dummy1; |
50 | uint8_t Dummy1; |
51 | uint8_t Dummy2; |
51 | uint8_t Dummy2; |
52 | } I2C_WriteCal_t; |
52 | } I2C_WriteCal_t; |
53 | 53 | ||
54 | typedef struct |
54 | typedef struct |
55 | { |
55 | { |
56 | int16_t Heading; |
56 | int16_t Heading; |
57 | } I2C_Heading_t; |
57 | } I2C_Heading_t; |
58 | 58 | ||
59 | - | ||
60 | extern uint8_t Tx_Idx, Rx_Idx, I2C_Direction; |
- | |
61 | 59 | ||
62 | extern I2C_Heading_t I2C_Heading; |
60 | extern I2C_Heading_t I2C_Heading; |
63 | extern I2C_WriteAttitude_t I2C_WriteNickRoll; |
61 | extern I2C_WriteAttitude_t I2C_WriteNickRoll; |
64 | extern I2C_Mag_t I2C_Mag; |
62 | extern I2C_Mag_t I2C_Mag; |
65 | extern I2C_Version_t I2C_Version; |
63 | extern I2C_Version_t I2C_Version; |
66 | extern I2C_WriteCal_t I2C_WriteCal; |
64 | extern I2C_WriteCal_t I2C_WriteCal; |
67 | 65 | ||
68 | void I2C_Init(void); |
66 | void I2C_Init(void); |
69 | 67 | ||
70 | 68 | ||
71 | #endif // _TWI_SLAVE_H_ |
69 | #endif // _TWI_SLAVE_H_ |
72 | 70 | ||
73 | 71 |