-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.cfg
810 lines (704 loc) · 27.9 KB
/
app.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
/******************************************************************************
@file app.cfg
Group: WCS LPC
Target Device: CC2652
******************************************************************************
Copyright (c) 2016-2017, Texas Instruments Incorporated
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Texas Instruments Incorporated nor the names of
its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
/* ================ Boot configuration ================ */
var Boot = xdc.useModule('ti.sysbios.family.arm.cc26xx.Boot');
/*
* This module contains family specific Boot APIs and configuration settings.
* See the SYS/BIOS API guide for more information.
*/
/*!
* Include a default customer configuration (CCFG) structure, default is
* false.
* Set to true to link in the default CCFG data structure in driverlib.
*/
Boot.customerConfig = false;
/* ================ Clock configuration ================ */
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
/*
* When using Power and calibrateRCOSC is set to true, this should be set to 10.
* The timer used by the Clock module supports TickMode_DYNAMIC. This enables us
* to set the tick period to 10 us without generating the overhead of additional
* interrupts.
*
* Note: The calibrateRCOSC parameter is set within the Power configuration
* structure in the "Board.c" file.
*/
Clock.tickPeriod = 10;
Clock.swiPriority = 4;
/* ================ Defaults (module) configuration ================ */
var Defaults = xdc.useModule('xdc.runtime.Defaults');
/*
* A flag to allow module names to be loaded on the target. Module name
* strings are placed in the .const section for debugging purposes.
*
* Pick one:
* - true (default)
* Setting this parameter to true will include name strings in the .const
* section so that Errors and Asserts are easier to debug.
* - false
* Setting this parameter to false will reduce footprint in the .const
* section. As a result, Error and Assert messages will contain an
* "unknown module" prefix instead of the actual module name.
*
* When using BIOS in ROM:
* This option must be set to false.
*/
//Defaults.common$.namedModule = true;
Defaults.common$.namedModule = false;
/* Compile out all Assert's */
//Defaults.common$.diags_ASSERT = Diags.ALWAYS_OFF;
/* ================ Error configuration ================ */
var Error = xdc.useModule('xdc.runtime.Error');
/*
* This function is called to handle all raised errors, but unlike
* Error.raiseHook, this function is responsible for completely handling the
* error with an appropriately initialized Error_Block.
*
* Pick one:
* - Error.policyDefault (default)
* Calls Error.raiseHook with an initialized Error_Block structure and logs
* the error using the module's logger.
* - Error.policySpin
* Simple alternative that traps on a while(1) loop for minimized target
* footprint.
* Using Error.policySpin, the Error.raiseHook will NOT called.
* - Error.policyMin
* Lightweight policy function that does minimum processing and returns.
*/
//Error.policyFxn = Error.policyDefault;
Error.policyFxn = Error.policySpin;
//Error.policyFxn = Error.policyMin;
/*
* If Error.policyFxn is set to Error.policyDefault, this function is called
* whenever an error is raised by the Error module.
*
* Pick one:
* - Error.print (default)
* Errors are formatted and output via System_printf() for easier
* debugging.
* - null
* Errors are not formatted or logged. This option reduces code footprint.
* - non-null function
* Errors invoke custom user function. See the Error module documentation
* for more details.
*/
//Error.raiseHook = Error.print;
Error.raiseHook = null;
//Error.raiseHook = "&myErrorFxn";
/*
* If Error.policyFxn is set to Error.policyDefault, this option applies to the
* maximum number of times the Error.raiseHook function can be recursively
* invoked. This option limits the possibility of an infinite recursion that
* could lead to a stack overflow.
* The default value is 16.
*/
Error.maxDepth = 2;
/* ================ Program configuration ================ */
/*
* Program.stack can be set to 0 to allow the setting
* of the system stack size to be determined in the example's
* linker command file.
*
* Program.stack is ignored with IAR. The C and Hwi stack sizes are determined
* by the size of the CSTACK section definition within the linker command file.
*/
if (Program.build.target.$name.match(/iar/)) {
Program.stack = 0;
}
else
{
Program.stack = 1536;
}
/*
* Uncomment to enable Semihosting for GNU targets to print to the CCS console.
* Please read the following TIRTOS Wiki page for more information on Semihosting:
* http://processors.wiki.ti.com/index.php/TI-RTOS_Examples_SemiHosting
*/
if (Program.build.target.$name.match(/gnu/)) {
//var SemiHost = xdc.useModule('ti.sysbios.rts.gnu.SemiHostSupport');
}
/* ================ ROM configuration ================ */
/*
* To use BIOS in flash, comment out the code block below.
*/
var ROM = xdc.useModule('ti.sysbios.rom.ROM');
if (Program.cpu.deviceName.match(/CC26/)) {
ROM.romName = ROM.CC26X2V2;
}
else if (Program.cpu.deviceName.match(/CC13/)) {
ROM.romName = ROM.CC13X2V2;
}
/* ================ Hwi configuration ================ */
var halHwi = xdc.useModule('ti.sysbios.hal.Hwi');
var m3Hwi = xdc.useModule('ti.sysbios.family.arm.m3.Hwi');
/*
* Checks for Hwi (system) stack overruns while in the Idle loop.
*
* Pick one:
* - true (default)
* Checks the top word for system stack overflows during the idle loop and
* raises an Error if one is detected.
* - false
* Disabling the runtime check improves runtime performance and yields a
* reduced flash footprint.
*/
//halHwi.checkStackFlag = true;
halHwi.checkStackFlag = false;
/*
* The following options alter the system's behavior when a hardware exception
* is detected.
*
* Pick one:
* - Hwi.enableException = true
* This option causes the default m3Hwi.excHandlerFunc function to fully
* decode an exception and dump the registers to the system console.
* This option raises errors in the Error module and displays the
* exception in ROV.
* - Hwi.enableException = false
* This option reduces code footprint by not decoding or printing the
* exception to the system console.
* It however still raises errors in the Error module and displays the
* exception in ROV.
* - Hwi.excHandlerFunc = null
* This is the most aggressive option for code footprint savings; but it
* can difficult to debug exceptions. It reduces flash footprint by
* plugging in a default while(1) trap when exception occur. This option
* does not raise an error with the Error module.
*/
//m3Hwi.enableException = true;
//m3Hwi.enableException = false;
//m3Hwi.excHandlerFunc = "&Main_excHandler";
m3Hwi.excHandlerFunc = null;
/*
* Enable hardware exception generation when dividing by zero.
*
* Pick one:
* - 0 (default)
* Disables hardware exceptions when dividing by zero
* - 1
* Enables hardware exceptions when dividing by zero
*/
m3Hwi.nvicCCR.DIV_0_TRP = 0;
//m3Hwi.nvicCCR.DIV_0_TRP = 1;
/*
* Enable hardware exception generation when accessing unaligned memory.
*
* Pick one:
* - 0 (default)
* Disables hardware exceptions when accessing unaligned memory
* - 1
* Enables hardware exceptions when accessing unaligned memory
*/
m3Hwi.nvicCCR.UNALIGN_TRP = 0;
//m3Hwi.nvicCCR.UNALIGN_TRP = 1;
/*
* Number of interrupts supported by target device.
*/
m3Hwi.NUM_INTERRUPTS = 54;
/*
* Address to place reset vector on target device.
* See the application's linker command file for further section
* information.
*/
m3Hwi.resetVectorAddress = 0x00;
/*
* Starting address to place the interrupt vector table.
* Note: This is currently placed in RAM to allow for interrupts to be
* configured at runtime.
*/
/* Put interrupt vector at start of RAM so interrupts can be configured at runtime */
m3Hwi.vectorTableAddress = 0x20000000;
/* ================ Idle configuration ================ */
var Idle = xdc.useModule('ti.sysbios.knl.Idle');
/*
* The Idle module is used to specify a list of functions to be called when no
* other tasks are running in the system.
*
* Functions added here will be run continuously within the idle task.
*
* Function signature:
* Void func(Void);
*/
//Idle.addFunc("&myIdleFunc");
Idle.addFunc('&Power_idleFunc'); /* Add the Power module's idle function */
/* ================ Kernel (SYS/BIOS) configuration ================ */
var BIOS = xdc.useModule('ti.sysbios.BIOS');
/*
* Enable asserts in the BIOS library.
*
* Pick one:
* - true (default)
* Enables asserts for debugging purposes.
* - false
* Disables asserts for a reduced code footprint and better performance.
*
* When using BIOS in ROM:
* This option must be set to false.
*/
//BIOS.assertsEnabled = true;
BIOS.assertsEnabled = false;
/*
* The SYS/BIOS runtime is provided in the form of a library that is linked
* with the application. Several forms of this library are provided with the
* SYS/BIOS product.
*
* Pick one:
* - BIOS.LibType_Custom
* Custom built library that is highly optimized for code footprint and
* runtime performance.
* - BIOS.LibType_Debug
* Custom built library that is non-optimized that can be used to
* single-step through APIs with a debugger.
*
*/
BIOS.libType = BIOS.LibType_Custom;
//BIOS.libType = BIOS.LibType_Debug;
/*
* A flag to determine if xdc.runtime sources are to be included in a custom
* built BIOS library.
*
* Pick one:
* - false (default)
* The pre-built xdc.runtime library is provided by the respective target
* used to build the application.
* - true
* xdc.runtime library sources are to be included in the custom BIOS
* library. This option yields the most efficient library in both code
* footprint and runtime performance.
*/
//BIOS.includeXdcRuntime = false;
BIOS.includeXdcRuntime = true;
/*
* Runtime instance creation enable flag.
*
* Pick one:
* - true (default)
* Allows Mod_create() and Mod_delete() to be called at runtime which
* requires a default heap for dynamic memory allocation.
* - false
* Reduces code footprint by disallowing Mod_create() and Mod_delete() to
* be called at runtime. Object instances are constructed via
* Mod_construct() and destructed via Mod_destruct().
*
* When using BIOS in ROM:
* This option must be set to true.
*/
BIOS.runtimeCreatesEnabled = true;
//BIOS.runtimeCreatesEnabled = false;
/*
* Enable logs in the BIOS library.
*
* Pick one:
* - true (default)
* Enables logs for debugging purposes.
* - false
* Disables logging for reduced code footprint and improved runtime
* performance.
*
* When using BIOS in ROM:
* This option must be set to false.
*/
//BIOS.logsEnabled = true;
BIOS.logsEnabled = false;
/* ================ Semaphore configuration ================ */
var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
/*
* Enables global support for Task priority pend queuing.
*
* Pick one:
* - true (default)
* This allows pending tasks to be serviced based on their task priority.
* - false
* Pending tasks are services based on first in, first out basis.
*
* When using BIOS in ROM:
* This option must be set to false.
*/
//Semaphore.supportsPriority = true;
Semaphore.supportsPriority = false;
/*
* Allows for the implicit posting of events through the semaphore,
* disable for additional code saving.
*
* Pick one:
* - true
* This allows the Semaphore module to post semaphores and events
* simultaneously.
* - false (default)
* Events must be explicitly posted to unblock tasks.
*
* When using BIOS in ROM:
* This option must be set to false.
*/
//Semaphore.supportsEvents = true;
Semaphore.supportsEvents = false;
/* ================ Swi configuration ================ */
var Swi = xdc.useModule('ti.sysbios.knl.Swi');
/*
* A software interrupt is an object that encapsulates a function to be
* executed and a priority. Software interrupts are prioritized, preempt tasks
* and are preempted by hardware interrupt service routines.
*
* This module is included to allow Swi's in a users' application.
*/
/*
* Reduce the number of swi priorities from the default of 16.
* Decreasing the number of swi priorities yields memory savings.
*/
Swi.numPriorities = 6;
/* ================ System configuration ================ */
var System = xdc.useModule('xdc.runtime.System');
/*
* The Abort handler is called when the system exits abnormally.
*
* Pick one:
* - System.abortStd (default)
* Call the ANSI C Standard 'abort()' to terminate the application.
* - System.abortSpin
* A lightweight abort function that loops indefinitely in a while(1) trap
* function.
* - A custom abort handler
* A user-defined function. See the System module documentation for
* details.
*/
//System.abortFxn = System.abortStd;
System.abortFxn = System.abortSpin;
//System.abortFxn = "&myAbortSystem";
/*
* The Exit handler is called when the system exits normally.
*
* Pick one:
* - System.exitStd (default)
* Call the ANSI C Standard 'exit()' to terminate the application.
* - System.exitSpin
* A lightweight exit function that loops indefinitely in a while(1) trap
* function.
* - A custom exit function
* A user-defined function. See the System module documentation for
* details.
*/
//System.exitFxn = System.exitStd;
System.exitFxn = System.exitSpin;
//System.exitFxn = "&myExitSystem";
/*
* Minimize exit handler array in the System module. The System module includes
* an array of functions that are registered with System_atexit() which is
* called by System_exit(). The default value is 8.
*/
System.maxAtexitHandlers = 0;
/*
* Enable System_printf() to display floats. Use the longer '%f%$L%$S%$F'
* if your code has SYS/BIOS instrumentation enabled (Asserts/Error/Log),
* as is typical with the 'debug' profile.
*/
//System.extendedFormats = '%f%$L%$S%$F';
//System.extendedFormats = '%f%$S';
/*
* The System.SupportProxy defines a low-level implementation of System
* functions such as System_printf(), System_flush(), etc.
*
* Pick one pair:
* - SysMin
* This module maintains an internal configurable circular buffer that
* stores the output until System_flush() is called.
* The size of the circular buffer is set via SysMin.bufSize.
* - SysCallback
* SysCallback allows for user-defined implementations for System APIs.
* The SysCallback support proxy has a smaller code footprint and can be
* used to supply custom System_printf services.
* The default SysCallback functions point to stub functions. See the
* SysCallback module's documentation.
*/
//var SysMin = xdc.useModule('xdc.runtime.SysMin');
//SysMin.bufSize = 2048;
//System.SupportProxy = SysMin;
//var SysCallback = xdc.useModule('xdc.runtime.SysCallback');
//System.SupportProxy = SysCallback;
//SysCallback.abortFxn = "&myUserAbort";
//SysCallback.exitFxn = "&myUserExit";
//SysCallback.flushFxn = "&myUserFlush";
//SysCallback.putchFxn = "&UartPrintf_putch";
//SysCallback.readyFxn = "&myUserReady";
/* ================ Task configuration ================ */
var Task = xdc.useModule('ti.sysbios.knl.Task');
/*
* Check task stacks for overflow conditions.
*
* Pick one:
* - true (default)
* Enables runtime checks for task stack overflow conditions during
* context switching ("from" and "to")
* - false
* Disables runtime checks for task stack overflow conditions.
*
* When using BIOS in ROM:
* This option must be set to false.
*/
//Task.checkStackFlag = true;
Task.checkStackFlag = false;
/*
* Set the default task stack size when creating tasks.
*
* The default is dependent on the device being used. Reducing the default stack
* size yields greater memory savings.
*/
Task.defaultStackSize = 512;
/*
* Enables the idle task.
*
* Pick one:
* - true (default)
* Creates a task with priority of 0 which calls idle hook functions. This
* option must be set to true to gain power savings provided by the Power
* module.
* - false
* No idle task is created. This option consumes less memory as no
* additional default task stack is needed.
* To gain power savings by the Power module without having the idle task,
* add Idle.run as the Task.allBlockedFunc.
*/
Task.enableIdleTask = true;
//Task.enableIdleTask = false;
//Task.allBlockedFunc = Idle.run;
/*
* If Task.enableIdleTask is set to true, this option sets the idle task's
* stack size.
*
* Reducing the idle stack size yields greater memory savings.
*/
Task.idleTaskStackSize = 512;
/*
* Reduce the number of task priorities.
* The default is 16.
* Decreasing the number of task priorities yield memory savings.
*/
Task.numPriorities = 6;
/* ================ Text configuration ================ */
var Text = xdc.useModule('xdc.runtime.Text');
/*
* These strings are placed in the .const section. Setting this parameter to
* false will save space in the .const section. Error, Assert and Log messages
* will print raw ids and args instead of a formatted message.
*
* Pick one:
* - true (default)
* This option loads test string into the .const for easier debugging.
* - false
* This option reduces the .const footprint.
*/
//Text.isLoaded = true;
Text.isLoaded = false;
/* ================ Types configuration ================ */
var Types = xdc.useModule('xdc.runtime.Types');
/*
* This module defines basic constants and types used throughout the
* xdc.runtime package.
*/
/* ================ Application Specific Instances ================ */
/* ================ Diagnostics configuration ================ */
var Diags = xdc.useModule('xdc.runtime.Diags');
/*
* You use the Diags module to set and clear bits in a module's diagnostics
* mask for the purpose of controlling diagnostics within that module. A
* module diagnostics mask controls both Assert and Log statements
* within that module, disabling these statements yields
* code savings.
*/
/* ================ Logging configuration ================ */
var Log = xdc.useModule('xdc.runtime.Log');
/*
* Modules and the application code generate Log_Event events by calling
* the Log module's functions.
* Disabling all Log statements here will allow the optimizer to completely
* remove all Log code from the application.
*
* Note: In order to generate Log events in your application both the Diags
* and the Log mask must be set. See the SYS/BIOS API guide for
* more information.
*/
/*
* LoggingSetup configures TI-RTOS modules to capture user-specified information
* such as CPU Load, Task Load and Task Execution so that it can be
* displayed by System Analyzer.
*
* loadLogging: (default = true) If true, LoggingSetup will add the kernel's
* load module, which measure the CPU load. See the BIOS API
* documentation for usage details
*/
//var LoggingSetup = xdc.useModule('ti.uia.sysbios.LoggingSetup');
//LoggingSetup.loadLogging = false;
//LoggingSetup.loadLoggerSize = 256;
//LoggingSetup.mainLoggerSize = 0x4000;
//LoggingSetup.sysbiosLoggerSize = 256;
//LoggingSetup.sysbiosSwiLogging = false;
//LoggingSetup.sysbiosHwiLogging = false;
//LoggingSetup.sysbiosSemaphoreLogging = false;
/* ================ Main configuration ================ */
//var Main = xdc.useModule('xdc.runtime.Main');
/* Configuration of this Main module is used for all code not in a module */
/* ================ POSIX configuration ================ */
//var Settings = xdc.useModule('ti.posix.tirtos.Settings');
/* ================ Event configuration ================ */
//var Event = xdc.useModule('ti.sysbios.knl.Event');
/* ================ Mailbox configuration ================ */
//var Mailbox = xdc.useModule('ti.sysbios.knl.Mailbox');
/* ================ GateMutexPri configuration ================ */
var GateMutexPri = xdc.useModule('ti.sysbios.gates.GateMutexPri');
/*
* Heap Configuration defines the type of Heap you want to use for the system (application + Stack)
* Only one Heap buffer will be allocated. This heap will be shared by the system and the stack through
* one manager (HeapMem, HeapMem+HeapTrack or OSAL)
* You can still decide to create several heaps if you want, but at least one heap needs to be created.
* The stack must have a Heap to run.
* The different Heap manager available are :
* OSAL HEAP: legacy Heap manager provided with all BLE sdk. By default, this Heap manager is used.
* HeapMem: heap manager provided by TI-RTOS (see TI-RTOS user guide for properties)
* HeapTrack: module on top of HeapMem allowing an easy debugging of memory allocated through HeapMem.
*
* The heap manager to use is selected by setting HEAPMGR_CONFIG to the corresponding value (see below)
* 0 = osal Heap manager, size is static.
* 0x80 = osal Heap manager, with auto-size: The remainning RAM (not used by the system) will be fully assign to the Heap.
* 1 = HeapMem with Static size
* 0x81 = HeapMem with auto-size. The remainning RAM (not used by the system) will be fully assign to the Heap.
* 2 = HeapTrack (with HeapMem) with fixe size
* 0x82 = HeapTrack (with HeapMem) with auto-size: The remainning RAM (not used by the system) will be fully assign to the Heap.
*
* If HEAPMGR_CONFIG is not defined, but the configuration file ble_stack_heap.cfg is used, then the value
* HEAPMGR_CONFIG = 0x80 is assumed.
* If HEAPMGR_CONFIG is not defined, and the file ble_stack_heap.cfg is not used, then the value
* HEAPMGR_CONFIG = 0x80 is assumed and the default Heap size will be 3072
* unless you define HEAPMGR_SIZE to a different value in the project option (0 meaning auto-size).
*
* From the configuration below, two #define will be created that will be used by the application to setup the Heap:
* #define HEAPMGR_SIZE
* #define HEAPMGR_CONFIG
* In order to use those define, this include line needs to be added: #include <xdc/cfg/global.h>
*
* In order for the auto-size Heap to work, the following symbol needs to be created by the linker:
* heapStart
* heapEnd
*/
/*
* DISCLAIMER: The HeapMem module in ROM can only use a GateMutex module. This means the malloc()
* function cannot be used in a Hwi/Swi.
* This means also that other access to the heap, with Icall_alloc for example, can potentially break the Heap...
* Therefore this solution is most effective when TI-RTOS is located in FLASH, so that a GateHwi can be used.
* If you try to use it in ROM, a workaround using HeapCallback is used, which will degrade performance.
*/
var Memory = xdc.useModule('xdc.runtime.Memory');
var HEAPMGR_CONFIG = 0x80;
var HEAPMGR_SIZE = 30000; //only valid if static size is used. This is the size of the buffer allocated for Heap.
if (typeof HEAPMGR_CONFIG === 'undefined' )
{
var HEAPMGR_CONFIG = 0x80;
}
// The following will create the #define HEAPMGR_CONFIG. It can then be used by include <xdc/cfg/global.h>
Program.global.HEAPMGR_CONFIG = HEAPMGR_CONFIG;
if (HEAPMGR_CONFIG === 1 || HEAPMGR_CONFIG === 0x81)
{
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
var heapMemParams = new HeapMem.Params();
if (HEAPMGR_CONFIG === 0x1)
{
heapMemParams.size = HEAPMGR_SIZE;
Program.global.HEAPMGR_SIZE = HEAPMGR_SIZE;
}
else
{
// if you get an undefined error for the symbol bellow it means that AUTOHEAPSIZE has been defined in the application.
Program.global.HEAPMGR_SIZE = 0;
heapMemParams.usePrimaryHeap = true;
HeapMem.primaryHeapBaseAddr = "&heapStart";
HeapMem.primaryHeapEndAddr = "&heapEnd";
}
Program.global.stackHeap = HeapMem.create(heapMemParams);
var GateHwi = xdc.useModule('ti.sysbios.gates.GateHwi');
HeapMem.common$.gate = GateHwi.create();
Memory.defaultHeapInstance = Program.global.stackHeap;
}
else if (HEAPMGR_CONFIG === 2 || HEAPMGR_CONFIG === 0x82)
{
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
var heapMemParams = new HeapMem.Params();
if (HEAPMGR_CONFIG === 2)
{
heapMemParams.size = HEAPMGR_SIZE;
Program.global.HEAPMGR_SIZE = HEAPMGR_SIZE;
}
else
{
// if you get an undefined error for the symbol bellow it means that AUTOHEAPSIZE has been defined in the application.
//
heapMemParams.usePrimaryHeap = true;
HeapMem.primaryHeapBaseAddr = "&heapStart";
HeapMem.primaryHeapEndAddr = "&heapEnd";
Program.global.HEAPMGR_SIZE = 0;
}
var tempHeap = HeapMem.create(heapMemParams);
var GateHwi = xdc.useModule('ti.sysbios.gates.GateHwi');
HeapMem.common$.gate = GateHwi.create();
var HeapTrack = xdc.useModule('ti.sysbios.heaps.HeapTrack');
var heapTrackParams = new HeapTrack.Params();
heapTrackParams.heap = tempHeap;
Program.global.stackHeap = HeapTrack.create(heapTrackParams)
Memory.defaultHeapInstance = Program.global.stackHeap;
}
else if (HEAPMGR_CONFIG === 0 || HEAPMGR_CONFIG === 0x80)
{
var HeapCallback = xdc.useModule('ti.sysbios.heaps.HeapCallback');
var params = new HeapCallback.Params();
params.arg = 1;
Program.global.heap0 = HeapCallback.create(params);
HeapCallback.initInstFxn = '&osalHeapInitFxn'; // Call First When BIOS boot. Initialize the Heap Manager.
HeapCallback.allocInstFxn = '&osalHeapAllocFxn'; // Call for allocating a buffer
HeapCallback.freeInstFxn = '&osalHeapFreeFxn'; // Call for Freeing a buffer
HeapCallback.getStatsInstFxn = '&osalHeapGetStatsFxn'; // Return Statistic on the Heap.
HeapCallback.isBlockingInstFxn = '&osalHeapIsBlockingFxn'; // Return TRUE: This heap is always blocking ('Hwi Gate' like )
//HeapCallback.createInstFxn = '&osalHeapCreateFxn'; // Not Supported
//HeapCallback.deleteInstFxn = '&osalHeapDeleteFxn'; // Not supported
Memory.defaultHeapInstance = Program.global.heap0;
if (HEAPMGR_CONFIG === 0)
{
// the following definition will create the #define HEAPMGR_SIZE ,
// which is used by thestack to have information about the heap manager size.
// if set to 0, this imply auto-size heap
Program.global.HEAPMGR_SIZE = HEAPMGR_SIZE;
}
else
{
// the following definition will create the #define HEAPMGR_SIZE ,
// which is used by the stack to have information about the heap manager size.
// if set to 0, this imply auto-size heap
// The heap buffer will be created automaticaly by using all the remaiing RAM available at the end of the build/link.
// For this, 2 symbole needs to be created by teh linker file: heapStart and heapEnd
Program.global.HEAPMGR_SIZE = 0;
}
}