/**
 * These arguments were used when this file was generated. They will be automatically applied on subsequent loads
 * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
 * @cliArgs --device "MSPM0G350X" --part "Default" --package "LQFP-64(PM)" --product "mspm0_sdk@2.02.00.05"
 * @v2CliArgs --device "MSPM0G3507" --package "LQFP-64(PM)" --product "mspm0_sdk@2.02.00.05"
 * @versions {"tool":"1.21.1+3772"}
 */
scripting.excludeFromBuild("Event.dot");

/**
 * Import the modules used in this configuration.
 */
const COMPARE       = scripting.addModule("/ti/driverlib/COMPARE", {}, false);
const COMPARE1      = COMPARE.addInstance();
const COMPARE2      = COMPARE.addInstance();
const GPIO          = scripting.addModule("/ti/driverlib/GPIO", {}, false);
const GPIO1         = GPIO.addInstance();
const GPIO2         = GPIO.addInstance();
const GPIO3         = GPIO.addInstance();
const GPIO4         = GPIO.addInstance();
const GPIO5         = GPIO.addInstance();
const GPIO6         = GPIO.addInstance();
const GPIO7         = GPIO.addInstance();
const I2C           = scripting.addModule("/ti/driverlib/I2C", {}, false);
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 SYSCTL        = scripting.addModule("/ti/driverlib/SYSCTL");
const TIMER         = scripting.addModule("/ti/driverlib/TIMER", {}, false);
const TIMER1        = TIMER.addInstance();
const UART          = scripting.addModule("/ti/driverlib/UART", {}, false);
const UART1         = UART.addInstance();
const UART2         = UART.addInstance();
const UART3         = UART.addInstance();
const UART4         = UART.addInstance();
const ProjectConfig = scripting.addModule("/ti/project_config/ProjectConfig");

/**
 * Write custom configuration values to the imported modules.
 */
const divider6       = system.clockTree["PLL_CLK2X_DIV"];
divider6.divideValue = 4;

const divider7       = system.clockTree["PLL_PDIV"];
divider7.divideValue = 2;

const divider9       = system.clockTree["UDIV"];
divider9.divideValue = 2;

const gate7  = system.clockTree["MFCLKGATE"];
gate7.enable = true;

const multiplier2         = system.clockTree["PLL_QDIV"];
multiplier2.multiplyValue = 10;

const mux8       = system.clockTree["HSCLKMUX"];
mux8.inputSelect = "HSCLKMUX_SYSPLL2X";

COMPARE1.inputFilter                        = true;
COMPARE1.filteringMode                      = "VOTING";
COMPARE1.interrupts                         = ["LOAD"];
COMPARE1.compareMode                        = "EDGE_COUNT_UP";
COMPARE1.$name                              = "Encoder1_TIM";
COMPARE1.timerPeriod                        = 1;
COMPARE1.peripheral.$assign                 = "TIMG7";
COMPARE1.peripheral.ccp0Pin.$assign         = "PA28";
COMPARE1.ccp0PinConfig.hideOutputInversion  = scripting.forceWrite(false);
COMPARE1.ccp0PinConfig.onlyInternalResistor = scripting.forceWrite(false);
COMPARE1.ccp0PinConfig.passedPeripheralType = scripting.forceWrite("Digital");
COMPARE1.ccp0PinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric6";

const Board = scripting.addModule("/ti/driverlib/Board", {}, false);

COMPARE2.inputFilter                        = true;
COMPARE2.filteringMode                      = "VOTING";
COMPARE2.interrupts                         = ["LOAD"];
COMPARE2.compareMode                        = "EDGE_COUNT_UP";
COMPARE2.timerPeriod                        = 1;
COMPARE2.$name                              = "Encoder2_TIM";
COMPARE2.peripheral.$assign                 = "TIMA0";
COMPARE2.peripheral.ccp0Pin.$assign         = "PA8";
COMPARE2.ccp0PinConfig.hideOutputInversion  = scripting.forceWrite(false);
COMPARE2.ccp0PinConfig.onlyInternalResistor = scripting.forceWrite(false);
COMPARE2.ccp0PinConfig.passedPeripheralType = scripting.forceWrite("Digital");
COMPARE2.ccp0PinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric6_COPY";

