Subversion Repositories MK3Mag

Rev

Go to most recent revision | Details | 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
 
37
struct str_I2C_Heading
38
{
39
  unsigned int Heading;
40
} ;
41
 
42
 
43
extern unsigned char Tx_Idx, Rx_Idx, I2C_Direction;
44
 
45
extern struct str_I2C_Heading       I2C_Heading;
46
extern struct str_I2C_WriteNickRoll I2C_WriteNickRoll;
47
extern struct str_I2C_Mag           I2C_Mag;
48
extern struct str_I2C_EEPROM        I2C_ReadEEPROM, I2C_WriteEEPROM;
49
extern struct str_I2C_Version       I2C_Version;
50
 
51
 
52
extern void InitIC2_Slave (void);
53
 
1 ingob 54
#define TWI_BUS_ERR_1   0x00
55
#define TWI_BUS_ERR_2   0xF8
56
 
57
// Status Slave RX Mode
58
#define SR_SLA_ACK      0x60
59
#define SR_LOST_ACK     0x68
60
#define SR_GEN_CALL_ACK 0x70
61
#define GEN_LOST_ACK    0x78
62
#define SR_PREV_ACK     0x80
63
#define SR_PREV_NACK    0x88
64
#define GEN_PREV_ACK    0x90
65
#define GEN_PREV_NACK   0x98
66
#define STOP_CONDITION  0xA0
67
#define REPEATED_START  0xA0
68
 
69
// Status Slave TX mode
70
#define SW_SLA_ACK      0xA8
71
#define SW_LOST_ACK     0xB0
72
#define SW_DATA_ACK     0xB8
73
#define SW_DATA_NACK    0xC0
74
#define SW_LAST_ACK     0xC8
75
 
76
#endif
77