Kaynağa Gözat

Major updates for ADC12 and GPIO pins updated here for CC-CV

namrota ghosh 6 ay önce
ebeveyn
işleme
2f0471478e
2 değiştirilmiş dosya ile 75 ekleme ve 17 silme
  1. 33 4
      main.c
  2. 42 13
      main.syscfg

+ 33 - 4
main.c

@@ -10,7 +10,7 @@
 #include <stdio.h>
 #include "src/battery_data/battery.h"
 #include "mock_setup.h"
-
+#include "src/adc_peripheral/adc_singleConversion.h"
 
 //define the varibales:
 volatile bool picommandPending = false;
@@ -115,7 +115,32 @@ int main(void)
     NVIC_EnableIRQ(I2C_0_INST_INT_IRQN);
     //Interrupt for target mcu
     NVIC_EnableIRQ(I2C_1_INST_INT_IRQN);
+    NVIC_EnableIRQ(ADC_Controller_INST_INT_IRQN);
+
+    DL_GPIO_clearPins(GPIO_Battery_Charging_PIN_PB7_PORT, GPIO_Battery_Charging_PIN_PB7_PIN);
+    DL_GPIO_clearPins(GPIO_Battery_Discharging_PIN_PB6_PORT, GPIO_Battery_Discharging_PIN_PB6_PIN);
+
+    DL_GPIO_clearPins(GPIO_Battery_Charging_PIN_PB9_PORT, GPIO_Battery_Charging_PIN_PB9_PIN);
+    DL_GPIO_clearPins(GPIO_Battery_Discharging_PIN_PB8_PORT, GPIO_Battery_Discharging_PIN_PB8_PIN);
+
+    DL_GPIO_clearPins(GPIO_Battery_Charging_PIN_PB15_PORT, GPIO_Battery_Charging_PIN_PB15_PIN);
+    DL_GPIO_clearPins(GPIO_Battery_Discharging_PIN_PB14_PORT, GPIO_Battery_Discharging_PIN_PB14_PIN);
+
+    DL_GPIO_clearPins(GPIO_Battery_Charging_PIN_PA12_PORT, GPIO_Battery_Charging_PIN_PA12_PIN);
+    DL_GPIO_clearPins(GPIO_Battery_Discharging_PIN_PB16_PORT, GPIO_Battery_Discharging_PIN_PB16_PIN);
+
+    DL_GPIO_clearPins(GPIO_Battery_Charging_PIN_PB19_PORT, GPIO_Battery_Charging_PIN_PB19_PIN);
+    DL_GPIO_clearPins(GPIO_Battery_Discharging_PIN_PB18_PORT, GPIO_Battery_Discharging_PIN_PB18_PIN);
+
+    DL_GPIO_clearPins(GPIO_Battery_Charging_PIN_PB20_PORT, GPIO_Battery_Charging_PIN_PB20_PIN);
+    DL_GPIO_clearPins(GPIO_Battery_Discharging_PIN_PA22_PORT, GPIO_Battery_Discharging_PIN_PA22_PIN);
 
+    DL_GPIO_clearPins(GPIO_Battery_Charging_PIN_PA24_PORT, GPIO_Battery_Charging_PIN_PA24_PIN);
+    DL_GPIO_clearPins(GPIO_Battery_Discharging_PIN_PB24_PORT, GPIO_Battery_Discharging_PIN_PB24_PIN);
+
+    DL_GPIO_clearPins(GPIO_Battery_Charging_PIN_PA26_PORT, GPIO_Battery_Charging_PIN_PA26_PIN);
+    DL_GPIO_clearPins(GPIO_Battery_Discharging_PIN_PA25_PORT, GPIO_Battery_Discharging_PIN_PA25_PIN);
+    
     while(1)
     {   
         if(picommandPending)
@@ -125,9 +150,13 @@ int main(void)
         }
         
         //DL_SYSCTL_getPendingNonMaskableInterrupt();
-        
 
-        for(uint8_t slot_id= 0; slot_id< NUM_SLOTS; slot_id++){
+        //PWM
+        processPWMController();
+
+
+
+        /*for(uint8_t slot_id= 0; slot_id< NUM_SLOTS; slot_id++){
             //GET battery measurement from the Target
             getBatteryMeasurement(slot_id);
             //Reading battery state:
@@ -140,7 +169,7 @@ int main(void)
                 battery_data[slot_id].charge_fraction, battery_data[slot_id].capacitance, battery_data[slot_id].cut_off_current);
             }
         
-        }
+        }*/
         
     }
 }

+ 42 - 13
main.syscfg

@@ -30,14 +30,15 @@ const ProjectConfig = scripting.addModule("/ti/project_config/ProjectConfig");
 /**
  * Write custom configuration values to the imported modules.
  */
