Explorar o código

Merge branch '4pwm-config' into control-and-refacotring-improvements

Heinrich Blatt hai 7 meses
pai
achega
b516164b78
Modificáronse 3 ficheiros con 57 adicións e 13 borrados
  1. 49 10
      main_target.syscfg
  2. 6 1
      src/battery_data/battery.c
  3. 2 2
      src/config.h

+ 49 - 10
main_target.syscfg

@@ -16,6 +16,9 @@ const I2C1          = I2C.addInstance();
 const I2C2          = I2C.addInstance();
 const PWM           = scripting.addModule("/ti/driverlib/PWM", {}, false);
 const PWM1          = PWM.addInstance();
+const PWM2          = PWM.addInstance();
+const PWM3          = PWM.addInstance();
+const PWM4          = PWM.addInstance();
 const SYSCTL        = scripting.addModule("/ti/driverlib/SYSCTL");
 const ProjectConfig = scripting.addModule("/ti/project_config/ProjectConfig");
 
@@ -25,7 +28,7 @@ const ProjectConfig = scripting.addModule("/ti/project_config/ProjectConfig");
 GPIO1.$name                         = "GPIOS";
 GPIO1.associatedPins[0].direction   = "INPUT";
 GPIO1.associatedPins[0].$name       = "ADDR";
-GPIO1.associatedPins[0].pin.$assign = "PA22";
+GPIO1.associatedPins[0].pin.$assign = "PA24/OPA0.IN0-";
 
 const Board                       = scripting.addModule("/ti/driverlib/Board", {}, false);
 Board.peripheral.$assign          = "DEBUGSS";
@@ -68,14 +71,51 @@ I2C2.sclPinConfig.onlyInternalResistor = scripting.forceWrite(false);
 I2C2.sclPinConfig.passedPeripheralType = scripting.forceWrite("Digital");
 I2C2.sclPinConfig.enableConfig         = true;
 
-PWM1.$name                      = "PWM_0";
-PWM1.ccIndex                    = [0];
-PWM1.timerCount                 = 320;
-PWM1.timerStartTimer            = true;
-PWM1.peripheral.ccp0Pin.$assign = "PA26";
-PWM1.PWM_CHANNEL_0.$name        = "ti_driverlib_pwm_PWMTimerCC0";
-PWM1.PWM_CHANNEL_0.dutyCycle    = 10;
-PWM1.ccp0PinConfig.$name        = "ti_driverlib_gpio_GPIOPinGeneric4";
+PWM1.timerCount                         = 320;
+PWM1.timerStartTimer                    = true;
+PWM1.ccIndex                            = [1];
+PWM1.$name                              = "PWM_3";
+PWM1.peripheral.$assign                 = "TIMG0";
+PWM1.peripheral.ccp1Pin.$assign         = "PA6";
+PWM1.ccp1PinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric11";
+PWM1.ccp1PinConfig.direction            = scripting.forceWrite("OUTPUT");
+PWM1.ccp1PinConfig.hideOutputInversion  = scripting.forceWrite(false);
+PWM1.ccp1PinConfig.onlyInternalResistor = scripting.forceWrite(false);
+PWM1.ccp1PinConfig.passedPeripheralType = scripting.forceWrite("Digital");
+PWM1.PWM_CHANNEL_1.$name                = "ti_driverlib_pwm_PWMTimerCC0";
+
+PWM2.ccIndex                            = [1];
+PWM2.$name                              = "PWM_2";
+PWM2.peripheral.$assign                 = "TIMG1";
+PWM2.peripheral.ccp1Pin.$assign         = "PA2";
+PWM2.ccp1PinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric6";
+PWM2.ccp1PinConfig.direction            = scripting.forceWrite("OUTPUT");
+PWM2.ccp1PinConfig.hideOutputInversion  = scripting.forceWrite(false);
+PWM2.ccp1PinConfig.onlyInternalResistor = scripting.forceWrite(false);
+PWM2.ccp1PinConfig.passedPeripheralType = scripting.forceWrite("Digital");
+PWM2.PWM_CHANNEL_1.$name                = "ti_driverlib_pwm_PWMTimerCC1";
+
+PWM3.ccIndex                            = [1];
+PWM3.$name                              = "PWM_1";
+PWM3.peripheral.$assign                 = "TIMG2";
+PWM3.peripheral.ccp1Pin.$assign         = "PA22";
+PWM3.ccp1PinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric8";
+PWM3.ccp1PinConfig.direction            = scripting.forceWrite("OUTPUT");
+PWM3.ccp1PinConfig.hideOutputInversion  = scripting.forceWrite(false);
+PWM3.ccp1PinConfig.onlyInternalResistor = scripting.forceWrite(false);
+PWM3.ccp1PinConfig.passedPeripheralType = scripting.forceWrite("Digital");
+PWM3.PWM_CHANNEL_1.$name                = "ti_driverlib_pwm_PWMTimerCC2";
+
+PWM4.ccIndex                            = [1];
+PWM4.$name                              = "PWM_0";
+PWM4.peripheral.$assign                 = "TIMG4";
+PWM4.peripheral.ccp1Pin.$assign         = "PA25";
+PWM4.ccp1PinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric10";
+PWM4.ccp1PinConfig.direction            = scripting.forceWrite("OUTPUT");
+PWM4.ccp1PinConfig.hideOutputInversion  = scripting.forceWrite(false);
+PWM4.ccp1PinConfig.onlyInternalResistor = scripting.forceWrite(false);
+PWM4.ccp1PinConfig.passedPeripheralType = scripting.forceWrite("Digital");
+PWM4.PWM_CHANNEL_1.$name                = "ti_driverlib_pwm_PWMTimerCC3";
 
 SYSCTL.disableNRSTPin     = true;
 SYSCTL.peripheral.$assign = "SYSCTL";
