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

📄 init.c

📁 ATMEL AT91RM9200开发板配套光盘上的全部示例程序
💻 C
字号:
//*----------------------------------------------------------------------------
//*         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
//* Object              : Low level initializations written in C
//* Creation            : ODi   06/26/2002
//* Change Include file   JPP 15/Jan/03 
//*
//*----------------------------------------------------------------------------

#include "include/AT91RM3400.h"
#include "include/lib_AT91RM3400.h"

// The following functions must be write in ARM mode this function called directly
// by exception vector
extern void AT91F_Spurious_handler(void);
extern void AT91F_Default_IRQ_handler(void);
extern void AT91F_Default_FIQ_handler(void);

//*----------------------------------------------------------------------------
//* \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_LowLevelInit
//* \brief This function performs very low level HW initialization
//*----------------------------------------------------------------------------
void AT91F_LowLevelInit()
{
 AT91PS_AIC     pAic;
 int i;
	//-----------------------------------------------------------------------------
	// Reset the Interrupt Controller
	//-------------------------------
	// Normally, the code is executed only if a reset has been actually performed.
	// So, the AIC initialization resumes at setting up the default vectors.
	//-----------------------------------------------------------------------------
	// Load System pAic Base address 
	pAic = AT91C_BASE_AIC; 
	
	// Mask All interrupt
	pAic->AIC_IDCR = 0xFFFFFFFF;
	
	// Perform 8 End Of Interrupt Command to make sure AIC will not Lock out nIRQ 
	for (i=0;i < 8; i++)
	{
		AT91F_AIC_AcknowledgeIt(AT91C_BASE_AIC);
	}

	// Set up the default interrupts handler vectors
	pAic->AIC_SVR[0] = (int) AT91F_Default_FIQ_handler ;
	for (i=1;i < 31; i++)
	{
		pAic->AIC_SVR[i] = (int) AT91F_Default_IRQ_handler ;
	}
	pAic->AIC_SPU  = (int) AT91F_Spurious_handler ;


	// Open PIO for DBGU
	AT91F_DBGU_CfgPIO();

	// Configure DBGU
	AT91F_US_Configure (
		(AT91PS_USART) AT91C_BASE_DBGU,          // DBGU base address
		48000000,                  // 48 MHz
		AT91C_US_CHMODE_NORMAL | AT91C_US_PAR_NONE ,        // mode Register to be programmed
		115200 ,                   // baudrate to be programmed
		0);                        // timeguard to be programmed

	// Enable Transmitter & Receiver
	 ((AT91PS_USART)AT91C_BASE_DBGU)->US_CR = AT91C_US_TXEN | AT91C_US_RXEN;

	AT91F_DBGU_Printk("Start target\n\r");

}

⌨️ 快捷键说明

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