Rev 1227 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1227 | Rev 1594 | ||
---|---|---|---|
1 | #ifndef _I2C_MASTER_H |
1 | #ifndef _I2C_MASTER_H |
2 | #define _I2C_MASTER_H |
2 | #define _I2C_MASTER_H |
3 | 3 | ||
4 | 4 | ||
5 | #include <inttypes.h> |
5 | #include <inttypes.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 volatile uint8_t motor_write; |
12 | extern volatile uint8_t motor_write; |
13 | extern volatile uint8_t motor_read; |
13 | extern volatile uint8_t motor_read; |
14 | 14 | ||
15 | extern uint8_t MissingMotor; |
15 | extern uint8_t MissingMotor; |
16 | 16 | ||
17 | #define MAX_MOTORS 12 |
17 | #define MAX_MOTORS 12 |
18 | 18 | ||
19 | typedef struct |
19 | typedef struct |
20 | { |
20 | { |
21 | uint8_t SetPoint; // written by attitude controller |
21 | uint8_t SetPoint; // written by attitude controller |
22 | uint8_t Present; // 0 if BL was found |
22 | uint8_t Present; // 1 if BL was found |
23 | uint8_t Error; // I2C error counter |
23 | uint8_t Error; // I2C error counter |
24 | uint8_t Current; // read byck from BL |
24 | uint8_t Current; // read back from BL |
25 | uint8_t MaxPWM; // read back from BL |
25 | uint8_t MaxPWM; // read back from BL |
26 | } __attribute__((packed)) MotorData_t; |
26 | } __attribute__((packed)) MotorData_t; |
27 | 27 | ||
28 | extern MotorData_t Motor[MAX_MOTORS]; |
28 | extern MotorData_t Motor[MAX_MOTORS]; |
29 | 29 | ||
30 | extern volatile uint16_t I2CTimeout; |
30 | extern volatile uint16_t I2CTimeout; |
31 | 31 | ||
32 | extern void I2C_Init (void); // Initialize I2C |
32 | extern void I2C_Init (void); // Initialize I2C |
33 | extern void I2C_Start(uint8_t start_state); // Start I2C |
33 | extern void I2C_Start(uint8_t start_state); // Start I2C |
34 | extern void I2C_Stop (uint8_t start_state); // Stop I2C |
34 | extern void I2C_Stop (uint8_t start_state); // Stop I2C |
35 | extern void I2C_Reset(void); // Reset I2C |
35 | extern void I2C_Reset(void); // Reset I2C |
36 | 36 | ||
37 | #endif |
37 | #endif |
38 | 38 |