-ADC121.$name                             = "ADC_Controller";
-ADC121.sampClkDiv                        = "DL_ADC12_CLOCK_DIVIDE_8";
-ADC121.powerDownMode                     = "DL_ADC12_POWER_DOWN_MODE_MANUAL";
-ADC121.sampleTime0                       = "12.5 us";
-ADC121.enabledInterrupts                 = ["DL_ADC12_INTERRUPT_MEM0_RESULT_LOADED"];
-ADC121.peripheral.adcPin0.$assign        = "PA27";
-ADC121.adcPin0Config.hideOutputInversion = scripting.forceWrite(false);
-ADC121.adcPin0Config.$name               = "ti_driverlib_gpio_GPIOPinGeneric5";
+ADC121.$name                      = "ADC_Controller";
+ADC121.sampClkDiv                 = "DL_ADC12_CLOCK_DIVIDE_8";
+ADC121.powerDownMode              = "DL_ADC12_POWER_DOWN_MODE_MANUAL";
+ADC121.sampleTime0                = "12.5 us";
+ADC121.enabledInterrupts          = ["DL_ADC12_INTERRUPT_MEM0_RESULT_LOADED"];
+ADC121.sampClkSrc                 = "DL_ADC12_CLOCK_ULPCLK";
+ADC121.adcMem0chansel             = "DL_ADC12_INPUT_CHAN_4";
+ADC121.peripheral.adcPin4.$assign = "PB17";
+ADC121.adcPin4Config.$name        = "ti_driverlib_gpio_GPIOPinGeneric5";
 
 Board.configureUnused             = true;
 Board.peripheral.$assign          = "DEBUGSS";
@@ -45,14 +46,42 @@ Board.peripheral.swclkPin.$assign = "PA20";
 Board.peripheral.swdioPin.$assign = "PA19";
 
 GPIO1.$name                         = "GPIO_Battery_Charging";
-GPIO1.port                          = "PORTB";
+GPIO1.associatedPins.create(8);
 GPIO1.associatedPins[0].$name       = "PIN_PB7";
 GPIO1.associatedPins[0].pin.$assign = "PB7";
+GPIO1.associatedPins[1].$name       = "PIN_PB9";
+GPIO1.associatedPins[1].pin.$assign = "PB9";
+GPIO1.associatedPins[2].$name       = "PIN_PB15";
+GPIO1.associatedPins[2].pin.$assign = "PB15";
+GPIO1.associatedPins[3].$name       = "PIN_PA12";
+GPIO1.associatedPins[3].pin.$assign = "PA12";
+GPIO1.associatedPins[4].$name       = "PIN_PB19";
+GPIO1.associatedPins[4].pin.$assign = "PB19";
+GPIO1.associatedPins[5].$name       = "PIN_PB20";
+GPIO1.associatedPins[5].pin.$assign = "PB20";
+GPIO1.associatedPins[6].$name       = "PIN_PA24";
+GPIO1.associatedPins[6].pin.$assign = "PA24";
+GPIO1.associatedPins[7].$name       = "PIN_PA26";
+GPIO1.associatedPins[7].pin.$assign = "PA26";
 
 GPIO2.$name                         = "GPIO_Battery_Discharging";
-GPIO2.port                          = "PORTB";
+GPIO2.associatedPins.create(8);
 GPIO2.associatedPins[0].$name       = "PIN_PB6";
-GPIO2.associatedPins[0].pin.$assign = "PB6";
+GPIO2.associatedPins[0].pin.$assign = "PA6";
+GPIO2.associatedPins[1].$name       = "PIN_PB8";
+GPIO2.associatedPins[1].pin.$assign = "PB8";
+GPIO2.associatedPins[2].$name       = "PIN_PB14";
+GPIO2.associatedPins[2].pin.$assign = "PB14";
+GPIO2.associatedPins[3].$name       = "PIN_PB16";
+GPIO2.associatedPins[3].pin.$assign = "PB16";
+GPIO2.associatedPins[4].$name       = "PIN_PB18";
+GPIO2.associatedPins[4].pin.$assign = "PB18";
+GPIO2.associatedPins[5].$name       = "PIN_PA22";
+GPIO2.associatedPins[5].pin.$assign = "PA22";
+GPIO2.associatedPins[6].$name       = "PIN_PB24";
+GPIO2.associatedPins[6].pin.$assign = "PB24";
+GPIO2.associatedPins[7].$name       = "PIN_PA25";
+GPIO2.associatedPins[7].pin.$assign = "PA25";
 
 GPIO3.port                          = "PORTA";
 GPIO3.$name                         = "GPIO_ADDR_PINS";
@@ -104,9 +133,9 @@ I2C2.sclPinConfig.$name        = "ti_driverlib_gpio_GPIOPinGeneric3";
 I2C2.sclPinConfig.enableConfig = true;
 
 PWM1.$name                      = "PWM_0";
-PWM1.timerCount                 = 320;
 PWM1.timerStartTimer            = true;
 PWM1.ccIndex                    = [0];
+PWM1.timerCount                 = 320;
 PWM1.peripheral.ccp0Pin.$assign = "PA5";
 PWM1.PWM_CHANNEL_0.$name        = "ti_driverlib_pwm_PWMTimerCC0";
 PWM1.PWM_CHANNEL_0.invert       = true;
@@ -132,5 +161,5 @@ ProjectConfig.migrationCondition = true;
  * version of the tool will not impact the pinmux you originally saw.  These lines can be completely deleted in order to
  * re-solve from scratch.
  */
-ADC121.peripheral.$suggestSolution = "ADC0";
+ADC121.peripheral.$suggestSolution = "ADC1";
 PWM1.peripheral.$suggestSolution   = "TIMG6";