📄 lib_udp.h
字号:
//*----------------------------------------------------------------------------
//* 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
//*----------------------------------------------------------------------------
#ifndef lib_udp_h
#define lib_udp_h
#include "periph/udp/udp.h"
// Following functions are declared in lib_udp.c
extern void AT91F_UdpReset(
AT91PS_UDP usb_pt);
extern void AT91F_UdpOpen(
AT91PS_UDP usb_pt);
extern void AT91F_UdpSetAddress (
AT91PS_UDP usb_pt,
unsigned int address);
extern char *AT91F_UdpEpRead(
AT91PS_UDP pUdp,
char epNumber,
char *pBuffer,
int nbBytes);
extern char const *AT91F_UdpEpWrite(
AT91PS_UDP pUdp,
char epNumber,
char const *pBuffer,
int nbBytes);
// Following functions are declared inline to speed up
// the access to the UDP ressources
__inline void AT91F_UdpSetState(
AT91PS_UDP pUdp,
unsigned int state)
{
pUdp->UDP_GLB_STATE = state;
}
__inline unsigned int AT91F_UdpGetState(
AT91PS_UDP pUdp)
{
return (pUdp->UDP_GLB_STATE & 0x0F);
}
/* Protocol Interrupt enable/disable functions */
__inline unsigned int AT91F_UdpUisr(
AT91PS_UDP pUdp)
{
return pUdp->UDP_UISR;
}
__inline unsigned int AT91F_UdpUimr(
AT91PS_UDP pUdp)
{
return pUdp->UDP_UIMR;
}
__inline void AT91F_UdpUicr(
AT91PS_UDP pUdp,
unsigned int its)
{
pUdp->UDP_UICR = its;
}
__inline void AT91F_UdpUier(
AT91PS_UDP pUdp,
unsigned int its)
{
pUdp->UDP_UIER = its;
}
__inline void AT91F_UdpUidr(
AT91PS_UDP pUdp,
unsigned int its)
{
pUdp->UDP_UIDR = its;
}
/* Endpoint Interrupt enable/disable functions */
__inline unsigned int AT91F_UdpEpUisr(
AT91PS_UDP pUdp,
char epIdx)
{
return ( pUdp->UDP_CSR[epIdx] & (
UDP_RCV_DATA_BANK1 | UDP_STALLSENT |
UDP_RXSETUP | UDP_RCV_DATA_BANK0 | UDP_TXCOMPLETE));
}
__inline void AT91F_UdpEpUicr(
AT91PS_UDP pUdp,
char epIdx,
unsigned int flags)
{
pUdp->UDP_CSR[epIdx] &= ~(flags);
}
__inline char AT91F_UdpEpRok(
AT91PS_UDP pUdp,
char epIdx)
{
register unsigned int csr = pUdp->UDP_CSR[epIdx];
if (csr & UDP_RCV_DATA_BANK0)
return UDP_RCV_DATA_BANK0;
else if (csr & UDP_RCV_DATA_BANK1)
return UDP_RCV_DATA_BANK1;
return 0;
}
__inline char AT91F_UdpEpWok(
AT91PS_UDP pUdp,
char epIdx)
{
return !(pUdp->UDP_CSR[epIdx] & (UDP_TXPKREADY));
}
__inline void AT91F_UdpEpStall(
AT91PS_UDP pUdp,
char epIdx)
{
pUdp->UDP_CSR[epIdx] = (UDP_FORCESTALL);
}
__inline void AT91F_UdpEpEor(
AT91PS_UDP pUdp,
char epIdx,
u_int bank)
{
pUdp->UDP_CSR[epIdx] &= ~bank;
}
__inline void AT91F_UdpEpEow(
AT91PS_UDP pUdp,
char epIdx)
{
pUdp->UDP_CSR[epIdx] |= UDP_TXPKREADY;
}
__inline unsigned int AT91F_UdpEpNbBytesRcv (
const AT91PS_UDP pUdp,
char epIdx)
{
return UDP_BYTE_COUNT(pUdp->UDP_CSR[epIdx]);
}
__inline void AT91F_UdpEpCtrlRead (
AT91PS_UDP pUdp,
char epIdx)
{
pUdp->UDP_CSR[epIdx] |= UDP_DIR;
}
__inline void AT91F_UdpEpConfigure (
AT91PS_UDP pUdp,
char epIdx,
unsigned int configuration)
{
pUdp->UDP_CSR[epIdx] = configuration;
}
#endif // lib_udp_h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -