tusb.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. #include "common/tusb_fifo.h"
  44. //------------- HOST -------------//
  45. #if TUSB_OPT_HOST_ENABLED
  46. #include "host/usbh.h"
  47. #if HOST_CLASS_HID
  48. #include "class/hid/hid_host.h"
  49. #endif
  50. #if CFG_TUH_MSC
  51. #include "class/msc/msc_host.h"
  52. #endif
  53. #if CFG_TUH_CDC
  54. #include "class/cdc/cdc_host.h"
  55. #endif
  56. #if CFG_TUSB_HOST_CUSTOM_CLASS
  57. #include "class/custom_host.h"
  58. #endif
  59. #endif
  60. //------------- DEVICE -------------//
  61. #if TUSB_OPT_DEVICE_ENABLED
  62. #include "device/usbd.h"
  63. #if CFG_TUD_HID
  64. #include "class/hid/hid_device.h"
  65. #endif
  66. #if CFG_TUD_CDC
  67. #include "class/cdc/cdc_device.h"
  68. #endif
  69. #if CFG_TUD_MSC
  70. #include "class/msc/msc_device.h"
  71. #endif
  72. #if CFG_TUD_CUSTOM_CLASS
  73. #include "class/custom/custom_device.h"
  74. #endif
  75. #endif
  76. //--------------------------------------------------------------------+
  77. // APPLICATION API
  78. //--------------------------------------------------------------------+
  79. /** \ingroup group_application_api
  80. * @{ */
  81. // Initialize device/host stack according to tusb_config.h
  82. // return true if success
  83. bool tusb_init(void);
  84. /** Run all tinyusb's internal tasks (e.g host task, device task) and invoke callback
  85. * This should be called periodically within the mainloop.
  86. @code
  87. int main(void)
  88. {
  89. your_init_code();
  90. tusb_init();
  91. // other config code
  92. while(1) // the mainloop
  93. {
  94. your_application_code();
  95. tusb_task(); // handle tinyusb event, task etc ...
  96. }
  97. }
  98. @endcode
  99. */
  100. void tusb_task(void);
  101. /** @} */
  102. #ifdef __cplusplus
  103. }
  104. #endif
  105. #endif /* _TUSB_H_ */