var Defaults = xdc.useModule('xdc.runtime.Defaults'); var Diags = xdc.useModule('xdc.runtime.Diags'); var Error = xdc.useModule('xdc.runtime.Error'); var Log = xdc.useModule('xdc.runtime.Log'); var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf'); var Main = xdc.useModule('xdc.runtime.Main'); var Memory = xdc.useModule('xdc.runtime.Memory') var SysMin = xdc.useModule('xdc.runtime.SysMin'); var System = xdc.useModule('xdc.runtime.System'); var Text = xdc.useModule('xdc.runtime.Text'); var BIOS = xdc.useModule('ti.sysbios.BIOS'); var Clock = xdc.useModule('ti.sysbios.knl.Clock'); var Swi = xdc.useModule('ti.sysbios.knl.Swi'); var Task = xdc.useModule('ti.sysbios.knl.Task'); var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore'); var Hwi = xdc.useModule('ti.sysbios.hal.Hwi'); var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem'); var CpIntc = xdc.useModule('ti.sysbios.family.arm.a15.tci66xx.CpIntc'); var devType = "k2g" /* Load the OSAL package */ var osType = "tirtos" var Osal = xdc.useModule('ti.osal.Settings'); Osal.osType = osType; Osal.socType = devType; /*use CSL package*/ var Csl = xdc.loadPackage('ti.csl'); Csl.Settings.deviceType = devType; /* Load the I2C package - required by board */ var I2c = xdc.loadPackage('ti.drv.i2c'); I2c.Settings.socType = devType; /* Load the Board package and set the board name */ var Board = xdc.loadPackage('ti.board'); Board.Settings.boardName = "evmK2G"; /* Load Profiling package */ var Utils = xdc.loadPackage('ti.utils.profiling'); /*XXX Load the gpio package ADDED*/ var Gpio = xdc.loadPackage('ti.drv.gpio'); Gpio.Settings.enableProfiling = true; Gpio.Settings.socType = devType; /* Load the spi package */ var Spi = xdc.loadPackage('ti.drv.spi'); Spi.Settings.enableProfiling = true; Spi.Settings.socType = devType; /* Load the uart package */ var Uart = xdc.useModule('ti.drv.uart.Settings'); Uart.socType = devType; /* * Uncomment this line to disable the Error print function. * We lose error information when this is disabled since the errors are * not printed. Disabling the raiseHook will save some code space if * your app is not using System_printf() since the Error_print() function * calls System_printf(). Error.raiseHook = null; */ /* * Uncomment this line to keep Error, Assert, and Log strings from being * loaded on the target. These strings are placed in the .const section. * Setting this parameter to false will save space in the .const section. * Error, Assert and Log message will print raw ids and args instead of * a formatted message. Text.isLoaded = false; */ /* * Uncomment this line to disable the output of characters by SysMin * when the program exits. SysMin writes characters to a circular buffer. * This buffer can be viewed using the SysMin Output view in ROV. SysMin.flushAtExit = false; */ /* No runtime stack checking is performed */ Task.checkStackFlag = false; /* Reduce the number of task priorities */ //XXX changed to 5 from 4 Task.numPriorities = 5; /* ================ Task configuration ================ */ var task0Params = new Task.Params(); task0Params.instance.name = "echo"; task0Params.stackSize = 0x1000; Program.global.echo = Task.create("&spi_test", task0Params); /* * The BIOS module will create the default heap for the system. * Specify the size of this default heap. */ BIOS.heapSize = 0x10000; /* * Build a custom SYS/BIOS library from sources. */ BIOS.libType = BIOS.LibType_Custom; /* System stack size (used by ISRs and Swis) */ Program.stack = 0x20000; /* Circular buffer size for System_printf() */ SysMin.bufSize = 0x400; /* * Create and install logger for the whole system */ var loggerBufParams = new LoggerBuf.Params(); loggerBufParams.numEntries = 32; var logger0 = LoggerBuf.create(loggerBufParams); Defaults.common$.logger = logger0; Main.common$.diags_INFO = Diags.ALWAYS_ON; System.SupportProxy = SysMin; var SemiHost = xdc.useModule('ti.sysbios.rts.gnu.SemiHostSupport'); var Cache = xdc.useModule('ti.sysbios.family.arm.a15.Cache'); var Mmu = xdc.useModule('ti.sysbios.family.arm.a15.Mmu'); /* Enable the cache */ Cache.enableCache = true; // Enable the MMU (Required for L1/L2 data caching) Mmu.enableMMU = true; // descriptor attribute structure var peripheralAttrs = new Mmu.DescriptorAttrs(); Mmu.initDescAttrsMeta(peripheralAttrs); peripheralAttrs.type = Mmu.DescriptorType_BLOCK; // BLOCK descriptor peripheralAttrs.noExecute = true; // not executable peripheralAttrs.accPerm = 0; // read/write at PL1 peripheralAttrs.attrIndx = 1; // MAIR0 Byte1 describes // memory attributes for // each BLOCK MMU entry // Define the base address of the 2 MB page // the peripheral resides in. var peripheralBaseAddrs = [ { base: 0x4ae00000, size: 0x00100000 }, // PRM { base: 0x02530C00, size: 0x00000400 }, // UART 0 regs { base: 0x02531000, size: 0x00000400 }, // UART 1 regs { base: 0x21805400, size: 0x00000800 }, // SPI 0/1/2/3 regs { base: 0x02603000, size: 0x00000100 }, // GPIO 0 regs { base: 0x0260a000, size: 0x00000100 } // GPIO 1 regs ]; // Configure the corresponding MMU page descriptor accordingly for (var i =0; i < peripheralBaseAddrs.length; i++) { for (var j = 0; j < peripheralBaseAddrs[i].size; j += 0x200000) { var addr = peripheralBaseAddrs[i].base + j; Mmu.setSecondLevelDescMeta(addr, addr, peripheralAttrs); } } /* Define and add one Task Hook Set */ Task.addHookSet({ registerFxn: '&TaskRegisterId', switchFxn: '&mySwitch', });