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

📄 demoapp.c.bak

📁 UCOS-II2.76在ADI-BF533上的移植.在UCOS-II网站提供的源码基础上修改了几处汇编代码.采用2.76版系统内核移植,在DSP++4.0上调试成功
💻 BAK
字号:
/*
*********************************************************************************************************
*                                                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 <uCOS-II_V2.70\source\ucos_ii.h>
#include <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

/*
***************************************************************************
*
*  Global variables & function prototypes
*
***************************************************************************
*/

void LedBlinkTask(void *Param);
void UartEchoTask(void *Param);
extern void CpuInit(void);
extern CoreTimerInit();

/*
***************************************************************************
*
*	  Main program function
*
***************************************************************************
*/


void main(void)
{
	int	i;
	int iErr;
	OS_STK *stack;

	// Initialization
			
	CpuInit();				// Init the CPU environment ( presently does nothing ! )
			
	OsCpuInit();			// Prepare CPU to run uC/OS
	
	OSInit();				// Initialize uC/OS
	
	EZLite_Init_LED(0);		// Initialize all LEDs off
	
	iErr = InternalUARTInit( UART_BAUD_9600, UART_8_DATABIT|UART_1_STOPBIT|UART_NO_PARITY ); 
	if ( iErr != OS_NO_ERR )
	{
		return;
	}
	
	// Start a task to echo whatever appears on the UART Rx
	
	stack = (OS_STK *)malloc( STACK_SIZE * sizeof( OS_STK) );			// Get a stack
	OSTaskCreateExt( UartEchoTask, (void *)0, stack + STACK_SIZE, 1, 1, stack, STACK_SIZE, (void *)0, 0 ); // Create a task

	// Start 6 tasks, each executing the same program code, but with a different stack.
	// Pass a parameter to each task to tell it which LED it uses.
	
	for ( i=0; i<6; i++ )
	{
		stack = (OS_STK *)malloc( STACK_SIZE * sizeof( OS_STK) );			// Get a stack
		OSTaskCreateExt( LedBlinkTask, (void *)i, stack + STACK_SIZE, i+2, i+2, stack, STACK_SIZE, (void *)0, 0 ); // Create a task
	}

		
	// Start the timer interrupt
	// NOTE:  	Starting the timer before OSStart() is contrary to the uC/OS-II porting guide.
	//			This is O.K. because the TickISR checks for the OSRunning flag, and simply exits
	//			if it is not set.
	
	CoreTimerInit( 135, milliSec * 100, OSTimeTick );		// 100 mS tick.. Callback is O/S tick function
	
	// Start Multitasking
	
	OSStart();			
	
	
		
}




/*
***************************************************************************
*
* 				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 + -