Rev 13 |
Rev 19 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#ifndef _TWI_SLAVE_H_
#define _TWI_SLAVE_H_
#define I2C_SLAVE_ADDRESS 0x50
#define I2C_CMD_VERSION 0x01
struct str_I2C_Version
{
unsigned char Hauptversion;
unsigned char Nebenversion;
unsigned char Comp;
} ;
#define I2C_CMD_WRITE_EEPROM 0x0A
#define I2C_CMD_READ_EEPROM 0x0B
struct str_I2C_EEPROM
{
unsigned char Adresse;
unsigned int Inhalt;
} ;
#define I2C_CMD_READ_MAG 0x02
struct str_I2C_Mag
{
int MagX;
int MagY;
int MagZ;
} ;
#define I2C_CMD_READ_HEADING 0x03
struct str_I2C_WriteNickRoll
{
int Nick;
int Roll;
} ;
#define I2C_CMD_WRITE_CAL 0x04
struct str_I2C_WriteCal
{
unsigned char CalByte;
unsigned char Dummy1;
unsigned char Dummy2;
} ;
struct str_I2C_Heading
{
unsigned int Heading;
} ;
extern unsigned char Tx_Idx, Rx_Idx, I2C_Direction;
extern struct str_I2C_Heading I2C_Heading;
extern struct str_I2C_WriteNickRoll I2C_WriteNickRoll;
extern struct str_I2C_Mag I2C_Mag;
extern struct str_I2C_EEPROM I2C_ReadEEPROM, I2C_WriteEEPROM;
extern struct str_I2C_Version I2C_Version;
extern struct str_I2C_WriteCal I2C_WriteCal;
extern void InitIC2_Slave (void);
#define TWI_BUS_ERR_1 0x00
#define TWI_BUS_ERR_2 0xF8
// Status Slave RX Mode
#define SR_SLA_ACK 0x60
#define SR_LOST_ACK 0x68
#define SR_GEN_CALL_ACK 0x70
#define GEN_LOST_ACK 0x78
#define SR_PREV_ACK 0x80
#define SR_PREV_NACK 0x88
#define GEN_PREV_ACK 0x90
#define GEN_PREV_NACK 0x98
#define STOP_CONDITION 0xA0
#define REPEATED_START 0xA0
// Status Slave TX mode
#define SW_SLA_ACK 0xA8
#define SW_LOST_ACK 0xB0
#define SW_DATA_ACK 0xB8
#define SW_DATA_NACK 0xC0
#define SW_LAST_ACK 0xC8
#endif