add uart rx; 4 bytes cmd parse

This commit is contained in:
2025-11-17 10:13:18 +08:00
parent 5b49a0ee24
commit 6de9d53e1c
7 changed files with 237 additions and 47 deletions

View File

@@ -17,6 +17,8 @@ const PWM = scripting.addModule("/ti/driverlib/PWM", {}, false);
const PWM1 = PWM.addInstance();
const SYSCTL = scripting.addModule("/ti/driverlib/SYSCTL");
const SYSTICK = scripting.addModule("/ti/driverlib/SYSTICK");
const TIMER = scripting.addModule("/ti/driverlib/TIMER", {}, false);
const TIMER1 = TIMER.addInstance();
const UART = scripting.addModule("/ti/driverlib/UART", {}, false);
const UART1 = UART.addInstance();
@@ -77,9 +79,7 @@ PWM1.clockDivider = 2;
PWM1.timerCount = 2000;
PWM1.pwmMode = "CENTER_ALIGN";
PWM1.PWM_CHANNEL_0.$name = "ti_driverlib_pwm_PWMTimerCC0";
PWM1.PWM_CHANNEL_0.ccValue = 1000;
PWM1.PWM_CHANNEL_1.$name = "ti_driverlib_pwm_PWMTimerCC1";
PWM1.PWM_CHANNEL_1.ccValue = 1000;
PWM1.ccp0PinConfig.$name = "ti_driverlib_gpio_GPIOPinGeneric4";
PWM1.ccp1PinConfig.$name = "ti_driverlib_gpio_GPIOPinGeneric5";
PWM1.peripheral.$assign = "TIMA0";
@@ -87,7 +87,6 @@ PWM1.peripheral.ccp0Pin.$assign = "PA21";
PWM1.peripheral.ccp1Pin.$assign = "PA22";
PWM1.peripheral.ccp2Pin.$assign = "PB20";
PWM1.PWM_CHANNEL_2.$name = "ti_driverlib_pwm_PWMTimerCC2";
PWM1.PWM_CHANNEL_2.ccValue = 1000;
PWM1.ccp2PinConfig.$name = "ti_driverlib_gpio_GPIOPinGeneric6";
SYSCTL.forceDefaultClkConfig = true;
@@ -97,6 +96,15 @@ SYSTICK.periodEnable = true;
SYSTICK.systickEnable = true;
SYSTICK.period = 16000000;
TIMER1.$name = "TIMER_0";
TIMER1.timerClkDiv = 8;
TIMER1.timerMode = "PERIODIC";
TIMER1.timerClkPrescale = 8;
TIMER1.interrupts = ["ZERO"];
TIMER1.timerClkSrc = "LFCLK";
TIMER1.timerPeriod = "1";
TIMER1.peripheral.$assign = "TIMG0";
UART1.$name = "UART_0";
UART1.rxFifoThreshold = "DL_UART_RX_FIFO_LEVEL_ONE_ENTRY";
UART1.targetBaudRate = 115200;
@@ -104,6 +112,8 @@ UART1.uartClkDiv = "8";
UART1.enableFIFO = true;
UART1.txFifoThreshold = "DL_UART_TX_FIFO_LEVEL_ONE_ENTRY";
UART1.enabledDMATXTriggers = "DL_UART_DMA_INTERRUPT_TX";
UART1.enabledInterrupts = ["DMA_DONE_RX"];
UART1.enabledDMARXTriggers = "DL_UART_DMA_INTERRUPT_RX";
UART1.peripheral.$assign = "UART0";
UART1.peripheral.rxPin.$assign = "PA11";
UART1.peripheral.txPin.$assign = "PA10";
@@ -114,6 +124,11 @@ UART1.DMA_CHANNEL_TX.addressMode = "b2f";
UART1.DMA_CHANNEL_TX.srcLength = "BYTE";
UART1.DMA_CHANNEL_TX.dstLength = "BYTE";
UART1.DMA_CHANNEL_TX.peripheral.$assign = "DMA_CH0";
UART1.DMA_CHANNEL_RX.$name = "DMA_CH1";
UART1.DMA_CHANNEL_RX.addressMode = "f2b";
UART1.DMA_CHANNEL_RX.srcLength = "BYTE";
UART1.DMA_CHANNEL_RX.dstLength = "BYTE";
UART1.DMA_CHANNEL_RX.transferMode = "FULL_CH_REPEAT_SINGLE";
const ProjectConfig = scripting.addModule("/ti/project_config/ProjectConfig", {}, false);
ProjectConfig.migrationCondition = true;
@@ -127,3 +142,4 @@ pinFunction4.peripheral.$suggestSolution = "SYSCTL";
pinFunction4.peripheral.hfxInPin.$suggestSolution = "PA5";
pinFunction4.peripheral.hfxOutPin.$suggestSolution = "PA6";
I2C1.peripheral.$suggestSolution = "I2C1";
UART1.DMA_CHANNEL_RX.peripheral.$suggestSolution = "DMA_CH1";