@@ -88,4 +128,3 @@ ProjectConfig.migrationCondition = true;
  * re-solve from scratch.
  */
 I2C2.peripheral.$suggestSolution = "I2C0";
-PWM1.peripheral.$suggestSolution = "TIMG1";

+ 6 - 1
src/battery_data/battery.c

@@ -17,7 +17,7 @@ static void set_dac(uint8_t slot, uint16_t value) {
 }
 static void set_pwm(uint8_t slot, uint16_t value) {
     battery_slots[slot].pwm_value = value;
-    DL_TimerG_setCaptureCompareValue(battery_slots[0].timer, value, DL_TIMER_CC_0_INDEX);
+    DL_TimerG_setCaptureCompareValue(battery_slots[0].timer, value, DL_TIMER_CC_1_INDEX);
 }
 static void batteryslots_disable(uint8_t slot) {
     if (battery_slots[slot].dac_value != 0) {
@@ -33,6 +33,11 @@ static void batteryslots_init() {
 
     // initialize data structures
     battery_slots[0].timer = PWM_0_INST;
+#if NUM_SLOTS == 4
+    battery_slots[1].timer = PWM_1_INST;
+    battery_slots[2].timer = PWM_2_INST;
+    battery_slots[3].timer = PWM_3_INST;
+#endif
 
     for(uint8_t i=0; i< NUM_SLOTS; i++){
 

+ 2 - 2
src/config.h

@@ -5,7 +5,7 @@
 
 // How many slots do we currently support?
 // use 1 for debugging, 4 for production
-#define NUM_SLOTS 1
+#define NUM_SLOTS 4
 
 //Battery Tolerance
 // how much tolerance do we allow if we charge / discharge before we 
@@ -86,4 +86,4 @@
 // controller mode only
 // (target for the other MCU is treated differently)
 #define I2C_TX_MAX_PACKET_SIZE 5
-#define I2C_RX_MAX_PACKET_SIZE 5  
+#define I2C_RX_MAX_PACKET_SIZE 5