GPIO1.$name                         = "LED";
GPIO1.port                          = "PORTB";
GPIO1.associatedPins.create(4);
GPIO1.associatedPins[0].$name       = "Board";
GPIO1.associatedPins[0].assignedPin = "22";
GPIO1.associatedPins[0].pin.$assign = "PB22";
GPIO1.associatedPins[1].$name       = "Led1";
GPIO1.associatedPins[1].assignedPin = "25";
GPIO1.associatedPins[1].pin.$assign = "PB25";
GPIO1.associatedPins[2].$name       = "Led2";
GPIO1.associatedPins[3].$name       = "Led3";
GPIO1.associatedPins[3].assignedPin = "20";
GPIO1.associatedPins[3].pin.$assign = "PB20";

GPIO2.$name                         = "Encoder1_GPIO";
GPIO2.port                          = "PORTA";
GPIO2.associatedPins[0].$name       = "Encoder1B_GPIO";
GPIO2.associatedPins[0].assignedPin = "31";
GPIO2.associatedPins[0].direction   = "INPUT";
GPIO2.associatedPins[0].pin.$assign = "PA31";

GPIO3.port                          = "PORTA";
GPIO3.$name                         = "Encoder2_GPIO";
GPIO3.associatedPins[0].direction   = "INPUT";
GPIO3.associatedPins[0].assignedPin = "9";
GPIO3.associatedPins[0].$name       = "Encoder2B_GPIO";
GPIO3.associatedPins[0].pin.$assign = "PA9";

GPIO4.$name                          = "Key";
GPIO4.associatedPins.create(4);
GPIO4.associatedPins[0].direction    = "INPUT";
GPIO4.associatedPins[0].$name        = "Key1";
GPIO4.associatedPins[0].interruptEn  = true;
GPIO4.associatedPins[0].polarity     = "RISE";
GPIO4.associatedPins[0].assignedPort = "PORTA";
GPIO4.associatedPins[0].assignedPin  = "7";
GPIO4.associatedPins[0].pin.$assign  = "PA7";
GPIO4.associatedPins[1].$name        = "Key2";
GPIO4.associatedPins[1].direction    = "INPUT";
GPIO4.associatedPins[1].interruptEn  = true;
GPIO4.associatedPins[1].polarity     = "RISE";
GPIO4.associatedPins[1].assignedPort = "PORTB";
GPIO4.associatedPins[1].assignedPin  = "10";
GPIO4.associatedPins[1].pin.$assign  = "PB10";
GPIO4.associatedPins[2].$name        = "Key3";
GPIO4.associatedPins[2].direction    = "INPUT";
GPIO4.associatedPins[2].interruptEn  = true;
GPIO4.associatedPins[2].polarity     = "RISE";
GPIO4.associatedPins[2].assignedPort = "PORTB";
GPIO4.associatedPins[2].assignedPin  = "11";
GPIO4.associatedPins[2].pin.$assign  = "PB11";
GPIO4.associatedPins[3].$name        = "Key4";
GPIO4.associatedPins[3].direction    = "INPUT";
GPIO4.associatedPins[3].interruptEn  = true;
GPIO4.associatedPins[3].polarity     = "RISE";
GPIO4.associatedPins[3].assignedPort = "PORTB";
GPIO4.associatedPins[3].assignedPin  = "14";
GPIO4.associatedPins[3].pin.$assign  = "PB14";

GPIO5.$name                         = "MotorDirection";
GPIO5.associatedPins.create(4);
GPIO5.associatedPins[0].$name       = "AIN1";
GPIO5.associatedPins[0].pin.$assign = "PA14";
GPIO5.associatedPins[1].$name       = "AIN2";
GPIO5.associatedPins[1].pin.$assign = "PA15";
GPIO5.associatedPins[2].$name       = "BIN1";
GPIO5.associatedPins[2].pin.$assign = "PA12";
GPIO5.associatedPins[3].$name       = "BIN2";
GPIO5.associatedPins[3].pin.$assign = "PA13";

