浏览代码

Fixes:
* Error-Handling in der Main wieder aktiviert
* DAC Initialisierung auf 0 gesetzt
* Cleanup im I2C: While-loop für fifo entfernt

Heinrich Blatt 6 月之前
父节点
当前提交
16c3c8623f
共有 3 个文件被更改,包括 7 次插入8 次删除
  1. 6 5
      main_target.c
  2. 1 0
      src/battery_data/battery.c
  3. 0 3
      src/interfaces/i2c_target.c

+ 6 - 5
main_target.c

@@ -98,10 +98,11 @@ int main(void)
 
 {   
     SYSCFG_DL_init();
-    battery_slotmgr.init();
     NVIC_EnableIRQ(I2C_controller_INST_INT_IRQN);
     NVIC_EnableIRQ(I2C_target_INST_INT_IRQN);
 
+    battery_slotmgr.init();
+
     initialize_target_address();
 
     while (1) {
@@ -118,11 +119,11 @@ int main(void)
             // step 2: control loop to adjust the dac / adc values,
             // but only if no error happens
             // (0x80 is the error flag of the state)
-            //if ((*battery_slots[slot].state & 0x80) == 0) {
+            if ((*battery_slots[slot].state & 0x80) == 0) {
                 battery_slotmgr.adjust_current(slot);
-            //} else {
-            //    battery_slotmgr.disable(slot);
-            //}
+            } else {
+                battery_slotmgr.disable(slot);
+            }
         }
         
         delay_cycles(MAINLOOP_DELAY);

+ 1 - 0
src/battery_data/battery.c

@@ -58,6 +58,7 @@ static void batteryslots_init() {
 
         DL_TimerG_startCounter(battery_slots[i].timer);
         set_pwm(i, 0);
+        set_dac(i, 0);
         delay_cycles(PWM_INITIALIZATION_DELAY);
     }
 

+ 0 - 3
src/interfaces/i2c_target.c

@@ -45,9 +45,6 @@ int8_t mcu_i2c_handle(I2C_Regs *i2c) {
     if (receivedCommand == CMD_GET_MEASUREMENT) {
         DL_I2C_flushTargetTXFIFO(i2c);
         DL_I2C_fillTargetTXFIFO(i2c, (uint8_t *)&battery_slots[slot].measurement, 8);
-        //wait until all bytes are written and sent to the Controller
-        uint16_t timeout = 32000;
-        while(!(DL_I2C_isTargetTXFIFOEmpty(i2c)) && timeout-- > 0);
     } else if (receivedCommand == CMD_SET_CURRENT) {
         return slot;
     } else if (receivedCommand == CMD_CLEAR_ERR) {