|
@@ -63,9 +63,12 @@ bool controller_GetBatteryMeasurement(uint8_t const TARGET_ADDRESS, uint8_t slot
|
|
|
//Receive the data from the target:
|
|
//Receive the data from the target:
|
|
|
//BatteryMeasurement size is 12 similar to the target side
|
|
//BatteryMeasurement size is 12 similar to the target side
|
|
|
DL_I2C_startControllerTransfer(I2C_1_INST, TARGET_ADDRESS, DL_I2C_CONTROLLER_DIRECTION_RX, sizeof(BatteryMeasurement));
|
|
DL_I2C_startControllerTransfer(I2C_1_INST, TARGET_ADDRESS, DL_I2C_CONTROLLER_DIRECTION_RX, sizeof(BatteryMeasurement));
|
|
|
- while((rx_index < sizeof(BatteryMeasurement)) && timeout > 0){
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ while((rx_index < sizeof(BatteryMeasurement)) && (timeout > 0)){
|
|
|
if(!DL_I2C_isControllerRXFIFOEmpty(I2C_1_INST)){
|
|
if(!DL_I2C_isControllerRXFIFOEmpty(I2C_1_INST)){
|
|
|
- rx_packet.rxBuffer[rx_index]= DL_I2C_receiveTargetData(I2C_1_INST);
|
|
|
|
|
|
|
+ //Get byte from the I2C RX FIFO of the target
|
|
|
|
|
+ rx_packet.rxBuffer[rx_index]= DL_I2C_receiveControllerData(I2C_1_INST);
|
|
|
//printf("Received Bytes[%d]: 0x%02X\n", rx_index, buffer[rx_index]);
|
|
//printf("Received Bytes[%d]: 0x%02X\n", rx_index, buffer[rx_index]);
|
|
|
rx_index++;
|
|
rx_index++;
|
|
|
}
|
|
}
|
|
@@ -83,6 +86,7 @@ bool controller_GetBatteryMeasurement(uint8_t const TARGET_ADDRESS, uint8_t slot
|
|
|
printf("Voltage: %u\n", measurement.voltage);
|
|
printf("Voltage: %u\n", measurement.voltage);
|
|
|
printf("Current: %d\n", measurement.current);
|
|
printf("Current: %d\n", measurement.current);
|
|
|
printf("Temp: %u\n", measurement.temperature);
|
|
printf("Temp: %u\n", measurement.temperature);
|
|
|
|
|
+ printf("Slot state: %u\n", measurement.slot_state);
|
|
|
DL_I2C_flushControllerRXFIFO(I2C_1_INST);
|
|
DL_I2C_flushControllerRXFIFO(I2C_1_INST);
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|