-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
1514 lines (1196 loc) · 39.5 KB
/
main.cpp
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
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// main.cpp
// Main file
// ----------------------------------
// Developed with embedXcode
// http://embedXcode.weebly.com
//
// Project PJPMidiTouch
//
// Created by Peter, 19-04-18 21:02
// PJP
//
// Copyright © Peter, 2018
// Licence <#licence#>
//
// See PJPMidiTouch.ino and ReadMe.txt for references
//
// ----------------------------------
// DO NOT EDIT THIS FILE.
// THE SKETCH IS IN PJPMidiTouch.ino
// ----------------------------------
//
// Last update: Jan 18, 2017 release 6.0.9
// IDE selection
#if defined(EMBEDXCODE)
// Core library and main()
#if defined(REDBEARLAB_DUO)
#warning MAIN_SECTION 37 = RedBear Duo
// ============================================================================= RedBear Duo specific
#elif defined(SIMBLEE)
#warning MAIN_SECTION 39 = Simblee
// ============================================================================= Digistump Oak
#elif defined(OAK)
#warning MAIN_SECTION 36 = Digistump Oak
// ============================================================================= Digistump Oak
#elif defined(UDOO_NEO_M4) || defined(UDOO_NEO)
#warning MAIN_SECTION 35 = UDOO Neo M4
// ============================================================================= UDOO Neo M4 specific
#elif defined(__LINKIT_ONE__)
#warning MAIN_SECTION 1 = LINKIT_ONE
// ============================================================================= LinkIt One specific
#elif defined(__LINKIT_DUO__)
#warning MAIN_SECTION 38 = LINKIT_DUO
// ============================================================================= LinkIt Smart 7688 Duo specific
#elif defined(ESP8266)
#warning MAIN_SECTION 2 = ESP8266
// ============================================================================= ESP8266 specific
// from core_esp8266_main.cpp
/* RELEASE 2.3.0 only
*/
/*
main.cpp - platform initialization and context switching
emulation
Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
This file is part of the esp8266 core for Arduino environment.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//This may be used to change user task stack size:
//#define CONT_STACKSIZE 4096
#include <Arduino.h>
#include "Schedule.h"
extern "C" {
#include "ets_sys.h"
#include "os_type.h"
#include "osapi.h"
#include "mem.h"
#include "user_interface.h"
#include "cont.h"
}
#include <core_version.h>
#define LOOP_TASK_PRIORITY 1
#define LOOP_QUEUE_SIZE 1
#define OPTIMISTIC_YIELD_TIME_US 16000
struct rst_info resetInfo;
extern "C" {
extern const uint32_t __attribute__((section(".ver_number"))) core_version = ARDUINO_ESP8266_GIT_VER;
const char* core_release =
#ifdef ARDUINO_ESP8266_RELEASE
ARDUINO_ESP8266_RELEASE;
#else
NULL;
#endif
} // extern "C"
int atexit(void (*func)())
{
return 0;
}
extern "C" void ets_update_cpu_frequency(int freqmhz);
void initVariant() __attribute__((weak));
void initVariant()
{
}
extern void loop();
extern void setup();
void preloop_update_frequency() __attribute__((weak));
void preloop_update_frequency()
{
#if defined(F_CPU) && (F_CPU == 160000000L)
REG_SET_BIT(0x3ff00014, BIT(0));
ets_update_cpu_frequency(160);
#endif
}
extern void (*__init_array_start)(void);
extern void (*__init_array_end)(void);
cont_t g_cont __attribute__((aligned(16)));
static os_event_t g_loop_queue[LOOP_QUEUE_SIZE];
static uint32_t g_micros_at_task_start;
extern "C" void esp_yield()
{
if (cont_can_yield(&g_cont))
{
cont_yield(&g_cont);
}
}
extern "C" void esp_schedule()
{
ets_post(LOOP_TASK_PRIORITY, 0, 0);
}
extern "C" void __yield()
{
if (cont_can_yield(&g_cont))
{
esp_schedule();
esp_yield();
}
else
{
panic();
}
}
extern "C" void yield(void) __attribute__((weak, alias("__yield")));
extern "C" void optimistic_yield(uint32_t interval_us)
{
if (cont_can_yield(&g_cont) &&
(system_get_time() - g_micros_at_task_start) > interval_us)
{
yield();
}
}
static void loop_wrapper()
{
static bool setup_done = false;
preloop_update_frequency();
if (!setup_done)
{
setup();
#ifdef DEBUG_ESP_PORT
DEBUG_ESP_PORT.setDebugOutput(true);
#endif
setup_done = true;
}
loop();
run_scheduled_functions();
esp_schedule();
}
static void loop_task(os_event_t *events)
{
g_micros_at_task_start = system_get_time();
cont_run(&g_cont, &loop_wrapper);
if (cont_check(&g_cont) != 0)
{
panic();
}
}
static void do_global_ctors(void)
{
void (**p)(void) = &__init_array_end;
while (p != &__init_array_start)
{
(*--p)();
}
}
extern "C" void __gdb_init() {}
extern "C" void gdb_init(void) __attribute__((weak, alias("__gdb_init")));
extern "C" void __gdb_do_break() {}
extern "C" void gdb_do_break(void) __attribute__((weak, alias("__gdb_do_break")));
void init_done()
{
system_set_os_print(1);
gdb_init();
do_global_ctors();
printf("\n%08x\n", core_version);
esp_schedule();
}
extern "C" void user_init(void)
{
struct rst_info *rtc_info_ptr = system_get_rst_info();
memcpy((void *) &resetInfo, (void *) rtc_info_ptr, sizeof(resetInfo));
uart_div_modify(0, UART_CLK_FREQ / (115200));
init();
initVariant();
cont_init(&g_cont);
ets_task(loop_task,
LOOP_TASK_PRIORITY, g_loop_queue,
LOOP_QUEUE_SIZE);
system_init_done_cb(&init_done);
}
#elif defined(SPARK) || defined(PARTICLE)
#warning MAIN_SECTION 3 = Particle / Spark
// ============================================================================= Particle / Spark specific
#elif defined(MBED)
#warning MAIN_SECTION 4 = mbed
// ============================================================================= mbed specific
#elif defined(MPIDE) || defined(CHIPKIT)
#warning MAIN_SECTION 5 = chipKIT
// ============================================================================= chipKIT specific
#elif defined(DIGISPARK)
#warning MAIN_SECTION 6 = Digispark
// ============================================================================= Digispark specific
#elif defined(MICRODUINO)
#warning MAIN_SECTION 7 = Microduino
// ============================================================================= Microduino specific
#elif defined(ENERGIA_MT)
// ============================================================================= Energia Multi-Tasking specific
#include "rtosTasks.h"
#if defined(__CC3200R1M1RGC__) || defined(__CC3200R1MXRGCR__) || defined(ENERGIA_ARCH_CC3200)
#warning MAIN_SECTION 7 = CC3200 EMT
// ----------------------------------------------------------------------------- LaunchPad CC3200 with RTOS specific
/*
======== main.cpp ========
MT wiring Task framework
*/
#include <stddef.h>
//#include <oslib/osi.h>
/* XDC Header files */
#include <xdc/cfg/global.h>
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/family/arm/m3/Hwi.h>
#include <xdc/runtime/System.h>
/* Board Support Header files (from configuration closure) */
//#include "Board.h"
#include <ti/runtime/wiring/Energia.h>
//#if defined(__TI_COMPILER_VERSION__) || defined(__GNUC__)
//__extern int __UNUSED_start__, __UNUSED_end__;
//#define START (&__UNUSED_start__)
//#define END (&__UNUSED_end__)
//#else
//#define START NULL
//#define END NULL
//#endif
/* magic insertion point 769d20fcd7a0eedaf64270f591438b01 */
/*
__extern void setup();
__extern void loop();
#define NUM_SKETCHES 1
void (*func_ptr[NUM_SKETCHES][2])(void) = {
{setup, loop}
};
*/
Void the_task(UArg _task_setup, UArg _task_loop);
/* set priority of simple link callbacks
must be >= 0 and < Task_numPriorities
where Task_numPriorities is set by
TI-RTOS config
*/
#define SIMPLELINK_PRI 3
/* Wiring-specific GPIO HW interrupt vectors */
//__extern void Wiring_GPIO_hwiIntFxn(UArg callbacks);
/*
======== main task ========
*/
Void the_task(UArg _task_setup, UArg _task_loop)
{
/* Call setup once */
(*(void(*)()) _task_setup)();
/* Call loop repeatedly */
for (;;)
{
(*(void(*)()) _task_loop)();
System_flush();
Task_yield();
}
}
// ~
///
/// @page Main setup
///
/// @author Rei Vilo
/// @date Jun 30, 2015 10:18
/// @version 102
///
/// @copyright (c) Rei Vilo, 2015
/// @copyright CC = BY SA NC
/// @{
///
/// @brief main setup function
/// @note rtosSetup() is called before all other tasks
/// * Optional declaration
/// * Defined in main sketch or in rtosGlobals
/// @warning No delay() in rtosSetup()!
///
void rtosSetup() __attribute__((weak));
///
/// @brief Proxy function for Task_create()
/// @note Task_create() requires non-weak functions
///
void rtos_Setup()
{
rtosSetup();
};
// ~
/*
======== main ========
*/
int main()
{
/* initialize all device/board specific peripherals */
Board_init(); /* this function is generated as part of TI-RTOS config */
// System_printf("unused memory: start = %p, end = %p\n", START, END);
/* The SimpleLink Host Driver requires a mechanism to allow functions to
execute in task context. The SpawnTask is created to handle such
situations. This task will remain blocked until the host driver
posts a function. If the SpawnTask priority is higher than other
tasks, it will immediately execute that function and return to a
blocked state. Otherwise, it will remain ready until it has
the highest priority of any ready function.
*/
// VStartSimpleLinkSpawnTask(SIMPLELINK_PRI);
/* hijack the common hwi func to point to Wiring's handler that clears
the GPIO interrupt
*/
// Hwi_setFunc(Hwi_handle((Hwi_Struct *)Board_gpioCallbacks0.hwiStruct),
// Wiring_GPIO_hwiIntFxn, (UArg)&Board_gpioCallbacks0);
// Hwi_setFunc(Hwi_handle((Hwi_Struct *)Board_gpioCallbacks1.hwiStruct),
// Wiring_GPIO_hwiIntFxn, (UArg)&Board_gpioCallbacks1);
// Hwi_setFunc(Hwi_handle((Hwi_Struct *)Board_gpioCallbacks2.hwiStruct),
// Wiring_GPIO_hwiIntFxn, (UArg)&Board_gpioCallbacks2);
// Hwi_setFunc(Hwi_handle((Hwi_Struct *)Board_gpioCallbacks3.hwiStruct),
// Wiring_GPIO_hwiIntFxn, (UArg)&Board_gpioCallbacks3);
Task_Params taskParams;
System_printf("Startup\n");
System_flush();
/* initialize taskParams and set to default */
Task_Params_init(&taskParams);
/* All tasks have the same priority */
taskParams.priority = Task_numPriorities - 1;
taskParams.stackSize = 0xc00;
// ~
// Add rtosSetup() as first tasks
taskParams.instance->name = (xdc_String) "rtosSetup";
Task_create((Task_FuncPtr) rtos_Setup, &taskParams, NULL);
// ~
uint8_t i = 0;
for (i = 0; i < NUM_SKETCHES; i++)
{
/* Set arg0 to setup() */
taskParams.arg0 = (xdc_UArg)func_ptr[i][0];
/* Set ar1 to loop */
taskParams.arg1 = (xdc_UArg)func_ptr[i][1];
/* Set the task name */
taskParams.instance->name = (xdc_String) taskNames[i];
/* Create the task */
Task_create(the_task, &taskParams, NULL);
}
/* does not return */
BIOS_start();
return (0); /* should never get here, but just in case ... */
}
#elif defined(__MSP432P401R__) || defined(ENERGIA_ARCH_MSP432)
#warning MAIN_SECTION 8 = MSP432 EMT
// ----------------------------------------------------------------------------- LaunchPad MSP432 with RTOS specific
/*
======== main.cpp ========
MT wiring Task framework
*/
#include <stddef.h>
//#include <oslib/osi.h>
/* XDC Header files */
#include <xdc/cfg/global.h>
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/family/arm/m3/Hwi.h>
#include <xdc/runtime/System.h>
/* Board Support Header files (from configuration closure) */
#include <ti/runtime/wiring/Energia.h>
/* magic insertion point 769d20fcd7a0eedaf64270f591438b01 */
//extern void setupsketch_aug24a();
//extern void loopsketch_aug24a();
//
//#define NUM_SKETCHES 1
//void (*func_ptr[NUM_SKETCHES][2])(void) = {
// {setupsketch_aug24a, loopsketch_aug24a}
//};
//const char *taskNames[] = {
// "loopsketch_aug24a"
//};
Void the_task(UArg _task_setup, UArg _task_loop);
/* set priority of simple link callbacks
must be >= 0 and < Task_numPriorities
where Task_numPriorities is set by
TI-RTOS config
*/
// ~
///
/// @page Main setup
///
/// @author Rei Vilo
/// @date Jun 30, 2015 10:18
/// @version 102
///
/// @copyright (c) Rei Vilo, 2015
/// @copyright CC = BY SA NC
/// @{
///
/// @brief main setup function
/// @note rtosSetup() is called before all other tasks
/// * Optional declaration
/// * Defined in main sketch or in rtosGlobals
/// @warning No delay() in rtosSetup()!
///
void rtosSetup() __attribute__((weak));
///
/// @brief Proxy function for Task_create()
/// @note Task_create() requires non-weak functions
///
void rtos_Setup()
{
rtosSetup();
};
// ~
/////
///// @brief Proxy function for Task_create()
///// @note Task_create() requires non-weak functions
/////
//void rtos_Loop() { ; }
/// @}
/*
======== main task ========
*/
Void the_task(UArg _task_setup, UArg _task_loop)
{
/* Call setup once */
(*(void(*)()) _task_setup)();
/* Call loop repeatedly */
for (;;)
{
(*(void(*)()) _task_loop)();
System_flush();
Task_yield();
}
}
/*
======== main ========
*/
int main()
{
/* initialize all device/board specific peripherals */
Board_init(); /* this function is generated as part of TI-RTOS config */
/* The SimpleLink Host Driver requires a mechanism to allow functions to
execute in task context. The SpawnTask is created to handle such
situations. This task will remain blocked until the host driver
posts a function. If the SpawnTask priority is higher than other
tasks, it will immediately execute that function and return to a
blocked state. Otherwise, it will remain ready until it has
the highest priority of any ready function.
*/
Task_Params taskParams;
/* initialize taskParams and set to default */
Task_Params_init(&taskParams);
/* All tasks have the same priority */
taskParams.priority = Task_numPriorities - 2;
taskParams.stackSize = 0x800;
// ~
// Add rtosSetup() as first tasks
taskParams.instance->name = (xdc_String) "rtosSetup";
Task_create((Task_FuncPtr) rtos_Setup, &taskParams, NULL);
// ~
uint8_t i = 0;
for (i = 0; i < NUM_SKETCHES; i++)
{
/* Set arg0 to setup() */
taskParams.arg0 = (xdc_UArg)func_ptr[i][0];
/* Set ar1 to loop */
taskParams.arg1 = (xdc_UArg)func_ptr[i][1];
/* Set the task name */
taskParams.instance->name = (xdc_String) taskNames[i];
/* Create the task */
Task_create(the_task, &taskParams, NULL);
}
/* does not return */
BIOS_start();
return (0); /* should never get here, but just in case ... */
}
#elif defined(__CC2650__)
#warning MAIN_SECTION 9 = CC2650 EMT
// ----------------------------------------------------------------------------- SensorTag CC2650 with RTOS specific
/*
======== main.cpp ========
MT wiring Task framework
*/
#include <stddef.h>
//#include <oslib/osi.h>
/* XDC Header files */
#include <xdc/cfg/global.h>
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/family/arm/m3/Hwi.h>
#include <xdc/runtime/System.h>
/* Board Support Header files (from configuration closure) */
//#include "Board.h"
#include <ti/runtime/wiring/Energia.h>
//#if defined(__TI_COMPILER_VERSION__) || defined(__GNUC__)
//__extern int __UNUSED_start__, __UNUSED_end__;
//#define START (&__UNUSED_start__)
//#define END (&__UNUSED_end__)
//#else
//#define START NULL
//#define END NULL
//#endif
/* magic insertion point 769d20fcd7a0eedaf64270f591438b01 */
/*
__extern void setup();
__extern void loop();
#define NUM_SKETCHES 1
void (*func_ptr[NUM_SKETCHES][2])(void) = {
{setup, loop}
};
*/
xdc_Void the_task(xdc_UArg _task_setup, xdc_UArg _task_loop);
/* set priority of simple link callbacks
must be >= 0 and < Task_numPriorities
where Task_numPriorities is set by
TI-RTOS config
*/
//#define SIMPLELINK_PRI 3
/* Wiring-specific GPIO HW interrupt vectors */
__extern void Wiring_GPIO_hwiIntFxn(xdc_UArg callbacks);
// ~
///
/// @page Main setup
///
/// @author Rei Vilo
/// @date Jun 30, 2015 10:18
/// @version 102
///
/// @copyright (c) Rei Vilo, 2015
/// @copyright CC = BY SA NC
/// @{
///
/// @brief main setup function
/// @note rtosSetup() is called before all other tasks
/// * Optional declaration
/// * Defined in main sketch or in rtosGlobals
/// @warning No delay() in rtosSetup()!
///
void rtosSetup() __attribute__((weak));
///
/// @brief Proxy function for Task_create()
/// @note Task_create() requires non-weak functions
///
void rtos_Setup()
{
rtosSetup();
};
// ~
/*
======== main task ========
*/
xdc_Void the_task(xdc_UArg _task_setup, xdc_UArg _task_loop)
{
/* Call setup once */
(*(void(*)()) _task_setup)();
/* Call loop repeatedly */
for (;;)
{
(*(void(*)()) _task_loop)();
System_flush();
Task_yield();
}
}
/*
======== main ========
*/
int main()
{
/* initialize all device/board specific peripherals */
Board_init(); /* this function is generated as part of TI-RTOS config */
/* The SimpleLink Host Driver requires a mechanism to allow functions to
execute in task context. The SpawnTask is created to handle such
situations. This task will remain blocked until the host driver
posts a function. If the SpawnTask priority is higher than other
tasks, it will immediately execute that function and return to a
blocked state. Otherwise, it will remain ready until it has
the highest priority of any ready function.
*/
// VStartSimpleLinkSpawnTask(SIMPLELINK_PRI);
/* hijack the common hwi func to point to Wiring's handler that clears
the GPIO interrupt
*/
// Hwi_setFunc(Hwi_handle((Hwi_Struct *)Board_gpioCallbacks0.hwiStruct),
// Wiring_GPIO_hwiIntFxn, (UArg)&Board_gpioCallbacks0);
// Hwi_setFunc(Hwi_handle((Hwi_Struct *)Board_gpioCallbacks1.hwiStruct),
// Wiring_GPIO_hwiIntFxn, (UArg)&Board_gpioCallbacks1);
// Hwi_setFunc(Hwi_handle((Hwi_Struct *)Board_gpioCallbacks2.hwiStruct),
// Wiring_GPIO_hwiIntFxn, (UArg)&Board_gpioCallbacks2);
// Hwi_setFunc(Hwi_handle((Hwi_Struct *)Board_gpioCallbacks3.hwiStruct),
// Wiring_GPIO_hwiIntFxn, (UArg)&Board_gpioCallbacks3);
Task_Params taskParams;
/* initialize taskParams and set to default */
Task_Params_init(&taskParams);
/* All tasks have the same priority */
taskParams.priority = Task_numPriorities - 2;
taskParams.stackSize = 0x800;
// ~
// Add rtosSetup() as first tasks
taskParams.instance->name = (xdc_String) "rtosSetup";
Task_create((Task_FuncPtr) rtos_Setup, &taskParams, NULL);
// ~
uint8_t i = 0;
for (i = 0; i < NUM_SKETCHES; i++)
{
/* Set arg0 to setup() */
taskParams.arg0 = (xdc_UArg)func_ptr[i][0];
/* Set ar1 to loop */
taskParams.arg1 = (xdc_UArg)func_ptr[i][1];
/* Set the task name */
taskParams.instance->name = (xdc_String) taskNames[i];
/* Create the task */
Task_create(the_task, &taskParams, NULL);
}
/* does not return */
BIOS_start();
return (0); /* should never get here, but just in case ... */
}
#elif defined(__CC1310__) || defined(ENERGIA_ARCH_CC13XX)
#warning MAIN_SECTION 41 = CC1310 EMT
// ----------------------------------------------------------------------------- LaunchPad CC1310 specific
#else
#error Board for Energia MT not defined
#endif
#elif defined(ENERGIA)
// ============================================================================= Energia Standard
#if defined(__CC3200R1M1RGC__) || defined(__CC3200R1MXRGCR__) || defined(ENERGIA_ARCH_CC3200)
#warning MAIN_SECTION 10 = CC3200 standard
// ----------------------------------------------------------------------------- LaunchPad CC3200 specific
#include <Energia.h>
#include "inc/hw_gpio.h"
#include "driverlib/rom_map.h"
#include "driverlib/prcm.h"
#include "driverlib/interrupt.h"
#include "driverlib/systick.h"
#include <driverlib/utils.h>
#include "inc/hw_hib1p2.h"
#include "inc/hw_hib3p3.h"
extern void (* const g_pfnVectors[])(void);
#ifdef __cplusplus
extern "C" {
#endif
void _init(void)
{
IntVTableBaseSet((unsigned long)&g_pfnVectors[0]);
MAP_PRCMPeripheralClkEnable(PRCM_GPIOA0, PRCM_RUN_MODE_CLK);
MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK);
MAP_PRCMPeripheralClkEnable(PRCM_GPIOA2, PRCM_RUN_MODE_CLK);
MAP_PRCMPeripheralClkEnable(PRCM_GPIOA3, PRCM_RUN_MODE_CLK);
MAP_IntMasterEnable();
PRCMCC3200MCUInit();
MAP_SysTickIntEnable();
MAP_SysTickPeriodSet(F_CPU / 1000);
MAP_SysTickEnable();
}
#ifdef __cplusplus
} /* extern "C" */
#endif
int main(void)
{
setup();
for (;;)
{
loop();
if (serialEventRun)
{
serialEventRun();
}
}
}
#elif defined(__TMS320F28027__) || defined(__TMS320F28069__)
#warning MAIN_SECTION 11 = C2000 standard
// ----------------------------------------------------------------------------- C2000 specific
#elif defined(__LM4F120H5QR__) || defined(__TM4C1230C3PM__) || defined(__TM4C129XNCZAD__) || defined(__TM4C123GH6PM__) || defined(ENERGIA_ARCH_TIVAC)
#warning MAIN_SECTION 12 = LM4F standard
// ----------------------------------------------------------------------------- LaunchPad Stellaris and Tiva specific
#include <Energia.h>
#if defined(PART_TM4C129XNCZAD)
#include "inc/tm4c129xnczad.h"
#elif defined(PART_TM4C1294NCPDT)
#include "inc/tm4c1294ncpdt.h"
#elif defined(PART_TM4C1233H6PM) || defined(PART_LM4F120H5QR)
#include "inc/tm4c123gh6pm.h"
#else
#error "**** No PART defined or unsupported PART ****"
#endif
#include "inc/hw_gpio.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "driverlib/eeprom.h"
#ifdef __cplusplus
extern "C" {
void _init(void)
{
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_EEPROM0);
if (ROM_EEPROMInit() == EEPROM_INIT_ERROR)
{
if (ROM_EEPROMInit() != EEPROM_INIT_ERROR)
{
EEPROMMassErase();
}
}
timerInit();
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOQ);
#ifdef TARGET_IS_SNOWFLAKE_RA0
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOR);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOS);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOT);
#endif
//Unlock and commit NMI pins PD7 and PF0
HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = 0x4C4F434B;
HWREG(GPIO_PORTF_BASE + GPIO_O_CR) |= 0x1;
HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = 0x4C4F434B;
HWREG(GPIO_PORTD_BASE + GPIO_O_CR) |= 0x80;
} /* void _init(void) */
} /* extern "C" */
#endif
int main(void)
{
setup();
for (;;)
{
loop();
if (serialEventRun)
{
serialEventRun();
}
}
}
#else
// ----------------------------------------------------------------------------- LaunchPad MSP430 and Experimeter Board FR5739 specific
#include <Energia.h>
int main(void)
{
init();
setup();
for (;;)
{
loop();
if (serialEventRun)
{
serialEventRun();
}
}
return 0;
}
#endif // Energia
#elif defined(LIGHTBLUE_CORE)
#warning MAIN_SECTION 13 = LightBlue Bean
// ============================================================================= LightBlue Bean specific
#elif defined(ROBOTIS)
#warning MAIN_SECTION 14 = Robotis
// ============================================================================= Robotis specific
#elif defined(MAPLE_IDE)
#warning MAIN_SECTION 15 = Maple
// ============================================================================= Maple specific
#include <WProgram.h>
// *****************************************************************************
// The MIT Licence
//
// Copyright (c) 2010 LeafLabs LLC.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use, copy,
// modify, merge, publish, distribute, subLicence, and/or sell copies
// of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//