|
|
@@ -12,11 +12,9 @@
|
|
|
|
|
|
|
|
|
//define the varibales:
|
|
|
-volatile bool mcuSendCommand = false;
|
|
|
volatile bool picommandPending = false;
|
|
|
volatile bool watchdog_triggered= false;
|
|
|
-volatile uint8_t current_command= 0x06;
|
|
|
-volatile bool txCommandSent= false;
|
|
|
+
|
|
|
|
|
|
// Interrupt for I2C instance -> MCU to Target
|
|
|
|
|
|
@@ -28,8 +26,7 @@ void I2C_1_INST_IRQHandler(void)
|
|
|
break;
|
|
|
|
|
|
case DL_I2C_IIDX_CONTROLLER_RXFIFO_TRIGGER:
|
|
|
- mcuSendCommand= true;
|
|
|
-
|
|
|
+
|
|
|
while(DL_I2C_isControllerRXFIFOEmpty(I2C_1_INST) != true) {
|
|
|
if(rxPacket.rxCount < rxPacket.rxLen){
|
|
|
//Get byte from the I2C RX FIFO of the target
|
|
|
@@ -49,13 +46,11 @@ void I2C_1_INST_IRQHandler(void)
|
|
|
|
|
|
case DL_I2C_IIDX_CONTROLLER_TXFIFO_TRIGGER:
|
|
|
/* Fill TX FIFO with bytes to send */
|
|
|
- mcuSendCommand = true;
|
|
|
- DL_I2C_fillControllerTXFIFO(I2C_1_INST, (uint8_t *)&txPacket.txBuffer[0], 1);
|
|
|
+ //DL_I2C_fillControllerTXFIFO(I2C_1_INST, (uint8_t *)&txPacket.txBuffer[0], 1);
|
|
|
txPacket.txComplete= true;
|
|
|
break;
|
|
|
|
|
|
case DL_I2C_IIDX_CONTROLLER_STOP:
|
|
|
- mcuSendCommand = true;
|
|
|
rxPacket.rxComplete= true;
|
|
|
txPacket.txComplete= true;
|
|
|
DL_I2C_flushControllerRXFIFO(I2C_1_INST);
|
|
|
@@ -122,12 +117,7 @@ int main(void)
|
|
|
pi_i2c_mcu();
|
|
|
picommandPending = false;
|
|
|
}
|
|
|
- if(mcuSendCommand){
|
|
|
- //printf("MCU Interrupt Triggered.\n");
|
|
|
- //getBatteryMeasurement_test();
|
|
|
- mcuSendCommand = false;
|
|
|
-
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
for(uint8_t slot_id= 0; slot_id< NUM_SLOTS; slot_id++){
|
|
|
//GET battery measurement from the Target
|