|
@@ -238,22 +238,22 @@ void controller_EvaluateBatterySlotState(uint8_t slot_id, BatteryMeasurement *me
|
|
|
bool getBatteryMeasurement_test(){
|
|
bool getBatteryMeasurement_test(){
|
|
|
|
|
|
|
|
//Enable the interrupt:
|
|
//Enable the interrupt:
|
|
|
- DL_I2C_enableInterrupt(I2C_INST, DL_I2C_INTERRUPT_CONTROLLER_TXFIFO_TRIGGER);
|
|
|
|
|
|
|
+ DL_I2C_enableInterrupt(I2C_1_INST, DL_I2C_INTERRUPT_CONTROLLER_TXFIFO_TRIGGER);
|
|
|
txPacket.txComplete= false;
|
|
txPacket.txComplete= false;
|
|
|
/* Wait for I2C to be Idle */
|
|
/* Wait for I2C to be Idle */
|
|
|
uint32_t timeout = 10000;
|
|
uint32_t timeout = 10000;
|
|
|
- while (!(DL_I2C_getControllerStatus(I2C_INST) & DL_I2C_CONTROLLER_STATUS_IDLE) && timeout--);
|
|
|
|
|
|
|
+ while (!(DL_I2C_getControllerStatus(I2C_1_INST) & DL_I2C_CONTROLLER_STATUS_IDLE) && timeout--);
|
|
|
if(timeout == 0){
|
|
if(timeout == 0){
|
|
|
printf("Error in reading from I2C Bus: Bus is not getting ready before transmit start\n");
|
|
printf("Error in reading from I2C Bus: Bus is not getting ready before transmit start\n");
|
|
|
- DL_I2C_resetControllerTransfer(I2C_INST);
|
|
|
|
|
|
|
+ DL_I2C_resetControllerTransfer(I2C_1_INST);
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* Send the packet to the controller.
|
|
/* Send the packet to the controller.
|
|
|
* This function will send Start + Stop automatically.
|
|
* This function will send Start + Stop automatically.
|
|
|
*/
|
|
*/
|
|
|
- DL_I2C_startControllerTransferAdvanced(I2C_INST,
|
|
|
|
|
- 0x49,
|
|
|
|
|
|
|
+ DL_I2C_startControllerTransferAdvanced(I2C_1_INST,
|
|
|
|
|
+ TARGET_BASE_ADDRESS,
|
|
|
DL_I2C_CONTROLLER_DIRECTION_TX,
|
|
DL_I2C_CONTROLLER_DIRECTION_TX,
|
|
|
1,
|
|
1,
|
|
|
DL_I2C_CONTROLLER_START_ENABLE,
|
|
DL_I2C_CONTROLLER_START_ENABLE,
|
|
@@ -267,7 +267,7 @@ bool getBatteryMeasurement_test(){
|
|
|
while(!(txPacket.txComplete) && timeout--);
|
|
while(!(txPacket.txComplete) && timeout--);
|
|
|
if(timeout == 0){
|
|
if(timeout == 0){
|
|
|
printf("Tx Transmit not completed.\n");
|
|
printf("Tx Transmit not completed.\n");
|
|
|
- DL_I2C_resetControllerTransfer(I2C_INST);
|
|
|
|
|
|
|
+ DL_I2C_resetControllerTransfer(I2C_1_INST);
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -278,9 +278,9 @@ bool getBatteryMeasurement_test(){
|
|
|
rxPacket.rxComplete= false;
|
|
rxPacket.rxComplete= false;
|
|
|
timeout= 32000;
|
|
timeout= 32000;
|
|
|
|
|
|
|
|
- DL_I2C_flushControllerRXFIFO(I2C_INST);
|
|
|
|
|
|
|
+ DL_I2C_flushControllerRXFIFO(I2C_1_INST);
|
|
|
|
|
|
|
|
- DL_I2C_enableInterrupt(I2C_INST, DL_I2C_INTERRUPT_CONTROLLER_RXFIFO_TRIGGER);
|
|
|
|
|
|
|
+ DL_I2C_enableInterrupt(I2C_1_INST, DL_I2C_INTERRUPT_CONTROLLER_RXFIFO_TRIGGER);
|
|
|
|
|
|
|
|
while(!(rxPacket.rxComplete) && timeout--);
|
|
while(!(rxPacket.rxComplete) && timeout--);
|
|
|
if(timeout==0){
|
|
if(timeout==0){
|
|
@@ -290,11 +290,11 @@ bool getBatteryMeasurement_test(){
|
|
|
//while (DL_I2C_getControllerStatus(I2C_INST) & DL_I2C_CONTROLLER_STATUS_BUSY_BUS);
|
|
//while (DL_I2C_getControllerStatus(I2C_INST) & DL_I2C_CONTROLLER_STATUS_BUSY_BUS);
|
|
|
|
|
|
|
|
/* Send a read request to Target */
|
|
/* Send a read request to Target */
|
|
|
- DL_I2C_startControllerTransferAdvanced(I2C_INST, 0x49, DL_I2C_CONTROLLER_DIRECTION_RX, 8, DL_I2C_CONTROLLER_START_ENABLE,
|
|
|
|
|
|
|
+ DL_I2C_startControllerTransferAdvanced(I2C_1_INST, TARGET_BASE_ADDRESS, DL_I2C_CONTROLLER_DIRECTION_RX, rxPacket.rxLen, DL_I2C_CONTROLLER_START_ENABLE,
|
|
|
DL_I2C_CONTROLLER_STOP_ENABLE,
|
|
DL_I2C_CONTROLLER_STOP_ENABLE,
|
|
|
DL_I2C_CONTROLLER_ACK_ENABLE);
|
|
DL_I2C_CONTROLLER_ACK_ENABLE);
|
|
|
|
|
|
|
|
- while (DL_I2C_getControllerStatus(I2C_INST) & DL_I2C_CONTROLLER_STATUS_BUSY)
|
|
|
|
|
|
|
+ while (DL_I2C_getControllerStatus(I2C_1_INST) & DL_I2C_CONTROLLER_STATUS_BUSY)
|
|
|
;
|
|
;
|
|
|
|
|
|
|
|
|
|
|