瀏覽代碼

Commented old code removed

namrota ghosh 6 月之前
父節點
當前提交
e4824642e0
共有 1 個文件被更改,包括 0 次插入67 次删除
  1. 0 67
      src/controller/controller.c

+ 0 - 67
src/controller/controller.c

@@ -24,27 +24,9 @@ void controllerSetCurrent(uint8_t slot_id, int16_t current_mA){
     //Filling the buffer with current value
     *((int16_t*)(&txBuffer_setCurrent[1])) = current_mA;
     
-    
     //Write function from Controller MCU to target MCU:
     i2c_hal.write(target_address, txBuffer_setCurrent, 3);
 
-    // Wait for the bus to be not IDLE WITH a timeout
-    /*uint32_t timeout = 10000; 
-    while (!(DL_I2C_getControllerStatus(I2C_1_INST) & DL_I2C_CONTROLLER_STATUS_IDLE) && timeout--);
-    if(timeout == 0){
-        printf("Error in reading from I2C Bus: Bus is not getting ready before transmit start\n");
-        DL_I2C_resetControllerTransfer(I2C_1_INST); 
-    }
-    //Flush the TX FIFO and make the buffer ready for the transmit
-    DL_I2C_flushControllerTXFIFO(I2C_1_INST);
-    //Fill the txBuffer with Command (1 byte) and Current (2 bytes)
-    DL_I2C_fillControllerTXFIFO(I2C_1_INST, txBuffer_setCurrent, 3);
-    // Add delays
-    delay_cycles(1000);
-    //start the transfer
-    DL_I2C_startControllerTransfer(I2C_1_INST, target_address, DL_I2C_CONTROLLER_DIRECTION_TX, 3);
-    */
-
     uint32_t timeout= 32000;
     while((DL_I2C_getControllerStatus(I2C_1_INST) & DL_I2C_CONTROLLER_STATUS_BUSY) && timeout--);
     if(timeout==0){
@@ -121,33 +103,6 @@ bool controllerGetBatteryMeasurement(uint8_t slot_id){
 
     printf("[I2C] TX Packet Sent:: 0x%02X\n", txPacket.txBuffer[0]);
 
-    /*DL_I2C_flushControllerTXFIFO(I2C_1_INST);
-    DL_I2C_fillControllerTXFIFO(I2C_1_INST, (uint8_t *)&txPacket.txBuffer[0], 1); 
-    */
-
-    /* Wait for I2C to be Idle */
-    /*uint32_t timeout = 10000;
-    while (!(DL_I2C_getControllerStatus(I2C_1_INST) & DL_I2C_CONTROLLER_STATUS_IDLE) && timeout--);
-    if(timeout == 0){
-        printf("Error in reading from I2C Bus: Bus is not getting ready before transmit start\n");
-        DL_I2C_resetControllerTransfer(I2C_1_INST); 
-        return false;
-    }
-    */
-    
-
-    /* Send the packet to the controller.
-     * This function will send Start + Stop automatically.
-     */
-    /*DL_I2C_startControllerTransferAdvanced(I2C_1_INST,
-                                           target_address,
-                                           DL_I2C_CONTROLLER_DIRECTION_TX,
-                                           txPacket.txLen,
-                                           DL_I2C_CONTROLLER_START_ENABLE,
-                                           DL_I2C_CONTROLLER_STOP_ENABLE,
-                                           DL_I2C_CONTROLLER_ACK_ENABLE);
-    */
-    
     /* Poll until the Controller writes all bytes */
     uint32_t timeout= 32000;
     while(!(txPacket.txComplete) && timeout--);
@@ -165,30 +120,8 @@ bool controllerGetBatteryMeasurement(uint8_t slot_id){
     //Re-initialize timeout for the Rx
     timeout= 32000;
 
-
     //Calling helper function for i2c read:
     i2c_hal.read(target_address);
-
-    //Make RX Buffer ready to receive the data
-    //DL_I2C_flushControllerRXFIFO(I2C_1_INST);
-    
-    // Clear any garbage
-    /*memset(rxPacket.rxBuffer, 0, sizeof(rxPacket.rxBuffer));
-    
-    DL_I2C_enableInterrupt(I2C_1_INST, DL_I2C_INTERRUPT_CONTROLLER_RXFIFO_TRIGGER);
-    
-    while (DL_I2C_getControllerStatus(I2C_1_INST) & DL_I2C_CONTROLLER_STATUS_BUSY)
-    ;
-    
-
-    //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_address, DL_I2C_CONTROLLER_DIRECTION_RX, rxPacket.rxLen, DL_I2C_CONTROLLER_START_ENABLE,
-                                           DL_I2C_CONTROLLER_STOP_ENABLE,
-                                           DL_I2C_CONTROLLER_ACK_ENABLE);
-    */
     
     while(rxPacket.rxCount < rxPacket.rxLen && timeout--);
     if(timeout==0){