Subversion Repositories FlightCtrl

Rev

Rev 1947 | Rev 1965 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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