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

📄 c_start.c

📁 ucos在9200上的移植
💻 C
📖 第 1 页 / 共 2 页
字号:
//*----------------------------------------------------------------------------
//*         ATMEL Microcontroller Software Support  -  ROUSSET  -
//*----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*----------------------------------------------------------------------------
//* File Name           : lib_AT91RM9200.h
//* Object              : AT91RM9200 inlined functions
//* Generated           : AT91 SW Application Group  04/16/2003 (12:30:07)
//*
//* CVS Reference       : /lib_pdc.h/1.2/Tue Jul 02 11:29:40 2002//
//* CVS Reference       : /lib_dbgu.h/1.1/Fri Jan 31 11:18:40 2003//
//* CVS Reference       : /lib_rtc_1245d.h/1.1/Fri Jan 31 11:19:12 2003//
//* CVS Reference       : /lib_ssc.h/1.4/Fri Jan 31 11:19:20 2003//
//* CVS Reference       : /lib_spi_AT91RMxxxx.h/1.2/Fri Jan 31 11:19:32 2003//
//* CVS Reference       : /lib_tc_1753b.h/1.1/Fri Jan 31 11:20:02 2003//
//* CVS Reference       : /lib_pmc.h/1.3/Thu Nov 14 06:40:46 2002//
//* CVS Reference       : /lib_pio.h/1.3/Fri Jan 31 11:18:56 2003//
//* CVS Reference       : /lib_twi.h/1.2/Fri Jan 31 11:19:38 2003//
//* CVS Reference       : /lib_usart.h/1.5/Thu Nov 21 15:01:54 2002//
//* CVS Reference       : /lib_mci.h/1.2/Wed Nov 20 13:18:56 2002//
//* CVS Reference       : /lib_aic.h/1.3/Fri Jul 12 06:46:12 2002//
//* CVS Reference       : /lib_udp.h/1.3/Fri Jan 31 11:19:48 2003//
//* CVS Reference       : /lib_st.h/1.4/Fri Jan 31 11:20:14 2003//
//*----------------------------------------------------------------------------

#include "lib_AT91RM9200.h"

//*----------------------------------------------------------------------------
//*         ATMEL Microcontroller Software Support  -  ROUSSET  -
//*----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*----------------------------------------------------------------------------
//* File Name           : init_c.c
//* Object              : Low level initialisations written in C
//* Creation            : FB   23/10/2002
//*
//*----------------------------------------------------------------------------

/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////

#define	FALSE					0
#define	TRUE					1
#define	DELAY_PLL				200
#define DELAY_MAIN_FREQ			200

/////////////////////////////////////////////////////////////////////////////////////////////////////
// Configuration for a Quartz 18.432000 MHz
/////////////////////////////////////////////////////////////////////////////////////////////////////

#define	PLLAR 					0x2026BE04	//* 179,712000 MHz for PCK 0x20263E04
#define	PLLBR 					0x10483E0E	//* 48,054857 MHz (divider by 2 for USB)
#define	MCKR  					0x00000202	//* PCK/3 = MCK Master Clock = 59,904000MHz with PLLA selected 0x00000202
#define SLOWCLOCK				32768		//* In Hz

/////////////////////////////////////////////////////////////////////////////////////////////////////
// Frequencies Range
/////////////////////////////////////////////////////////////////////////////////////////////////////

#define INPUT_FREQ_MIN			900000
#define INPUT_FREQ_MAX			32000000


#define BASE_EBI_CS0_ADDRESS	0x10000000	//* base address to access memory on CS0
#define BASE_EBI_CS1_ADDRESS	0x20000000	//* base address to access memory on CS1

#define OUTPUT_FREQ_MIN			80000000
#define OUTPUT_FREQ_MAX			240000000


//*----------------------------------------------------------------------------
//* \fn    AT91F_DBGU_Printk
//* \brief This function is used to send a string through the DBGU channel (Very low level debugging)
//*----------------------------------------------------------------------------
void AT91F_DBGU_Printk(
	char *buffer) // \arg pointer to a string ending by \0
{
	while(*buffer != '\0') {
		while (!AT91F_US_TxReady((AT91PS_USART)AT91C_BASE_DBGU));
		AT91F_US_PutChar((AT91PS_USART)AT91C_BASE_DBGU, *buffer++);
	}
}

