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

📄 appli.c

📁 三星S34510板子上移植的uCosII源码
💻 C
字号:
/****************************************************************************
 *    Appli.c
 *    Implementation of a simple led blink program with Ucos on a EB01
 *    Task1 : Red   Led blink 
 *    Task2 : Amber Led blink 
 *    Task3 : Green Led blink 
 *
 * - 1.0  21/08/00  EL     : Creation
 ***************************************************************************/

#include "includes.h"

#include "s3c4510b.h"

#include "typDef.h"
#include "head.h"
#include "uart.h"


#include "timer.h"
/* allocate memory for tasks' stacks */
#define STACKSIZE 512

/* Global Variable */
//xiebin
unsigned int Stack0[STACKSIZE];
unsigned int Stack1[STACKSIZE];
unsigned int Stack2[STACKSIZE];
unsigned int Stack3[STACKSIZE];
unsigned int Stack4[STACKSIZE];

OS_EVENT	*TSTMbox;
INT32U		Task1Cnt;
OS_STK		*StkPtrCur;



//*----------------------------------------------------------------------------
//* Function Name       : Task1
//* Object              : Red Led blink (50ms)
//* Input Parameters    : none
//* Output Parameters   : none
//*----------------------------------------------------------------------------
void Task1(void *i)
{
	INT32U *pcnt;
	INT8U err;
    while(1)
    {
    	pcnt = (INT32U *)OSMboxPend(TSTMbox, 181, &err);
    	if(err == OS_NO_ERR)
    		printf("******OSMboxPend Success!Pend:%lu\n",*pcnt);
    	else
    		printf("******OSMboxPend Error!Error:%d\n",err);
    	Task1Cnt++;
		/* set LED */
		//at91_pio_write (&PIO_DESC, LED1, PIO_CLEAR_OUT ) ;
    	printf("******Task1:CLEAR.\n");
        /* wait a short while */
        OSTimeDly(50);
	
	
		/* clear LED */
	    //at91_pio_write (&PIO_DESC, LED1, PIO_SET_OUT ) ;   
		printf("******Task1:SET.\n");
        /* wait a short while */
        OSTimeDly(50);          
    }
}

//*----------------------------------------------------------------------------
//* Function Name       : Task2
//* Object              : Amber Led blink (80ms)
//* Input Parameters    : none
//* Output Parameters   : none
//*----------------------------------------------------------------------------
void Task2(void *i)
{
	INT8U err;
    while(1)
    {
    	err = OSMboxPost(TSTMbox,(void *)&Task1Cnt);
    	if(err == 0)
    		printf("******OSMboxPost Success!Post:%lu\n",Task1Cnt);
    	else
    		printf("******OSMboxPost Error!Error:%d\n",err);
      	/* set LED */
		//at91_pio_write (&PIO_DESC, LED2, PIO_CLEAR_OUT ) ;
       	printf("******Task2:CLEAR.\n");
		/* wait a short while */
        OSTimeDly(80);
        
		/* clear LED */
		//at91_pio_write (&PIO_DESC, LED2, PIO_SET_OUT ) ;
		printf("******Task2:SET.\n");
        /* wait a short while */
        OSTimeDly(80);        
    }
}


//*----------------------------------------------------------------------------
//* Function Name       : Task3
//* Object              : Green Led blink (200ms)
//* Input Parameters    : none
//* Output Parameters   : none
//*----------------------------------------------------------------------------
 void Task3(void *i)
{
	char *pBuff = NULL;
    char datBuf[1024];
   // UINT16 *pFlash;
   // UINT16 *pTmp;
   char a;
    a=82;
  // uartDevInit(0);

    while(1)
    {
 
      /*
    pBuff = "Hello From armAnyWhere UART0!\r\n";           
    armUartWrite(0, pBuff, 31);   			//从串口0打印信息.
            
    print("******Task2:SET.\n",&a);
    pBuff = "请任意输入10测试字符:\r\n";           
    armUartWrite(0, pBuff, 21);   			//从串口0打印信息.
    armUartRead(0,datBuf, 10);
    datBuf[10] = '\r';
    datBuf[11] = '\n';
    armUartWrite(0, datBuf, 12);   			//从串口0打印信息.
    
  */
  //display();
 ledRun(1);                //循环点亮10次led.
 

   
    }
}
  
  //*-------------------------------- led program  ------------------------------------*/
  
void led(void *i)
{
//UINT16  i;

      ARMTargetStart(); 
   ledShine(7); 
             //熄灭GPIO上所有的led  
 while(1)
 {    
  
     //ledRun(1);
    
      OSTimeDly (15);
      
       ledAllOn();  
       delayMs(600);
      ledAllOff(); 
      
    //ledRun(1);                //循环点亮10次led.
   
    
 }

}

//*----------------------------------------------------------------------------
//* Function Name       : TaskStart
//* Object              : First created task with lower priority
//*			: Enable timer interrupt
//*			: Creation of the other tasks 
//* Input Parameters    : Task creation arguments
//* Output Parameters   : none
//*----------------------------------------------------------------------------
void TaskStart (void *i)
{

  //  char Id1 = '1';
  //  char Id2 = '2';
    char Id3 = '3';
    char Id5 = '5';

    //TC0_IER = TC_CPCS;            // enable timer counter interrupt
   // *Timer1Control = TimerEnable;      // Enable the Timer                  
    /*
    * create the tasks in uC/OS and assign decreasing
    * priority to them
    */
	//TSTMbox = OSMboxCreate((void *)0);
   // OSTaskCreate(Task1, &Id1, &Stack1[STACKSIZE - 1], 2);
   // OSTaskCreate(Task2, &Id2, &Stack2[STACKSIZE - 1], 3)

   OSTaskCreate(Task3, &Id3, &Stack3[STACKSIZE - 1], 6);
   OSTaskCreate(led, &Id5, &Stack0[STACKSIZE - 1], 4);
      
 

   
   
    // Delete current task
    OSTaskDel(OS_PRIO_SELF);
    //printf("Exit TaskStart.\n");
}

//*----------------------------------------------------------------------------
//* Function Name       : SYS_StartTicker
//* Object              : Setup timer interrupt every 10ms 
//* Input Parameters    : none
//* Output Parameters   : none
//*----------------------------------------------------------------------------
void SYS_StartTicker(void) 
{
}


//*----------------------------------------------------------------------------
//* Function Name       : main
//* Object              : Main function 
//* Input Parameters    : none
//* Output Parameters   : none
//*----------------------------------------------------------------------------
int main()
{
  
   char Id4 = '4';
  char Id3 = '3';
    char Id5 = '5';
    /* Hardware and software module related initializations */
    // SYS_StartTicker();
    ARMTargetInit();
      
    OSInit();
  
   // OSTimeSet(0);

   /* create the start task */
   //OSTaskCreate(TaskStart, &Id4, &Stack4[STACKSIZE - 1], 6);


    OSTaskCreate(Task3, &Id3, &Stack3[STACKSIZE - 1], 5);
    OSTaskCreate(led, &Id5, &Stack0[STACKSIZE - 1], 4);
  
    /* start the operating system */
    OSStart();

    return(0);
//* End
}

⌨️ 快捷键说明

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