Rev 2369 | Rev 2380 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2369 | Rev 2370 | ||
---|---|---|---|
Line 253... | Line 253... | ||
253 | switch(Motor[motor_read].ReadMode) |
253 | switch(Motor[motor_read].ReadMode) |
254 | { |
254 | { |
255 | case BL_READMODE_CONFIG: |
255 | case BL_READMODE_CONFIG: |
256 | pBuff = (uint8_t*)&BLConfig; |
256 | pBuff = (uint8_t*)&BLConfig; |
257 | BuffLen = sizeof(BLConfig_t); |
257 | BuffLen = sizeof(BLConfig_t); |
- | 258 | Motor[motor_read].ReadMode = BL_READMODE_STATUS; // only once |
|
258 | break; |
259 | break; |
259 | - | ||
260 | case BL_READMODE_STATUS: |
260 | case BL_READMODE_STATUS: |
261 | pBuff = (uint8_t*)&(Motor[motor_read].Current); |
261 | pBuff = (uint8_t*)&(Motor[motor_read].Current); |
262 | if(motor_read == motor_read_temperature) BuffLen = 3; // read Current, MaxPwm & Temp |
262 | if(motor_read == motor_read_temperature) BuffLen = 3; // read Current, MaxPwm & Temp |
263 | else BuffLen = 1;// read Current only |
263 | else BuffLen = 1;// read Current only |
264 | break; |
264 | break; |
Line 387... | Line 387... | ||
387 | { |
387 | { |
388 | if(!(Motor[motor-1].State & MOTOR_STATE_PRESENT_MASK)) return(BLCONFIG_ERR_MOTOR_NOT_EXIST); // motor does not exist! |
388 | if(!(Motor[motor-1].State & MOTOR_STATE_PRESENT_MASK)) return(BLCONFIG_ERR_MOTOR_NOT_EXIST); // motor does not exist! |
389 | if(!(Motor[motor-1].Version & MOTOR_STATE_NEW_PROTOCOL_MASK)) return(BLCONFIG_ERR_HW_NOT_COMPATIBLE); // not a new BL! |
389 | if(!(Motor[motor-1].Version & MOTOR_STATE_NEW_PROTOCOL_MASK)) return(BLCONFIG_ERR_HW_NOT_COMPATIBLE); // not a new BL! |
390 | } |
390 | } |
391 | // check BL configuration to send |
391 | // check BL configuration to send |
392 | if((BLConfig.Revision & 0x0D) != BLCONFIG_REVISION) return (BLCONFIG_ERR_SW_NOT_COMPATIBLE); // bad revison |
392 | if((BLConfig.Revision & 0x0B) != BLCONFIG_REVISION) return (BLCONFIG_ERR_SW_NOT_COMPATIBLE); // bad revison |
393 | i = RAM_Checksum((uint8_t*)&BLConfig, sizeof(BLConfig_t) - 1); |
393 | i = RAM_Checksum((uint8_t*)&BLConfig, sizeof(BLConfig_t) - 1); |
394 | if(i != BLConfig.crc) return(BLCONFIG_ERR_CHECKSUM); // bad checksum |
394 | if(i != BLConfig.crc) return(BLCONFIG_ERR_CHECKSUM); // bad checksum |
Line 395... | Line 395... | ||
395 | 395 | ||
396 | timer = SetDelay(2000); |
396 | timer = SetDelay(2000); |
Line 459... | Line 459... | ||
459 | { |
459 | { |
460 | I2C_Start(TWI_STATE_MOTOR_TX); // start an i2c transmission |
460 | I2C_Start(TWI_STATE_MOTOR_TX); // start an i2c transmission |
461 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
461 | while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
462 | }while(BLConfig_ReadMask && !CheckDelay(timer)); // repeat until the BL config has been received from all motors |
462 | }while(BLConfig_ReadMask && !CheckDelay(timer)); // repeat until the BL config has been received from all motors |
463 | // validate result |
463 | // validate result |
464 | if((BLConfig.Revision & 0x0D) != BLCONFIG_REVISION) return (BLCONFIG_ERR_SW_NOT_COMPATIBLE); // bad revison |
464 | if((BLConfig.Revision & 0x0B) != BLCONFIG_REVISION) return (BLCONFIG_ERR_SW_NOT_COMPATIBLE); // bad revison |
465 | i = RAM_Checksum((uint8_t*)&BLConfig, sizeof(BLConfig_t) - 1); |
465 | i = RAM_Checksum((uint8_t*)&BLConfig, sizeof(BLConfig_t) - 1); |
466 | if(i != BLConfig.crc) return(BLCONFIG_ERR_CHECKSUM); // bad checksum |
466 | if(i != BLConfig.crc) return(BLCONFIG_ERR_CHECKSUM); // bad checksum |
467 | return(BLCONFIG_SUCCESS); |
467 | return(BLCONFIG_SUCCESS); |
468 | } |
468 | } |