Hanna
Sourcecode Kontrollplatine
Datenstrukturen | Makrodefinitionen | Typdefinitionen | Aufzählungen | Funktionen
usb_defaults.h-Dateireferenz

Bibliothek zur USB-Kommunikation von Jürgen W. Mehr ...

#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <stddef.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
Include-Abhängigkeitsdiagramm für usb_defaults.h:
Dieser Graph zeigt, welche Datei direkt oder indirekt diese Datei enthält:

gehe zum Quellcode dieser Datei

Datenstrukturen

struct  ATTR_PACKED
 
struct  ATTR_PACKED
 
struct  ATTR_PACKED
 
struct  ATTR_PACKED
 
struct  ATTR_PACKED
 
struct  ATTR_PACKED
 
struct  ATTR_PACKED
 
struct  ATTR_PACKED
 
struct  ATTR_PACKED
 
struct  ATTR_PACKED
 
struct  ATTR_PACKED
 
struct  ATTR_PACKED
 
struct  ATTR_PACKED
 
struct  ATTR_PACKED
 
struct  ATTR_PACKED
 
struct  ATTR_PACKED
 
struct  USB_Request_Header
 

Makrodefinitionen

#define ARCH_HAS_EEPROM_ADDRESS_SPACE
 
#define ARCH_HAS_FLASH_ADDRESS_SPACE
 
#define ARCH_HAS_MULTI_ADDRESS_SPACE
 
#define ARCH_LITTLE_ENDIAN
 
#define ATTR_ALIAS(Func)    __attribute__ ((alias( #Func )))
 
#define ATTR_ALWAYS_INLINE   __attribute__ ((always_inline))
 
#define ATTR_CONST   __attribute__ ((const))
 
#define ATTR_DEPRECATED   __attribute__ ((deprecated))
 
#define ATTR_INIT_SECTION(SectionIndex)   __attribute__ ((naked, section (".init" #SectionIndex )))
 
#define ATTR_NAKED   __attribute__ ((naked))
 
#define ATTR_NO_INIT   __attribute__ ((section (".noinit")))
 
#define ATTR_NO_INLINE   __attribute__ ((noinline))
 
#define ATTR_NO_RETURN   __attribute__ ((noreturn))
 
#define ATTR_NON_NULL_PTR_ARG(...)   __attribute__ ((nonnull (__VA_ARGS__)))
 
#define ATTR_PACKED   __attribute__ ((packed))
 
#define ATTR_PURE   __attribute__ ((pure))
 
#define ATTR_WARN_UNUSED_RESULT   __attribute__ ((warn_unused_result))
 
#define ATTR_WEAK   __attribute__ ((weak))
 
#define CONTROL_REQTYPE_DIRECTION   0x80
 
#define CONTROL_REQTYPE_RECIPIENT   0x1F
 
#define CONTROL_REQTYPE_TYPE   0x60
 
#define CPU_TO_LE16(x)   x
 
#define ENDPOINT_ATTR_ADAPTIVE   (2 << 2)
 
#define ENDPOINT_ATTR_ASYNC   (1 << 2)
 
#define ENDPOINT_ATTR_NO_SYNC   (0 << 2)
 
#define ENDPOINT_ATTR_SYNC   (3 << 2)
 
#define ENDPOINT_DESCRIPTOR_DIR_IN   ENDPOINT_DIR_IN
 
#define ENDPOINT_DESCRIPTOR_DIR_OUT   ENDPOINT_DIR_OUT
 
#define ENDPOINT_DIR_IN   0x80
 
#define ENDPOINT_DIR_MASK   0x80
 
#define ENDPOINT_DIR_OUT   0x00
 
#define ENDPOINT_USAGE_DATA   (0 << 4)
 
#define ENDPOINT_USAGE_FEEDBACK   (1 << 4)
 
#define ENDPOINT_USAGE_IMPLICIT_FEEDBACK   (2 << 4)
 
#define EP_TYPE_BULK   0x02
 
#define EP_TYPE_CONTROL   0x00
 
#define EP_TYPE_INTERRUPT   0x03
 
#define EP_TYPE_ISOCHRONOUS   0x01
 
#define FEATURE_REMOTE_WAKEUP_ENABLED   (1 << 1)
 
#define FEATURE_SELFPOWERED_ENABLED   (1 << 0)
 
#define GCC_FORCE_ALIGN_2
 
#define GCC_FORCE_POINTER_ACCESS(StructPtr)
 
#define GCC_IS_COMPILE_CONST(x)    0
 
#define GCC_MEMORY_BARRIER()
 