/*----------------------------------------------------------------------------	*/
/* \fn    AT91F_DataAbort							*/
/* \brief This function reports an Abort					*/
/*----------------------------------------------------------------------------	*/
void AT91F_SpuriousHandler() 
{
	AT91F_DBGU_Printk("-F- Spurious Interrupt detected\n\r");
	while (1);
}


/*----------------------------------------------------------------------------	*/
/* \fn    AT91F_DataAbort							*/
/* \brief This function reports an Abort					*/
/*----------------------------------------------------------------------------	*/
void AT91F_DataAbort() 
{
	AT91F_DBGU_Printk("-F- Data Abort detected\n\r");
	while (1);
}

/*----------------------------------------------------------------------------	*/
/* \fn    AT91F_FetchAbort							*/
/* \brief This function reports an Abort					*/
/*----------------------------------------------------------------------------	*/
void AT91F_FetchAbort()
{
	AT91F_DBGU_Printk("-F- Prefetch Abort detected\n\r");
	while (1);
}

/*----------------------------------------------------------------------------	*/
/* \fn    AT91F_Undef								*/
/* \brief This function reports an Abort					*/
/*----------------------------------------------------------------------------	*/
void AT91F_Undef() 
{
	AT91F_DBGU_Printk("-F- Undef detected\n\r");
	while (1);
}

/*----------------------------------------------------------------------------	*/
/* \fn    AT91F_UndefHandler							*/
/* \brief This function reports that no handler have been set for current IT	*/
/*----------------------------------------------------------------------------	*/
void AT91F_UndefHandler() 
{
	AT91F_DBGU_Printk("-F- Undef detected\n\r");
	while (1);
}


//*----------------------------------------------------------------------------
//* \fn    AT91F_WaitForMainClockFrequency
//* \brief This function performs very low level HW initialization
//*----------------------------------------------------------------------------
unsigned char AT91F_WaitForMainClockFrequency()
{
	volatile char	tmp	= 0;

/////////////////////////////////////////////////////////////////////////////////////////////////////
// Step 2.
// Checking the Main Oscillator Frequency (Optional)
/////////////////////////////////////////////////////////////////////////////////////////////////////
    AT91C_BASE_CKGR->CKGR_MOR=0x1;
	//* Determine the main clock frequency
	
	while(!(AT91C_BASE_CKGR->CKGR_MCFR & AT91C_CKGR_MAINRDY) && (tmp++ < DELAY_MAIN_FREQ));

	if (tmp >= DELAY_MAIN_FREQ)
		return FALSE;

	return TRUE;
}

//*----------------------------------------------------------------------------
//* \fn    AT91F_CheckPLL_FrequencyRange
//* \brief This function performs very low level HW initialiszation
//*----------------------------------------------------------------------------
unsigned char AT91F_CheckPLL_FrequencyRange(int MainClock,int pllDivider ,int pllMultiplier)
{
	if(pllDivider == 0)
		return FALSE;

	//* Check Input Frequency
	if( ((MainClock/pllDivider) < INPUT_FREQ_MIN)
	 || ((MainClock/pllDivider) > INPUT_FREQ_MAX) )
		return FALSE;

	//* Check Output Frequency
	if( ((MainClock/pllDivider*pllMultiplier) < OUTPUT_FREQ_MIN)
	 || ((MainClock/pllDivider*pllMultiplier) > OUTPUT_FREQ_MAX) )
		return FALSE;

	return TRUE;
}

//*----------------------------------------------------------------------------
//* \fn    AT91F_InitClocks
//* \brief This function performs very low level HW initialization
//*----------------------------------------------------------------------------
unsigned char AT91F_InitClocks(int PLLAR_Register,int PLLBR_Register ,int MCKR_Register)
{
	volatile char 	tmp = 0;
	unsigned int	MainClock;

⌨️ 快捷键说明

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