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 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 Swi = xdc.useModule('ti.sysbios.knl.Swi');
var Task = xdc.useModule('ti.sysbios.knl.Task');
var Event = xdc.useModule('ti.sysbios.knl.Event');
var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
var Mailbox = xdc.useModule('ti.sysbios.knl.Mailbox');
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
var Timer = xdc.useModule('ti.sysbios.hal.Timer');
var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');
var Memory = xdc.useModule('xdc.runtime.Memory');
var HeapBuf = xdc.useModule('ti.sysbios.heaps.HeapBuf');
 var Idle = xdc.useModule('ti.sysbios.knl.Idle');
/* 
 * Program.argSize sets the size of the .args section. 
 * The examples don't use command line args so argSize is set to 0.
 */
Program.argSize = 0x0;
Program.sectionsExclude = "^\.resetVecs$" ;
Task.idleTaskStackSize = 0x200 ; 

/*
 * Uncomment this line to globally disable Asserts.
 * All modules inherit the default from the 'Defaults' module.  You
 * can override these defaults on a per-module basis using Module.common$. 
 * Disabling Asserts will save code space and improve runtime performance.
Defaults.common$.diags_ASSERT = Diags.ALWAYS_OFF;
 */

/*
 * Uncomment this line to keep module names from being loaded on the target.
 * The module name strings are placed in the .const section. Setting this
 * parameter to false will save space in the .const section.  Error and
 * Assert messages will contain an "unknown module" prefix instead
 * of the actual module name.
Defaults.common$.namedModule = false;
 */

/*
 * Minimize exit handler array in System.  The System module includes
 * an array of functions that are registered with System_atexit() to be
 * called by System_exit().
 */
System.maxAtexitHandlers = 4;       

/* 
 * 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;
 */

/*
 * The BIOS module will create the default heap for the system.
 * Specify the size of this default heap.
 */
BIOS.heapSize = 0x0400;

/*
 * Build a custom SYS/BIOS library from sources.
 */
BIOS.libType = BIOS.LibType_Custom;

/* System stack size (used by ISRs and Swis) */
Program.stack = 5120;

/* Circular buffer size for System_printf() */
SysMin.bufSize = 0x200;

/* 
 * Create and install logger for the whole system
 */
var loggerBufParams = new LoggerBuf.Params();
loggerBufParams.numEntries = 16;
var logger0 = LoggerBuf.create(loggerBufParams);
Defaults.common$.logger = logger0;
Main.common$.diags_INFO = Diags.ALWAYS_ON;

