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

📄 test.c

📁 Keil UV3中自带操作系统ARTX的应用例程
💻 C
字号:
/*----------------------------------------------------------------------------
 *      A R T X   K e r n e l   E x a m p l e
 *----------------------------------------------------------------------------
 *      Name:    ARTX_EX1.C
 *      Purpose: Your First Advanced RTX example program
 *      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 <ARTX.h>                      /* ARTX kernel functions & defines    */
#include <AT91SAM7S64.h> 
/* id1, id2 will contain task identifications at run-time */
OS_TID t_light_on,t_light_off;

unsigned int i;

/* Forward reference */
//void init (void) __task;
void light_on (void) __task;
void light_off (void) __task;


void init (void) __task 
{
 	*AT91C_PMC_PCER=0x0000000F;		//PMC外设时钟使能
	*AT91C_PIOA_PER=0x0000000F;	  	//PIOA0-3作为I/O使用
	*AT91C_PIOA_OER=0x0000000F;	   	//PIOA0-3输出使能
	
	t_light_on   = os_tsk_create (light_on,  0); /* start clock task                 */
    //亮灯的任务                                   /* start command task               */
   // t_light_off   = os_tsk_create (light_off,  0);
  t_light_off  = os_tsk_create (light_off, 0); /* start lights task               */
  	//熄灯的任务
    os_tsk_delete_self ();               /* stop init task (no longer needed)  */
   //初始化任务执行完后就把它删除
}



/*----------------------------------------------------------------------------
 *   Task 1:  ARTX Kernel starts this task with os_sys_init (task1)
 *---------------------------------------------------------------------------*/
void light_on (void) __task {
  /* Obtain own system task identification number */
  //t_light_on = os_tsk_self ();
  /* Assign system identification number of task2 to id2 */
  //id2 = os_tsk_create (task2, 1);
  for (;;) 
  {   
  if(i<15) i++;
  else i=0;
  *AT91C_PIOA_SODR=i;     //点亮对应的LED
    /* Wait now for 50 ms */
    os_dly_wait (50);
  }
}

/*----------------------------------------------------------------------------
 *   Task 2:  ARTX Kernel starts this task with os_tsk_create (task2, 1)
 *---------------------------------------------------------------------------*/
void light_off (void) __task {
  for (;;) 
  {   
  //if(i<15) i++;
 // else i=0;
  *AT91C_PIOA_CODR=i;     //熄灭对应的LED
    /* Wait now for 50 ms */
    os_dly_wait (50);
  }
}

/*----------------------------------------------------------------------------
 *        Main: Initialize and start ARTX Kernel
 *---------------------------------------------------------------------------*/
void main (void) 
{

  os_sys_init (init);   //从最开始的init任务开始
}

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

⌨️ 快捷键说明

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