Subversion Repositories FlightCtrl

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1471 Nick666 1
#ifndef _I2C_MASTER_H
2
#define _I2C_MASTER_H
3
 
4
 
5
#include <inttypes.h>
6
 
7
#define TWI_STATE_MOTOR_TX                      0
8
#define TWI_STATE_MOTOR_RX                      3
9
#define TWI_STATE_GYRO_OFFSET_TX        7
10
 
11
extern volatile uint8_t twi_state;
12
extern volatile uint8_t motor_write;
13
extern volatile uint8_t motor_read;
14
 
15
extern uint8_t MissingMotor;
16
 
17
#define MAX_MOTORS      12
18
 
19
typedef struct
20
{
21
        uint8_t SetPoint; // written by attitude controller
22
        uint8_t Present;  // 0 if BL was found
23
        uint8_t Error;    // I2C error counter
24
        uint8_t Current;  // read byck from BL
25
        uint8_t MaxPWM;   // read back from BL
26
} __attribute__((packed)) MotorData_t;
27
 
28
extern MotorData_t Motor[MAX_MOTORS];
29
 
30
extern volatile uint16_t I2CTimeout;
31
 
32
extern void I2C_Init (void); // Initialize I2C
33
extern void I2C_Start(uint8_t start_state); // Start I2C
34
extern void I2C_Stop (uint8_t start_state); // Stop I2C
35
extern void I2C_Reset(void); // Reset I2C
36
 
37
#endif