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

📄 dfuinit.c

📁 at91rm9200 的rom程序
💻 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           : DfuInit.c//* Object              ://* Date : 22/04/01 HI	: creation//*----------------------------------------------------------------------------#include    "parts\lib_booster.h"#include	"Drivers\systimer\systimer.h"#include	"Drivers\monitor\drv_jtag.h"#include    "appli\includes\com.h"#include	"appli\includes\main.h"#include	"periph\apmc\lib_apmcbooster.h"/* prototypes */int InitSourceUpload(const char *, unsigned int);void InitUsart(void);//*----------------------------------------------------------------------------//* Function Name       : InitUsart//* Object              : Initialize the dbgu//* Input Parameters    ://* Output Parameters   ://*----------------------------------------------------------------------------void InitUsart(void){	int mcki = MASTER_CLOCK;	u_int	baud_value;	//* Open com	at91_clock_open(PIOA_DESC.periph_id);	baud_value = ((mcki*10)/(BAUD_RATE * 16));	if ((baud_value % 10) >= 5)		baud_value = (baud_value / 10) + 1;	else		baud_value /= 10;	//* open usart	at91_usart2_open (&DBGU_DESC, COM_8_BIT | COM_PAR_NONE | COM_NBSTOP_1 | COM_FLOW_CONTROL_NONE | US_CLKS_MCK, baud_value, 0);	//* Disable all interrupts	DBGU_DESC.usart_base->US_IDR = 0xFFFFFFFF ;}//*----------------------------------------------------------------------------//* Function Name       : InitSourceUpload//* Object              : wait for an attempt of upload and return the way to upload//* Input Parameters    : pbuffer:buffer to receive the first setupdata//* Output Parameters   : return the way to upload//* COMMRX : Communications Channel Receive//*		When HIGH, this signal denotes that the comms channel receive buffer is empty.//*----------------------------------------------------------------------------int InitSourceUpload(const char *pBuffer, unsigned int bufferSize ){	int i = 0;	int *pint = (int *)pBuffer;	InitUsart();	//* Store the address of the buffer	DBGU_DESC.usart_base->US_RPR = (unsigned int)pBuffer;	//* Store the number of bytes to receive	DBGU_DESC.usart_base->US_RCR = bufferSize;	//* Enables the receiver PDC transfer requests	DBGU_DESC.usart_base->US_PTCR = US_RXTEN ;	while( 	( !(DBGU_DESC.usart_base->US_CSR & US_ENDRX )) &&			(!(jtag_read_ctrl() & R_BIT)) &&			( !(at91_usb_uisr(USB_BASE) & USB_ENDBUSRES ))		 );	if ( DBGU_DESC.usart_base->US_CSR & US_ENDRX )		return UPLOAD_USART;	if (jtag_read_ctrl() & R_BIT)	{		i = 0;		while(i < (bufferSize/(sizeof(int))))	//* 2 = SetupData(8) / (sizeof(int))		{			if (jtag_read_car(pint++) == JTAG_READ_OK)				i++;		}		return UPLOAD_JTAG;	}	if (at91_usb_uisr(USB_BASE) & USB_ENDBUSRES ) {		at91_usb_reset(USB_BASE);		at91_usb_uier(USB_BASE, (USB_EP0INT));		at91_usb_uicr(USB_BASE, USB_ENDBUSRES);		return UPLOAD_USB;	}}

⌨️ 快捷键说明

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