System.SupportProxy = SysMin;
/******************************* Task *****************************************/
var task0Params = new Task.Params();
task0Params.instance.name = "TSK_HANDLE_POWER";
task0Params.priority = 5;
task0Params.stackSize = 960;
Program.global.TSK_HANDLE_POWER = Task.create("&TSK_APP_POWER", task0Params);
/******************************* Semaphore *****************************************/
var semaphore0Params = new Semaphore.Params();
semaphore0Params.instance.name = "SEM_HANDLE_SDW";
semaphore0Params.mode = Semaphore.Mode_COUNTING;
Program.global.SEM_HANDLE_SDW = Semaphore.create(1, semaphore0Params);
var semaphore1Params = new Semaphore.Params();
semaphore1Params.instance.name = "SEM_HANDLE_FRAM";
Program.global.SEM_HANDLE_FRAM = Semaphore.create(1, semaphore1Params);
/******************************* EventFlag *****************************************/
var event0Params = new Event.Params();
event0Params.instance.name = "EVENT_HANDLE_CAN";
Program.global.EVENT_HANDLE_CAN = Event.create(event0Params);
var mailbox3Params = new Mailbox.Params();
mailbox3Params.instance.name = "MBX_HANDLE_CTRL";
Program.global.MBX_HANDLE_CTRL = Mailbox.create(16, 15, mailbox3Params);
var mailbox4Params = new Mailbox.Params();
mailbox4Params.instance.name = "MBX_HANDLE_WLAPP";
Program.global.MBX_HANDLE_WLAPP = Mailbox.create(16, 15, mailbox4Params);
var mailbox8Params = new Mailbox.Params();
mailbox8Params.instance.name = "MBX_HANDLE_DIAG";
Program.global.MBX_HANDLE_DIAG = Mailbox.create(16, 5, mailbox8Params);
var mailbox9Params = new Mailbox.Params();
mailbox9Params.instance.name = "MBX_HANDLE_GPS";
Program.global.MBX_HANDLE_GPS = Mailbox.create(16, 5, mailbox9Params);
var hwi1Params = new Hwi.Params();
hwi1Params.instance.name = "HWI_HANDLE_WTD";
hwi1Params.enableInt = false;
Program.global.HWI_HANDLE_WTD = Hwi.create(34, "&WatchDog0Handler", hwi1Params);
Memory.defaultHeapSize = 1024;
var event2Params = new Event.Params();
event2Params.instance.name = "EVENT_HANDLE_DEBUG";
Program.global.EVENT_HANDLE_DEBUG = Event.create(event2Params);
var event3Params = new Event.Params();
event3Params.instance.name = "EVENT_HANDLE_GPS";
Program.global.EVENT_HANDLE_GPS = Event.create(event3Params);
var mailbox7Params0 = new Mailbox.Params();
mailbox7Params0.instance.name = "MBX_HANDLE_ADC";
Program.global.MBX_HANDLE_ADC = Mailbox.create(16, 5, mailbox7Params0);
Task.enableIdleTask = false;
var event3Params0 = new Event.Params();
event3Params0.instance.name = "EVENT_HANDLE_CLOCK";
Program.global.EVENT_HANDLE_CLOCK = Event.create(event3Params0);
var semaphore2Params = new Semaphore.Params();
semaphore2Params.instance.name = "SEM_HANDLE_CLOCK";
Program.global.SEM_HANDLE_CLOCK = Semaphore.create(1, semaphore2Params);
var hwi6Params = new Hwi.Params();
hwi6Params.instance.name = "hwi_CAN1_handle";
hwi6Params.priority = 10;
hwi6Params.enableInt = false;
Program.global.hwi_CAN1_handle = Hwi.create(56, "&hwi_CAN1_fxn", hwi6Params);
var mailbox8Params0 = new Mailbox.Params();
mailbox8Params0.instance.name = "Mb_uart2_handle";
Program.global.Mb_uart2_handle = Mailbox.create(8, 5, mailbox8Params0);
var event4Params = new Event.Params();
event4Params.instance.name = "EVENT_HANDLE_POWER";
Program.global.EVENT_HANDLE_POWER = Event.create(event4Params);
HeapBuf.trackMaxAllocs = true;
Idle.idleFxns[0] = null;
var semaphore3Params = new Semaphore.Params();
semaphore3Params.instance.name = "SEM_HANDLE_SDR";
Program.global.SEM_HANDLE_SDR = Semaphore.create(1, semaphore3Params);
Task.allBlockedFunc = "&Func_WTDClear";
var event5Params = new Event.Params();
event5Params.instance.name = "EVENT_HANDLE_UDS";
Program.global.EVENT_HANDLE_UDS = Event.create(event5Params);
var task1Params = new Task.Params();
task1Params.instance.name = "TSK_HANDLE_TEST_1";
task1Params.priority = 15;
task1Params.stackSize = 960;
Program.global.TSK_HANDLE_TEST_1 = Task.create("&TSK_TEST_1", task1Params);
var task2Params = new Task.Params();
task2Params.instance.name = "TSK_HANDLE_TEST_2";
task2Params.priority = 5;
task2Params.stackSize = 960;
Program.global.TSK_HANDLE_TEST_2 = Task.create("&TSK_TEST_2", task2Params);
var task3Params = new Task.Params();
task3Params.instance.name = "TSK_HANDLE_TEST_3";
task3Params.priority = 5;
task3Params.stackSize = 960;
Program.global.TSK_HANDLE_TEST_3 = Task.create("&TSK_TEST_3", task3Params);
var task4Params = new Task.Params();
task4Params.instance.name = "TSK_HANDLE_TEST_4";
task4Params.priority = 5;
task4Params.stackSize = 960;
Program.global.TSK_HANDLE_TEST_4 = Task.create("&TSK_TEST_4", task4Params);
var task5Params = new Task.Params();
task5Params.instance.name = "TSK_HANDLE_TEST_5";
task5Params.priority = 5;
task5Params.stackSize = 960;
Program.global.TSK_HANDLE_TEST_5 = Task.create("&TSK_TEST_5", task5Params);
var task6Params = new Task.Params();
task6Params.instance.name = "TSK_HANDLE_TEST_6";
task6Params.priority = 5;
task6Params.stackSize = 960;
Program.global.TSK_HANDLE_TEST_6 = Task.create("&TSK_TEST_6", task6Params);
var timer1Params0 = new Timer.Params();
timer1Params0.instance.name = "CYC_HANDLE_TEST_1";
timer1Params0.period = 10000;
Program.global.CYC_HANDLE_TEST_1 = Timer.create(2, "&CYC_TEST_1", timer1Params0);
var timer2Params = new Timer.Params();
timer2Params.instance.name = "CYC_HANDLE_TEST_2";
timer2Params.period = 10000;
Program.global.CYC_HANDLE_TEST_2 = Timer.create(3, "&CYC_TEST_2", timer2Params);
var timer3Params = new Timer.Params();
timer3Params.instance.name = "CYC_HANDLE_TEST_3";
timer3Params.period = 10000;
Program.global.CYC_HANDLE_TEST_3 = Timer.create(4, "&CYC_TEST_3", timer3Params);