#define INTERNAL_SERIAL_LENGTH_BITS   (8 * (1 + (offsetof(NVM_PROD_SIGNATURES_t, COORDY1) - offsetof(NVM_PROD_SIGNATURES_t, LOTNUM0))))
 
#define INTERNAL_SERIAL_START_ADDRESS   offsetof(NVM_PROD_SIGNATURES_t, LOTNUM0)
 
#define LACR16(addr, msk)   __lac((unsigned char)msk,(unsigned char*)addr)
 From Atmel: Macros for XMEGA instructions not yet supported by the toolchain.
 
#define LANGUAGE_ID_ENG   0x0409
 
#define LASR16(addr, msk)   __las((unsigned char)msk,(unsigned char*)addr)
 
#define LATR16(addr, msk)   __lat(msk,addr)
 
#define likely(x)   x
 
#define MACROE   while (0)
 
#define MACROS   do
 
#define MAX(x, y)    (((x) > (y)) ? (x) : (y))
 
#define MIN(x, y)    (((x) < (y)) ? (x) : (y))
 
#define NO_DESCRIPTOR   0
 
#define REQDIR_DEVICETOHOST   (1 << 7)
 
#define REQDIR_HOSTTODEVICE   (0 << 7)
 
#define REQREC_DEVICE   (0 << 0)
 
#define REQREC_ENDPOINT   (2 << 0)
 
#define REQREC_INTERFACE   (1 << 0)
 
#define REQREC_OTHER   (3 << 0)
 
#define REQTYPE_CLASS   (1 << 5)
 
#define REQTYPE_STANDARD   (0 << 5)
 
#define REQTYPE_VENDOR   (2 << 5)
 
#define STRINGIFY(x)    #x
 
#define STRINGIFY_EXPANDED(x)    STRINGIFY(x)
 
#define unlikely(x)   x
 
#define USB_CONFIG_ATTR_BUSPOWERED   0x80
 
#define USB_CONFIG_ATTR_REMOTEWAKEUP   0x20
 
#define USB_CONFIG_ATTR_SELFPOWERED   0x40
 
#define USB_CONFIG_POWER_MA(mA)   ((mA) >> 1)
 
#define USB_DEF_EP0_SIZE   64
 
#define USB_DEF_EP_MAX   16
 
#define USB_DEF_EP_NUM   3
 
#define USB_DEF_PID   0x2404
 
#define USB_DEF_VID   0x03EB
 
#define USB_STRING_LEN(UnicodeChars)   (sizeof(USB_Descriptor_Header_t) + ((UnicodeChars) << 1))
 
#define USE_INTERNAL_SERIAL   0xDC
 
#define VERSION_BCD(x)   CPU_TO_LE16((((VERSION_TENS(x) << 4) | VERSION_ONES(x)) << 8) | ((VERSION_TENTHS(x) << 4) | VERSION_HUNDREDTHS(x)))
 
#define VERSION_HUNDREDTHS(x)   (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x)))
 
#define VERSION_ONES(x)   (int)((x) - (10 * VERSION_TENS(x)))
 
#define VERSION_TENS(x)   (int)((x) / 10)
 
#define VERSION_TENTHS(x)   (int)(((x) - (int)(x)) * 10)
 
#define XCHR16(addr, msk)   __xch(msk,addr)
 

Typdefinitionen

typedef uint8_t uint_reg_t
 
typedef struct USB_Request_Header USB_Request_Header_t
 
typedef struct USB_Request_Header USB_Requst_Header_t
 

Aufzählungen

enum  USB_Control_Request_t {
  REQ_GetStatus = 0, REQ_ClearFeature = 1, REQ_SetFeature = 3, REQ_SetAddress = 5,
  REQ_GetDescriptor = 6, REQ_SetDescriptor = 7, REQ_GetConfiguration = 8, REQ_SetConfiguration = 9,
  REQ_GetInterface = 10, REQ_SetInterface = 11, REQ_SynchFrame = 12
}
 
enum  USB_Descriptor_ClassSubclassProtocol_t {
  USB_CSCP_NoDeviceClass = 0x00, USB_CSCP_NoDeviceSubclass = 0x00, USB_CSCP_NoDeviceProtocol = 0x00, USB_CSCP_VendorSpecificClass = 0xFF,
  USB_CSCP_VendorSpecificSubclass = 0xFF, USB_CSCP_VendorSpecificProtocol = 0xFF, USB_CSCP_IADDeviceClass = 0xEF, USB_CSCP_IADDeviceSubclass = 0x02,
  USB_CSCP_IADDeviceProtocol = 0x01
}
 
