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

📄 dfupipe.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           : DfuPipe.c
//* Object              : Low level functions for Usart Dfu
//*
//* 1.0 23/03/01 	    : Creation
//*----------------------------------------------------------------------------

#include <stdio.h>
#include "appli\includes\main.h"
#include "appli\includes\StructDfu.h"

#define TIMEOUT_WRITE	10000
#define PERIPH_BUSY		1

#if DFU_ENABLE
//*----------------------------------------------------------------------------
//* Function Name       : WritePolling()
//* Object              : 
//* Input Parameters    : 
//* Output Parameters   : 
//*----------------------------------------------------------------------------
void WritePolling(SPipe const *pPipe, char const *pBuffer, const unsigned int Size)
{
	unsigned int TimeOut = 0;
	pPipe->pPeriph->pBuffer->SetOutBuffer(pPipe->pPeriph->pBuffer, pBuffer, Size);
	while(!(pPipe->pPeriph->pBuffer->IsEmpty(pPipe->pPeriph->pBuffer)))
	{
		while( (pPipe->pPeriph->GetStatus(pPipe->pPeriph) == PERIPH_BUSY) && (TimeOut++ < TIMEOUT_WRITE));
		if (TimeOut < TIMEOUT_WRITE)
			pPipe->pPeriph->Send(pPipe->pPeriph);
		else
			return;	// Timeout error
	}	
}	


//*----------------------------------------------------------------------------
//* Function Name       : WriteIt()
//* Object              : 
//* Input Parameters    : 
//* Output Parameters   : 
//*----------------------------------------------------------------------------
void WriteIt(SPipe const *pPipe, char const *pBuffer, const unsigned int Size)
{
	pPipe->pPeriph->pBuffer->SetOutBuffer(pPipe->pPeriph->pBuffer, pBuffer, Size);
	pPipe->pPeriph->Send(pPipe->pPeriph);
}	


//*----------------------------------------------------------------------------
//* Function Name       : ReadPolling()
//* Object              : 
//* Input Parameters    : 
//* Output Parameters   : 
//*----------------------------------------------------------------------------
unsigned int ReadPolling(SPipe const *pPipe, const char *pBuffer, const unsigned int Size)
{
	pPipe->pPeriph->pBuffer->SetInBuffer(pPipe->pPeriph->pBuffer, pBuffer, Size);
	while(!pPipe->pPeriph->pBuffer->IsFull(pPipe->pPeriph->pBuffer))
	{
		pPipe->pPeriph->Receive(pPipe->pPeriph);
	}
}	


//*----------------------------------------------------------------------------
//* Function Name       : ReadPolling()
//* Object              : 
//* Input Parameters    : 
//* Output Parameters   : 
//*----------------------------------------------------------------------------
unsigned int ReadIt(SPipe const *pPipe, const char *pBuffer, const unsigned int Size)
{
	pPipe->pPeriph->pBuffer->SetInBuffer(pPipe->pPeriph->pBuffer, pBuffer, Size);
}	
#endif

⌨️ 快捷键说明

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