Source file: /~heha/ewa/Motor/Maxmaus8.zip/usblib/usbd.h

// TITLE: types and definitions used during USB enumeration
#pragma once
#include "usblib.h"	//usb::tRequest

namespace usb{

// The states for endpoint zero during enumeration.
enum tEP0State{
    // The USB device is waiting on a request from the host controller on endpoint zero.
    eUSBStateIdle,
    // The USB device is sending data back to the host due to an IN request.
    eUSBStateTx,
    // The USB device is sending the configuration descriptor back to the host due to an IN request.
    eUSBStateRx,
    // The USB device has completed the IN or OUT request and is now waiting
    // for the host to acknowledge the end of the IN/OUT transaction.  This
    // is the status phase for a USB control transaction.
    eUSBStateStatus,
    // This endpoint has signaled a stall condition and is waiting for the
    // stall to be acknowledged by the host controller.
    eUSBStateStall
};

// The USB controller device information
struct tDevice {
  //! USB event handler functions
  virtual ~tDevice() {}
  virtual void idle() {}
      //! This callback is made whenever the USB host requests a descriptor from the device.
  virtual bool cbGetDescriptor(const tRequest&)		{return false;}
      //! This callback is made whenever the USB host makes a request.
  virtual bool cbRequestHandler(const tRequest&)	{return false;}
      //! This callback is made in response to a SetInterface request from the host.
  virtual void cbInterfaceChange(uint8_t InterfaceNum, uint8_t AlternateSetting)	{}
      //! This callback is made in response to a SetConfiguration request from the host.
  virtual void cbConfigChange(uint32_t ui32Info)	{}
      //! This callback is made when data has been received following to a call
      //! to USBDCDRequestDataEP0.
  virtual void cbDataReceived(uint32_t ui32Info)	{}
      //! This callback is made when a USB reset is detected.
  virtual void cbResetHandler()			{}
      //! This callback is made when the device is disconnected from the USB bus.
  virtual void cbDisconnectHandler()		{cbResetHandler();}
    // The current state of endpoint zero.
  volatile tEP0State iEP0State;
    // The devices current address, this also has a change pending bit in the
    // MSB of this value specified by DEV_ADDR_PENDING.
  volatile uint8_t ui32DevAddress;
    // This holds the current active configuration for this device.
  uint8_t config;
  // Holds the current device status.
  uint8_t devstat;
    // This is the pointer to the current data being sent out or received
    // on endpoint zero.
  uint8_t *pui8EP0Data;
    // This is the number of bytes that remain to be sent from or received
    // into the g_sUSBDeviceState.pui8EP0Data data buffer.
  volatile unsigned ui32EP0DataRemain;

  bool Init();
  void Term();
  void StallEP0();
  void RequestDataEP0(uint8_t*,uint32_t);
  void SendDataEP0(const uint8_t*,unsigned);
  void SendDataEP0(const uint8_t*,unsigned, const tRequest&);
  void PowerStatusSet(bool selfpower) {if (selfpower) devstat|=1; else devstat&=~1;}

  static void USB0DeviceIntHandler();
private:
  void ReadAndDispatchRequest();
  void DeviceEnumHandler();
  void IntHandlerInternal(uint32_t, uint32_t);
  void EP0StateTx();
};
}
Detected encoding: ASCII (7 bit)2