enum  USB_DescriptorTypes_t {
  DTYPE_Device = 0x01, DTYPE_Configuration = 0x02, DTYPE_String = 0x03, DTYPE_Interface = 0x04,
  DTYPE_Endpoint = 0x05, DTYPE_DeviceQualifier = 0x06, DTYPE_Other = 0x07, DTYPE_InterfacePower = 0x08,
  DTYPE_InterfaceAssociation = 0x0B, DTYPE_CSInterface = 0x24, DTYPE_CSEndpoint = 0x25
}
 
enum  USB_Device_States_t {
  DEVICE_STATE_Unattached = 0, DEVICE_STATE_Powered = 1, DEVICE_STATE_Default = 2, DEVICE_STATE_Addressed = 3,
  DEVICE_STATE_Configured = 4, DEVICE_STATE_Suspended = 5
}
 

Funktionen

void EVENT_USB_Device_ConfigurationChanged (uint8_t config)
 
void EVENT_USB_Device_ControlOUT (uint8_t *data, uint8_t len)
 
bool EVENT_USB_Device_ControlRequest (struct USB_Request_Header *req)
 
void EVENT_USB_Device_Reset (void)
 
bool EVENT_USB_Device_SetInterface (uint8_t interface, uint8_t altsetting)
 
void EVENT_USB_Device_StartOfFrame (void)
 
void EVENT_USB_Device_Suspend (void)
 
void EVENT_USB_Device_WakeUp (void)
 

Ausführliche Beschreibung

Bibliothek zur USB-Kommunikation von Jürgen W.

Autor
Jürgen H. (woodym) aus http://www.mikrocontroller.net/topic/295339
Datum
03.05.2013
                $Revision: 464 $
                $Date: 2016-04-02 12:30:30 +0200 (Sa, 02 Apr 2016) $

Definiert in Datei usb_defaults.h.

Dokumentation der Aufzählungstypen

Aufzählungswerte
REQ_GetStatus 

Implemented in the library for device and endpoint recipients. Passed to the user application for other recipients via the EVENT_USB_Device_ControlRequest() event when received in device mode.

REQ_ClearFeature 

Implemented in the library for device and endpoint recipients. Passed to the user application for other recipients via the EVENT_USB_Device_ControlRequest() event when received in device mode.

REQ_SetFeature 

Implemented in the library for device and endpoint recipients. Passed to the user application for other recipients via the EVENT_USB_Device_ControlRequest() event when received in device mode.

REQ_SetAddress 

Implemented in the library for the device recipient. Passed to the user application for other recipients via the EVENT_USB_Device_ControlRequest() event when received in device mode.

REQ_GetDescriptor 

Implemented in the library for device and interface recipients. Passed to the user application for other recipients via the EVENT_USB_Device_ControlRequest() event when received in device mode.

REQ_SetDescriptor 

Not implemented in the library, passed to the user application via the EVENT_USB_Device_ControlRequest() event when received in device mode.

REQ_GetConfiguration 

Implemented in the library for the device recipient. Passed to the user application for other recipients via the EVENT_USB_Device_ControlRequest() event when received in device mode.

REQ_SetConfiguration 

Implemented in the library for the device recipient. Passed to the user application for other recipients via the EVENT_USB_Device_ControlRequest() event when received in device mode.

REQ_GetInterface 

Not implemented in the library, passed to the user application via the EVENT_USB_Device_ControlRequest() event when received in device mode.

REQ_SetInterface 

Not implemented in the library, passed to the user application via the EVENT_USB_Device_ControlRequest() event when received in device mode.

REQ_SynchFrame 

Not implemented in the library, passed to the user application via the EVENT_USB_Device_ControlRequest() event when received in device mode.

Definiert in Zeile 604 der Datei usb_defaults.h.

Enum for possible Class, Subclass and Protocol values of device and interface descriptors.

Aufzählungswerte
USB_CSCP_NoDeviceClass 

Descriptor Class value indicating that the device does not belong to a particular class at the device level.

USB_CSCP_NoDeviceSubclass 

Descriptor Subclass value indicating that the device does not belong to a particular subclass at the device level.

USB_CSCP_NoDeviceProtocol 

Descriptor Protocol value indicating that the device does not belong to a particular protocol at the device level.

USB_CSCP_VendorSpecificClass 

Descriptor Class value indicating that the device/interface belongs to a vendor specific class.

USB_CSCP_VendorSpecificSubclass 

Descriptor Subclass value indicating that the device/interface belongs to a vendor specific subclass.

USB_CSCP_VendorSpecificProtocol 

