⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main_os_q.c

📁 embOS的MSP430F2274移植版
💻 C
字号:
/*********************************************************************
*               SEGGER MICROCONTROLLER GmbH & Co KG                  *
*       Solutions for real time microcontroller applications         *
**********************************************************************
*                                                                    *
*       (c) 1995 - 2008  SEGGER Microcontroller GmbH & Co KG         *
*                                                                    *
*       www.segger.com     Support: support@segger.com               *
*                                                                    *
**********************************************************************
*                                                                    *
*       embOS * Real time operating system for microcontrollers      *
*                                                                    *
*                                                                    *
*       Please note:                                                 *
*                                                                    *
*       Knowledge of this file may under no circumstances            *
*       be used to write a similar product or a real-time            *
*       operating system for in-house use.                           *
*                                                                    *
*       Thank you for your fairness !                                *
*                                                                    *
**********************************************************************
*                                                                    *
*       embOS version: 3.60a                                         *
*                                                                    *
**********************************************************************

----------------------------------------------------------------------
File    : Main_OS_Q.c
Purpose : Sample program for embOS using queues
--------- END-OF-HEADER --------------------------------------------*/

#include "RTOS.h"

OS_STACKPTR int StackHP[128], StackLP[128];          /* Task stacks */
OS_TASK TCBHP, TCBLP;                        /* Task-control-blocks */

/********************************************************************/

static OS_Q _MyQ;
static char _MyQBuffer[100];
	
static void HPTask(void) {
  char* pData;
  while (1) {
    int Len;
    Len = OS_Q_GetPtr(&_MyQ, (void**)&pData);
    OS_Delay(10);
    if (Len) {  /* Evaluate Message ... */
      OS_SendString(pData);
      OS_Q_Purge(&_MyQ);
    }
  }
}
	
static void LPTask(void) {
  while (1) {
    OS_Q_Put(&_MyQ, "\nHello", 7);
    OS_Q_Put(&_MyQ, "\nWorld !", 9);
    OS_Delay (500);
  }
}
	
/*********************************************************************
*
*       main
*
*********************************************************************/

int main(void) {
  OS_IncDI();                   /* Initially disable interrupts     */
  OS_InitKern();                /* initialize OS                    */
  OS_InitHW();                  /* initialize Hardware for OS       */
  OS_Q_Create(&_MyQ, &_MyQBuffer, sizeof(_MyQBuffer));
  /* You need to create at least one task before calling OS_Start() */
  OS_CREATETASK(&TCBHP, "HP Task", HPTask, 100, StackHP);
  OS_CREATETASK(&TCBLP, "LP Task", LPTask,  50, StackLP);
  OS_DecRI();                   /* Enable interrupts before sending */
  OS_SendString("embOS OS_Q example");
  OS_SendString("\n\nDemonstrating message passing\n");
  OS_Start();                   /* Start multitasking               */
  return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -