Rev 189 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
41 | ingob | 1 | #ifndef __I2C_H |
2 | #define __I2C_H |
||
1 | ingob | 3 | |
41 | ingob | 4 | #define I2C_CMD_VERSION 0x01 |
5 | #define I2C_CMD_READ_MAG 0x02 |
||
6 | #define I2C_CMD_READ_HEADING 0x03 |
||
7 | #define I2C_CMD_WRITE_CAL 0x04 |
||
1 | ingob | 8 | |
41 | ingob | 9 | |
10 | typedef struct |
||
1 | ingob | 11 | { |
41 | ingob | 12 | u8 Major; |
13 | u8 Minor; |
||
14 | u8 Patch; |
||
15 | u8 Compatible; |
||
16 | } __attribute__((packed)) I2C_Version_t; |
||
1 | ingob | 17 | |
41 | ingob | 18 | typedef struct |
1 | ingob | 19 | { |
41 | ingob | 20 | s16 MagX; |
21 | s16 MagY; |
||
22 | s16 MagZ; |
||
23 | } __attribute__((packed)) I2C_Mag_t; |
||
1 | ingob | 24 | |
41 | ingob | 25 | |
26 | typedef struct |
||
1 | ingob | 27 | { |
28 | s16 Nick; |
||
29 | s16 Roll; |
||
41 | ingob | 30 | } __attribute__((packed)) I2C_WriteAttitude_t; |
1 | ingob | 31 | |
41 | ingob | 32 | |
33 | typedef struct |
||
1 | ingob | 34 | { |
35 | u8 CalByte; |
||
36 | u8 Dummy1; |
||
37 | u8 Dummy2; |
||
41 | ingob | 38 | } __attribute__((packed)) I2C_Cal_t; |
1 | ingob | 39 | |
41 | ingob | 40 | typedef struct |
1 | ingob | 41 | { |
41 | ingob | 42 | s16 Heading; |
43 | } __attribute__((packed)) I2C_Heading_t; |
||
1 | ingob | 44 | |
41 | ingob | 45 | extern volatile u32 I2C1_Timeout; |
1 | ingob | 46 | |
41 | ingob | 47 | extern volatile I2C_Heading_t I2C_Heading; |
48 | extern volatile I2C_Mag_t I2C_Mag; |
||
49 | extern volatile I2C_Version_t MK3MAG_Version; |
||
1 | ingob | 50 | |
41 | ingob | 51 | void I2C1_Init(void); |
52 | void I2C1_Deinit(void); |
||
53 | void I2C1_SendCommand(u8 command); |
||
54 | void I2C1_GetMK3MagVersion(void); |
||
146 | killagreg | 55 | void I2C1_UpdateCompass(void); |
1 | ingob | 56 | |
41 | ingob | 57 | #endif // I2C_H |
1 | ingob | 58 |