From 23615c02f267183c71ceb06fa898377243101287 Mon Sep 17 00:00:00 2001 From: maakshishov Date: Wed, 31 Mar 2021 19:06:28 +0300 Subject: [PATCH] First --- .ccsproject | 17 +++ .cproject | 310 +++++++++++++++++++++++++++++++++++++++++++++ .project | 28 ++++ .xdchelp | 0 mss_main.c | 263 ++++++++++++++++++++++++++++++++++++++ mss_mmw.cfg | 55 ++++++++ mss_mmw_linker.cmd | 12 ++ r4f_linker.cmd | 38 ++++++ 8 files changed, 723 insertions(+) create mode 100644 .ccsproject create mode 100644 .cproject create mode 100644 .project create mode 100644 .xdchelp create mode 100644 mss_main.c create mode 100644 mss_mmw.cfg create mode 100644 mss_mmw_linker.cmd create mode 100644 r4f_linker.cmd diff --git a/.ccsproject b/.ccsproject new file mode 100644 index 0000000..f3d15cb --- /dev/null +++ b/.ccsproject @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/.cproject b/.cproject new file mode 100644 index 0000000..164e5dd --- /dev/null +++ b/.cproject @@ -0,0 +1,310 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..c27dd9c --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + mmw_mss_16xx + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.rtsc.xdctools.buildDefinitions.XDC.xdcNature + com.ti.ccstudio.core.ccsNature + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/.xdchelp b/.xdchelp new file mode 100644 index 0000000..e69de29 diff --git a/mss_main.c b/mss_main.c new file mode 100644 index 0000000..d2772af --- /dev/null +++ b/mss_main.c @@ -0,0 +1,263 @@ +/* Standard Include Files. */ +#include +#include +#include +#include +#include +#include + +/* BIOS/XDC Include Files. */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* mmWave SDK Include Files: */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +SOC_Handle socHandle; +Event_Handle event; +uint8_t period = 0; +uint8_t buffer = 0; +uint8_t metka = 0; + +UInt eventMask1 = Event_Id_00; +UInt eventMask2 = Event_Id_01; +UInt eventMask3 = Event_Id_02; + +uint32_t BAUDRATE = 115200; +uint8_t STOPBITS = 1; +uint8_t DATALEN = 8; +uint8_t PARITY_VALUE = 4; +uint8_t gMCPIUARTPollingModeEnable = 0; + +Event_Handle event1; + +uint32_t gCPUClockFrequency = (200 * 1000000); + +uint8_t uartDataLenths [] = { + 0, // Padding + 0, + 0, + 0, + 0, + (uint8_t) UART_LEN_5, + (uint8_t) UART_LEN_6, + (uint8_t) UART_LEN_7, + (uint8_t) UART_LEN_8 +}; + +uint8_t uartParityTypes [] = { + (uint8_t) UART_PAR_ZERO, + (uint8_t) UART_PAR_ONE, + (uint8_t) UART_PAR_EVEN, + (uint8_t) UART_PAR_ODD, + (uint8_t) UART_PAR_NONE +}; + +uint8_t uartStopBits [] = { + 0, // Padding + (uint8_t) UART_STOP_ONE, + (uint8_t) UART_STOP_TWO +}; + +void Flashing_LED(UArg arg0, UArg arg1) +{ + UInt flag; + while (TRUE) + { + flag = Event_pend(event1, Event_Id_NONE, eventMask1 + eventMask2 + eventMask3, BIOS_WAIT_FOREVER); + if(flag & eventMask1) { + GPIO_write(arg0, 1U); + continue; + } + else if(flag & eventMask3) { + GPIO_write(arg0, 0U); + continue; + } + while(TRUE){ + GPIO_toggle(arg0); + if(Event_pend(event1, Event_Id_NONE, eventMask1 + eventMask3, period)) { + break; + } + } + } +} + +void Work_UART(UArg arg0, UArg arg1) +{ + uint8_t index[128]; + UART_Params params; + UART_Handle handle; + uint8_t len; + + /* Setup the default UART Parameters */ + UART_Params_init(¶ms); + params.writeDataMode = UART_DATA_TEXT; + params.readDataMode = UART_DATA_TEXT; + params.readReturnMode = UART_RETURN_NEWLINE; + params.isPinMuxDone = 1; + params.baudRate = BAUDRATE; + params.dataLength = (UART_LEN) uartDataLenths[DATALEN]; + handle = UART_open(0, ¶ms); + + if (handle == NULL) + { + printf("Error: Unable to open the UART Instance\n"); + return; + } + + while(TRUE) + { + len = UART_read(handle, index, sizeof(index)/sizeof(uint8_t)) - 1; + if(len <= 13) + { + if(memcmp(index, "On", 2) == 0) + { + Event_post(event1, eventMask1); + UART_write(handle, "\nOk\n", 4); + } + else if(memcmp(index, "Off", 3) == 0) + { + Event_post(event1, eventMask3); + UART_write(handle, "\nOk\n", 4); + } + else if(memcmp(index, "Period ", 7) == 0) { + int i; + for(i = 7; i < len; i++) + { + if(index[i] >= '0' && index[i] <= '9') + { + buffer = buffer * 10 + (index[i] - '0'); + } + else { + metka = 1; + break; + } + } + if(metka == 1 || buffer == 0) { + UART_write(handle, "\nError\n", 7); + metka = 0; + continue; + } + UART_write(handle, "\nOk\n", 4); + period = buffer; + buffer = 0; + Event_post(event1, eventMask2); + } + else { + UART_write(handle, "\nError\n", 7); + } + } + else { + UART_write(handle, "\nError\n", 7); + } + } +} + +static void InitTask(UArg arg0, UArg arg1) +{ + Task_Params taskParamsUART; + + Task_Params taskParamsLED; + Task_Params_init(&taskParamsLED); + taskParamsLED.stackSize = 4*1024; + taskParamsLED.priority = 1; + taskParamsLED.arg0 = (UArg)SOC_XWR16XX_GPIO_2; + + Task_create(Flashing_LED, &taskParamsLED, NULL); + Event_Params eventParams; + Event_Params_init(&eventParams); + event1 = Event_create(&eventParams, NULL); + /* Initialize the GPIO */ + GPIO_init (); + + /* Initialize the UART */ + UART_init(); + + /* Test the GPIO Output: Configure pin K13 as GPIO_2 output */ + Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINK13_PADAZ, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL); + Pinmux_Set_FuncSel(SOC_XWR16XX_PINK13_PADAZ, SOC_XWR16XX_PINK13_PADAZ_GPIO_2); + GPIO_setConfig (SOC_XWR16XX_GPIO_2, GPIO_CFG_OUTPUT); + + /* Setup the PINMUX to bring out the MSS UART-1 */ + Pinmux_Set_FuncSel(SOC_XWR16XX_PINN5_PADBE, SOC_XWR16XX_PINN5_PADBE_MSS_UARTA_TX); + Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINN5_PADBE, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL); + Pinmux_Set_FuncSel(SOC_XWR16XX_PINN4_PADBD, SOC_XWR16XX_PINN4_PADBD_MSS_UARTA_RX); + Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINN4_PADBD, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL); + + /* Initialize the Task Parameters. */ + Task_Params_init(&taskParamsUART); + taskParamsUART.stackSize = 4*1024; + taskParamsUART.priority = 2; + Task_create(Work_UART, &taskParamsUART, NULL); + return; +} + + +int main (void) +{ + int32_t errCode; + Task_Params taskParams; + SOC_Cfg socCfg; + Error_Block eb; + + /* Initialize the ESM: Dont clear errors as TI RTOS does it */ + ESM_init(0U); + + /* Initialize the SOC confiugration: */ + memset ((void *)&socCfg, 0, sizeof(SOC_Cfg)); + + /* Populate the SOC configuration: */ + socCfg.clockCfg = SOC_SysClock_INIT; + /* Initialize the SOC Module: This is done as soon as the application is started + * to ensure that the MPU is correctly configured. */ + socHandle = SOC_init (&socCfg, &errCode); + if (socHandle == NULL) + { + System_printf ("Error: SOC Module Initialization failed [Error code %d]\n", errCode); + return -1; + } + + event = Event_create(NULL, &eb); + if (event == NULL) { + System_printf ("Error: Event not create\n"); + return -1; + } + + /* Initialize the Task Parameters. */ + Task_Params_init(&taskParams); + taskParams.stackSize = 2*1024; + Task_create(InitTask, &taskParams, NULL); + + + /* Start BIOS */ + BIOS_start(); + return 0; +} diff --git a/mss_mmw.cfg b/mss_mmw.cfg new file mode 100644 index 0000000..4eb027f --- /dev/null +++ b/mss_mmw.cfg @@ -0,0 +1,55 @@ +/* + * Copyright 2011 by Texas Instruments Incorporated. + * + * All rights reserved. Property of Texas Instruments Incorporated. + * Restricted rights to use, duplicate or disclose this code are + * granted through contract. + * + */ +environment['xdc.cfg.check.fatal'] = 'false'; + +/******************************************************************** + ************************** BIOS Modules **************************** + ********************************************************************/ +var Memory = xdc.useModule('xdc.runtime.Memory'); +var BIOS = xdc.useModule('ti.sysbios.BIOS'); +var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem'); +var HeapBuf = xdc.useModule('ti.sysbios.heaps.HeapBuf'); +var Task = xdc.useModule('ti.sysbios.knl.Task'); +var Idle = xdc.useModule('ti.sysbios.knl.Idle'); +var SEM = xdc.useModule('ti.sysbios.knl.Semaphore'); +var Event = xdc.useModule('ti.sysbios.knl.Event'); +var Hwi = xdc.useModule('ti.sysbios.family.arm.v7r.vim.Hwi'); +var System = xdc.useModule('xdc.runtime.System'); +var SysStd = xdc.useModule('xdc.runtime.SysStd'); +var clock = xdc.useModule('ti.sysbios.knl.Clock'); +var Pmu = xdc.useModule('ti.sysbios.family.arm.v7a.Pmu'); +System.SupportProxy = SysStd; + +/* Install idle function to sleep the R4F (using WFI instruction). Note if Load + module is used for any reason in future, Load.updateInIdle must be false + else Load will not be functional. Also, no other book-keeping etc functions + should be installed in the idle thread */ +//Idle.addFunc('&MmwDemo_sleep'); + +/* FIQ Stack Usage: */ +Hwi.fiqStackSize = 2048; +Hwi.fiqStackSection = ".myFiqStack" +Program.sectMap[".myFiqStack"] = "DATA_RAM"; + +/* Default Heap Creation: Local L2 memory */ +var heapMemParams = new HeapMem.Params(); +heapMemParams.size = 40*1024; +heapMemParams.sectionName = "systemHeap"; +Program.global.heap0 = HeapMem.create(heapMemParams); +Memory.defaultHeapInstance = Program.global.heap0; + +/* Enable BIOS Task Scheduler */ +BIOS.taskEnabled = true; + +Program.sectMap[".vecs"] = "VECTORS"; + +/* Make sure libraries are built with 32-bit enum types to be compatible with DSP enum types*/ +BIOS.includeXdcRuntime = true; +BIOS.libType = BIOS.LibType_Custom; +BIOS.customCCOpts += " --enum_type=int "; diff --git a/mss_mmw_linker.cmd b/mss_mmw_linker.cmd new file mode 100644 index 0000000..13d749f --- /dev/null +++ b/mss_mmw_linker.cmd @@ -0,0 +1,12 @@ +/*----------------------------------------------------------------------------*/ +/* Linker Settings */ +--retain="*(.intvecs)" + +/*----------------------------------------------------------------------------*/ +/* Section Configuration */ +SECTIONS +{ + systemHeap : {} > DATA_RAM +} +/*----------------------------------------------------------------------------*/ + diff --git a/r4f_linker.cmd b/r4f_linker.cmd new file mode 100644 index 0000000..3c72a3b --- /dev/null +++ b/r4f_linker.cmd @@ -0,0 +1,38 @@ +/*----------------------------------------------------------------------------*/ +/* r4f_linker.cmd */ +/* */ +/* (c) Texas Instruments 2016, All rights reserved. */ +/* */ + +/* USER CODE BEGIN (0) */ +/* USER CODE END */ + + +/*----------------------------------------------------------------------------*/ +/* Linker Settings */ +--retain="*(.intvecs)" + +/*----------------------------------------------------------------------------*/ +/* Memory Map */ +MEMORY{ + VECTORS (X) : origin=0x00000000 length=0x00000100 + PROG_RAM (RX) : origin=0x00000100 length=0x0003FF00 + DATA_RAM (RW) : origin=0x08000000 length=0x00030000 + L3_RAM (RW) : origin=0x51000000 length=MMWAVE_L3RAM_SIZE + HS_RAM (RW) : origin=0x52080000 length=0x8000 +} + +/*----------------------------------------------------------------------------*/ +/* Section Configuration */ +SECTIONS{ + .intvecs : {} > VECTORS + .text : {} > PROG_RAM ALIGN(8) + .const : {} > PROG_RAM ALIGN(8) + .cinit : {} > PROG_RAM ALIGN(8) + .pinit : {} > PROG_RAM ALIGN(8) + .bss : {} > DATA_RAM + .data : {} > DATA_RAM + .stack : {} > DATA_RAM ALIGN(32) +} +/*----------------------------------------------------------------------------*/ +