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

📄 main_event.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_EVENT.c
Purpose : Sample program for embOS using EVENT object
--------- END-OF-HEADER --------------------------------------------*/

#include "RTOS.h"

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

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

/****** Interface to HW module **************************************/

void HW_Wait(void);
void HW_Free(void);
void HW_Init(void);

/********************************************************************/
/****** HW module ***************************************************/

OS_STACKPTR int _StackHW[128];                       /* Task stack  */
OS_TASK _TCBHW;                              /* Task-control-block  */

/****** local data **************************************************/

static OS_EVENT _HW_Event;

/****** local functions *********************************************/

static void _HWTask(void) {
  /* Initialize HW functionallity    */
  OS_Delay(100);
  /* Init done, send broadcast to waiting tasks */
  HW_Free();
  while (1) {
    OS_Delay (40);
  }
}

/****** global functions ********************************************/

void HW_Wait(void) {
  OS_EVENT_Wait(&_HW_Event);
}

void HW_Free(void) {
  OS_EVENT_Set(&_HW_Event);
}

void HW_Init(void) {
  OS_CREATETASK(&_TCBHW, "HWTask", _HWTask, 25, _StackHW);
  OS_EVENT_Create(&_HW_Event);
}

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

static void HPTask(void) {
  HW_Wait();                      /* Wait until HW module is set up */
  while (1) {
    OS_Delay (50);
  }
}

static void LPTask(void) {
  HW_Wait();                      /* Wait until HW module is set up */
  while (1) {
    OS_Delay (200);
  }
}

/*********************************************************************
*
*       main
*
*********************************************************************/

int main(void) {
  OS_IncDI();                      /* Initially disable interrupts  */
  OS_InitKern();                   /* initialize OS                 */
  OS_InitHW();                     /* initialize Hardware for OS    */
  HW_Init();                       /* initialize HW module          */
  /* 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_SendString("Start project will start multitasking !\n");
  OS_Start();                      /* Start multitasking            */
  return 0;
}

⌨️ 快捷键说明

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