小磷光一

USB工作下ADSP-BF533的一些常用初始化函数

0
阅读(1795)

 

#ifndef __CPU_H__
#define __CPU_H__

#include 
#include 
#include 
#include "bf5xx.h"
#include "cpu.h"

/**********************************************************************************
* 名称 :isp1362_ebiuinit
* 功能 :初始化BF533 EBIU
* 入口参数 :无
* 出口参数 :无
***********************************************************************************/
void isp1362_ebiuinit(void)
{
	*pEBIU_AMBCTL0	= 0x7bb07bb0;
	*pEBIU_AMBCTL1	= 0xffc27bb0;
	*pEBIU_AMGCTL	= 0x000f;
}

/**********************************************************************************
* 名称 :usbpf_init
* 功能 :初始化BF533的PF接口
* 入口参数 :无
* 出口参数 :无
***********************************************************************************/
void usbpf_init(void)
{//rising edge
	// set up programmable flags
	*pFIO_DIR		&= ~IRQ_PF;//0=Input 1=Output
	*pFIO_EDGE		|= IRQ_PF;//0-level,1-edge

	*pFIO_POLAR		|= IRQ_PF;//0-high or rising edge,1-low or falling edge 
    *pFIO_BOTH      &= ~IRQ_PF;    //0-sigle edge, 1-both edge
	*pFIO_INEN		|= IRQ_PF; //0-input buffer disable,1-input buffer enable
	
	*pFIO_MASKB_D   |= IRQ_PF;
}

/**********************************************************************************
* 名称 :timer_init
* 功能 :初始化内核时钟和系统时钟
* 入口参数 :pmsel pssel 设置参数
* 出口参数 :无
***********************************************************************************/
void timer_init(void)
{
	*pTIMER0_CONFIG		= 0x0019;
	*pTIMER0_PERIOD		= 0x001e8800;
	*pTIMER0_WIDTH		= 0x00000040;
	*pTIMER_DISABLE		= 0x0001;
	*pTIMER_ENABLE		= 0x0001;

}

unsigned char led_value = 0xff;
int timer_cnt = 0;
/**********************************************************************************
* 名称 :EX_INTERRUPT_HANDLER(Timer0_ISR)
* 功能 :定时器中断函数
* 入口参数 :无
* 出口参数 :无
***********************************************************************************/
EX_INTERRUPT_HANDLER(Timer0_ISR)
{
    // confirm interrupt handling
	*pTIMER_STATUS = 0x0001;
	timer_cnt++;

	if (timer_cnt%2)
		Led4_On();
	else
		Led4_Off();		

	usb_isr();
}


int int_cnt = 0;