Subversion Repositories FlightCtrl

Rev

Rev 1639 | Rev 1650 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1639 Rev 1648
Line 18... Line 18...
18
 
18
 
Line 19... Line 19...
19
//############################################################################
19
//############################################################################
20
 
20
 
21
extern volatile unsigned char twi_state;
21
extern volatile unsigned char twi_state;
Line 22... Line 22...
22
extern unsigned char motor,MissingMotor;
22
extern unsigned char motor,MissingMotor;
23
extern unsigned char motorread,TransmitBlConfig;
23
extern unsigned char motorread;
24
 
24
 
Line 25... Line 25...
25
#define MAX_MOTORS      12
25
#define MAX_MOTORS      12
Line -... Line 26...
-
 
26
#define MOTOR_STATE_PRESENT_MASK                0x80
-
 
27
#define MOTOR_STATE_ERROR_MASK                  0x7F
-
 
28
 
-
 
29
 
-
 
30
#define MOTOR_STATE_NEW_PROTOCOL_MASK   0x01
-
 
31
 
-
 
32
#define BLFLAG_READ_VERSION     0x01
-
 
33
#define BLFLAG_SEND_CONFIG              0x02
-
 
34
#define BLFLAG_TX_COMPLETE              0x04
-
 
35
 
-
 
36
extern unsigned char BLFlags;
-
 
37
 
-
 
38
#define MASK_SET_PWM_SCALING            0x01
-
 
39
#define MASK_SET_CURRENT_LIMIT          0x02
-
 
40
#define MASK_SET_TEMP_LIMIT                     0x04
-
 
41
#define MASK_SET_CURRENT_SCALING        0x08
-
 
42
#define MASK_SET_BITCONFIG                      0x10
-
 
43
#define MASK_RESET_CAPCOUNTER           0x20
-
 
44
#define MASK_SET_DEFAULT_PARAMS         0x40
-
 
45
#define MASK_SET_SAVE_EEPROM            0x80
-
 
46
 
-
 
47
#define BITCONF_REVERSE_ROTATION 0x01
-
 
48
#define BITCONF_RES1 0x02
-
 
49
#define BITCONF_RES2 0x04
26
#define MOTOR_STATE_PRESENT_MASK                0x80
50
#define BITCONF_RES3 0x08
27
#define MOTOR_STATE_ERROR_MASK                  0x7F
51
#define BITCONF_RES4 0x10
28
 
52
#define BITCONF_RES5 0x20
29
 
53
#define BITCONF_RES6 0x40
30
#define MOTOR_STATE_NEW_PROTOCOL_MASK   0x01
54
#define BITCONF_RES7 0x80
31
 
55
 
32
typedef struct
56
typedef struct
33
{
57
{
34
        unsigned char SetPoint; // written by attitude controller
58
        unsigned char SetPoint; // written by attitude controller
35
        unsigned char State;    // 7 bit for I2C error counter, highest bit indicates if motor is present
59
        unsigned char State;    // 7 bit for I2C error counter, highest bit indicates if motor is present
Line 36... Line 60...
36
        unsigned char Current;  // in 0.1 A steps, read back from BL
60
        unsigned char Current;  // in 0.1 A steps, read back from BL
Line -... Line 61...
-
 
61
        unsigned char MaxPWM;   // read back from BL is less than 255 if BL is in current limit
-
 
62
        unsigned char Temperature; // old BL-Ctrl will return a 255 here
-
 
63
        unsigned char SetPointLowerBits; // for higher Resolution
-
 
64
    unsigned char Version;
-
 
65
} __attribute__((packed)) MotorData_t;
-
 
66
 
-
 
67
extern MotorData_t Motor[MAX_MOTORS];
-
 
68
 
-
 
69
typedef struct
-
 
70
{
-
 
71
        unsigned char SetMask;                  // settings mask
-
 
72
        unsigned char PwmScaling;                       // maximum value of control pwm, acts like a thrust limit
37
        unsigned char MaxPWM;   // read back from BL is less than 255 if BL is in current limit
73
        unsigned char CurrentLimit;             // current limit in A
38
          signed char Temperature; // old BL-Ctrl will return a 255 here 
74
        unsigned char TempLimit;                        // in °C
39
        unsigned char SetPointLowerBits; // for higher Resolution
-
 
40
    unsigned char Version;
-
 
41
} __attribute__((packed)) MotorData_t;
75
        unsigned char CurrentScaling;           // scaling factor for current measurement
42
 
76
        unsigned char BitConfig;                        // see defines below
-
 
77
}  __attribute__((packed)) BLConfig_t;
Line 43... Line 78...
43
extern MotorData_t Motor[MAX_MOTORS];
78
 
44
 
79
extern BLConfig_t BLConfig[MAX_MOTORS];
45
void i2c_reset(void);
80
 
46
extern void i2c_init (void); // I2C initialisieren
81
void i2c_reset(void);