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

📄 sample.c

📁 RTX51 example use. Inside are example on how to use RTX51 RTOS. it uses memory pool, messages, RTXba
💻 C
字号:
#pragma large

#include  <Rtx51.h>               // RTX-51 Definitions
#define  PRODUCER_NBR    0        // Tasknumber for the producer task
#define  CONSUMER_NBR    1        // Tasknumber for the consumer task
#define  FIRST_MAILBOX   0        // The mailbox identification
#define  WAIT_FOREVER    0xFF     // A constant, signalling to the RTX
                                  // call, that no timeout for the call is
                                  // expected.


void  ProducerTask (void) _task_ PRODUCER_NBR
{
   unsigned int  MessageToSend = 1;

   os_create_task (CONSUMER_NBR);   // Create the Consumer-Task
   for (;;)                         // endless loop
   {
      // Send the actual value of 'send_mes' to mailbox 0
      // if the mailbox is full, wait until there is place for the message
      os_send_message (FIRST_MAILBOX, MessageToSend, WAIT_FOREVER);
      MessageToSend++;
   }
}


void  ConsumerTask (void) _task_ CONSUMER_NBR _priority_ 1
{
   unsigned int  ReceiveBuffer;

   for (;;)
   {
      // Read from mailbox FIRST_MAILBOX one message
      // Wait for a message, if the mailbox is empty
      os_wait (K_MBX + FIRST_MAILBOX, WAIT_FOREVER, &ReceiveBuffer);
      //
      // ... perform some calculations with the message
      //
   }
}


void  main (void)
{
   signed char  RtxReturnState;

   // Init the system and start the Producer-Task
   RtxReturnState = os_start_system (PRODUCER_NBR);
}

⌨️ 快捷键说明

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