tusb.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /**************************************************************************/
  2. /*!
  3. @file tusb.h
  4. @author hathach (tinyusb.org)
  5. @section LICENSE
  6. Software License Agreement (BSD License)
  7. Copyright (c) 2013, hathach (tinyusb.org)
  8. All rights reserved.
  9. Redistribution and use in source and binary forms, with or without
  10. modification, are permitted provided that the following conditions are met:
  11. 1. Redistributions of source code must retain the above copyright
  12. notice, this list of conditions and the following disclaimer.
  13. 2. Redistributions in binary form must reproduce the above copyright
  14. notice, this list of conditions and the following disclaimer in the
  15. documentation and/or other materials provided with the distribution.
  16. 3. Neither the name of the copyright holders nor the
  17. names of its contributors may be used to endorse or promote products
  18. derived from this software without specific prior written permission.
  19. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
  20. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
  23. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
  26. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. This file is part of the tinyusb stack.
  30. */
  31. /**************************************************************************/
  32. #ifndef _TUSB_H_
  33. #define _TUSB_H_
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37. //--------------------------------------------------------------------+
  38. // INCLUDE
  39. //--------------------------------------------------------------------+
  40. #include "common/tusb_common.h"
  41. #include "tusb_hal.h"
  42. #include "osal/osal.h"
  43. //------------- HOST -------------//
  44. #if MODE_HOST_SUPPORTED
  45. #include "host/usbh.h"
  46. #if HOST_CLASS_HID
  47. #include "class/hid/hid_host.h"
  48. #endif
  49. #if CFG_TUSB_HOST_MSC
  50. #include "class/msc/msc_host.h"
  51. #endif
  52. #if CFG_TUSB_HOST_CDC
  53. #include "class/cdc/cdc_host.h"
  54. #endif
  55. #if CFG_TUSB_HOST_CUSTOM_CLASS
  56. #include "class/custom_host.h"
  57. #endif
  58. #endif
  59. //------------- DEVICE -------------//
  60. #if MODE_DEVICE_SUPPORTED
  61. #include "device/usbd.h"
  62. #if DEVICE_CLASS_HID
  63. #include "class/hid/hid_device.h"
  64. #endif
  65. #if CFG_TUD_CDC
  66. #include "class/cdc/cdc_device.h"
  67. #endif
  68. #if CFG_TUD_MSC
  69. #include "class/msc/msc_device.h"
  70. #endif
  71. #if CFG_TUD_CUSTOM_CLASS
  72. #include "class/custom/custom_device.h"
  73. #endif
  74. #endif
  75. //--------------------------------------------------------------------+
  76. // APPLICATION API
  77. //--------------------------------------------------------------------+
  78. /** \ingroup group_application_api
  79. * @{ */
  80. /** \brief Initialize the usb stack
  81. * \return Error Code of the \ref TUSB_ERROR enum
  82. * \note Function will initialize the stack according to configuration in the configure file (tusb_config.h)
  83. */
  84. tusb_error_t tusb_init(void);
  85. #if CFG_TUSB_OS == OPT_OS_NONE
  86. /** \brief Run all tinyusb's internal tasks (e.g host task, device task).
  87. * \note This function is only required when using no RTOS (\ref CFG_TUSB_OS == OPT_OS_NONE). All the stack functions
  88. * & callback are invoked within this function, so it should be called periodically within the mainloop
  89. *
  90. @code
  91. int main(void)
  92. {
  93. your_init_code();
  94. tusb_init();
  95. // other config code
  96. while(1) // the mainloop
  97. {
  98. your_application_code();
  99. tusb_task(); // handle tinyusb event, task etc ...
  100. }
  101. }
  102. @endcode
  103. *
  104. */
  105. void tusb_task(void);
  106. #endif
  107. /** @} */
  108. #ifdef __cplusplus
  109. }
  110. #endif
  111. #endif /* _TUSB_H_ */