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

📄 demo0.c

📁 Nucleus+PLUS+Internals+源码+2410
💻 C
字号:
/* Include necessary files.  */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include"2410addr.h"
#include"2410lib.h"

/* Include necessary Nucleus PLUS files.  */
#include  "nucleus.h"
#define SERIAL_IO   NU_TRUE  /* Change to NU_FALSE for no serial IO */
#define NU_PRINTF   NU_FALSE /* Change to NU_TRUE for printf support. */
                             /* MUST BE NU_FALSE when running from FLASH */


#if (SERIAL_IO)

/* Using serial IO */
#include "nu_sd.h"                  /* Nucleus Serial Driver interface */

#endif /* SERIAL_IO */


extern void ENABLE_INTERRUPT(void);

/* Application Structures */
NU_TASK         Task_1;
NU_TASK         Task_2;

NU_MEMORY_POOL  System_Memory;


#if (SERIAL_IO)
NU_SERIAL_PORT  port;               /* Serial IO being used */
#endif

extern  int ERC_System_Error(int);
/* Function Prototypes */
VOID    task_1(UNSIGNED argc, VOID *argv);
VOID    task_2(UNSIGNED argc, VOID *argv);


// int NestX=0;
/* Define the Application_Initialize routine that determines the initial
   Nucleus PLUS application environment.  */
void    Application_Initialize(void *first_available_memory)
{

VOID           *pointer;
STATUS         status;

 
/*--------------------------uart initialize---------------------------------*/
     ChangeClockDivider(1,1);
     ChangeMPllValue(0xa1,0x3,0x1);   
     Port_Init();
     ENABLE_INTERRUPT();
    
     Uart_Select(0);
     Uart_Init(0,115200);
     Uart_Printf("now nucleus begin to run!!!!\n");
/*----------------------------end-------------------------------------------*/

    /* Create a system memory pool that will be used to allocate task stacks,
       queue areas, etc.  */
    status = NU_Create_Memory_Pool(&System_Memory, "SYSMEM",
                        first_available_memory, 25000, 50, NU_FIFO);
    if (status != NU_SUCCESS)
    {
    
        ERC_System_Error(status);
    }
    else
    {
        Uart_Printf("System_Memory have been cteated!\n");
    }

    /* Create each task in the system.  */

    /* Create task1.*/
    NU_Allocate_Memory(&System_Memory, &pointer, 512, NU_NO_SUSPEND);
    status=NU_Create_Task(&Task_1, "TASK 1", task_1, 0, NULL, pointer,
                                      512, 3, 20, NU_PREEMPT, NU_START);
    if (status != NU_SUCCESS)
    {
    	
    	ERC_System_Error(status);
    }
    else
    {
        Uart_Printf("Task1 have been created\n");
    
    }
    /* Create task2.*/
    NU_Allocate_Memory(&System_Memory, &pointer, 512, NU_NO_SUSPEND);
    status=NU_Create_Task(&Task_2, "TASK 2", task_2, 0, NULL, pointer,
                                      512, 3, 15, NU_PREEMPT, NU_START);
    if (status != NU_SUCCESS)
    {
    	    	
    	ERC_System_Error(status);
    }
    else
    {
        Uart_Printf("task2 have been created\n");
        Uart_Printf("-----------------------\n");
    }
    
}


/* Define the system timer task.  More complicated systems might use a
   routine like this to perform periodic message sending and other time
   oriented functions.  */
   
void task_1(UNSIGNED argc, VOID *argv)
{
	STATUS  status;
        int     i=0;
	status =  (STATUS) argc + (STATUS) argv;

	while(1)
	{
 	    i++;
        Uart_Printf("task1 is:%d\n",i);
		NU_Sleep(20);
	}
    
}	


	
void task_2(UNSIGNED argc, VOID *argv)
{
	STATUS  status;
	int     j=1;
    status =  (STATUS) argc + (STATUS) argv;

	while(1)
	{
        j++;
		Uart_Printf("task2 is:%d\n",j);
        NU_Sleep(8);
	}
}	



⌨️ 快捷键说明

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