71,17 → 71,9 |
|
MotorData_t Motor[MAX_MOTORS]; |
|
BLConfig_t BLConfig = |
{ |
MASK_SET_PWM_SCALING|MASK_SET_CURRENT_LIMIT|MASK_SET_TEMP_LIMIT|MASK_SET_CURRENT_SCALING|MASK_SET_BITCONFIG, |
255, // MaxPWM |
30, // Current Limit in A |
99, // Temperature Limit in °C |
64, // Current Scaling |
0, // BitConfig |
}; |
BLConfig_t BLConfig[MAX_MOTORS]; |
|
uint8_t *pTxBuff = (uint8_t*)&BLConfig; |
uint8_t *pTxBuff = (uint8_t*)&BLConfig[0]; |
|
#define BL_CONF_SYNC_BYTE '#' |
|
123,6 → 115,12 |
Motor[i].State = 0; |
Motor[i].Current = 0; |
Motor[i].MaxPWM = 0; |
BLConfig[i].SetMask = MASK_SET_PWM_SCALING|MASK_SET_CURRENT_LIMIT|MASK_SET_TEMP_LIMIT|MASK_SET_CURRENT_SCALING|MASK_SET_BITCONFIG; |
BLConfig[i].PwmScaling = 255; // MaxPWM |
BLConfig[i].CurrentLimit = 30; // Current Limit in A |
BLConfig[i].TempLimit = 99; // Temperature Limit in °C |
BLConfig[i].CurrentScaling = 64; // Current Scaling |
BLConfig[i].BitConfig = 0; // BitConfig |
} |
|
SREG = sreg; |
275,6 → 273,7 |
{ |
I2C_WriteByte(BL_CONF_SYNC_BYTE); |
crc += BL_CONF_SYNC_BYTE; // update crc |
pTxBuff = (uint8_t*)&BLConfig[motor_write]; // select configuration for motor |
} |
else if(byte_counter >= sizeof(BLConfig_t)+1) // last byte? |
{ // send crc byte at the end |
438,6 → 437,7 |
I2CTimeout = 10; |
motor_write = 0; |
motor_read = 0; |
break; |
} |
} |
|
444,9 → 444,9 |
|
void I2C_SendBLConfig(void) |
{ |
uint8_t i; |
unsigned char i; |
while(!(BLFlags & BLFLAG_TX_COMPLETE)); //wait for complete transfer |
BLFlags |= BLFLAG_SEND_CONFIG; // enable sending of BL config |
while(!(BLFlags & BLFLAG_TX_COMPLETE)); //wait for complete transfer |
for(i = 0; i < MAX_MOTORS; i++) |
{ |
Motor[i].SetPoint = 0; |