usb_cdc.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /******************************************************************************
  2. *
  3. * Freescale Semiconductor Inc.
  4. * (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
  5. * ALL RIGHTS RESERVED.
  6. *
  7. ******************************************************************************
  8. *
  9. * THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
  10. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  11. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  12. * IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  13. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  14. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  15. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  16. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  17. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  18. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  19. * THE POSSIBILITY OF SUCH DAMAGE.
  20. *
  21. **************************************************************************//*!
  22. *
  23. * @file usb_cdc.h
  24. *
  25. * @author
  26. *
  27. * @version
  28. *
  29. * @date May-28-2009
  30. *
  31. * @brief The file contains USB stack CDC class layer API header function.
  32. *
  33. *****************************************************************************/
  34. #ifndef _USB_CDC_H
  35. #define _USB_CDC_H
  36. /******************************************************************************
  37. * Includes
  38. *****************************************************************************/
  39. #include "types.h"
  40. #include "usb_descriptor.h"
  41. #include "usb_class.h"
  42. #include "usb_cdc_pstn.h"
  43. #include "usb_devapi.h"
  44. #ifdef COMPOSITE_DEV
  45. #include "usb_composite.h"
  46. #endif
  47. /******************************************************************************
  48. * Constants - None
  49. *****************************************************************************/
  50. /******************************************************************************
  51. * Macro's
  52. *****************************************************************************/
  53. /* Class specific request Codes */
  54. #define SEND_ENCAPSULATED_COMMAND (0x00)
  55. #define GET_ENCAPSULATED_RESPONSE (0x01)
  56. #define SET_COMM_FEATURE (0x02)
  57. #define GET_COMM_FEATURE (0x03)
  58. #define CLEAR_COMM_FEATURE (0x04)
  59. #define SET_AUX_LINE_STATE (0x10)
  60. #define SET_HOOK_STATE (0x11)
  61. #define PULSE_SETUP (0x12)
  62. #define SEND_PULSE (0x13)
  63. #define SET_PULSE_TIME (0x14)
  64. #define RING_AUX_JACK (0x15)
  65. #define SET_LINE_CODING (0x20)
  66. #define GET_LINE_CODING (0x21)
  67. #define SET_CONTROL_LINE_STATE (0x22)
  68. #define SEND_BREAK (0x23)
  69. #define SET_RINGER_PARAMS (0x30)
  70. #define GET_RINGER_PARAMS (0x31)
  71. #define SET_OPERATION_PARAM (0x32)
  72. #define GET_OPERATION_PARAM (0x33)
  73. #define SET_LINE_PARAMS (0x34)
  74. #define GET_LINE_PARAMS (0x35)
  75. #define DIAL_DIGITS (0x36)
  76. #define SET_UNIT_PARAMETER (0x37)
  77. #define GET_UNIT_PARAMETER (0x38)
  78. #define CLEAR_UNIT_PARAMETER (0x39)
  79. #define GET_PROFILE (0x3A)
  80. #define SET_ETHERNET_MULTICAST_FILTERS (0x40)
  81. #define SET_ETHERNET_POW_PATTER_FILTER (0x41)
  82. #define GET_ETHERNET_POW_PATTER_FILTER (0x42)
  83. #define SET_ETHERNET_PACKET_FILTER (0x43)
  84. #define GET_ETHERNET_STATISTIC (0x44)
  85. #define SET_ATM_DATA_FORMAT (0x50)
  86. #define GET_ATM_DEVICE_STATISTICS (0x51)
  87. #define SET_ATM_DEFAULT_VC (0x52)
  88. #define GET_ATM_VC_STATISTICS (0x53)
  89. #define MDLM_SPECIFIC_REQUESTS_MASK (0x7F)
  90. /* Class Specific Notification Codes */
  91. #define NETWORK_CONNECTION_NOTIF (0x00)
  92. #define RESPONSE_AVAIL_NOTIF (0x01)
  93. #define AUX_JACK_HOOK_STATE_NOTIF (0x08)
  94. #define RING_DETECT_NOTIF (0x09)
  95. #define SERIAL_STATE_NOTIF (0x20)
  96. #define CALL_STATE_CHANGE_NOTIF (0x28)
  97. #define LINE_STATE_CHANGE_NOTIF (0x29)
  98. #define CONNECTION_SPEED_CHANGE_NOTIF (0x2A)
  99. #define MDLM_SPECIFIC_NOTIF_MASK (0x5F)
  100. /* Events to the Application */ /* 0 to 4 are reserved for class events */
  101. #define USB_APP_CDC_CARRIER_DEACTIVATED (0x21)
  102. #define USB_APP_CDC_CARRIER_ACTIVATED (0x22)
  103. /* other macros */
  104. #define NOTIF_PACKET_SIZE (0x08)
  105. #define NOTIF_REQUEST_TYPE (0xA1)
  106. /* macros for queuing */
  107. #define MAX_QUEUE_ELEMS (4)
  108. #if CIC_NOTIF_ELEM_SUPPORT
  109. #define CIC_SEND_ENDPOINT CIC_NOTIF_ENDPOINT
  110. #endif
  111. #if DIC_ISOCHRONOUS_SETTING
  112. #define DIC_SEND_ENDPOINT DIC_ISO_IN_ENDPOINT
  113. #define DIC_RECV_ENDPOINT DIC_ISO_OUT_ENDPOINT
  114. #else
  115. #define DIC_SEND_ENDPOINT DIC_BULK_IN_ENDPOINT
  116. #define DIC_RECV_ENDPOINT DIC_BULK_OUT_ENDPOINT
  117. #endif
  118. /******************************************************************************
  119. * Types
  120. *****************************************************************************/
  121. #ifndef COMPOSITE_DEV
  122. typedef struct _app_data_struct
  123. {
  124. uint_8_ptr data_ptr; /* pointer to buffer */
  125. USB_PACKET_SIZE data_size; /* buffer size of endpoint */
  126. }APP_DATA_STRUCT;
  127. #endif
  128. /* structure to hold a request in the endpoint queue */
  129. typedef struct _usb_class_cdc_queue
  130. {
  131. uint_8 controller_ID; /* Controller ID */
  132. uint_8 channel; /* Endpoint Number */
  133. APP_DATA_STRUCT app_data; /* Application Data Structure */
  134. }USB_CLASS_CDC_QUEUE, *PTR_USB_CLASS_CDC_QUEUE;
  135. /* USB class cdc endpoint data */
  136. typedef struct _usb_class_cdc_endpoint
  137. {
  138. uint_8 endpoint; /* endpoint num */
  139. uint_8 type; /* type of endpoint (interrupt, bulk or isochronous) */
  140. uint_8 bin_consumer;/* the num of queued elements */
  141. uint_8 bin_producer;/* the num of de-queued elements */
  142. USB_CLASS_CDC_QUEUE queue[MAX_QUEUE_ELEMS]; /* queue data */
  143. }USB_CLASS_CDC_ENDPOINT;
  144. /******************************************************************************
  145. * Global Functions
  146. *****************************************************************************/
  147. extern uint_8 USB_Class_CDC_Init (
  148. uint_8 controller_ID, /* [IN] Controller ID */
  149. USB_CLASS_CALLBACK cdc_class_callback, /* [IN] CDC Class Callback */
  150. USB_REQ_FUNC vendor_req_callback, /* [IN] Vendor Request Callback */
  151. USB_CLASS_CALLBACK pstn_callback, /* [IN] PSTN Callback */
  152. uint_8 bVregEn /* Enables or disables internal regulator */
  153. );
  154. #ifdef COMPOSITE_DEV
  155. extern uint_8 USB_CDC_Other_Requests(uint_8 controller_ID,
  156. USB_SETUP_STRUCT * setup_packet,
  157. uint_8_ptr *data,
  158. USB_PACKET_SIZE *size);
  159. #endif
  160. extern uint_8 USB_Class_CDC_DeInit
  161. (
  162. uint_8 controller_ID
  163. );
  164. extern uint_8 USB_Class_CDC_Send_Data (
  165. uint_8 controller_ID,
  166. uint_8 ep_num,
  167. uint_8_ptr buff_ptr,
  168. USB_PACKET_SIZE size
  169. );
  170. #if CIC_NOTIF_ELEM_SUPPORT
  171. #define USB_Class_CDC_Interface_CIC_Send_Data(a,b,c) \
  172. USB_Class_CDC_Send_Data(a,CIC_SEND_ENDPOINT,b,c)
  173. #endif
  174. #define USB_Class_CDC_Interface_DIC_Send_Data(a,b,c) \
  175. USB_Class_CDC_Send_Data(a,DIC_SEND_ENDPOINT,b,c)
  176. #define USB_Class_CDC_Interface_DIC_Recv_Data(a,b,c) \
  177. _usb_device_recv_data(a,DIC_RECV_ENDPOINT,b,c)
  178. #define USB_Class_CDC_Interface_DIC_Get_Send_Buffer(a,b,c) \
  179. _usb_device_get_send_buffer(a,DIC_SEND_ENDPOINT,b,c)
  180. #define USB_Class_CDC_Periodic_Task USB_Class_Periodic_Task
  181. #endif