Explorar o código

Battery Measurement is being received by the controller

namrota ghosh hai 7 meses
pai
achega
0ac9006a98
Modificáronse 1 ficheiros con 6 adicións e 2 borrados
  1. 6 2
      src/controller/controller.c

+ 6 - 2
src/controller/controller.c

@@ -63,9 +63,12 @@ bool controller_GetBatteryMeasurement(uint8_t const TARGET_ADDRESS, uint8_t slot
     //Receive the data from the target:
     //BatteryMeasurement size is 12 similar to the target side
     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)){
-            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]);
             rx_index++;
         }
@@ -83,6 +86,7 @@ bool controller_GetBatteryMeasurement(uint8_t const TARGET_ADDRESS, uint8_t slot
     printf("Voltage: %u\n", measurement.voltage);
     printf("Current: %d\n",  measurement.current);
     printf("Temp:    %u\n", measurement.temperature);
+    printf("Slot state:    %u\n", measurement.slot_state);
     DL_I2C_flushControllerRXFIFO(I2C_1_INST);
     return true;
 }