Subversion Repositories MK3Mag

Rev

Rev 18 | Rev 22 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18 Rev 19
Line 1... Line 1...
1
#ifndef _TWI_SLAVE_H_
1
#ifndef _TWI_SLAVE_H_
2
#define _TWI_SLAVE_H_
2
#define _TWI_SLAVE_H_
Line -... Line 3...
-
 
3
 
-
 
4
#include <inttypes.h>
3
 
5
 
-
 
6
#define I2C_SLAVE_ADDRESS               0x50
Line 4... Line 7...
4
#define I2C_SLAVE_ADDRESS 0x50
7
#define I2C_PROTOCOL_COMP               1
5
 
8
 
6
#define I2C_CMD_VERSION   0x01
-
 
7
struct str_I2C_Version
9
#define I2C_CMD_VERSION                 0x01
8
{
10
#define I2C_CMD_READ_MAG        0x02
9
  unsigned char Hauptversion;
-
 
10
  unsigned char Nebenversion;
-
 
11
  unsigned char Comp;
-
 
12
} ;
11
#define I2C_CMD_READ_HEADING    0x03
13
 
12
#define I2C_CMD_WRITE_CAL       0x04
-
 
13
#define I2C_CMD_WRITE_EEPROM    0x0A
-
 
14
#define I2C_CMD_READ_EEPROM     0x0B
14
#define I2C_CMD_WRITE_EEPROM   0x0A
15
 
15
#define I2C_CMD_READ_EEPROM    0x0B
16
 
16
struct str_I2C_EEPROM
17
typedef struct
17
{
18
{
-
 
19
        uint8_t Major;
18
  unsigned char Adresse;
20
        uint8_t Minor;
Line 19... Line -...
19
  unsigned int Inhalt;
-
 
-
 
21
        uint8_t Compatible;
20
} ;
22
} I2C_Version_t;
21
 
23
 
22
#define I2C_CMD_READ_MAG     0x02
24
 
23
struct str_I2C_Mag
25
typedef struct
24
{
26
{
25
  int MagX;
-
 
Line 26... Line -...
26
  int MagY;
-
 
-
 
27
        uint8_t Adress;
27
  int MagZ;
28
        uint16_t Content;
28
} ;
29
} I2C_EEPROM_t;
-
 
30
 
29
 
31
 
30
#define I2C_CMD_READ_HEADING     0x03
32
typedef struct
31
struct str_I2C_WriteNickRoll
33
{
Line -... Line 34...
-
 
34
        int16_t MagX;
-
 
35
        int16_t MagY;
-
 
36
        int16_t MagZ;
-
 
37
} I2C_Mag_t;
-
 
38
 
32
{
39
 
-
 
40
typedef struct
-
 
41
{
-
 
42
        int16_t Nick;
-
 
43
        int16_t Roll;
-
 
44
} I2C_WriteAttitude_t;
-
 
45
 
-
 
46
 
33
  int Nick;
47
typedef struct
-
 
48
{
-
 
49
  uint8_t CalByte;
34
  int Roll;
50
  uint8_t Dummy1;
35
} ;
-
 
36
 
-
 
37
#define I2C_CMD_WRITE_CAL     0x04
51
  uint8_t Dummy2;
38
struct str_I2C_WriteCal
-
 
39
{
-
 
40
  unsigned char CalByte;
52
} I2C_WriteCal_t;
41
  unsigned char Dummy1;
-
 
42
  unsigned char Dummy2;
-
 
43
} ;
-
 
44
 
53
 
45
struct str_I2C_Heading
54
typedef struct
46
{
55
{
47
  unsigned int Heading;
56
  int16_t Heading;
48
} ;
57
} I2C_Heading_t;
49
 
58
 
50
 
59
 
51
extern unsigned char Tx_Idx, Rx_Idx, I2C_Direction;
-
 
52
 
60
extern uint8_t Tx_Idx, Rx_Idx, I2C_Direction;
53
extern struct str_I2C_Heading       I2C_Heading;
61
 
54
extern struct str_I2C_WriteNickRoll I2C_WriteNickRoll;
-
 
55
extern struct str_I2C_Mag           I2C_Mag;
62
extern I2C_Heading_t            I2C_Heading;
56
extern struct str_I2C_EEPROM        I2C_ReadEEPROM, I2C_WriteEEPROM;
63
extern I2C_WriteAttitude_t      I2C_WriteNickRoll;
57
extern struct str_I2C_Version       I2C_Version;
-
 
58
extern struct str_I2C_WriteCal      I2C_WriteCal;
-
 
59
 
-
 
60
 
-
 
61
extern void InitIC2_Slave (void);
-
 
62
 
-
 
63
#define TWI_BUS_ERR_1   0x00
-
 
64
#define TWI_BUS_ERR_2   0xF8
-
 
65
 
-
 
66
// Status Slave RX Mode
-
 
67
#define SR_SLA_ACK      0x60
-
 
68
#define SR_LOST_ACK     0x68
-
 
69
#define SR_GEN_CALL_ACK 0x70
-
 
70
#define GEN_LOST_ACK    0x78
-
 
71
#define SR_PREV_ACK     0x80
-
 
72
#define SR_PREV_NACK    0x88
64
extern I2C_Mag_t                        I2C_Mag;
73
#define GEN_PREV_ACK    0x90
-
 
74
#define GEN_PREV_NACK   0x98
-
 
75
#define STOP_CONDITION  0xA0
-
 
76
#define REPEATED_START  0xA0
-
 
77
 
-
 
78
// Status Slave TX mode
-
 
Line 79... Line 65...
79
#define SW_SLA_ACK      0xA8
65
extern I2C_Version_t            I2C_Version;