Source file: /~heha/ewa/Motor/Maxmaus6.zip/usblib/usbdma.cpp

// TITLE: USB Library DMA handling functions.
#include "usbdma.h"
#include "usblib.h"	// USB_BASE, INT_USB
#include <interrupt.h>
#include <usb.h>
#include <string>	// std::memset

static tUSBDMAInstance g_psUSBDMAInst;

//*****************************************************************************
//
// Macros used to determine if a uDMA endpoint configuration is used for
// receive or transmit.
//
//*****************************************************************************
//#define UDMAConfigIsRx(ui32Config) ((ui32Config & UDMA_SRC_INC_NONE) == UDMA_SRC_INC_NONE)
//#define UDMAConfigIsTx(ui32Config) ((ui32Config & UDMA_DEST_INC_NONE) == UDMA_DEST_INC_NONE)

void tUSBDMAInstance::IntHandler(uint32_t DMAIntBits) {
  ui32Pending &=~DMAIntBits;
  ui32Complete|= DMAIntBits;
}

void tUSBDMAInstance::init(uint32_t index) {
  ASSERT(index == USB_BASE);
  ui32Base = index;  // Save the base address of the USB controller.
  ui32IntNum = INT_USB;  // Save the interrupt number for the USB controller.
  // Clear out the endpoint and the current configuration.
  std::memset(pui8Endpoint,0,sizeof pui8Endpoint);
  std::memset(pui32Config,0,sizeof pui32Config);
  ui32Pending = 0;
  ui32Complete = 0;
}

//*****************************************************************************
//! This function is used to initialize the DMA interface for a USB instance.
//!
//! \param ui32Index is the index of the USB controller for this instance.
//!
//! This function performs any initialization and configuration of the DMA
//! portions of the USB controller.  This function returns a pointer that
//! is used with the remaining USBLibDMA APIs or the function returns zero
//! if the requested controller cannot support DMA.  If this function is called
//! when already initialized it will not reinitialize the DMA controller and
//! will instead return the previously initialized DMA instance.
//!
//! \return A pointer to use with USBLibDMA APIs.
//
//*****************************************************************************
tUSBDMAInstance * USBLibDMAInit(uint32_t index) {
  g_psUSBDMAInst.init(index);
  return &g_psUSBDMAInst;
}
Detected encoding: ASCII (7 bit)2