Subversion Repositories FlightCtrl

Rev

Rev 2035 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2035 Rev 2189
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
#include "configuration.h"
5
#include "configuration.h"
6
 
6
 
7
#define TWI_STATE_MOTOR_TX                      0
7
#define TWI_STATE_MOTOR_TX                      0
8
#define TWI_STATE_MOTOR_RX                      3
8
#define TWI_STATE_MOTOR_RX                      3
9
#define TWI_STATE_GYRO_OFFSET_TX        7
9
#define TWI_STATE_GYRO_OFFSET_TX        7
10
 
10
 
11
extern volatile uint8_t twi_state;
11
extern volatile uint8_t twi_state;
12
extern uint8_t missingMotor;
12
extern uint8_t missingMotor;
13
 
13
 
14
typedef struct {
14
typedef struct {
15
        uint8_t throttle; // written by attitude controller
15
  uint8_t throttle;
-
 
16
  uint8_t current;
-
 
17
  uint8_t maxPWM;
16
        uint8_t present; // 0 if BL was found
18
        uint8_t present; // 0 if BL was found
17
        uint8_t error; // I2C error counter
19
        uint8_t error; // I2C error counter
18
        uint8_t current; // read back from BL
-
 
19
        uint8_t maxPWM; // read back from BL
-
 
20
}__attribute__((packed)) motorData_t;
20
}__attribute__((packed)) MLBLC_t;
21
 
21
 
22
extern motorData_t motor[MAX_MOTORS];
22
extern MLBLC_t mkblcs[MAX_I2CCHANNELS];
23
 
23
 
24
extern volatile uint16_t I2CTimeout;
24
extern volatile uint16_t I2CTimeout;
25
 
25
 
26
extern void I2C_init(void); // Initialize I2C
26
extern void I2C_init(void); // Initialize I2C
27
extern void I2C_Start(uint8_t start_state); // Start I2C
27
extern void I2C_start(uint8_t startState); // Start I2C
28
extern void I2C_Stop(uint8_t start_state); // Stop I2C
28
extern void I2C_stop(uint8_t startState);  // Stop I2C
29
extern void I2C_Reset(void); // Reset I2C
29
extern void I2C_reset(void); // Reset I2C
30
extern void twi_diagnostics(void);
30
extern void twi_diagnostics(void);
31
 
31
 
32
#endif
32
#endif
33
 
33