demo.c
来自「基于nucleus操作系统的GPRS无线数据传输终端全套源文件。包括支持ARM7」· C语言 代码 · 共 224 行
C
224 行
/****************************************************************************/
/* */
/* Copyright (c) 2000 by Accelerated Technology, Inc. */
/* */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the subject */
/* matter of this material. All manufacturing, reproduction, use and sales */
/* rights pertaining to this subject matter are governed by the license */
/* agreement. The recipient of this software implicity accepts the terms */
/* of the license. */
/* */
/****************************************************************************/
/****************************************************************************/
/* */
/* FILE NAME VERSION */
/* */
/* demo.c PLUS/KS32C41000 1.11.1 */
/* */
/* DESCRIPTION */
/* */
/* */
/* FUNCTIONS */
/* */
/* Nucleus demo program */
/* */
/* task_0 */
/* task_1 */
/* task_2 */
/* task_3_and_4 */
/* task_5 */
/* */
/* DEPENDENCIES */
/* */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* Bobby Iden 04-18-2000 Created initial version 1.11.1 for the */
/* the Samsung KS32C41000. */
/****************************************************************************/
/* Include necessary Nucleus PLUS files. */
#include "nucleus.h"
#include "uart_defs.h"
extern VOID C_Board_Init(VOID);
extern VOID ERC_System_Error(INT error_code);
extern VOID WdtuApp(UNSIGNED argc, VOID *argv);
extern VOID WdtuIdle(UNSIGNED argc, VOID *argv);
extern VOID WdtuEther(UNSIGNED argc, VOID *argv);
extern VOID WdtuConfig(UNSIGNED argc, VOID *argv);
extern VOID int_uart0(VOID);
extern VOID int_uart1(VOID);
extern VOID int_config_uart1(VOID);
extern VOID UART0_LISR(INT Vector);
extern VOID UART1_LISR(INT Vector);
extern VOID ENT_INT_RTL8019AS( INT VECTOR );
extern VOID CFG_HISR_Entry (VOID);
VOID WatchDog_Timer_Expire(UNSIGNED id);
NU_TIMER watchdog_interval;
NU_TASK WDTU_APP;
NU_TASK WDTU_IDLE;
NU_TASK WDTU_ETHER;
NU_TASK WDTU_CFG;
NU_HISR CONFIG_HISR;
NU_MEMORY_POOL System_Memory;
NU_MEMORY_POOL NETI_NET_Memory_Pool;
NU_MEMORY_POOL ETHER_TEST_Memory_Pool;
#define MEMORY_POOL_SIZE 81920
#define NET_MEMORY_POOL_SIZE 204800
#define TEST_MEMORY_POOL_SIZE 2097152 //2MB
#define TASK_STACK_SIZE 4096
#define HISR_STACK_SIZE 1024
/* Define the Application_Initialize routine that determines the initial
Nucleus PLUS application environment. */
VOID Application_Initialize(VOID *first_available_memory)
{
VOID *pointer;
VOID (*old_lisr)(INT);
STATUS status;
C_Board_Init(); /* michael add */
int_uart0();
int_config_uart1();
mask_irq(23);
mask_irq(24);
////////////////////////////////add for MC35 by cj//////////////////////////////////////////////////////
/*pc2 use for EMERGOFF_close_MC35(void) add by cj */
*(RP)0x1000B020|=0x04; //portc2_sel 输出 PE7 0X80
//*(RP)0x1000B024|=0x04; //portc2_data export 1
*(RP)0x1000B024&=~0x04; //portc2_data export 0
*(RP)0x1000B01C&=~0x04; //portc2_dir
/*pc1 is for IGT_OPEN_MC35(void) add by cj */
*(RP)0x1000B020|=0x02; //portc1_sel 输出 PE7 0X80
//*(RP)0x1000B024|=0x02; //portc1_data export 1
*(RP)0x1000B024&=~0x02; //portc1_data export 0
*(RP)0x1000B01C&=~0x02; //portc1_dir
////////////////////////////////add for MC35 by cj//////////////////////////////////////////////////////
/* 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, MEMORY_POOL_SIZE, 50, NU_FIFO);
if (status != NU_SUCCESS)
{
ERC_System_Error(status);
}
status = NU_Create_Memory_Pool(&NETI_NET_Memory_Pool, "NETMEM",
((VOID*)((UINT32)first_available_memory+100000)), NET_MEMORY_POOL_SIZE, 50, NU_FIFO);
if (status != NU_SUCCESS)
{
ERC_System_Error(status);
}
status = NU_Create_Memory_Pool(ÐER_TEST_Memory_Pool, "NETMEM",
((VOID*)((UINT32)first_available_memory+400000)), TEST_MEMORY_POOL_SIZE, 50, NU_FIFO);
if (status != NU_SUCCESS)
{
ERC_System_Error(status);
}
////////////////////////////////add for WatchDog by cj///////////////////////////////////////////////////
status =NU_Create_Timer(&watchdog_interval,"WdogTime",WatchDog_Timer_Expire,0,10,10,NU_ENABLE_TIMER);
if (status != NU_SUCCESS)
{
ERC_System_Error(status);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
NU_Register_LISR(0x18, UART0_LISR, &old_lisr);
NU_Register_LISR(0x17, UART1_LISR, &old_lisr);
NU_Register_LISR(0x0f, ENT_INT_RTL8019AS, &old_lisr);
////////////////////////////////add for GPRS by cj///////////////////////////////////////////////////////
NU_Allocate_Memory(&System_Memory, &pointer, TASK_STACK_SIZE, NU_NO_SUSPEND);
status = NU_Create_Task(&WDTU_APP, "TASKAPP", WdtuApp, 0, NU_NULL, pointer,
TASK_STACK_SIZE, 10, 0, NU_PREEMPT, NU_START);
if (status != NU_SUCCESS)
{
ERC_System_Error(status);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////add for IDEL by cj///////////////////////////////////////////////////////
NU_Allocate_Memory(&System_Memory, &pointer, TASK_STACK_SIZE, NU_NO_SUSPEND);
status = NU_Create_Task(&WDTU_IDLE, "TASKIDLE", WdtuIdle, 0, NU_NULL, pointer,
TASK_STACK_SIZE, 100, 0, NU_PREEMPT, NU_START);
if (status != NU_SUCCESS)
{
ERC_System_Error(status);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////add for ETHER by cj//////////////////////////////////////////////////////
//NU_Allocate_Memory(&System_Memory, &pointer, TASK_STACK_SIZE, NU_NO_SUSPEND);
//status = NU_Create_Task(&WDTU_ETHER, "TASKETHI", WdtuEther, 0, NU_NULL, pointer,
// TASK_STACK_SIZE, 10, 0, NU_PREEMPT, NU_START);
//
//if (status != NU_SUCCESS)
//{
// ERC_System_Error(status);
//}
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////add for CONFIG by Renix/////////////////////////////////////////////////
NU_Allocate_Memory(&System_Memory, &pointer, HISR_STACK_SIZE, NU_NO_SUSPEND);
status = NU_Create_HISR(&CONFIG_HISR,"HISR_CFG",CFG_HISR_Entry,2,pointer,400);
if (status != NU_SUCCESS)
{
ERC_System_Error(status);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////add for CONFIG by Renix/////////////////////////////////////////////////
NU_Allocate_Memory(&System_Memory, &pointer, TASK_STACK_SIZE, NU_NO_SUSPEND);
status = NU_Create_Task(&WDTU_CFG, "TASKCNFG",WdtuConfig,0 , NU_NULL, pointer,
TASK_STACK_SIZE, 20, 0, NU_PREEMPT, NU_START);
if (status != NU_SUCCESS)
{
ERC_System_Error(status);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
}
//*********************************************************************************************************
// this function like a gpt (10ms) to wacthdog
//*********************************************************************************************************
VOID WatchDog_Timer_Expire(UNSIGNED id)
{
INT dog=0;
///watch dog
*(RP)0x1000B020|=0x08; //portc3_sel 输出例
*(RP)0x1000B024|=0x08; //portc3_data export 1
//*(RP)0x1000B024&=~0x08; //portc3_data export 0
*(RP)0x1000B01C&=~0x08; //portc3_dir
for(dog=1;dog<5;dog++);
//*(RP)0x1000B020|=0x08; //portc3_sel 输出例
//*(RP)0x1000B024|=0x08; //portc3_data export 1
*(RP)0x1000B024&=~0x08; //portc3_data export 0
*(RP)0x1000B01C&=~0x08; //portc3_dir
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?