Subversion Repositories FlightCtrl

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 ingob 1
/*############################################################################
2
############################################################################*/
3
 
4
#ifndef _I2C_MASTER_H
5
#define _I2C_MASTER_H
6
 
7
//############################################################################
8
 
9
// I2C Konstanten
10
#define SCL_CLOCK  200000L
11
#define I2C_TIMEOUT 30000
12
#define I2C_START          0x08
13
#define I2C_REPEATED_START 0x10
14
#define I2C_TX_SLA_ACK     0x18
15
#define I2C_TX_DATA_ACK    0x28
16
#define I2C_RX_SLA_ACK     0x40
17
#define I2C_RX_DATA_ACK    0x50
18
 
19
//############################################################################
20
 
918 hbuss 21
extern volatile unsigned char twi_state;
1210 hbuss 22
extern unsigned char motor,MissingMotor;
1 ingob 23
extern unsigned char motorread;
24
 
1479 killagreg 25
#define MAX_MOTORS      12
26
#define MOTOR_STATE_PRESENT_MASK        0x80
27
#define MOTOR_STATE_ERROR_MASK          0x7F
28
 
29
typedef struct
30
{
31
        uint8_t SetPoint; // written by attitude controller
32
        uint8_t State;    // 7 bit for I2C error counter, highest bit indicates if motor is present
33
        uint8_t Current;  // in 0.1 A steps, read back from BL
34
        uint8_t MaxPWM;   // read back from BL is less than 255 if BL is in current limit
35
} __attribute__((packed)) MotorData_t;
36
 
37
extern MotorData_t Motor[MAX_MOTORS];
38
 
304 ingob 39
void i2c_reset(void);
395 hbuss 40
extern void i2c_init (void); // I2C initialisieren
1209 hbuss 41
extern void i2c_start (void); // Start I2C
395 hbuss 42
extern void i2c_stop (void); // Stop I2C
1209 hbuss 43
extern void i2c_write_byte (char byte); // 1 Byte schreiben
395 hbuss 44
extern void i2c_reset(void);
1 ingob 45
 
46
#endif