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

📄 ar_clock.c

📁 Keil开发环境下ARM7内核单片机的ARTX RTOS内核源代码
💻 C
字号:
/*----------------------------------------------------------------------------
 *      A R T X  -  K e r n e l
 *----------------------------------------------------------------------------
 *      Name:    AR_CLOCK.C
 *      Purpose: System clock demon
 *      Rev.:    V2.00 / 19-oct-2005
 *----------------------------------------------------------------------------
 *      This code is part of the ARTX-ARM kernel package of Keil Software.
 *      Copyright (c) 2004-2005 Keil Software. All rights reserved. 
 *---------------------------------------------------------------------------*/

#include "Kernel\ARTX_Config.h"
#include "Kernel\AR_List.h"
#include "Kernel\AR_Task.h"
#include "Kernel\AR_Event.h"
#include "Kernel\AR_Mailbox.h"
#include "Kernel\AR_Semaphore.h"
#include "Kernel\AR_Timer.h"
#include "Kernel\AR_Lib.h"

/*----------------------------------------------------------------------------
 *      Global Variables
 *---------------------------------------------------------------------------*/

extern struct OS_TCB os_clock_TCB;
extern U16  os_time;
extern BIT  os_psh_flag;
extern U32  os_psh_cnt;
extern U16  os_psq_first;
extern U16  os_psq_last;


/*----------------------------------------------------------------------------
 *      Global Functions
 *---------------------------------------------------------------------------*/

/*--------------------------- os_psh_req ------------------------------------*/

void os_psh_req (void) {
   /* Initiate a post service handling request if required.                  */
   /* Modifies system globals os_psh_flag, os_psh_cnt accordingly.           */
   if (!os_tmr_inspect_ovf()) {
      os_psh_cnt = os_tmr_inspect_cnt();
      if (!os_tmr_inspect_ovf()) {
         os_psh_flag = __TRUE;
         os_tmr_force_irq();
         }
      else
         os_psh_flag = __FALSE;
      }
} /* end of os_psh_req */


/*--------------------------- os_clock_demon --------------------------------*/

void os_clock_demon (void) __task {
   /* Check for system clock update and ISR post service requests.           */
   /* Suspend running task: maybe it will be continued afterwards, so        */
   /* the CARM ISR prolog can not be used.                                   */
   struct OS_XCB *p_CB;
   BOOL tmr_ovfl = __FALSE;
   void *msg;

   for (;;) {
      /* Check if it is a timer overflow or only an explicit request */
      if ((!tstclrb (&os_psh_flag)) || (os_tmr_inspect_cnt() < os_psh_cnt)) {
         /* There was a timer overflow */
         os_tmr_reload ();
         os_time++;
         os_dec_dly ();
         tmr_ovfl = __TRUE;
         }
      /* In any case: check for ps-requests */
      while (os_psq_first != os_psq_last) {
         p_CB = os_psq_deq (&msg);
         if (p_CB->cb_type == TCB) {
            /* Is of TCB type */
            os_evt_psh ((P_TCB)p_CB);
            }
         else if (p_CB->cb_type == MCB) {
            /* Is of MCB type */
            os_mbx_psh ((P_MCB)p_CB, msg);
            }
         else {
            /* Must be of SCB type */
            os_sem_psh ((P_SCB)p_CB);
            }
         };
      /* Check the user timers and Round Robin timeout. */
      if (tmr_ovfl) {
         os_tmr_tick ();
         os_chk_robin ();
         tmr_ovfl = __FALSE;
      }
      /* all done */
      os_clock_TCB.state = WAIT_ITV;
      /* Switch back to highest ready task */
      os_dispatch (NULL);
   }
} /* end of os_clock_demon */

/*----------------------------------------------------------------------------
 * end of file
 *---------------------------------------------------------------------------*/

⌨️ 快捷键说明

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