Subversion Repositories MK3Mag

Rev

Rev 18 | Rev 22 | Go to most recent revision | Show entire file | Ignore 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 3... Line 3...
3
 
3
 
Line 4... Line 4...
4
#define I2C_SLAVE_ADDRESS 0x50
4
#include <inttypes.h>
5
 
-
 
6
#define I2C_CMD_VERSION   0x01
-
 
7
struct str_I2C_Version
-
 
8
{
5
 
9
  unsigned char Hauptversion;
-
 
10
  unsigned char Nebenversion;
-
 
Line -... Line 6...
-
 
6
#define I2C_SLAVE_ADDRESS               0x50
11
  unsigned char Comp;
7
#define I2C_PROTOCOL_COMP               1
12
} ;
8
 
13
 
9
#define I2C_CMD_VERSION                 0x01
14
#define I2C_CMD_WRITE_EEPROM   0x0A
-
 
15
#define I2C_CMD_READ_EEPROM    0x0B
10
#define I2C_CMD_READ_MAG        0x02
16
struct str_I2C_EEPROM
11
#define I2C_CMD_READ_HEADING    0x03
17
{
-
 
Line 18... Line -...
18
  unsigned char Adresse;
-
 
-
 
12
#define I2C_CMD_WRITE_CAL       0x04
19
  unsigned int Inhalt;
13
#define I2C_CMD_WRITE_EEPROM    0x0A
20
} ;
14
#define I2C_CMD_READ_EEPROM     0x0B
21
 
15
 
22
#define I2C_CMD_READ_MAG     0x02
16
 
23
struct str_I2C_Mag
17
typedef struct
-
 
18
{
24
{
19
        uint8_t Major;
Line 25... Line -...
25
  int MagX;
-
 
26
  int MagY;
20
        uint8_t Minor;
27
  int MagZ;
21
        uint8_t Compatible;
28
} ;
22
} I2C_Version_t;
29
 
23
 
30
#define I2C_CMD_READ_HEADING     0x03
24
 
Line 31... Line -...
31
struct str_I2C_WriteNickRoll
-
 
-
 
25
typedef struct
32
{
26
{
33
  int Nick;
27
        uint8_t Adress;
34
  int Roll;
28
        uint16_t Content;
35
} ;
29
} I2C_EEPROM_t;
36
 
30
 
-
 
31
 
37
#define I2C_CMD_WRITE_CAL     0x04
32
typedef struct
Line 38... Line 33...
38
struct str_I2C_WriteCal
33
{
39
{
34
        int16_t MagX;
40
  unsigned char CalByte;
35
        int16_t MagY;
41
  unsigned char Dummy1;
36
        int16_t MagZ;
-
 
37
} I2C_Mag_t;
Line -... Line 38...
-
 
38
 
-
 
39
 
42
  unsigned char Dummy2;
40
typedef struct
-
 
41
{
-
 
42
        int16_t Nick;
-
 
43
        int16_t Roll;
Line 43... Line -...
43
} ;
-
 
44
 
-
 
45
struct str_I2C_Heading
44
} I2C_WriteAttitude_t;
46
{
-
 
-
 
45
 
47
  unsigned int Heading;
46
 
48
} ;
47
typedef struct
Line 49... Line 48...
49
 
48
{
Line -... Line 49...
-
 
49
  uint8_t CalByte;
-
 
50
  uint8_t Dummy1;
50
 
51
  uint8_t Dummy2;
51
extern unsigned char Tx_Idx, Rx_Idx, I2C_Direction;
52
} I2C_WriteCal_t;
-
 
53
 
Line 52... Line -...
52
 
-
 
53
extern struct str_I2C_Heading       I2C_Heading;
-
 
54
extern struct str_I2C_WriteNickRoll I2C_WriteNickRoll;
-
 
55
extern struct str_I2C_Mag           I2C_Mag;
-
 
56
extern struct str_I2C_EEPROM        I2C_ReadEEPROM, I2C_WriteEEPROM;
-
 
57
extern struct str_I2C_Version       I2C_Version;
-
 
58
extern struct str_I2C_WriteCal      I2C_WriteCal;
-
 
59
 
-
 
60
 
-
 
61
extern void InitIC2_Slave (void);
54
typedef struct
62
 
-
 
Line 63... Line -...
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
-
 
Line 69... Line 55...
69
#define SR_GEN_CALL_ACK 0x70
55
{