usblibpriv.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. //*****************************************************************************
  2. //
  3. // usblibpriv.h - Private header file used to share internal variables and
  4. // function prototypes between the various modules in the USB
  5. // library. This header MUST NOT be used by application code.
  6. //
  7. // Copyright (c) 2008-2010 Texas Instruments Incorporated. All rights reserved.
  8. // Software License Agreement
  9. //
  10. // Texas Instruments (TI) is supplying this software for use solely and
  11. // exclusively on TI's microcontroller products. The software is owned by
  12. // TI and/or its suppliers, and is protected under applicable copyright
  13. // laws. You may not combine this software with "viral" open-source
  14. // software in order to form a larger program.
  15. //
  16. // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
  17. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
  18. // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  19. // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
  20. // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  21. // DAMAGES, FOR ANY REASON WHATSOEVER.
  22. //
  23. // This is part of AM1808 StarterWare USB Library and reused from revision 6288
  24. // of the Stellaris USB Library.
  25. //
  26. //*****************************************************************************
  27. #ifndef __USBLIBPRIV_H__
  28. #define __USBLIBPRIV_H__
  29. //*****************************************************************************
  30. //
  31. // If building with a C++ compiler, make all of the definitions in this header
  32. // have a C binding.
  33. //
  34. //*****************************************************************************
  35. #ifdef __cplusplus
  36. extern "C"
  37. {
  38. #endif
  39. //*****************************************************************************
  40. //
  41. // Internal interrupt handlers called from the main vectors in device and
  42. // host mode.
  43. //
  44. //*****************************************************************************
  45. extern void USBDeviceIntHandlerInternal(unsigned int ulIndex,
  46. unsigned int ulStatus, unsigned int *ePStatus);
  47. extern void USBHostIntHandlerInternal(unsigned int ulIndex,
  48. unsigned int ulStatus, unsigned int *endPStatus);
  49. //*****************************************************************************
  50. //
  51. // These defines are used to register the tick handlers used by the stack.
  52. // These handlers are internal to the stack and should never be called directly
  53. // by an application.
  54. //
  55. //*****************************************************************************
  56. #define USB_TICK_HANDLER_OTG 0 // OTG mode tick handler.
  57. #define USB_TICK_HANDLER_DEVICE 1 // Device mode tick handler.
  58. #define USB_TICK_HANDLER_HOST 2 // Host mode tick handler.
  59. #define USB_TICK_HANDLER_NUM 3 // Total number of tick handlers.
  60. //*****************************************************************************
  61. //
  62. // This value defines the number of SOF ticks that must pass before a call
  63. // is made to InternalUSBStartOfFrameTick. The value 5 ensures that the
  64. // function is called every 5 milliseconds assuming that SOF interrupts are
  65. // enabled and SOF is present.
  66. //
  67. //*****************************************************************************
  68. #define USB_SOF_TICK_DIVIDE 5
  69. //*****************************************************************************
  70. //
  71. // Tick handler function pointer type.
  72. //
  73. //*****************************************************************************
  74. typedef void(* tUSBTickHandler)(void *pvInstance, unsigned int ulTicksmS,
  75. unsigned int ulIndex);
  76. //*****************************************************************************
  77. //
  78. // Internal functions use to initialize the tick handler and register tick
  79. // callbacks.
  80. //
  81. //*****************************************************************************
  82. extern void InternalUSBTickInit(void);
  83. extern void InternalUSBRegisterTickHandler(unsigned int ulHandler,
  84. tUSBTickHandler pfHandler,
  85. void *pvInstance);
  86. extern void InternalUSBStartOfFrameTick(unsigned int ulTicksmS,
  87. unsigned int ulIndex);
  88. extern void InternalUSBHCDSendEvent(unsigned int ulIndex, unsigned int ulEvent);
  89. //*****************************************************************************
  90. //
  91. // g_ulCurrentUSBTick holds the elapsed time in milliseconds since the
  92. // tick module was first initialized based on calls to the function
  93. // InternalUSBStartOfFrameTick. The granularity is USB_SOF_TICK_DIVIDE
  94. // milliseconds.
  95. //
  96. //*****************************************************************************
  97. extern unsigned int g_ulCurrentUSBTick;
  98. //*****************************************************************************
  99. //
  100. // g_ulUSBSOFCount is a global counter for Start of Frame interrupts. It is
  101. // incremented by the low level device- or host-mode interrupt handlers.
  102. //
  103. //*****************************************************************************
  104. extern unsigned int g_ulUSBSOFCount;
  105. //*****************************************************************************
  106. //
  107. // InternalUSBGetTime is a macro which will return the system time in
  108. // milliseconds as calculated based on calls to the function
  109. // InternalUSBStartOfFrameTick. The granularity is USB_SOF_TICK_DIVIDE
  110. // milliseconds.
  111. //
  112. // Currently, this merely returns the value of a global variable.
  113. //
  114. //*****************************************************************************
  115. #define InternalUSBGetTime() g_ulCurrentUSBTick
  116. //*****************************************************************************
  117. //
  118. // Mark the end of the C bindings section for C++ compilers.
  119. //
  120. //*****************************************************************************
  121. #ifdef __cplusplus
  122. }
  123. #endif
  124. #endif // __USBLIBPRIV_H__