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

📄 lib_udp.c

📁 ARM9200开发板的ROM boot程序源码1.0
💻 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           : 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -