/**
 * 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" --package "LQFP-64(PM)" --part "Default" --product "mspm0_sdk@1.30.00.03"
 * @versions {"tool":"1.19.0+3426"}
 */

/**
 * Import the modules used in this configuration.
 */
const ADC12   = scripting.addModule("/ti/driverlib/ADC12", {}, false);
const ADC121  = ADC12.addInstance();
const GPIO    = scripting.addModule("/ti/driverlib/GPIO", {}, false);
const GPIO1   = GPIO.addInstance();
const SYSCTL  = scripting.addModule("/ti/driverlib/SYSCTL");
const SYSTICK = scripting.addModule("/ti/driverlib/SYSTICK");
const UART    = scripting.addModule("/ti/driverlib/UART", {}, false);
const UART1   = UART.addInstance();

/**
 * Write custom configuration values to the imported modules.
 */
const divider2       = system.clockTree["HFCLK4MFPCLKDIV"];
divider2.divideValue = 6;

const divider6       = system.clockTree["PLL_CLK2X_DIV"];
divider6.divideValue = 1;

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

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

const gate8  = system.clockTree["MFPCLKGATE"];
gate8.enable = true;

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

const mux4       = system.clockTree["EXHFMUX"];
mux4.inputSelect = "EXHFMUX_XTAL";

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

const mux12       = system.clockTree["SYSPLLMUX"];
mux12.inputSelect = "zSYSPLLMUX_HFCLK";

const pinFunction3     = system.clockTree["HFCLKEXT"];
pinFunction3.inputFreq = 40;

const pinFunction4     = system.clockTree["HFXT"];
pinFunction4.inputFreq = 40;
pinFunction4.enable    = true;

ADC121.$name               = "ADC12_0";
ADC121.sampClkDiv          = "DL_ADC12_CLOCK_DIVIDE_8";
ADC121.repeatMode          = true;
ADC121.adcMem0_name        = "ADC_CH0";
ADC121.sampClkSrc          = "DL_ADC12_CLOCK_ULPCLK";
ADC121.sampleTime0         = "2us";
ADC121.enabledInterrupts   = ["DL_ADC12_INTERRUPT_MEM0_RESULT_LOADED"];
ADC121.adcPin0Config.$name = "ti_driverlib_gpio_GPIOPinGeneric2";

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

GPIO1.$name                         = "Gray_Address";
GPIO1.associatedPins.create(3);
GPIO1.associatedPins[0].$name       = "PIN_0";
GPIO1.associatedPins[0].pin.$assign = "PB0";
GPIO1.associatedPins[1].$name       = "PIN_1";
GPIO1.associatedPins[1].pin.$assign = "PB1";
GPIO1.associatedPins[2].$name       = "PIN_2";
GPIO1.associatedPins[2].pin.$assign = "PB2";

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

SYSTICK.periodEnable      = true;
SYSTICK.interruptEnable   = true;
SYSTICK.interruptPriority = "0";
SYSTICK.period            = 80000;
SYSTICK.systickEnable     = true;

UART1.$name                    = "UART_0";
UART1.uartClkDiv               = "2";
UART1.peripheral.rxPin.$assign = "PA11";
UART1.peripheral.txPin.$assign = "PA10";
UART1.txPinConfig.$name        = "ti_driverlib_gpio_GPIOPinGeneric0";
UART1.rxPinConfig.$name        = "ti_driverlib_gpio_GPIOPinGeneric1";

/**
 * 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.
 */
pinFunction4.peripheral.$suggestSolution           = "SYSCTL";
pinFunction4.peripheral.hfxInPin.$suggestSolution  = "PA5";
pinFunction4.peripheral.hfxOutPin.$suggestSolution = "PA6";
ADC121.peripheral.$suggestSolution                 = "ADC0";
ADC121.peripheral.adcPin0.$suggestSolution         = "PA27";
Board.peripheral.$suggestSolution                  = "DEBUGSS";
Board.peripheral.swclkPin.$suggestSolution         = "PA20";
Board.peripheral.swdioPin.$suggestSolution         = "PA19";
UART1.peripheral.$suggestSolution                  = "UART0";
