dfupipe.c

来自「at91rm9200 的rom程序」· C语言 代码 · 共 85 行

C
85
字号
//*----------------------------------------------------------------------------
//*      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 + =
减小字号Ctrl + -
显示快捷键?