board.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /**************************************************************************/
  2. /*!
  3. @file board.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. /** \ingroup group_demo
  33. * \defgroup group_board Boards Abstraction Layer
  34. * @{ */
  35. #ifndef _TUSB_BOARD_H_
  36. #define _TUSB_BOARD_H_
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40. #include <stdint.h>
  41. #include <stdbool.h>
  42. #include "ansi_escape.h"
  43. #include "tusb.h"
  44. //--------------------------------------------------------------------+
  45. // BOARD DEFINE
  46. //--------------------------------------------------------------------+
  47. /** \defgroup group_supported_board Supported Boards
  48. * @{ */
  49. #define BOARD_LPCXPRESSO11U14 1114 ///< LPCXpresso 11u14, some APIs requires the base board
  50. #define BOARD_LPCXPRESSO11U68 1168 ///< LPC11U37 from microbuilder http://www.microbuilder.eu/Blog/13-03-14/LPC1xxx_1GHZ_Wireless_Board_Preview.aspx
  51. #define BOARD_LPCXPRESSO1347 1347 ///< LPCXpresso 1347, some APIs requires the base board
  52. #define BOARD_LPCXPRESSO1769 1769 ///< LPCXpresso 1769, some APIs requires the base board
  53. #define BOARD_NGX4330 4330 ///< NGX 4330 Xplorer
  54. #define BOARD_EA4357 4357 ///< Embedded Artists LPC4357 developer kit
  55. #define BOARD_MCB4300 4300 ///< Keil MCB4300
  56. #define BOARD_HITEX4350 4350 ///< Hitex 4350
  57. #define BOARD_LPC4357USB 4304 ///< microbuilder.eu
  58. #define BOARD_LPCLINK2 4370 ///< LPClink2 uses as LPC4370 development board
  59. /** @} */
  60. //--------------------------------------------------------------------+
  61. // PRINTF TARGET DEFINE
  62. //--------------------------------------------------------------------+
  63. /** \defgroup group_printf Printf Retarget
  64. * \brief Retarget the standard stdio printf/getchar to other IOs
  65. * @{ */
  66. #define PRINTF_TARGET_SEMIHOST 1 ///< Using the semihost support from toolchain, requires no hardware but is the slowest
  67. #define PRINTF_TARGET_UART 2 ///< Using UART as stdio, this is the default for most of the board
  68. #define PRINTF_TARGET_SWO 3 ///< Using non-instructive serial wire output (SWO), is the best option since it does not slow down MCU but requires supported from debugger and IDE
  69. #define PRINTF_TARGET_NONE 4 ///< Using none at all.
  70. /** @} */
  71. #define PRINTF(...) printf(__VA_ARGS__)
  72. //--------------------------------------------------------------------+
  73. // BOARD INCLUDE
  74. //--------------------------------------------------------------------+
  75. #if BOARD == BOARD_LPCXPRESSO11U14
  76. #include "lpcxpresso11u14/board_lpcxpresso11u14.h"
  77. #elif BOARD == BOARD_LPCXPRESSO11U68
  78. #include "lpcxpresso11u68/board_lpcxpresso11u68.h"
  79. #elif BOARD == BOARD_LPCXPRESSO1347
  80. #include "lpcxpresso1347/board_lpcxpresso1347.h"
  81. #elif BOARD == BOARD_LPCXPRESSO1769
  82. #include "lpcxpresso1769/board_lpcxpresso1769.h"
  83. #elif BOARD == BOARD_NGX4330
  84. #include "ngx/board_ngx4330.h"
  85. #elif BOARD == BOARD_EA4357
  86. #include "ea4357/board_ea4357.h"
  87. #elif BOARD == BOARD_MCB4300
  88. #include "keil/board_mcb4300.h"
  89. #elif BOARD == BOARD_HITEX4350
  90. #include "hitex/board_hitex4350.h"
  91. #elif BOARD == BOARD_LPC4357USB
  92. #include "microbuilder/board_lpc4357usb.h"
  93. #elif BOARD == BOARD_LPCLINK2
  94. #include "lpcxpresso/board_lpclink2.h"
  95. #elif defined BOARD_PCA10056
  96. #include "pca10056/board_pca10056.h"
  97. #else
  98. #error BOARD is not defined or supported yet
  99. #endif
  100. //--------------------------------------------------------------------+
  101. // Common Configuration
  102. //--------------------------------------------------------------------+
  103. #define CFG_UART_BAUDRATE 115200 ///< Baudrate for UART
  104. //--------------------------------------------------------------------+
  105. // Board Common API
  106. //--------------------------------------------------------------------+
  107. /** \defgroup group_board_api Board API
  108. * \brief All the board must support these APIs.
  109. * @{ */
  110. /// Initialize all required peripherals on board including uart, led, buttons etc ...
  111. void board_init(void);
  112. /** \brief Turns on and off leds on the board
  113. * \param[in] on_mask Bitmask for LED's numbers is turning ON
  114. * \param[out] off_mask Bitmask for LED's numbers is turning OFF
  115. * \note the \a on_mask is more priority then \a off_mask, if an led's number is present on both.
  116. * It will be turned ON.
  117. */
  118. void board_leds(uint32_t on_mask, uint32_t off_mask);
  119. /** \brief Get the current state of the buttons on the board
  120. * \return Bitmask where a '1' means active (pressed), a '0' means inactive.
  121. */
  122. uint32_t board_buttons(void);
  123. /** \brief Get a character input from UART
  124. * \return ASCII code of the input character or zero if none.
  125. */
  126. uint8_t board_uart_getchar(void);
  127. /** \brief Send a character to UART
  128. * \param[in] c the character to be sent
  129. */
  130. void board_uart_putchar(uint8_t c);
  131. /** @} */
  132. #if 0
  133. //------------- Board Application -------------//
  134. void led_blinking_task(void* param);
  135. /// Initialize the LED blinking task application. The initial blinking rate is 1 Hert (1 per second)
  136. void led_blinking_init(void);
  137. /** \brief Change the blinking rate.
  138. * \param[in] ms The interval between on and off.
  139. */
  140. void led_blinking_set_interval(uint32_t ms);
  141. #endif
  142. #ifdef __cplusplus
  143. }
  144. #endif
  145. #endif /* _TUSB_BOARD_H_ */
  146. /** @} */