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

📄 helloworld.c

📁 一个小的测试程序
💻 C
字号:
#include <stdio.h>
#include <stdlib.h>
#include <csl.h>
#include <std.h>
#include <sys.h>
#include <tsk.h>
#include <log.h>
#include "iekc64.h"

// DSP/BIOS object
extern Uint32 seg_sdrama;
extern far LOG_Obj LOG_hello; 
	

void simpledelay(Uint16 delay_count);   //a simple delay funciton
void tsk_main();						//task

//
// Function implementation
//


//a simple delay funciton
void simpledelay(Uint16 delay_count)
{
	int i;
	for (i=0;i<delay_count; i++)
	{
		asm("	nop ");
	}


}


main()
{
IEKC64_STATUS status;       // the status enum of IEKC64x
TSK_Attrs attrs;            // task attributes of which you will creat

	//
	// Remember you should call CSL_init() first when using CSL of DSP/BIOS
	//
	CSL_init();
	
	//
	// This is the first API call you need
	// It is mandatory to initialize the board
	//
	status = IEKC64_init();

	if (!IEKC64_SUCCESS(status))
	{
		printf( "IEKC64_Init() failed with 0x%08X\n", status );
		abort();
	}
	
	// Toggle the on board LEDs
	// First turn off all LEDs
   	LED_set( BRACKET_RED, OFF );
 	LED_set( BRACKET_GREEN, OFF );
 	LED_set( ONBOARD_GREEN, OFF );
 	LED_set( ONBOARD_YELLOW, OFF );
 	LED_set( ONBOARD_RED, OFF );

	// Now toggle 
 	LED_set( ONBOARD_GREEN, ON );
 	simpledelay(1000);
 	LED_set( ONBOARD_YELLOW, ON );
 	simpledelay(1000);
 	LED_set( ONBOARD_RED, ON );
 	simpledelay(1000);
   	LED_set( BRACKET_RED, ON );
 	simpledelay(1000);
 	LED_set( BRACKET_GREEN, ON );
 	simpledelay(5000);

	// Turn off again
   	LED_set( BRACKET_RED, OFF );
 	LED_set( BRACKET_GREEN, OFF );
 	LED_set( ONBOARD_GREEN, OFF );
 	LED_set( ONBOARD_YELLOW, OFF );
 	LED_set( ONBOARD_RED, OFF );

	// Notice for the users!!!
	// Put your application specific initialization function here!
	// 
	
	
	// Now create the main task
	attrs = TSK_ATTRS;
	attrs.priority = 4;
	attrs.stacksize = 200;
	attrs.stackseg = seg_sdrama;
	TSK_create((Fxn)tsk_main, &attrs);
	
	// After the main() exit, DSP/BIOS will be entered.
}


//
// This is the task you creat in the main().
//
void tsk_main(void)
{
	Uint32 			boardCpuClock;
	Uint32 			dspBiosCpuClock;

	// Check CPU frequency configuration
	// 函数的返回值为 IEKC64_cpuClock,
	// 而同时*pDspBiosClock被赋予由DSP/BIOS反算得到的DSP Speed。
	boardCpuClock=IEKC64_getCpuClock(&dspBiosCpuClock);
	
	LOG_printf(&LOG_hello, "DSP clock frequency: %u Mhz\n", boardCpuClock);
	LOG_printf(&LOG_hello, "DSP/BIOS clock frequency: %u Mhz\n", dspBiosCpuClock);

	if(boardCpuClock != dspBiosCpuClock)
		LOG_printf(&LOG_hello, "WARNING: Board clock is different from DSP/BIOS configuration file clock.\n");

	LOG_printf(&LOG_hello, "Exit from task tsk_main !\n\n");
}


//
// This is the PRD event you creat in the DSP/BIOS
// It willed be called once per 1s
// 
void myPRD_func()
{
	static unsigned int count=0;
	
	LOG_printf(&LOG_hello, "This is HelloWorld PRD event number: %d!\n", count++);

	// toggle the green LED
 	if (count%2)
	 	LED_set( ONBOARD_GREEN, ON );
    else
	 	LED_set( ONBOARD_GREEN, OFF );
    
	
	return;

}




⌨️ 快捷键说明

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