GPIO6.$name                              = "Tracker";
GPIO6.associatedPins.create(7);
GPIO6.associatedPins[0].$name            = "Track1";
GPIO6.associatedPins[0].direction        = "INPUT";
GPIO6.associatedPins[0].polarity         = "FALL";
GPIO6.associatedPins[0].interruptEn      = true;
GPIO6.associatedPins[0].assignedPort     = "PORTB";
GPIO6.associatedPins[0].assignedPin      = "0";
GPIO6.associatedPins[0].internalResistor = "PULL_UP";
GPIO6.associatedPins[0].pin.$assign      = "PB0";
GPIO6.associatedPins[1].direction        = "INPUT";
GPIO6.associatedPins[1].$name            = "Track2";
GPIO6.associatedPins[1].assignedPort     = "PORTB";
GPIO6.associatedPins[1].assignedPin      = "1";
GPIO6.associatedPins[1].interruptEn      = true;
GPIO6.associatedPins[1].polarity         = "FALL";
GPIO6.associatedPins[1].internalResistor = "PULL_UP";
GPIO6.associatedPins[1].pin.$assign      = "PB1";
GPIO6.associatedPins[2].$name            = "Track3";
GPIO6.associatedPins[2].direction        = "INPUT";
GPIO6.associatedPins[2].assignedPort     = "PORTB";
GPIO6.associatedPins[2].assignedPin      = "21";
GPIO6.associatedPins[2].interruptEn      = true;
GPIO6.associatedPins[2].polarity         = "FALL";
GPIO6.associatedPins[2].internalResistor = "PULL_UP";
GPIO6.associatedPins[2].pin.$assign      = "PB21";
GPIO6.associatedPins[3].$name            = "Track4";
GPIO6.associatedPins[3].direction        = "INPUT";
GPIO6.associatedPins[3].interruptEn      = true;
GPIO6.associatedPins[3].polarity         = "FALL";
GPIO6.associatedPins[3].internalResistor = "PULL_UP";
GPIO6.associatedPins[3].assignedPort     = "PORTB";
GPIO6.associatedPins[3].assignedPin      = "24";
GPIO6.associatedPins[3].pin.$assign      = "PB24";
GPIO6.associatedPins[4].$name            = "Track5";
GPIO6.associatedPins[4].direction        = "INPUT";
GPIO6.associatedPins[4].assignedPort     = "PORTB";
GPIO6.associatedPins[4].assignedPin      = "17";
GPIO6.associatedPins[4].interruptEn      = true;
GPIO6.associatedPins[4].polarity         = "FALL";
GPIO6.associatedPins[4].internalResistor = "PULL_UP";
GPIO6.associatedPins[4].pin.$assign      = "PB17";
GPIO6.associatedPins[5].$name            = "Track6";
GPIO6.associatedPins[5].direction        = "INPUT";
GPIO6.associatedPins[5].assignedPort     = "PORTB";
GPIO6.associatedPins[5].assignedPin      = "18";
GPIO6.associatedPins[5].interruptEn      = true;
GPIO6.associatedPins[5].polarity         = "FALL";
GPIO6.associatedPins[5].internalResistor = "PULL_UP";
GPIO6.associatedPins[5].pin.$assign      = "PB18";
GPIO6.associatedPins[6].$name            = "Track7";
GPIO6.associatedPins[6].direction        = "INPUT";
GPIO6.associatedPins[6].assignedPort     = "PORTB";
GPIO6.associatedPins[6].assignedPin      = "19";
GPIO6.associatedPins[6].interruptEn      = true;
GPIO6.associatedPins[6].polarity         = "FALL";
GPIO6.associatedPins[6].internalResistor = "PULL_UP";
GPIO6.associatedPins[6].pin.$assign      = "PB19";

GPIO7.port                               = "PORTA";
GPIO7.$name                              = "Lights";
GPIO7.associatedPins[0].$name            = "Light";
GPIO7.associatedPins[0].internalResistor = "PULL_DOWN";
GPIO7.associatedPins[0].assignedPin      = "18";
GPIO7.associatedPins[0].pin.$assign      = "PA18";

I2C1.$name                     = "I2C_0";
I2C1.basicEnableController     = true;
I2C1.peripheral.$assign        = "I2C0";
I2C1.peripheral.sdaPin.$assign = "PA0";
I2C1.peripheral.sclPin.$assign = "PA1";
I2C1.sdaPinConfig.$name        = "ti_driverlib_gpio_GPIOPinGeneric8";
I2C1.sclPinConfig.$name        = "ti_driverlib_gpio_GPIOPinGeneric9";

I2C2.$name                     = "I2C_1";
I2C2.basicEnableController     = true;
I2C2.peripheral.$assign        = "I2C1";
I2C2.peripheral.sdaPin.$assign = "PB3";
I2C2.peripheral.sclPin.$assign = "PB2";
I2C2.sdaPinConfig.$name        = "ti_driverlib_gpio_GPIOPinGeneric16";
I2C2.sclPinConfig.$name        = "ti_driverlib_gpio_GPIOPinGeneric17";

