Subversion Repositories FlightCtrl

Rev

Rev 1821 | Rev 1960 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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