Subversion Repositories MK3Mag

Rev

Rev 16 | Rev 32 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 ingob 1
#ifndef _TWI_SLAVE_H_
2
#define _TWI_SLAVE_H_
3
 
3 ingob 4
#define I2C_SLAVE_ADDRESS 0x50
1 ingob 5
 
3 ingob 6
#define I2C_CMD_VERSION   0x01
7
struct str_I2C_Version
8
{
9
  unsigned char Hauptversion;
10
  unsigned char Nebenversion;
11
  unsigned char Comp;
12
} ;
1 ingob 13
 
3 ingob 14
#define I2C_CMD_WRITE_EEPROM   0x0A
15
#define I2C_CMD_READ_EEPROM    0x0B
16
struct str_I2C_EEPROM
17
{
18
  unsigned char Adresse;
19
  unsigned int Inhalt;
20
} ;
21
 
22
#define I2C_CMD_READ_MAG     0x02
23
struct str_I2C_Mag
24
{
25
  int MagX;
26
  int MagY;
27
  int MagZ;
28
} ;
29
 
30
#define I2C_CMD_READ_HEADING     0x03
31
struct str_I2C_WriteNickRoll
32
{
33
  int Nick;
34
  int Roll;
35
} ;
36
 
7 hbuss 37
#define I2C_CMD_WRITE_CAL     0x04
38
struct str_I2C_WriteCal
39
{
40
  unsigned char CalByte;
41
  unsigned char Dummy1;
42
  unsigned char Dummy2;
43
} ;
44
 
17 holgerb 45
#define I2C_CMD_READ_HEADING_INTERNAL_ACC     0x05
16 holgerb 46
 
3 ingob 47
struct str_I2C_Heading
48
{
49
  unsigned int Heading;
50
} ;
51
 
16 holgerb 52
#define I2C_CMD_READ_ACC     0x06
53
struct str_I2C_Acc
54
{
55
  int AccN;
56
  int AccR;
57
  int AccZ;
58
};
3 ingob 59
 
60
extern unsigned char Tx_Idx, Rx_Idx, I2C_Direction;
61
 
62
extern struct str_I2C_Heading       I2C_Heading;
63
extern struct str_I2C_WriteNickRoll I2C_WriteNickRoll;
64
extern struct str_I2C_Mag           I2C_Mag;
65
extern struct str_I2C_EEPROM        I2C_ReadEEPROM, I2C_WriteEEPROM;
66
extern struct str_I2C_Version       I2C_Version;
7 hbuss 67
extern struct str_I2C_WriteCal      I2C_WriteCal;
16 holgerb 68
extern struct str_I2C_Acc           I2C_Acc;
3 ingob 69
 
70
 
71
extern void InitIC2_Slave (void);
72
 
1 ingob 73
#define TWI_BUS_ERR_1   0x00
74
#define TWI_BUS_ERR_2   0xF8
75
 
76
// Status Slave RX Mode
77
#define SR_SLA_ACK      0x60
78
#define SR_LOST_ACK     0x68
79
#define SR_GEN_CALL_ACK 0x70
80
#define GEN_LOST_ACK    0x78
81
#define SR_PREV_ACK     0x80
82
#define SR_PREV_NACK    0x88
83
#define GEN_PREV_ACK    0x90
84
#define GEN_PREV_NACK   0x98
85
#define STOP_CONDITION  0xA0
86
#define REPEATED_START  0xA0
87
 
88
// Status Slave TX mode
89
#define SW_SLA_ACK      0xA8
90
#define SW_LOST_ACK     0xB0
91
#define SW_DATA_ACK     0xB8
92
#define SW_DATA_NACK    0xC0
93
#define SW_LAST_ACK     0xC8
94
 
95
#endif
96