zoukankan      html  css  js  c++  java
  • CMSIS Example

     1 /*----------------------------------------------------------------------------
     2  *      RL-ARM - RTX
     3  *----------------------------------------------------------------------------
     4  *      Name:    RTX_EX1.C
     5  *      Purpose: Your First RTX example program
     6  *----------------------------------------------------------------------------
     7  *
     8  * Copyright (c) 1999-2009 KEIL, 2009-2012 ARM Germany GmbH
     9  * All rights reserved.
    10  * Redistribution and use in source and binary forms, with or without
    11  * modification, are permitted provided that the following conditions are met:
    12  *  - Redistributions of source code must retain the above copyright
    13  *    notice, this list of conditions and the following disclaimer.
    14  *  - Redistributions in binary form must reproduce the above copyright
    15  *    notice, this list of conditions and the following disclaimer in the
    16  *    documentation and/or other materials provided with the distribution.
    17  *  - Neither the name of ARM  nor the names of its contributors may be used 
    18  *    to endorse or promote products derived from this software without 
    19  *    specific prior written permission.
    20  *
    21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
    22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
    23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    24  * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
    25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
    27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
    28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
    29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
    30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    31  * POSSIBILITY OF SUCH DAMAGE.
    32  *---------------------------------------------------------------------------*/
    33 
    34 #include "cmsis_os.h"
    35 
    36 /* Forward reference */
    37 void threadX (void const *argument);
    38 
    39 /* Thread IDs */
    40 osThreadId main_id;
    41 osThreadId threadX_id;
    42 
    43 /* Thread definitions */
    44 osThreadDef(threadX, osPriorityNormal, 1, 0);
    45 
    46 /*----------------------------------------------------------------------------
    47  *   Thread X
    48  *---------------------------------------------------------------------------*/
    49 void threadX (void const *argument) {
    50   for (;;) {
    51     /* Wait for completion of do-this */
    52     osSignalWait(0x0004, osWaitForever); /* do-that */
    53     /* Pause for 20 ms until signaling event to main thread */
    54     osDelay(20);
    55     /* Indicate to main thread completion of do-that */
    56     osSignalSet(main_id, 0x0004);
    57   }
    58 }
    59 
    60 /*----------------------------------------------------------------------------
    61  *   Main Thread
    62  *---------------------------------------------------------------------------*/
    63 int main (void) {
    64 
    65   /* Get main thread ID */
    66   main_id = osThreadGetId();
    67   /* Create thread X */
    68   threadX_id = osThreadCreate(osThread(threadX), NULL);
    69   for (;;) {    /* do-this */
    70     /* Indicate to thread X completion of do-this */
    71     osSignalSet(threadX_id, 0x0004);
    72     /* Wait for completion of do-that */
    73     osSignalWait(0x0004, osWaitForever);
    74     /* Wait now for 50 ms */
    75     osDelay(50);
    76   }
    77 }
    78 
    79 /*----------------------------------------------------------------------------
    80  * end of file
    81  *---------------------------------------------------------------------------*/
  • 相关阅读:
    Vue实现添加、删除、关键字查询
    打开新页面 自定义方法并获取携带值
    unity3d 刷新速率
    unity3d AssetStore 下载的资源位置
    unity3d c# http 请求json数据解析
    unity3d 自定义载入条/载入动画
    课程改进意见
    梦断代码
    An internal error occurred during: "Launching MVC on Tomcat 7.x".
    n以内的1的个数
  • 原文地址:https://www.cnblogs.com/shangdawei/p/3854414.html
Copyright © 2011-2022 走看看