Quelltext /~heha/ewa/Motor/Maxmaus9.zip/usblib/usblib.h

// TITLE: Main header file for the USB Library
#pragma once
#include <stdint.h>		// uint32_t
#include <inc/hw_types.h>	// uint8_t
#include <inc/hw_memmap.h>	// USBA_BASE

#ifdef __TMS320C28XX__
#define INT_USB                 INT_USBA  // USB Define for C28x.
#define USB_BASE                USBA_BASE // USB Define for C28x.
#else
#define INT_USB                 INT_USB0  // USB Define for CM.
#define USB_BASE                USB0_BASE // USB Define for C28x.
#endif

namespace usb{
// USB-Request als Byte-struct erspart Alignment-Probleme
struct tRequest{
  uint8_t bmRequestType,// Determines the type and direction of the request.
  bRequest,		// Identifies the specific request being made.
  wValueL, wValueH,	// Word-sized field that varies according to the request.
  wIndexL, wIndexH,	// Word-sized field that varies according to the request.
  wLengthL, wLengthH;	// The number of bytes to transfer if there is a data stage to the request.
  uint16_t wRequest() const {return bRequest<<8|bmRequestType;}
  uint16_t wValue() const {return wValueH<<8|wValueL;}
  uint16_t wIndex() const {return wIndexH<<8|wIndexL;}
  uint16_t wLength() const {return wLengthH<<8|wLengthL;}
  void limitLength(unsigned&l) const {if (l>wLength()) l=wLength();}
  void limitLength(volatile unsigned&l) const {if (l>wLength()) l=wLength();}
  operator uint8_t*() {return &bmRequestType;}
};
}

// Generate two-byte, three-byte, and four-byte value for USB descriptors
#define USB2(v)  (v) & 0xff, (v) >> 8
#define USB3(v)  USB2((v)&0xFFFF), (v)>> 16
#define USB4(v)  USB2((v)&0xFFFF), USB2((v)>>16)
Vorgefundene Kodierung: UTF-80