📄 locust_main.c
字号:
/*----------------------------------------------------------------
[BASIC]
{
[FILENAME] test_main.c
[CONTENT] test project main inital
[AUTHOR] XuCao
[VERSION] 01.0.00.051117
[COMPANY] APLUS COMMUNICATION TECHNOLOGY (BeiJing) CO.,LTD
}
[MOD]
{
01.0.00.051117:
1.Create initial version
}
----------------------------------------------------------------*/
#include <assert.h> /* assert head file for debug */
#include <string.h> /* memset */
#include <locale.h>
#include <stdio.h> /* for printf define */
#include "nucleus.h" /* Nucleus head file */
#include "drv_extr.h" /* driver interface */
#include "sd_extr.h"
void test_TSK(UNSIGNED argc, VOID *argv);
void test_TIMER(UNSIGNED id);
void eint4_LISR(INT vector);
extern void Test_SD(void);
extern void Test_FS(void);
const int data_table[5] = {0,1,2,3,4};
char str2[] = "aplus";
/*-------------------- Nucleus object -----------------------------*/
NU_MEMORY_POOL system_memory; /* system memory */
NU_TASK TSK_test; /* ui manage task */
NU_TIMER TIMER_test; /* ui timer for rtc update */
int timer_count = 0; /* for test */
/*---------------------------------------------------------------------------
Function: Application_Initialize
Date: 2005-11-17
Description:
Application Initialize for nucleus, it create rtos object
Arguments:
first_available_memory: first available memory pointer
Return Value: none
----------------------------------------------------------------------------*/
void Application_Initialize(void *first_available_memory)
{
VOID* pointer = NULL; /* pointer for memory allocating */
STATUS status = 0xFFFFFFFF; /* return value of memory allocating and tasks etc. creating */
VOID (*old_lisr)(INT);
/*----------------------------------- memory pool -------------------------------------*/
/* 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, 0x300000, 0x10, NU_FIFO);
assert(status == NU_SUCCESS); /* be sure success */
/*---------------------------- Test task and queue creat ---------------------------------*/
/* allocate stack for ui manage task */
status = NU_Allocate_Memory(&system_memory, &pointer, 0x1000, NU_NO_SUSPEND);
assert(status == NU_SUCCESS); /* be sure success */
/* create ui manage task */
status = NU_Create_Task(&TSK_test, "T-ui", test_TSK, 0, NU_NULL, pointer, 0x1000, 18, 2, NU_PREEMPT, NU_START);
assert(status == NU_SUCCESS); /* be sure success */
/* create timer 500ms for timer */
memset(&TIMER_test, 0, sizeof(NU_TIMER));
status = NU_Create_Timer(&TIMER_test, "test", test_TIMER, 1, 250, 125, NU_ENABLE_TIMER);
assert(status == NU_SUCCESS); /* be sure success */
status = NU_Register_LISR(IRQ_VECTOR_EINT4_7, eint4_LISR, &old_lisr);
assert(status == NU_SUCCESS); /* be sure success */
irq_enable(IRQ_VECTOR_EINT4_7); /* enable the irq */
GPFCON &= 0xFCFF; /* clear the I/O setting */
GPFCON |= 0x0200; /* set the I/O to EINT4 */
EXTINT0 &= 0xFFF8FFFF; /* clear int type of EINT4 */
EXTINT0 |= 0x00070000; /* set type to both edge triggered */
EINTMASK &= 0xFFEF; /* clear the EINT4 mask */
/*-------------test code-------------*/
uart_init();
lcd_init();
//SD_Initialize(&sds);
}
int val = 0;
/*-------------------------------------------------------
Function: test_TSK
Date: 2005-11-17
Description:
test task routeline
Arguments:
first_available_memory: first available memory pointer
Return Value: none
-------------------------------------------------------*/
void test_TSK(UNSIGNED argc, VOID *argv)
{
setlocale( LC_ALL, "C" ); /* for atoi to work ok */
#if 1
//Test_SD();
Test_FS();
#else
int i=0; /* loop count */
while(1)
{
NU_Sleep(500);
i = NU_Get_Idle_Record(); /* get the idle count for cpu speed */
i = i;
val = i;
printf("CPU speed value:%05d\n\r",i);
}
#endif
}
/*-------------------------------------------------------
Function: test_TIMER
Date: 2005-02-07
Description: give a message for update rtc
Arguments: none
Return Value: none
-------------------------------------------------------*/
void test_TIMER(UNSIGNED id)
{
int i;
unsigned short * p_s;
static unsigned short color = 0;
timer_count++;
p_s = (unsigned short *)0x30800000;
for (i=0; i<320*240;i++)
{
*(p_s++) = color;
}
if (color==0)
color = 0xFFFF;
else color = 0;
}
int int_count=0;
/*-------------------------------------------------------
Function: eint4_lisr
Date: 2005-03-30
Description: eint4 interrupt service routine
Arguments: interrupt vector
Return Value: none
-------------------------------------------------------*/
void eint4_LISR(INT vector)
{
EINTPEND = 0x10; /* clear the interrupt */
int_count++;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -