- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

# usb_internal.h

    00001 /*
    00002   FreeRTOS V4.0.1 - copyright (C) 2003-2006 Richard Barry.
    00003
    00004   This file is part of the FreeRTOS distribution.
    00005
    00006   FreeRTOS is free software; you can redistribute it and/or modify
    00007   it under the terms of the GNU General Public License as published by
    00008   the Free Software Foundation; either version 2 of the License, or
    00009   (at your option) any later version.
    00010
    00011   FreeRTOS is distributed in the hope that it will be useful,
    00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00014   GNU General Public License for more details.
    00015
    00016   You should have received a copy of the GNU General Public License
    00017   along with FreeRTOS; if not, write to the Free Software
    00018   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00019
    00020   A special exception to the GPL can be applied should you wish to distribute
    00021   a combined work that includes FreeRTOS, without being obliged to provide
    00022   the source code for any proprietary components.  See the licensing section
    00023   of http://www.FreeRTOS.org for full details of how and when the exception
    00024   can be applied.
    00025
    00026   ***************************************************************************
    00027   See http://www.FreeRTOS.org for documentation, latest information, license
    00028   and contact details.  Please ensure to read the configuration and relevant
    00029   port sections of the online documentation.
    00030   ***************************************************************************
    00031 */
    00032
    00033 /* Descriptor type definitions. */
    00034 #define usbDESCRIPTOR_TYPE_DEVICE     ( 0x01 )
    00035 #define usbDESCRIPTOR_TYPE_CONFIGURATION  ( 0x02 )
    00036 #define usbDESCRIPTOR_TYPE_STRING     ( 0x03 )
    00037
    00038 /* USB request type definitions. */
    00039 #define usbGET_REPORT_REQUEST       ( 0x01 )
    00040 #define usbGET_IDLE_REQUEST         ( 0x02 )
    00041 #define usbGET_PROTOCOL_REQUEST       ( 0x03 )
    00042 #define usbSET_REPORT_REQUEST       ( 0x09 )
    00043 #define usbSET_IDLE_REQUEST         ( 0x0A )
    00044 #define usbSET_PROTOCOL_REQUEST       ( 0x0B )
    00045 #define usbGET_CONFIGURATION_REQUEST    ( 0x08 )
    00046 #define usbGET_STATUS_REQUEST       ( 0x00 )
    00047 #define usbCLEAR_FEATURE_REQUEST      ( 0x01 )
    00048 #define usbSET_FEATURE_REQUEST        ( 0x03 )
    00049 #define usbSET_ADDRESS_REQUEST        ( 0x05 )
    00050 #define usbGET_DESCRIPTOR_REQUEST     ( 0x06 )
    00051 #define usbSET_CONFIGURATION_REQUEST    ( 0x09 )
    00052 #define usbGET_INTERFACE_REQUEST      ( 0x0A )
    00053 #define usbSET_INTERFACE_REQUEST      ( 0x0B )
    00054
    00055 /* ACM Requests */
    00056 #define usbSEND_ENCAPSULATED_COMMAND    ( 0x00 )
    00057 #define usbGET_ENCAPSULATED_RESPONSE    ( 0x01 )
    00058 #define usbSET_LINE_CODING          ( 0x20 )
    00059 #define usbGET_LINE_CODING          ( 0x21 )
    00060 #define usbSET_CONTROL_LINE_STATE     ( 0x22 )
    00061
    00062 /* Misc USB definitions. */
    00063 #define usbDEVICE_CLASS_VENDOR_SPECIFIC   ( 0xFF )
    00064 #define usbBUS_POWERED            ( 0x80 )
    00065 #define usbHID_REPORT_DESCRIPTOR      ( 0x22 )
    00066 #define AT91C_UDP_TRANSCEIVER_ENABLE    ( *( ( unsigned long * ) 0xfffb0074 ) )
    00067
    00068 /* Index to the various string. */
    00069 #define usbLANGUAGE_STRING          ( 0 )
    00070 #define usbMANUFACTURER_STRING        ( 1 )
    00071 #define usbPRODUCT_STRING         ( 2 )
    00072 #define usbCONFIGURATION_STRING       ( 3 )
    00073 #define usbINTERFACE_STRING         ( 4 )
    00074
    00075 /* Defines fields of standard SETUP request.  Now in normal order. */
    00076 #define usbREQUEST_TYPE_INDEX       ( 0 )
    00077 #define usbREQUEST_INDEX          ( 1 )
    00078 #define usbVALUE_HIGH_BYTE          ( 3 )
    00079 #define usbVALUE_LOW_BYTE         ( 2 )
    00080 #define usbINDEX_HIGH_BYTE          ( 5 )
    00081 #define usbINDEX_LOW_BYTE         ( 4 )
    00082 #define usbLENGTH_HIGH_BYTE         ( 7 )
    00083 #define usbLENGTH_LOW_BYTE          ( 6 )
    00084
    00085 /* Misc application definitions. */
    00086 #define usbINTERRUPT_PRIORITY       ( 3 )
    00087 #define usbQUEUE_LENGTH           ( 0x3 ) /* Must have all bits set! */
    00088 #define usbFIFO_LENGTH            ( ( unsigned portLONG ) 8 )
    00089 #define usbEND_POINT_0            ( 0 )
    00090 #define usbEND_POINT_1            ( 1 )
    00091 #define usbEND_POINT_2            ( 2 )
    00092 #define usbEND_POINT_3            ( 3 )
    00093 #define usbMAX_CONTROL_MESSAGE_SIZE     ( 128 )
    00094 #define usbRX_COUNT_MASK          ( ( unsigned portLONG ) 0x7ff )
    00095 #define AT91C_UDP_STALLSENT         AT91C_UDP_ISOERROR
    00096 #define usbSHORTEST_DELAY         ( ( portTickType ) 1 )
    00097 #define usbINIT_DELAY           ( ( portTickType ) 1000 / portTICK_RATE_MS )
    00098 #define usbSHORT_DELAY            ( ( portTickType ) 50 / portTICK_RATE_MS )
    00099 #define usbEND_POINT_RESET_MASK       ( ( unsigned portLONG ) 0x0f )
    00100 #define usbDATA_INC             ( ( portCHAR ) 5 )
    00101 #define usbEXPECTED_NUMBER_OF_BYTES     ( ( unsigned portLONG ) 8 )
    00102
    00103 /* Control request types. */
    00104 #define usbSTANDARD_DEVICE_REQUEST      ( 0 )
    00105 #define usbSTANDARD_INTERFACE_REQUEST   ( 1 )
    00106 #define usbSTANDARD_END_POINT_REQUEST   ( 2 )
    00107 #define usbCLASS_INTERFACE_REQUEST      ( 5 )
    00108
    00109
    00110 /* Macros to manipulate the control and status registers.  These registers
    00111 cannot be accessed using a direct read modify write operation outside of the
    00112 ISR as some bits are left unchanged by writing with a 0, and some are left
    00113 unchanged by writing with a 1. */
    00114
    00115
    00116 #define usbCSR_SET_BIT( pulValueNow, ulBit )                      \
    00117 {                                           \
    00118   /* Set TXCOMP, RX_DATA_BK0, RXSETUP, */                       \
    00119   /* STALLSENT and RX_DATA_BK1 to 1 so the */                     \
    00120   /* write has no effect. */                              \
    00121   ( * ( ( unsigned portLONG * ) pulValueNow ) ) |= ( unsigned portLONG ) 0x4f;    \
    00122                                             \
    00123   /* Clear the FORCE_STALL and TXPKTRDY bits */                   \
    00124   /* so the write has no effect. */                         \
    00125   ( * ( ( unsigned portLONG * ) pulValueNow ) ) &= ( unsigned portLONG ) 0xffffffcf;  \
    00126                                             \
    00127   /* Set whichever bit we want set. */                        \
    00128   ( * ( ( unsigned portLONG * ) pulValueNow ) ) |= ( ulBit );             \
    00129 }
    00130
    00131 #define usbCSR_CLEAR_BIT( pulValueNow, ulBit )                      \
    00132 {                                           \
    00133   /* Set TXCOMP, RX_DATA_BK0, RXSETUP, */                       \
    00134   /* STALLSENT and RX_DATA_BK1 to 1 so the */                     \
    00135   /* write has no effect. */                              \
    00136   ( * ( ( unsigned portLONG * ) pulValueNow ) ) |= ( unsigned portLONG ) 0x4f;    \
    00137                                             \
    00138   /* Clear the FORCE_STALL and TXPKTRDY bits */                   \
    00139   /* so the write has no effect. */                         \
    00140   ( * ( ( unsigned portLONG * ) pulValueNow ) ) &= ( unsigned portLONG ) 0xffffffcf;  \
    00141                                             \
    00142   /* Clear whichever bit we want clear. */                      \
    00143   ( * ( ( unsigned portLONG * ) pulValueNow ) ) &= ( ~ulBit );            \
    00144 }

The Make Controller Kit is an open source project maintained by MakingThings.
MakingThings code is released under the Apache 2.0 license.
Bug tracker, development wiki and status can be found at http://dev.makingthings.com.
This document was last updated on 18 May 2009.