Source file: /~heha/ewa/Motor/Maxmaus4.zip/usblib/usblibpriv.h

// TITLE: Private header file used to share internal variables and
//        library.  This header MUST NOT be used by application code.
#pragma once
void USBDeviceIntHandlerInternal(uint32_t ui32Status,uint32_t ui32IntStatusEP);

// The maximum number of tick handlers that can be registered in a system.
#define MAX_USB_TICK_HANDLERS       6

//*****************************************************************************
//
// This value defines the number of SOF ticks that must pass before a call
// is made to InternalUSBStartOfFrameTick.  The value 5 ensures that the
// function is called every 5 milliseconds assuming that SOF interrupts are
// enabled and SOF is present.
//
//*****************************************************************************
#define USB_SOF_TICK_DIVIDE 5

//*****************************************************************************
//
// Tick handler function pointer type.
//
//*****************************************************************************
typedef void(* tUSBTickHandler)(void *pvInstance, uint32_t ui32TicksmS);

//*****************************************************************************
//
// Internal functions use to initialize the tick handler and register tick
// callbacks.
//
//*****************************************************************************
void InternalUSBTickInit(void);
void InternalUSBTickReset(void);
int32_t InternalUSBRegisterTickHandler(tUSBTickHandler pfnHandler, void *pvInstance);
void InternalUSBStartOfFrameTick(uint32_t ui32TicksmS);

//*****************************************************************************
//
// g_ui32CurrentUSBTick holds the elapsed time in milliseconds since the
// tick module was first initialized based on calls to the function
// InternalUSBStartOfFrameTick.  The granularity is USB_SOF_TICK_DIVIDE
// milliseconds.
//
//*****************************************************************************
extern uint32_t g_ui32CurrentUSBTick;

//*****************************************************************************
//
// g_ui32USBSOFCount is a global counter for Start of Frame interrupts.  It is
// incremented by the low level device- or host-mode interrupt handlers.
//
//*****************************************************************************
extern uint32_t g_ui32USBSOFCount;

//*****************************************************************************
//
// InternalUSBGetTime is a macro which will return the system time in
// milliseconds as calculated based on calls to the function
// InternalUSBStartOfFrameTick.  The granularity is USB_SOF_TICK_DIVIDE
// milliseconds.
//
// Currently, this merely returns the value of a global variable.
//
//*****************************************************************************
#define InternalUSBGetTime()    g_ui32CurrentUSBTick

//*****************************************************************************
//
// Macros to convert between USB controller base address and an index.  These
// are currently trivial but are included to allow for the possibility of
// supporting more than one controller in the future.
//
//*****************************************************************************
#define USBBaseToIndex(BaseAddr)(0)
#define USBIndexToBase(Index)   (USB_BASE)

//
// Maximum number of channels for Type 0 USB controllers.
//
#define USB_MAX_DMA_CHANNELS_0  6

//
// Maximum number of channels for all other USB controllers.
//
#define USB_MAX_DMA_CHANNELS    8

//*****************************************************************************
//
// Values returned by the USBLibDMAChannelStatus() function.
//
//*****************************************************************************
#define USBLIBSTATUS_DMA_IDLE   0x00000000
#define USBLIBSTATUS_DMA_COMPLETE                                             \
                                0x00000001
#define USBLIBSTATUS_DMA_ERROR  0x00000002
#define USBLIBSTATUS_DMA_PENDING                                              \
                                0x00000004

//*****************************************************************************
//
// DMA endpoint types used with the USBLibDMAChannelAllocate() function.
//
//*****************************************************************************
#define USB_DMA_EP_RX           0x00000080
#define USB_DMA_EP_TX           0x00000000
#define USB_DMA_EP_HOST         0x00000040
#define USB_DMA_EP_DEVICE       0x00000000
#define USB_DMA_EP_TYPE_CTRL    0x00000000
#define USB_DMA_EP_TYPE_ISOC    0x00000001
#define USB_DMA_EP_TYPE_BULK    0x00000002
#define USB_DMA_EP_TYPE_INT     0x00000003
#define USB_DMA_EP_TYPE_M       0x00000003

//*****************************************************************************
//
// This is the internal instance data for the DMA functions and should not
// be modified outside the usbdma.c file.
//
//*****************************************************************************
struct tUSBDMAInstance {
  uint32_t ui32Base;
  uint32_t ui32IntNum;
  uint32_t pui32Config[USB_MAX_DMA_CHANNELS];
  uint32_t pui32MaxPacketSize[USB_MAX_DMA_CHANNELS];
  uint32_t *ppui32Data[USB_MAX_DMA_CHANNELS];
  uint32_t pui32Count[USB_MAX_DMA_CHANNELS];
  uint8_t pui8Endpoint[USB_MAX_DMA_CHANNELS];
  uint32_t pui32EPDMAMode0[USB_MAX_DMA_CHANNELS];
  uint32_t pui32EPDMAMode1[USB_MAX_DMA_CHANNELS];
  uint32_t ui32Pending;
  uint32_t ui32Complete;
  virtual void ArbSizeSet(uint32_t Channel, uint32_t ArbSize)	{}
  virtual uint32_t ChannelAllocate( uint8_t Endpoint,
                                    uint32_t MaxPacketSize,
                                    uint32_t Config)		{return 0;}
  virtual void ChannelEnable(uint32_t Channel)			{}
  virtual void ChannelDisable(uint32_t Channel)			{}
  virtual void ChannelRelease(uint8_t Endpoint)			{}
  virtual uint32_t ChannelStatus(uint32_t ui32Channel)		{return USBLIBSTATUS_DMA_IDLE;}
  virtual void ChannelIntDisable(uint32_t ui32Channel)		{}
  virtual void ChannelIntEnable(uint32_t ui32Channel)		{}
  virtual void IntHandler(uint32_t ui32Status);
  virtual uint32_t IntStatus()					{return 0;}
  virtual void IntStatusClear(uint32_t Status)			{ui32Complete &= ~Status;}
  virtual uint32_t Status()					{return 0;}
  virtual uint32_t Transfer(uint32_t ui32Channel, void *pvBuffer,
                             uint32_t ui32Size)			{return 0;}
  virtual void UnitSizeSet(uint32_t Channel, uint32_t BitSize)	{}
  void init(uint32_t);
};

//*****************************************************************************
// These are the USB libraries DMA functions.
//*****************************************************************************
tUSBDMAInstance * USBLibDMAInit(uint32_t ui32Index);
Detected encoding: ASCII (7 bit)2