Subversion Repositories MK3Mag

Rev

Rev 19 | Rev 23 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#ifndef _TWI_SLAVE_H_
#define _TWI_SLAVE_H_

#include <inttypes.h>

#define I2C_SLAVE_ADDRESS               0x50
#define I2C_PROTOCOL_COMP               1

#define I2C_CMD_VERSION                 0x01
#define I2C_CMD_READ_MAG        0x02
#define I2C_CMD_READ_HEADING    0x03
#define I2C_CMD_WRITE_CAL       0x04
#define I2C_CMD_WRITE_EEPROM    0x0A
#define I2C_CMD_READ_EEPROM     0x0B


typedef struct
{
        uint8_t Major;
        uint8_t Minor;
        uint8_t Compatible;
} I2C_Version_t;


typedef struct
{
        uint8_t Adress;
        uint16_t Content;
} I2C_EEPROM_t;


typedef struct
{
        int16_t MagX;
        int16_t MagY;
        int16_t MagZ;
} I2C_Mag_t;


typedef struct
{
        int16_t Nick;
        int16_t Roll;
} I2C_WriteAttitude_t;


typedef struct
{
  uint8_t CalByte;
  uint8_t Dummy1;
  uint8_t Dummy2;
} I2C_WriteCal_t;

typedef struct
{
  int16_t Heading;
} I2C_Heading_t;


extern I2C_Heading_t            I2C_Heading;
extern I2C_WriteAttitude_t      I2C_WriteNickRoll;
extern I2C_Mag_t                        I2C_Mag;
extern I2C_Version_t            I2C_Version;
extern I2C_WriteCal_t           I2C_WriteCal;

void I2C_Init(void);


#endif // _TWI_SLAVE_H_