Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | ingob | 1 | #ifndef _I2C_MASTER_H |
2 | #define _I2C_MASTER_H |
||
886 | killagreg | 3 | |
1 | ingob | 4 | |
886 | killagreg | 5 | #include <inttypes.h> |
1 | ingob | 6 | |
936 | killagreg | 7 | #define TWI_STATE_MOTOR_TX 0 |
1222 | killagreg | 8 | #define TWI_STATE_MOTOR_RX 3 |
936 | killagreg | 9 | #define TWI_STATE_GYRO_OFFSET_TX 7 |
1 | ingob | 10 | |
886 | killagreg | 11 | extern volatile uint8_t twi_state; |
1222 | killagreg | 12 | extern volatile uint8_t motor_write; |
13 | extern volatile uint8_t motor_read; |
||
1180 | killagreg | 14 | |
1222 | killagreg | 15 | extern uint8_t MissingMotor; |
1180 | killagreg | 16 | |
1222 | killagreg | 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 | |||
936 | killagreg | 30 | extern volatile uint16_t I2CTimeout; |
1 | ingob | 31 | |
936 | killagreg | 32 | extern void I2C_Init (void); // Initialize I2C |
1222 | killagreg | 33 | extern void I2C_Start(uint8_t start_state); // Start I2C |
34 | extern void I2C_Stop (uint8_t start_state); // Stop I2C |
||
886 | killagreg | 35 | extern void I2C_Reset(void); // Reset I2C |
1 | ingob | 36 | |
37 | #endif |