|
|
@@ -38,24 +38,16 @@ void controllerSetCurrent(uint8_t slot_id, int16_t current_mA){
|
|
|
|
|
|
//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 slot_id){
|
|
|
+void controllerClearError(uint8_t slot_id){
|
|
|
|
|
|
//For dynamic addressing:
|
|
|
uint8_t target_address= TARGET_BASE_ADDRESS + ((slot_id & 0b00000100) >> 2);
|
|
|
printf("Target Address 0x%02X \n", target_address);
|
|
|
|
|
|
//Tx Buffer:
|
|
|
- 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_fillControllerTXFIFO(I2C_1_INST, (uint8_t *)&txPacket.txBuffer, txPacket.txLen);
|
|
|
- while (DL_I2C_getControllerStatus(I2C_1_INST) & DL_I2C_CONTROLLER_STATUS_BUSY_BUS);
|
|
|
- DL_I2C_flushControllerTXFIFO(I2C_1_INST);
|
|
|
+ uint8_t txBuffer_clearError[1];
|
|
|
+ txBuffer_clearError[0]= CMD_CLEAR_ERR| (slot_id<<4); //shift slot_id to the left by 4 bits
|
|
|
+ i2c_hal.write(target_address, (uint8_t *)&txBuffer_clearError, 1);
|
|
|
}
|
|
|
|
|
|
|