Explorar o código

printf statements

namrota ghosh hai 8 meses
pai
achega
77f112888d
Modificáronse 3 ficheiros con 9 adicións e 8 borrados
  1. 5 4
      main_target.c
  2. 1 1
      src/i2c_comm/mcu_slave_interface.c
  3. 3 3
      src/peripherals/adc/adc_hal.c

+ 5 - 4
main_target.c

@@ -160,7 +160,7 @@ int main(void)
     SYSCFG_DL_init();
     Battery_Init();
     NVIC_EnableIRQ(I2C_controller_INST_INT_IRQN);
-    //NVIC_EnableIRQ(I2C_target_INST_INT_IRQN);
+    NVIC_EnableIRQ(I2C_target_INST_INT_IRQN);
 
 
     /*printf("&gRxPacket:     %p\n", (void*)gRxPacket);
@@ -170,13 +170,14 @@ int main(void)
     printf("&gTxADClen:     %p\n", (void*)&gTxADClen);
     */
     
-    printf("Memory address of batteries: %p\n", &batteries[0]);
+    //printf("Memory address of batteries: %p\n", &batteries[0]);
     while (1) {
-        /*if(mcu_CommandPending){
+
+        if(mcu_CommandPending){
             mcu_i2c_handle(I2C_target_INST);
             mcu_CommandPending= false;
             continue;
-        }*/
+        }
         
         for(uint8_t slot= 0; slot< NUM_SLOTS; slot++){
             for(uint8_t channel= 0; channel< 2; channel++){

+ 1 - 1
src/i2c_comm/mcu_slave_interface.c

@@ -15,7 +15,7 @@ References: https://stackoverflow.com/questions/246127/why-is-volatile-needed-in
 void mcu_i2c_handle(I2C_Regs *i2c) {
   //printf("MCU interrupt triggered\n");
   uint8_t receivedCommand = DL_I2C_receiveTargetData(i2c);
-  printf("[SLAVE] Received Command: 0x%02X\n", receivedCommand);
+  //printf("[SLAVE] Received Command: 0x%02X\n", receivedCommand);
   uint8_t tx_buffer[8] = {0};
   //changed to volatile variable, so that the compiler cannot optimize the variable out and is forced to do as told by the code
   volatile uint8_t rx_buffer[8] = {0};

+ 3 - 3
src/peripherals/adc/adc_hal.c

@@ -115,11 +115,11 @@ static uint8_t construct_config_byte(ADC_Params *params) {
  * I2C*/
 
 static bool adc_configure(uint8_t slot_id, ADC_Params *params) {
-  printf("Configuring for channel: %d\n", params->channel);
+  /*printf("Configuring for channel: %d\n", params->channel);
   printf("Configuring for resolution: %d\n", params->resolution);
   printf("Configuring for gain: %d\n", params->gain); 
   printf("Continuous or Single: %d\n", params->continuous);
-  
+  */
   uint8_t config_byte = construct_config_byte(params);
   printf("Config Byte: 0x%02X\n", config_byte);
   // Wait for I2C Bus to be Free**
@@ -127,7 +127,7 @@ static bool adc_configure(uint8_t slot_id, ADC_Params *params) {
          DL_I2C_CONTROLLER_STATUS_BUSY_BUS)
     ;
   if(config_byte == 0xFF){
-    //printf("[ADC] Unable to send config bytes\n");
+    printf("[ADC] Unable to send config bytes\n");
     return false;
   } 
   // Prepare TX Buffer: