|
|
@@ -44,21 +44,21 @@ void controller_SetCurrent(uint8_t slot_id, int16_t current_mA){
|
|
|
printf("Tx transmit not completed");
|
|
|
}
|
|
|
printf("STATUS ***SetCurrent successful for slot %d with current %d mA***\n", slot_id, current_mA);
|
|
|
- // Clean up and exit
|
|
|
- //DL_I2C_flushControllerTXFIFO(I2C_1_INST);
|
|
|
|
|
|
}
|
|
|
|
|
|
//Clear error flag to the target to change it back to SLOT_STATE_OK
|
|
|
//Format: command + ((slot_id) + data (optional))
|
|
|
-void controller_ClearError(uint8_t const TARGET_ADDRESS, uint8_t slot_id){
|
|
|
+void controller_ClearError(uint8_t slot_id){
|
|
|
+ uint8_t target_address= TARGET_BASE_ADDRESS + ((slot_id & 0b00000100) >> 2);
|
|
|
+ printf("Target Address 0x%02X \n", target_address);
|
|
|
uint8_t command= CMD_CLEAR_ERR| (slot_id<<4); //shift slot_id to the left by 4 bits
|
|
|
printf("[MCU] Clear Error Bitmasked Command:: 0x%02X\n", command);
|
|
|
txPacket.txBuffer[0]= command;
|
|
|
txPacket.txBuffer[1]= slot_id;
|
|
|
txPacket.txLen= sizeof(txPacket.txBuffer);
|
|
|
while (DL_I2C_getControllerStatus(I2C_1_INST) & DL_I2C_CONTROLLER_STATUS_BUSY_BUS);
|
|
|
- DL_I2C_startControllerTransfer(I2C_1_INST, TARGET_ADDRESS, DL_I2C_CONTROLLER_DIRECTION_TX, txPacket.txLen);
|
|
|
+ DL_I2C_startControllerTransfer(I2C_1_INST, target_address, DL_I2C_CONTROLLER_DIRECTION_TX, txPacket.txLen);
|
|
|
DL_I2C_fillControllerTXFIFO(I2C_1_INST, txPacket.txBuffer, txPacket.txLen);
|
|
|
while (DL_I2C_getControllerStatus(I2C_1_INST) & DL_I2C_CONTROLLER_STATUS_BUSY_BUS);
|
|
|
DL_I2C_flushControllerTXFIFO(I2C_1_INST);
|
|
|
@@ -123,7 +123,7 @@ bool getBatteryMeasurement(uint8_t slot_id){
|
|
|
* This function will send Start + Stop automatically.
|
|
|
*/
|
|
|
DL_I2C_startControllerTransferAdvanced(I2C_1_INST,
|
|
|
- TARGET_BASE_ADDRESS,
|
|
|
+ target_address,
|
|
|
DL_I2C_CONTROLLER_DIRECTION_TX,
|
|
|
txPacket.txLen,
|
|
|
DL_I2C_CONTROLLER_START_ENABLE,
|
|
|
@@ -161,7 +161,7 @@ bool getBatteryMeasurement(uint8_t slot_id){
|
|
|
//while (DL_I2C_getControllerStatus(I2C_INST) & DL_I2C_CONTROLLER_STATUS_BUSY_BUS);
|
|
|
|
|
|
/* Send a read request to Target */
|
|
|
- DL_I2C_startControllerTransferAdvanced(I2C_1_INST, TARGET_BASE_ADDRESS, DL_I2C_CONTROLLER_DIRECTION_RX, rxPacket.rxLen, DL_I2C_CONTROLLER_START_ENABLE,
|
|
|
+ DL_I2C_startControllerTransferAdvanced(I2C_1_INST, target_address, DL_I2C_CONTROLLER_DIRECTION_RX, rxPacket.rxLen, DL_I2C_CONTROLLER_START_ENABLE,
|
|
|
DL_I2C_CONTROLLER_STOP_ENABLE,
|
|
|
DL_I2C_CONTROLLER_ACK_ENABLE);
|
|
|
|