PWM1.timerCount                         = 10000;
PWM1.clockDivider                       = 8;
PWM1.timerStartTimer                    = true;
PWM1.$name                              = "Motor";
PWM1.peripheral.$assign                 = "TIMA1";
PWM1.peripheral.ccp0Pin.$assign         = "PA17";
PWM1.peripheral.ccp1Pin.$assign         = "PA16";
PWM1.PWM_CHANNEL_0.$name                = "ti_driverlib_pwm_PWMTimerCC0";
PWM1.PWM_CHANNEL_0.invert               = true;
PWM1.PWM_CHANNEL_0.dutyCycle            = 50;
PWM1.PWM_CHANNEL_1.$name                = "ti_driverlib_pwm_PWMTimerCC1";
PWM1.PWM_CHANNEL_1.invert               = true;
PWM1.PWM_CHANNEL_1.dutyCycle            = 50;
PWM1.ccp0PinConfig.direction            = scripting.forceWrite("OUTPUT");
PWM1.ccp0PinConfig.hideOutputInversion  = scripting.forceWrite(false);
PWM1.ccp0PinConfig.onlyInternalResistor = scripting.forceWrite(false);
PWM1.ccp0PinConfig.passedPeripheralType = scripting.forceWrite("Digital");
PWM1.ccp0PinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric4";
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.ccp1PinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric5";

PWM2.$name                              = "Beep";
PWM2.clockDivider                       = 8;
PWM2.ccIndex                            = [1];
PWM2.timerCount                         = 2500;
PWM2.peripheral.$assign                 = "TIMG6";
PWM2.peripheral.ccp1Pin.$assign         = "PA22";
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.ccp1PinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric10";
PWM2.PWM_CHANNEL_1.$name                = "ti_driverlib_pwm_PWMTimerCC2";
PWM2.PWM_CHANNEL_1.dutyCycle            = 50;

PWM3.$name                              = "Servo";
PWM3.timerCount                         = 10000;
PWM3.clockDivider                       = 8;
PWM3.clockPrescale                      = 10;
PWM3.timerStartTimer                    = true;
PWM3.peripheral.$assign                 = "TIMG8";
PWM3.peripheral.ccp0Pin.$assign         = "PA23";
PWM3.peripheral.ccp1Pin.$assign         = "PA2";
PWM3.PWM_CHANNEL_0.$name                = "ti_driverlib_pwm_PWMTimerCC3";
PWM3.PWM_CHANNEL_0.invert               = true;
PWM3.PWM_CHANNEL_0.dutyCycle            = 7.5;
PWM3.PWM_CHANNEL_1.$name                = "ti_driverlib_pwm_PWMTimerCC4";
PWM3.PWM_CHANNEL_1.invert               = true;
PWM3.PWM_CHANNEL_1.dutyCycle            = 7.5;
PWM3.ccp0PinConfig.direction            = scripting.forceWrite("OUTPUT");
PWM3.ccp0PinConfig.hideOutputInversion  = scripting.forceWrite(false);
PWM3.ccp0PinConfig.onlyInternalResistor = scripting.forceWrite(false);
PWM3.ccp0PinConfig.passedPeripheralType = scripting.forceWrite("Digital");
PWM3.ccp0PinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric12";
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.ccp1PinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric13";

SYSCTL.forceDefaultClkConfig = true;
SYSCTL.clockTreeEn           = true;

TIMER1.$name              = "Encoder_Count";
TIMER1.timerClkDiv        = 8;
TIMER1.timerMode          = "PERIODIC_UP";
TIMER1.interrupts         = ["ZERO"];
TIMER1.timerStartTimer    = true;
TIMER1.timerClkPrescale   = 10;
TIMER1.timerPeriod        = "100 ms";
TIMER1.peripheral.$assign = "TIMG0";

