Forráskód Böngészése

ADC read from the Controller Board, added logic for LED ERROR togggling

namrota ghosh 6 hónapja
szülő
commit
39ccbba6bb
1 módosított fájl, 10 hozzáadás és 2 törlés
  1. 10 2
      src/adc_peripheral/adc_singleConversion.c

+ 10 - 2
src/adc_peripheral/adc_singleConversion.c

@@ -1,6 +1,6 @@
 #include "ti_msp_dl_config.h"
 #include "src/battery_data/battery.h"
-
+#include <stdio.h>
 
 /* ADC variables:
  * bare_voltage gets the ADC value from the memory register
@@ -13,6 +13,8 @@ bool checkADC = false;
 void processADC(){
     uint16_t gADCvoltage= 0;
     int16_t gADCcurrent= 0;
+
+
     //Start the ADC Sampling:
     DL_ADC12_startConversion(ADC_Controller_INST);
 
@@ -32,8 +34,14 @@ void processADC(){
     gADCvoltage = bare_voltage*(56+100)/56; // Because of the voltage divider
     gADCcurrent= bare_voltage*10/1000;
 
+    printf("ADC Voltage Read on Controller Board: %d\n", gADCvoltage);
+    printf("ADC Current Received:%d\n", gADCcurrent);
     
-
+    //If the controller exceeds HOV_THRESHOLD then
+    if(gADCvoltage >= (HOV_THRESHOLD_MV - CONTROLLER_HYSTERESIS)){
+        printf("Controller HOV state\n");
+        DL_GPIO_togglePins(GPIO_ControllerBoard_PORT, GPIO_ControllerBoard_LED_Error_PIN);
+    }
     checkADC = false;
     DL_ADC12_enableConversions(ADC_Controller_INST);
 }