]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_MPU_LPC54018_MCUXpresso/Demo/main.c
Add MPU demo project for LPC54018 board.
[freertos] / FreeRTOS / Demo / CORTEX_MPU_LPC54018_MCUXpresso / Demo / main.c
1 /*\r
2  * FreeRTOS Kernel V10.2.1\r
3  * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software.\r
14  *\r
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
21  *\r
22  * http://www.FreeRTOS.org\r
23  * http://aws.amazon.com/freertos\r
24  *\r
25  * 1 tab == 4 spaces!\r
26  */\r
27 /* Scheduler includes. */\r
28 #include "FreeRTOS.h"\r
29 #include "task.h"\r
30 \r
31 /* BSP includes. */\r
32 #include "board.h"\r
33 #include "pin_mux.h"\r
34 \r
35 /* Demo includes. */\r
36 #include "mpu_demo.h"\r
37 \r
38 /**\r
39  * @brief Performs board specific initialization.\r
40  */\r
41 static void prvInitHardware( void );\r
42 /*-----------------------------------------------------------*/\r
43 \r
44 static void prvInitHardware( void )\r
45 {\r
46         /* Attach 12 MHz clock to FLEXCOMM0 (debug console). */\r
47         CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);\r
48 \r
49         BOARD_InitPins();\r
50         BOARD_BootClockPLL180M();\r
51         BOARD_InitDebugConsole();\r
52 }\r
53 /*-----------------------------------------------------------*/\r
54 \r
55 int main( void )\r
56 {\r
57         /* Initialize hardware. */\r
58         prvInitHardware();\r
59 \r
60         /* Start the MPU demo. */\r
61         vStartMPUDemo();\r
62 \r
63         /* Start the scheduler. */\r
64         vTaskStartScheduler();\r
65 \r
66         /* Should not get here. */\r
67         for( ;; );\r
68 }\r
69 /*-----------------------------------------------------------*/\r
70 \r
71 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )\r
72 {\r
73         /* If configCHECK_FOR_STACK_OVERFLOW is set to either 1 or 2 then this\r
74         function will automatically get called if a task overflows its stack. */\r
75         ( void ) pxTask;\r
76         ( void ) pcTaskName;\r
77         for( ;; );\r
78 }\r
79 /*-----------------------------------------------------------*/\r
80 \r
81 void vApplicationMallocFailedHook( void )\r
82 {\r
83         /* If configUSE_MALLOC_FAILED_HOOK is set to 1 then this function will\r
84         be called automatically if a call to pvPortMalloc() fails.  pvPortMalloc()\r
85         is called automatically when a task, queue or semaphore is created. */\r
86         for( ;; );\r
87 }\r
88 /*-----------------------------------------------------------*/\r
89 \r
90 /* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an\r
91 implementation of vApplicationGetIdleTaskMemory() to provide the memory that is\r
92 used by the Idle task. */\r
93 void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize )\r
94 {\r
95 /* If the buffers to be provided to the Idle task are declared inside this\r
96 function then they must be declared static - otherwise they will be allocated on\r
97 the stack and so not exists after this function exits. */\r
98 static StaticTask_t xIdleTaskTCB;\r
99 static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];\r
100 \r
101         /* Pass out a pointer to the StaticTask_t structure in which the Idle task's\r
102         state will be stored. */\r
103         *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;\r
104 \r
105         /* Pass out the array that will be used as the Idle task's stack. */\r
106         *ppxIdleTaskStackBuffer = uxIdleTaskStack;\r
107 \r
108         /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.\r
109         Note that, as the array is necessarily of type StackType_t,\r
110         configMINIMAL_STACK_SIZE is specified in words, not bytes. */\r
111         *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;\r
112 }\r
113 /*-----------------------------------------------------------*/\r
114 \r
115 /* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the\r
116 application must provide an implementation of vApplicationGetTimerTaskMemory()\r
117 to provide the memory that is used by the Timer service task. */\r
118 void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize )\r
119 {\r
120 /* If the buffers to be provided to the Timer task are declared inside this\r
121 function then they must be declared static - otherwise they will be allocated on\r
122 the stack and so not exists after this function exits. */\r
123 static StaticTask_t xTimerTaskTCB;\r
124 static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];\r
125 \r
126         /* Pass out a pointer to the StaticTask_t structure in which the Timer\r
127         task's state will be stored. */\r
128         *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;\r
129 \r
130         /* Pass out the array that will be used as the Timer task's stack. */\r
131         *ppxTimerTaskStackBuffer = uxTimerTaskStack;\r
132 \r
133         /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.\r
134         Note that, as the array is necessarily of type StackType_t,\r
135         configMINIMAL_STACK_SIZE is specified in words, not bytes. */\r
136         *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;\r
137 }\r
138 /*-----------------------------------------------------------*/\r