?? demoapp.c
字號:
/*
*********************************************************************************************************
* uC/OS-II
* The Real-Time Kernel
*
* Demonstration Program for
* Analog Devices
* Blackfin ADSP-BF533
* EZLite Board
*
*
* This program tests and demonstrates the MicroC/OS-II port to the
* Blackfin ADSP-BF533 processor on the EZ Lite evaluation board. It
* starts a task for each of the 6 LEDS on the eval board. Each task
* blinks a single LED passed as an argument at a rate determined by
* the LED number.
* Another task reads the serial UART port ( 9600 baud ) and echoes back
* any character it receives - converting CR to CR+LF
*
* File : DemoApp.C
* By : Ron Territo ron@territocomputerservices.com
*********************************************************************************************************
Copyright...
This code is placed in the public domain, and can be distributed freely with no restrictions provided that the heading
of each source module file is not modified to remove the credit to the original author.
Disclaimer...
This program code is provided "as is". There is no warranty, either expressed or implied as to its fitness for use in
any application. It is provided only as an example of porting the MicroC/OS operating system to the Blackfin processor.
Its use is strictly at the risk of the user. The author will not be liable for any damages direct or consequential related
to the use of this software including, but not limited to loss of profit.
*/
//#include <services/services.h>
//#include <ezkitutilities.h>
#include <uCOS-II_V2.70\source\ucos_ii.h>
#include <Inc\BF533_EZLite.h>
//#include <Internal_UART.h>
#include <stdlib.h>
#define STACK_SIZE 1024 // stack size in # of entries
#define milliSec 2000 // define millisecond tick counter
#define pIMASK ((volatile unsigned long *)IMASK)
/*
***************************************************************************
*
* Global variables & function prototypes
*
***************************************************************************
*/
//static u8 IntMgrData[(ADI_INT_SECONDARY_MEMORY * 2)];
//void LedBlinkTask(void *Param);
//void UartEchoTask(void *Param);
extern void CpuInit(void);
extern void CoreTimerInit(INT32U TSCALEValue,INT32U TCONTValue, void *IRQCallback);
extern void EnableCoreTimer(void);
void TestTask(void *pdata);
OS_STK TestTaskStk[100];
/*
***************************************************************************
*
* Main program function
*
***************************************************************************
*/
/*
static void Callback(void *AppHandle,u32 Event,void *pArg)
{
switch ( (u32)pArg ) {
case ADI_TMR_CORE_TIMER:
ezToggleLED(EZ_FIRST_LED+3);
break;
default:
ezToggleLED(EZ_FIRST_LED+2);
break;
}
// return
}
void InitTimers(void)
{
ADI_TMR_CORE_CMD_VALUE_PAIR CoreTimerConfigurationTable[]={
{ADI_TMR_CORE_CMD_SET_ACTIVE_MODE, (void *)TRUE},
{ADI_TMR_CORE_CMD_ENABLE_TIMER, (void *)TRUE},
{ADI_TMR_CORE_CMD_SET_AUTO_RELOAD, (void *)TRUE},
{ADI_TMR_CORE_CMD_SET_COUNT, (void *)0x00000320},//內核定時計數值
{ADI_TMR_CORE_CMD_SET_PERIOD, (void *)0x00000320},//重載值
{ADI_TMR_CORE_CMD_SET_SCALE, (void *)0x000000}, //計數比率
{ADI_TMR_CORE_CMD_END, NULL },
};
//Open Timer for access
adi_tmr_Open(ADI_TMR_CORE_TIMER);
//Program timer with Timer table
adi_tmr_CoreControl(ADI_TMR_CORE_CMD_TABLE,CoreTimerConfigurationTable);
//enable callbacks for timer
adi_tmr_InstallCallback(ADI_TMR_CORE_TIMER,TRUE,(void *)ADI_TMR_CORE_CMD_START,NULL,Callback);
}*/
void main(void)
{
int i;
int iErr;
OS_STK *stack;
// u32 ResponseCount;
// void *pExitCriticalArg;
// Initialization
// CpuInit(); // Init the CPU environment ( presently does nothing ! )
OsCpuInit(); // Prepare CPU to run uC/OS
OSInit(); // Initialize uC/OS
// initialize the EZ-Kit
// ezInit(1);
// initialize the Timer manager
// ezErrorCheck(adi_tmr_Init(NULL));
// initialize interrupt manager
// ezErrorCheck(adi_int_Init(IntMgrData, sizeof(IntMgrData), &ResponseCount, NULL));
CoreTimerInit( 135, milliSec * 300, OSTimeTick ); // 100 mS tick.. Callback is O/S tick function
// Start Multitasking
stack = (OS_STK *)malloc( STACK_SIZE * sizeof( OS_STK) );
OSTaskCreate(TestTask,(void *)0,&TestTaskStk[99],0);
OSStart();
}
void TestTask(void *pdata)
{
BOOLEAN led_state;
pdata = pdata;
// EnableCoreTimer();
led_state = FALSE;
while(1)
{
OSTimeDly(2);
if(led_state == FALSE)
{
led_state = TRUE;
EZLite_Init_LED(1);
}
else
{
led_state = FALSE;
EZLite_Init_LED(0);
}
}
}
/*
***************************************************************************
*
* LED blinker task
*
* Parameter.. # of LED to blink ( 0-5 )
*
***************************************************************************
*/
/*
void LedBlinkTask(void *Param)
{
char lite = (char)Param;
int inch;
// Do forever....
while( true )
{
OSTimeDly(lite+1);
EZLite_Set_LED(lite); // turn on a single LED passed as arg.
OSTimeDly(lite+1); // wait
EZLite_Clr_LED(lite); // turn off the same LED
}
}
*/
/*
***************************************************************************
*
* UART echo task
*
* Echoes any character received on UART, convert CR to CR+LF
*
* Parameter.. none
*
***************************************************************************
*/
/*
void UartEchoTask(void *Param)
{
int inch = 0x2a;
// Do forever....
while( true )
{
if ( ( inch = InternalUartGetChar( 0 ) ) != -1 )
{
InternalUartPutChar( inch );
if ( inch == 0x0d ) InternalUartPutChar( 0x0a );
}
}
}
*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -