Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-rtos by
Diff: rtx/rt_CMSIS.c
- Revision:
- 31:015df9e602b6
- Parent:
- 11:db1fc233faa9
--- a/rtx/rt_CMSIS.c Tue May 27 08:30:16 2014 +0100 +++ b/rtx/rt_CMSIS.c Tue Jun 03 11:30:14 2014 +0100 @@ -15,19 +15,19 @@ * - 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 ARM nor the names of its contributors may be used - * to endorse or promote products derived from this software without + * - Neither the name of ARM 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 + * 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 COPYRIGHT HOLDERS AND 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) + * 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. *---------------------------------------------------------------------------*/ @@ -131,9 +131,9 @@ return _##f(f,a1,a2,a3,a4); \ } -#define SVC_1_2 SVC_1_1 -#define SVC_1_3 SVC_1_1 -#define SVC_2_3 SVC_2_1 +#define SVC_1_2 SVC_1_1 +#define SVC_1_3 SVC_1_1 +#define SVC_2_3 SVC_2_1 #elif defined (__GNUC__) /* GNU Compiler */ @@ -257,9 +257,9 @@ return (t) rv; \ } -#define SVC_1_2 SVC_1_1 -#define SVC_1_3 SVC_1_1 -#define SVC_2_3 SVC_2_1 +#define SVC_1_2 SVC_1_1 +#define SVC_1_3 SVC_1_1 +#define SVC_2_3 SVC_2_1 #elif defined (__ICCARM__) /* IAR Compiler */ @@ -405,7 +405,7 @@ tick = ((1000 * millisec) + os_clockrate - 1) / os_clockrate; if (tick > 0xFFFE) return 0xFFFE; - + return tick; } @@ -517,12 +517,12 @@ /// Start the RTOS Kernel osStatus osKernelStart (void) { uint32_t stack[8]; - + if (__get_IPSR() != 0) return osErrorISR; // Not allowed in ISR switch (__get_CONTROL() & 0x03) { case 0x00: // Privileged Thread mode & MSP __set_PSP((uint32_t)(stack + 8)); // Initial PSP - if (os_flags & 1) { + if (os_flags & 1) { __set_CONTROL(0x02); // Set Privileged Thread mode & PSP } else { __set_CONTROL(0x03); // Set Unprivileged Thread mode & PSP @@ -576,20 +576,20 @@ /// Create a thread and add it to Active Threads and set it to state READY osThreadId svcThreadCreate (osThreadDef_t *thread_def, void *argument) { P_TCB ptcb; - + if ((thread_def == NULL) || (thread_def->pthread == NULL) || (thread_def->tpriority < osPriorityIdle) || (thread_def->tpriority > osPriorityRealtime) || (thread_def->stacksize == 0) || (thread_def->stack_pointer == NULL) ) { - sysThreadError(osErrorParameter); - return NULL; + sysThreadError(osErrorParameter); + return NULL; } - + U8 priority = thread_def->tpriority - osPriorityIdle + 1; P_TCB task_context = &thread_def->tcb; - + /* If "size != 0" use a private user provided stack. */ task_context->stack = (U32*)thread_def->stack_pointer; task_context->priv_stack = thread_def->stacksize; @@ -604,7 +604,7 @@ task_context->task_id = tsk; DBG_TASK_NOTIFY(task_context, __TRUE); rt_dispatch (task_context); - + ptcb = (P_TCB)os_active_TCB[tsk - 1]; // TCB pointer *((uint32_t *)ptcb->tsk_stack + 13) = (uint32_t)osThreadExit; @@ -625,14 +625,14 @@ osStatus svcThreadTerminate (osThreadId thread_id) { OS_RESULT res; P_TCB ptcb; - + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer if (ptcb == NULL) return osErrorParameter; - + res = rt_tsk_delete(ptcb->task_id); // Delete task if (res == OS_R_NOK) return osErrorResource; // Delete task failed - + return osOK; } @@ -671,7 +671,7 @@ ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer if (ptcb == NULL) return osPriorityError; - return (osPriority)(ptcb->prio - 1 + osPriorityIdle); + return (osPriority)(ptcb->prio - 1 + osPriorityIdle); } @@ -720,8 +720,8 @@ /// INTERNAL - Not Public /// Auto Terminate Thread on exit (used implicitly when thread exists) -__NO_RETURN void osThreadExit (void) { - __svcThreadTerminate(__svcThreadGetId()); +__NO_RETURN void osThreadExit (void) { + __svcThreadTerminate(__svcThreadGetId()); for (;;); // Should never come here } @@ -794,7 +794,7 @@ #define osTimerStopped 1 #define osTimerRunning 2 -// Timer structures +// Timer structures typedef struct os_timer_cb_ { // Timer Control Block struct os_timer_cb_ *next; // Pointer to next active Timer @@ -802,7 +802,7 @@ uint8_t type; // Timer Type (Periodic/One-shot) uint16_t reserved; // Reserved uint16_t tcnt; // Timer Delay Count - uint16_t icnt; // Timer Initial Count + uint16_t icnt; // Timer Initial Count void *arg; // Timer Function Argument osTimerDef_t *timer; // Pointer to Timer definition } os_timer_cb; @@ -933,7 +933,7 @@ default: return osErrorResource; } - + rt_timer_insert(pt, tcnt); return osOK; @@ -1054,8 +1054,8 @@ /// INTERNAL - Not Public /// Get timer callback parameters (used by OS Timer Thread) -os_InRegs osCallback osTimerCall (osTimerId timer_id) { - return __svcTimerCall(timer_id); +os_InRegs osCallback osTimerCall (osTimerId timer_id) { + return __svcTimerCall(timer_id); } @@ -1183,7 +1183,7 @@ /// Set the specified Signal Flags of an active thread int32_t osSignalSet (osThreadId thread_id, int32_t signals) { if (__get_IPSR() != 0) { // in ISR - return isrSignalSet(thread_id, signals); + return isrSignalSet(thread_id, signals); } else { // in Thread return __svcSignalSet(thread_id, signals); } @@ -1367,7 +1367,7 @@ } rt_sem_init(sem, count); // Initialize Semaphore - + return sem; } @@ -1398,7 +1398,7 @@ if (((P_SCB)sem)->cb_type != SCB) return osErrorParameter; if (((P_SCB)sem)->tokens == osFeature_Semaphore) return osErrorResource; - + rt_sem_send(sem); // Release Semaphore return osOK; @@ -1532,7 +1532,7 @@ /// Return an allocated memory block back to a specific memory pool osStatus sysPoolFree (osPoolId pool_id, void *block) { int32_t res; - + if (pool_id == NULL) return osErrorParameter; res = rt_free_box(pool_id, block); @@ -1601,7 +1601,7 @@ sysThreadError(osErrorParameter); return NULL; } - + if (((P_MCB)queue_def->pool)->cb_type != 0) { sysThreadError(osErrorParameter); return NULL; @@ -1645,7 +1645,7 @@ } res = rt_mbx_wait(queue_id, &ret.value.p, rt_ms2tick(millisec)); - + if (res == OS_R_TMO) { ret.status = millisec ? osEventTimeout : osOK; return osEvent_ret_value; @@ -1693,13 +1693,13 @@ } res = isr_mbx_receive(queue_id, &ret.value.p); - + if (res != OS_R_MBX) { ret.status = osOK; return ret; } - ret.status = osEventMessage; + ret.status = osEventMessage; return ret; } @@ -1812,7 +1812,7 @@ rt_block(rt_ms2tick(millisec), WAIT_MBX); } - return mem; + return mem; } /// Free a memory block from a mail