UART1.$name                            = "PRINTF";
UART1.enabledInterrupts                = ["RX"];
UART1.targetBaudRate                   = 115200;
UART1.uartClkSrc                       = "MFCLK";
UART1.peripheral.$assign               = "UART0";
UART1.peripheral.rxPin.$assign         = "PA11";
UART1.peripheral.txPin.$assign         = "PA10";
UART1.txPinConfig.direction            = scripting.forceWrite("OUTPUT");
UART1.txPinConfig.hideOutputInversion  = scripting.forceWrite(false);
UART1.txPinConfig.onlyInternalResistor = scripting.forceWrite(false);
UART1.txPinConfig.passedPeripheralType = scripting.forceWrite("Digital");
UART1.txPinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric0";
UART1.rxPinConfig.hideOutputInversion  = scripting.forceWrite(false);
UART1.rxPinConfig.onlyInternalResistor = scripting.forceWrite(false);
UART1.rxPinConfig.passedPeripheralType = scripting.forceWrite("Digital");
UART1.rxPinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric1";

UART2.$name                            = "IMU";
UART2.targetBaudRate                   = 115200;
UART2.uartClkSrc                       = "MFCLK";
UART2.enabledInterrupts                = ["RX"];
UART2.peripheral.$assign               = "UART2";
UART2.peripheral.rxPin.$assign         = "PB16";
UART2.peripheral.txPin.$assign         = "PB15";
UART2.txPinConfig.direction            = scripting.forceWrite("OUTPUT");
UART2.txPinConfig.hideOutputInversion  = scripting.forceWrite(false);
UART2.txPinConfig.onlyInternalResistor = scripting.forceWrite(false);
UART2.txPinConfig.passedPeripheralType = scripting.forceWrite("Digital");
UART2.txPinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric2";
UART2.rxPinConfig.hideOutputInversion  = scripting.forceWrite(false);
UART2.rxPinConfig.onlyInternalResistor = scripting.forceWrite(false);
UART2.rxPinConfig.passedPeripheralType = scripting.forceWrite("Digital");
UART2.rxPinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric3";

UART3.$name                            = "HOST";
UART3.uartClkSrc                       = "MFCLK";
UART3.targetBaudRate                   = 115200;
UART3.enabledInterrupts                = ["RX"];
UART3.peripheral.$assign               = "UART3";
UART3.peripheral.rxPin.$assign         = "PB13";
UART3.peripheral.txPin.$assign         = "PB12";
UART3.txPinConfig.direction            = scripting.forceWrite("OUTPUT");
UART3.txPinConfig.hideOutputInversion  = scripting.forceWrite(false);
UART3.txPinConfig.onlyInternalResistor = scripting.forceWrite(false);
UART3.txPinConfig.passedPeripheralType = scripting.forceWrite("Digital");
UART3.txPinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric7";
UART3.rxPinConfig.hideOutputInversion  = scripting.forceWrite(false);
UART3.rxPinConfig.onlyInternalResistor = scripting.forceWrite(false);
UART3.rxPinConfig.passedPeripheralType = scripting.forceWrite("Digital");
UART3.rxPinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric11";

UART4.$name                            = "Stepmotor";
UART4.targetBaudRate                   = 115200;
UART4.uartClkSrc                       = "MFCLK";
UART4.enabledInterrupts                = ["RX"];
UART4.peripheral.$assign               = "UART1";
UART4.peripheral.rxPin.$assign         = "PB5";
UART4.peripheral.txPin.$assign         = "PB4";
UART4.txPinConfig.direction            = scripting.forceWrite("OUTPUT");
UART4.txPinConfig.hideOutputInversion  = scripting.forceWrite(false);
UART4.txPinConfig.onlyInternalResistor = scripting.forceWrite(false);
UART4.txPinConfig.passedPeripheralType = scripting.forceWrite("Digital");
UART4.txPinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric14";
UART4.rxPinConfig.hideOutputInversion  = scripting.forceWrite(false);
UART4.rxPinConfig.onlyInternalResistor = scripting.forceWrite(false);
UART4.rxPinConfig.passedPeripheralType = scripting.forceWrite("Digital");
UART4.rxPinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric15";

ProjectConfig.genStartup = false;
ProjectConfig.genLinker  = false;
ProjectConfig.genOpts    = false;
ProjectConfig.genLibs    = false;

/**
 * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
 * 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.
 */
Board.peripheral.$suggestSolution            = "DEBUGSS";
Board.peripheral.swclkPin.$suggestSolution   = "PA20";
Board.peripheral.swdioPin.$suggestSolution   = "PA19";
GPIO1.associatedPins[2].pin.$suggestSolution = "PB23";
