lib_udp.c

来自「ARM9200开发板的ROM boot程序源码1.0」· C语言 代码 · 共 99 行

C
99
字号
//*----------------------------------------------------------------------------
//*      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_udp.h
//* Object              : Low level UDP access functions
//*
//* 1.0 Sept 3rd 01     : ODi Creation
//*----------------------------------------------------------------------------
#include "lib_udp.h"

//*----------------------------------------------------------------------------
//* Function Name       : AT91F_UdpReset()
//* Object              :
//* Input Parameters    :
//* Output Parameters   :
//*----------------------------------------------------------------------------
void AT91F_UdpReset(
	AT91PS_UDP pUdp)
{
	pUdp->UDP_RESET_EP  = 0;
	pUdp->UDP_GLB_STATE = 0;
}

//*----------------------------------------------------------------------------
//* Function Name       : AT91F_UdpOpen()
//* Object              :
//* Input Parameters    :
//* Output Parameters   :
//*----------------------------------------------------------------------------
void AT91F_UdpOpen(
	AT91PS_UDP pUdp)
{
	// Desactivate all IT
	pUdp->UDP_UIDR = (unsigned int) (0xFFFFFFFF);
	// Disable all pending IT
	pUdp->UDP_UICR = (unsigned int) (0xFFFFFFFF);

	AT91F_UdpReset(pUdp);
}

//*----------------------------------------------------------------------------
//* Function Name       : AT91F_UdpSetAddress()
//* Object              :
//* Input Parameters    :
//* Output Parameters   :
//*----------------------------------------------------------------------------
void AT91F_UdpSetAddress (
	AT91PS_UDP   pUdp,
	unsigned int address)
{
	/* Record the address assigned by the host */
	pUdp->UDP_FADDR = UDP_FEN | address;

}

//*----------------------------------------------------------------------------
//* Function Name       : AT91F_UdpEpRead()
//* Object              :
//* Input Parameters    :
//* Output Parameters   :
//*----------------------------------------------------------------------------
char *AT91F_UdpEpRead(
	AT91PS_UDP pUdp,
	char  epNumber,
	char  *pBuffer,
	int   nbBytes)
{
	volatile char *pFdr = (char *) &(pUdp->UDP_FDR[epNumber]);

	while (nbBytes-- > 0)
		*(pBuffer++) = *pFdr;
	return pBuffer;
}

//*----------------------------------------------------------------------------
//* Function Name       : AT91F_UdpEpWrite()
//* Object              :
//* Input Parameters    :
//* Output Parameters   :
//*----------------------------------------------------------------------------
char const *AT91F_UdpEpWrite(
	AT91PS_UDP pUdp,
	char       epNumber,
	char const *pBuffer,
	int        nbBytes)
{
	volatile char *pFdr = (char *) &(pUdp->UDP_FDR[epNumber]);

	while (nbBytes-- > 0)
		*pFdr = *(pBuffer++);
	return pBuffer;
}

⌨️ 快捷键说明

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