Repostiory containing DAPLink source code with Reset Pin workaround for HANI_IOT board.
Upstream: https://github.com/ARMmbed/DAPLink
source/rtos/RTX_Config.c@0:01f31e923fe2, 2020-04-07 (annotated)
- Committer:
- Pawel Zarembski
- Date:
- Tue Apr 07 12:55:42 2020 +0200
- Revision:
- 0:01f31e923fe2
hani: DAPLink with reset workaround
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Pawel Zarembski |
0:01f31e923fe2 | 1 | /** |
Pawel Zarembski |
0:01f31e923fe2 | 2 | * @file RTX_Config.c |
Pawel Zarembski |
0:01f31e923fe2 | 3 | * @brief Project settings for the RTX kernel |
Pawel Zarembski |
0:01f31e923fe2 | 4 | * |
Pawel Zarembski |
0:01f31e923fe2 | 5 | * DAPLink Interface Firmware |
Pawel Zarembski |
0:01f31e923fe2 | 6 | * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved |
Pawel Zarembski |
0:01f31e923fe2 | 7 | * SPDX-License-Identifier: Apache-2.0 |
Pawel Zarembski |
0:01f31e923fe2 | 8 | * |
Pawel Zarembski |
0:01f31e923fe2 | 9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
Pawel Zarembski |
0:01f31e923fe2 | 10 | * not use this file except in compliance with the License. |
Pawel Zarembski |
0:01f31e923fe2 | 11 | * You may obtain a copy of the License at |
Pawel Zarembski |
0:01f31e923fe2 | 12 | * |
Pawel Zarembski |
0:01f31e923fe2 | 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
Pawel Zarembski |
0:01f31e923fe2 | 14 | * |
Pawel Zarembski |
0:01f31e923fe2 | 15 | * Unless required by applicable law or agreed to in writing, software |
Pawel Zarembski |
0:01f31e923fe2 | 16 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
Pawel Zarembski |
0:01f31e923fe2 | 17 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Pawel Zarembski |
0:01f31e923fe2 | 18 | * See the License for the specific language governing permissions and |
Pawel Zarembski |
0:01f31e923fe2 | 19 | * limitations under the License. |
Pawel Zarembski |
0:01f31e923fe2 | 20 | */ |
Pawel Zarembski |
0:01f31e923fe2 | 21 | |
Pawel Zarembski |
0:01f31e923fe2 | 22 | #include "RTL.h" |
Pawel Zarembski |
0:01f31e923fe2 | 23 | #include "util.h" |
Pawel Zarembski |
0:01f31e923fe2 | 24 | #include "cortex_m.h" |
Pawel Zarembski |
0:01f31e923fe2 | 25 | |
Pawel Zarembski |
0:01f31e923fe2 | 26 | /*---------------------------------------------------------------------------- |
Pawel Zarembski |
0:01f31e923fe2 | 27 | * RTX User configuration part BEGIN |
Pawel Zarembski |
0:01f31e923fe2 | 28 | *---------------------------------------------------------------------------*/ |
Pawel Zarembski |
0:01f31e923fe2 | 29 | |
Pawel Zarembski |
0:01f31e923fe2 | 30 | //-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- |
Pawel Zarembski |
0:01f31e923fe2 | 31 | // |
Pawel Zarembski |
0:01f31e923fe2 | 32 | // <h>Task Configuration |
Pawel Zarembski |
0:01f31e923fe2 | 33 | // ===================== |
Pawel Zarembski |
0:01f31e923fe2 | 34 | // |
Pawel Zarembski |
0:01f31e923fe2 | 35 | // <o>Number of concurrent running tasks <0-250> |
Pawel Zarembski |
0:01f31e923fe2 | 36 | // <i> Define max. number of tasks that will run at the same time. |
Pawel Zarembski |
0:01f31e923fe2 | 37 | // <i> Default: 6 |
Pawel Zarembski |
0:01f31e923fe2 | 38 | #ifndef OS_TASKCNT |
Pawel Zarembski |
0:01f31e923fe2 | 39 | #define OS_TASKCNT 4 |
Pawel Zarembski |
0:01f31e923fe2 | 40 | // Threads with user provided stacks: |
Pawel Zarembski |
0:01f31e923fe2 | 41 | // -serial_process |
Pawel Zarembski |
0:01f31e923fe2 | 42 | // -hid_process |
Pawel Zarembski |
0:01f31e923fe2 | 43 | // -timer_task_30mS |
Pawel Zarembski |
0:01f31e923fe2 | 44 | // -main_task |
Pawel Zarembski |
0:01f31e923fe2 | 45 | #endif |
Pawel Zarembski |
0:01f31e923fe2 | 46 | |
Pawel Zarembski |
0:01f31e923fe2 | 47 | // <o>Number of tasks with user-provided stack <0-250> |
Pawel Zarembski |
0:01f31e923fe2 | 48 | // <i> Define the number of tasks that will use a bigger stack. |
Pawel Zarembski |
0:01f31e923fe2 | 49 | // <i> The memory space for the stack is provided by the user. |
Pawel Zarembski |
0:01f31e923fe2 | 50 | // <i> Default: 0 |
Pawel Zarembski |
0:01f31e923fe2 | 51 | #ifndef OS_PRIVCNT |
Pawel Zarembski |
0:01f31e923fe2 | 52 | #define OS_PRIVCNT OS_TASKCNT |
Pawel Zarembski |
0:01f31e923fe2 | 53 | // All tasks use private stacks (aside from background thread) |
Pawel Zarembski |
0:01f31e923fe2 | 54 | #endif |
Pawel Zarembski |
0:01f31e923fe2 | 55 | |
Pawel Zarembski |
0:01f31e923fe2 | 56 | // <o>Task stack size [bytes] <20-4096:8><#/4> |
Pawel Zarembski |
0:01f31e923fe2 | 57 | // <i> Set the stack size for tasks which is assigned by the system. |
Pawel Zarembski |
0:01f31e923fe2 | 58 | // <i> Default: 200 |
Pawel Zarembski |
0:01f31e923fe2 | 59 | #ifndef OS_STKSIZE |
Pawel Zarembski |
0:01f31e923fe2 | 60 | #define OS_STKSIZE 34 |
Pawel Zarembski |
0:01f31e923fe2 | 61 | // Used by: |
Pawel Zarembski |
0:01f31e923fe2 | 62 | // -os_idle_demon |
Pawel Zarembski |
0:01f31e923fe2 | 63 | #endif |
Pawel Zarembski |
0:01f31e923fe2 | 64 | |
Pawel Zarembski |
0:01f31e923fe2 | 65 | // <q>Check for the stack overflow |
Pawel Zarembski |
0:01f31e923fe2 | 66 | // =============================== |
Pawel Zarembski |
0:01f31e923fe2 | 67 | // <i> Include the stack checking code for a stack overflow. |
Pawel Zarembski |
0:01f31e923fe2 | 68 | // <i> Note that additional code reduces the Kernel performance. |
Pawel Zarembski |
0:01f31e923fe2 | 69 | #ifndef OS_STKCHECK |
Pawel Zarembski |
0:01f31e923fe2 | 70 | #define OS_STKCHECK 1 |
Pawel Zarembski |
0:01f31e923fe2 | 71 | #endif |
Pawel Zarembski |
0:01f31e923fe2 | 72 | |
Pawel Zarembski |
0:01f31e923fe2 | 73 | // <q>Run in privileged mode |
Pawel Zarembski |
0:01f31e923fe2 | 74 | // ========================= |
Pawel Zarembski |
0:01f31e923fe2 | 75 | // <i> Run all Tasks in privileged mode. |
Pawel Zarembski |
0:01f31e923fe2 | 76 | // <i> Default: Unprivileged |
Pawel Zarembski |
0:01f31e923fe2 | 77 | #ifndef OS_RUNPRIV |
Pawel Zarembski |
0:01f31e923fe2 | 78 | #define OS_RUNPRIV 1 |
Pawel Zarembski |
0:01f31e923fe2 | 79 | #endif |
Pawel Zarembski |
0:01f31e923fe2 | 80 | |
Pawel Zarembski |
0:01f31e923fe2 | 81 | // </h> |
Pawel Zarembski |
0:01f31e923fe2 | 82 | // <h>SysTick Timer Configuration |
Pawel Zarembski |
0:01f31e923fe2 | 83 | // ============================= |
Pawel Zarembski |
0:01f31e923fe2 | 84 | // <o>Timer clock value [Hz] <1-1000000000> |
Pawel Zarembski |
0:01f31e923fe2 | 85 | // <i> Set the timer clock value for selected timer. |
Pawel Zarembski |
0:01f31e923fe2 | 86 | #ifndef OS_CLOCK |
Pawel Zarembski |
0:01f31e923fe2 | 87 | #error "OS_CLOCK should be defined by HIC configuration" |
Pawel Zarembski |
0:01f31e923fe2 | 88 | #endif |
Pawel Zarembski |
0:01f31e923fe2 | 89 | |
Pawel Zarembski |
0:01f31e923fe2 | 90 | // <o>Timer tick value [us] <1-1000000> |
Pawel Zarembski |
0:01f31e923fe2 | 91 | // <i> Set the timer tick value for selected timer. |
Pawel Zarembski |
0:01f31e923fe2 | 92 | #ifndef OS_TICK |
Pawel Zarembski |
0:01f31e923fe2 | 93 | #error "OS_TICK should be defined by RTOS configuration" |
Pawel Zarembski |
0:01f31e923fe2 | 94 | #endif |
Pawel Zarembski |
0:01f31e923fe2 | 95 | |
Pawel Zarembski |
0:01f31e923fe2 | 96 | // </h> |
Pawel Zarembski |
0:01f31e923fe2 | 97 | |
Pawel Zarembski |
0:01f31e923fe2 | 98 | // <h>System Configuration |
Pawel Zarembski |
0:01f31e923fe2 | 99 | // ======================= |
Pawel Zarembski |
0:01f31e923fe2 | 100 | // <e>Round-Robin Task switching |
Pawel Zarembski |
0:01f31e923fe2 | 101 | // ============================= |
Pawel Zarembski |
0:01f31e923fe2 | 102 | // <i> Enable Round-Robin Task switching. |
Pawel Zarembski |
0:01f31e923fe2 | 103 | #ifndef OS_ROBIN |
Pawel Zarembski |
0:01f31e923fe2 | 104 | #define OS_ROBIN 0 |
Pawel Zarembski |
0:01f31e923fe2 | 105 | #endif |
Pawel Zarembski |
0:01f31e923fe2 | 106 | |
Pawel Zarembski |
0:01f31e923fe2 | 107 | // <o>Round-Robin Timeout [ticks] <1-1000> |
Pawel Zarembski |
0:01f31e923fe2 | 108 | // <i> Define how long a task will execute before a task switch. |
Pawel Zarembski |
0:01f31e923fe2 | 109 | // <i> Default: 5 |
Pawel Zarembski |
0:01f31e923fe2 | 110 | #ifndef OS_ROBINTOUT |
Pawel Zarembski |
0:01f31e923fe2 | 111 | #define OS_ROBINTOUT 10 |
Pawel Zarembski |
0:01f31e923fe2 | 112 | #endif |
Pawel Zarembski |
0:01f31e923fe2 | 113 | |
Pawel Zarembski |
0:01f31e923fe2 | 114 | // </e> |
Pawel Zarembski |
0:01f31e923fe2 | 115 | |
Pawel Zarembski |
0:01f31e923fe2 | 116 | // <o>Number of user timers <0-250> |
Pawel Zarembski |
0:01f31e923fe2 | 117 | // <i> Define max. number of user timers that will run at the same time. |
Pawel Zarembski |
0:01f31e923fe2 | 118 | // <i> Default: 0 (User timers disabled) |
Pawel Zarembski |
0:01f31e923fe2 | 119 | #ifndef OS_TIMERCNT |
Pawel Zarembski |
0:01f31e923fe2 | 120 | #define OS_TIMERCNT 0 |
Pawel Zarembski |
0:01f31e923fe2 | 121 | #endif |
Pawel Zarembski |
0:01f31e923fe2 | 122 | |
Pawel Zarembski |
0:01f31e923fe2 | 123 | // <o>ISR FIFO Queue size<4=> 4 entries <8=> 8 entries |
Pawel Zarembski |
0:01f31e923fe2 | 124 | // <12=> 12 entries <16=> 16 entries |
Pawel Zarembski |
0:01f31e923fe2 | 125 | // <24=> 24 entries <32=> 32 entries |
Pawel Zarembski |
0:01f31e923fe2 | 126 | // <48=> 48 entries <64=> 64 entries |
Pawel Zarembski |
0:01f31e923fe2 | 127 | // <96=> 96 entries |
Pawel Zarembski |
0:01f31e923fe2 | 128 | // <i> ISR functions store requests to this buffer, |
Pawel Zarembski |
0:01f31e923fe2 | 129 | // <i> when they are called from the iterrupt handler. |
Pawel Zarembski |
0:01f31e923fe2 | 130 | // <i> Default: 16 entries |
Pawel Zarembski |
0:01f31e923fe2 | 131 | #ifndef OS_FIFOSZ |
Pawel Zarembski |
0:01f31e923fe2 | 132 | #define OS_FIFOSZ 4 |
Pawel Zarembski |
0:01f31e923fe2 | 133 | #endif |
Pawel Zarembski |
0:01f31e923fe2 | 134 | |
Pawel Zarembski |
0:01f31e923fe2 | 135 | // </h> |
Pawel Zarembski |
0:01f31e923fe2 | 136 | |
Pawel Zarembski |
0:01f31e923fe2 | 137 | //------------- <<< end of configuration section >>> ----------------------- |
Pawel Zarembski |
0:01f31e923fe2 | 138 | |
Pawel Zarembski |
0:01f31e923fe2 | 139 | // Standard library system mutexes |
Pawel Zarembski |
0:01f31e923fe2 | 140 | // =============================== |
Pawel Zarembski |
0:01f31e923fe2 | 141 | // Define max. number system mutexes that are used to protect |
Pawel Zarembski |
0:01f31e923fe2 | 142 | // the arm standard runtime library. For microlib they are not used. |
Pawel Zarembski |
0:01f31e923fe2 | 143 | #ifndef OS_MUTEXCNT |
Pawel Zarembski |
0:01f31e923fe2 | 144 | #define OS_MUTEXCNT 1 |
Pawel Zarembski |
0:01f31e923fe2 | 145 | #endif |
Pawel Zarembski |
0:01f31e923fe2 | 146 | |
Pawel Zarembski |
0:01f31e923fe2 | 147 | /*---------------------------------------------------------------------------- |
Pawel Zarembski |
0:01f31e923fe2 | 148 | * RTX User configuration part END |
Pawel Zarembski |
0:01f31e923fe2 | 149 | *---------------------------------------------------------------------------*/ |
Pawel Zarembski |
0:01f31e923fe2 | 150 | |
Pawel Zarembski |
0:01f31e923fe2 | 151 | #define OS_TRV ((U32)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1) |
Pawel Zarembski |
0:01f31e923fe2 | 152 | |
Pawel Zarembski |
0:01f31e923fe2 | 153 | /*---------------------------------------------------------------------------- |
Pawel Zarembski |
0:01f31e923fe2 | 154 | * Global Functions |
Pawel Zarembski |
0:01f31e923fe2 | 155 | *---------------------------------------------------------------------------*/ |
Pawel Zarembski |
0:01f31e923fe2 | 156 | |
Pawel Zarembski |
0:01f31e923fe2 | 157 | /*--------------------------- os_idle_demon ---------------------------------*/ |
Pawel Zarembski |
0:01f31e923fe2 | 158 | |
Pawel Zarembski |
0:01f31e923fe2 | 159 | __task void os_idle_demon(void) |
Pawel Zarembski |
0:01f31e923fe2 | 160 | { |
Pawel Zarembski |
0:01f31e923fe2 | 161 | /* The idle demon is a system task, running when no other task is ready */ |
Pawel Zarembski |
0:01f31e923fe2 | 162 | /* to run. The 'os_xxx' function calls are not allowed from this task. */ |
Pawel Zarembski |
0:01f31e923fe2 | 163 | for (;;) { |
Pawel Zarembski |
0:01f31e923fe2 | 164 | /* HERE: include optional user code to be executed when no task runs.*/ |
Pawel Zarembski |
0:01f31e923fe2 | 165 | } |
Pawel Zarembski |
0:01f31e923fe2 | 166 | } |
Pawel Zarembski |
0:01f31e923fe2 | 167 | |
Pawel Zarembski |
0:01f31e923fe2 | 168 | |
Pawel Zarembski |
0:01f31e923fe2 | 169 | /*--------------------------- os_tmr_call -----------------------------------*/ |
Pawel Zarembski |
0:01f31e923fe2 | 170 | |
Pawel Zarembski |
0:01f31e923fe2 | 171 | void os_tmr_call(U16 info) |
Pawel Zarembski |
0:01f31e923fe2 | 172 | { |
Pawel Zarembski |
0:01f31e923fe2 | 173 | /* This function is called when the user timer has expired. Parameter */ |
Pawel Zarembski |
0:01f31e923fe2 | 174 | /* 'info' holds the value, defined when the timer was created. */ |
Pawel Zarembski |
0:01f31e923fe2 | 175 | /* HERE: include optional user code to be executed on timeout. */ |
Pawel Zarembski |
0:01f31e923fe2 | 176 | } |
Pawel Zarembski |
0:01f31e923fe2 | 177 | |
Pawel Zarembski |
0:01f31e923fe2 | 178 | |
Pawel Zarembski |
0:01f31e923fe2 | 179 | /*--------------------------- os_error --------------------------------------*/ |
Pawel Zarembski |
0:01f31e923fe2 | 180 | |
Pawel Zarembski |
0:01f31e923fe2 | 181 | void os_error(U32 err_code) |
Pawel Zarembski |
0:01f31e923fe2 | 182 | { |
Pawel Zarembski |
0:01f31e923fe2 | 183 | /* This function is called when a runtime error is detected. Parameter */ |
Pawel Zarembski |
0:01f31e923fe2 | 184 | /* 'err_code' holds the runtime error code (defined in RTL.H). */ |
Pawel Zarembski |
0:01f31e923fe2 | 185 | switch (err_code) { |
Pawel Zarembski |
0:01f31e923fe2 | 186 | case OS_ERR_STK_OVF: |
Pawel Zarembski |
0:01f31e923fe2 | 187 | util_assert(0); |
Pawel Zarembski |
0:01f31e923fe2 | 188 | break; |
Pawel Zarembski |
0:01f31e923fe2 | 189 | |
Pawel Zarembski |
0:01f31e923fe2 | 190 | case OS_ERR_FIFO_OVF: |
Pawel Zarembski |
0:01f31e923fe2 | 191 | util_assert(0); |
Pawel Zarembski |
0:01f31e923fe2 | 192 | break; |
Pawel Zarembski |
0:01f31e923fe2 | 193 | |
Pawel Zarembski |
0:01f31e923fe2 | 194 | case OS_ERR_MBX_OVF: |
Pawel Zarembski |
0:01f31e923fe2 | 195 | util_assert(0); |
Pawel Zarembski |
0:01f31e923fe2 | 196 | break; |
Pawel Zarembski |
0:01f31e923fe2 | 197 | |
Pawel Zarembski |
0:01f31e923fe2 | 198 | default: |
Pawel Zarembski |
0:01f31e923fe2 | 199 | util_assert(0); |
Pawel Zarembski |
0:01f31e923fe2 | 200 | break; |
Pawel Zarembski |
0:01f31e923fe2 | 201 | } |
Pawel Zarembski |
0:01f31e923fe2 | 202 | |
Pawel Zarembski |
0:01f31e923fe2 | 203 | SystemReset(); |
Pawel Zarembski |
0:01f31e923fe2 | 204 | |
Pawel Zarembski |
0:01f31e923fe2 | 205 | for (;;); // Wait for reset |
Pawel Zarembski |
0:01f31e923fe2 | 206 | } |
Pawel Zarembski |
0:01f31e923fe2 | 207 | |
Pawel Zarembski |
0:01f31e923fe2 | 208 | |
Pawel Zarembski |
0:01f31e923fe2 | 209 | /*---------------------------------------------------------------------------- |
Pawel Zarembski |
0:01f31e923fe2 | 210 | * RTX Configuration Functions |
Pawel Zarembski |
0:01f31e923fe2 | 211 | *---------------------------------------------------------------------------*/ |
Pawel Zarembski |
0:01f31e923fe2 | 212 | |
Pawel Zarembski |
0:01f31e923fe2 | 213 | #include "RTX_lib.c" |
Pawel Zarembski |
0:01f31e923fe2 | 214 | |
Pawel Zarembski |
0:01f31e923fe2 | 215 | /*---------------------------------------------------------------------------- |
Pawel Zarembski |
0:01f31e923fe2 | 216 | * end of file |
Pawel Zarembski |
0:01f31e923fe2 | 217 | *---------------------------------------------------------------------------*/ |