Descriptor Protocol value indicating that the device/interface belongs to a vendor specific protocol.

USB_CSCP_IADDeviceClass 

Descriptor Class value indicating that the device belongs to the Interface Association Descriptor class.

USB_CSCP_IADDeviceSubclass 

Descriptor Subclass value indicating that the device belongs to the Interface Association Descriptor subclass.

USB_CSCP_IADDeviceProtocol 

Descriptor Protocol value indicating that the device belongs to the Interface Association Descriptor protocol.

Definiert in Zeile 253 der Datei usb_defaults.h.

Enum for the possible standard descriptor types, as given in each descriptor's header.

Aufzählungswerte
DTYPE_Device 

Indicates that the descriptor is a device descriptor.

DTYPE_Configuration 

Indicates that the descriptor is a configuration descriptor.

DTYPE_String 

Indicates that the descriptor is a string descriptor.

DTYPE_Interface 

Indicates that the descriptor is an interface descriptor.

DTYPE_Endpoint 

Indicates that the descriptor is an endpoint descriptor.

DTYPE_DeviceQualifier 

Indicates that the descriptor is a device qualifier descriptor.

DTYPE_Other 

Indicates that the descriptor is of other type.

DTYPE_InterfacePower 

Indicates that the descriptor is an interface power descriptor.

DTYPE_InterfaceAssociation 

Indicates that the descriptor is an interface association descriptor.

DTYPE_CSInterface 

Indicates that the descriptor is a class specific interface descriptor.

DTYPE_CSEndpoint 

Indicates that the descriptor is a class specific endpoint descriptor.

Definiert in Zeile 237 der Datei usb_defaults.h.

Enum for the various states of the USB Device state machine. Only some states are implemented in the LUFA library - other states are left to the user to implement.

For information on each possible USB device state, refer to the USB 2.0 specification.

Siehe auch
USB_DeviceState, which stores the current device state machine state.
Aufzählungswerte
DEVICE_STATE_Unattached 

Internally implemented by the library. This state indicates that the device is not currently connected to a host.

DEVICE_STATE_Powered 

Internally implemented by the library. This state indicates that the device is connected to a host, but enumeration has not yet begun.

DEVICE_STATE_Default 

Internally implemented by the library. This state indicates that the device's USB bus has been reset by the host and it is now waiting for the host to begin the enumeration process.

DEVICE_STATE_Addressed 

Internally implemented by the library. This state indicates that the device has been addressed by the USB Host, but is not yet configured.

DEVICE_STATE_Configured 

May be implemented by the user project. This state indicates that the device has been enumerated by the host and is ready for USB communications to begin.

DEVICE_STATE_Suspended 

May be implemented by the user project. This state indicates that the USB bus has been suspended by the host, and the device should power down to a minimal power level until the bus is resumed.

Definiert in Zeile 659 der Datei usb_defaults.h.

Dokumentation der Funktionen

void EVENT_USB_Device_ConfigurationChanged ( uint8_t  config)

Event when the USB configuration is changed. The configuration is stored in variable USB_Device_ConfigurationNumber

Definiert in Zeile 191 der Datei usb_cdc.c.

void EVENT_USB_Device_ControlOUT ( uint8_t *  data,
uint8_t  len 
)

Event when OUT data is received as part of a control transfer.

Definiert in Zeile 221 der Datei usb_cdc.c.

bool EVENT_USB_Device_ControlRequest ( USB_Request_Header_t req)

Event handlers. These functions are called from ISRs or are otherwise time-critical, so handle them quickly.Callback to handle a control request that was not handled by the library. Return true if the request has been handled. Returning false will send a STALL to the host.

Event handler for the library USB Control Request reception event.

Definiert in Zeile 239 der Datei usb_cdc.c.

void EVENT_USB_Device_Reset ( void  )

Event when the host resets the device. Called after the library resets the control endpoint

Definiert in Zeile 215 der Datei usb_cdc.c.

bool EVENT_USB_Device_SetInterface ( uint8_t  interface,
uint8_t  altsetting 
)

Event when an alternate setting for an interface is selected. Return true to accept the alternate setting, or FALSE to send a STALL reply

Definiert in Zeile 183 der Datei usb_cdc.c.

void EVENT_USB_Device_StartOfFrame ( void  )

Event called on start of frame, if enabled

void EVENT_USB_Device_Suspend ( void  )

Event when the USB bus suspends

Definiert in Zeile 201 der Datei usb_cdc.c.

void EVENT_USB_Device_WakeUp ( void  )

Event when the USB bus returns from suspend

Definiert in Zeile 208 der Datei usb_cdc.c.