gd32f303e_eval.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*!
  2. \file gd32f303e_eval.h
  3. \brief definitions for GD32F303E_EVAL's leds, keys and COM ports hardware resources
  4. \version 2017-02-10, V1.0.0, firmware for GD32F30x
  5. \version 2018-10-10, V1.1.0, firmware for GD32F30x
  6. \version 2018-12-25, V2.0.0, firmware for GD32F30x
  7. \version 2020-09-30, V2.1.0, firmware for GD32F30x
  8. */
  9. /*
  10. Copyright (c) 2020, GigaDevice Semiconductor Inc.
  11. Redistribution and use in source and binary forms, with or without modification,
  12. are permitted provided that the following conditions are met:
  13. 1. Redistributions of source code must retain the above copyright notice, this
  14. list of conditions and the following disclaimer.
  15. 2. Redistributions in binary form must reproduce the above copyright notice,
  16. this list of conditions and the following disclaimer in the documentation
  17. and/or other materials provided with the distribution.
  18. 3. Neither the name of the copyright holder nor the names of its contributors
  19. may be used to endorse or promote products derived from this software without
  20. specific prior written permission.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  22. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  25. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  26. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  27. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  28. WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  30. OF SUCH DAMAGE.
  31. */
  32. #ifndef GD32F303E_EVAL_H
  33. #define GD32F303E_EVAL_H
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37. #include "gd32f30x.h"
  38. /* exported types */
  39. typedef enum
  40. {
  41. LED2 = 0,
  42. LED3 = 1,
  43. LED4 = 2,
  44. LED5 = 3
  45. } led_typedef_enum;
  46. typedef enum
  47. {
  48. KEY_WAKEUP = 0,
  49. KEY_TAMPER = 1,
  50. KEY_USER1 = 2,
  51. KEY_USER2 = 3
  52. } key_typedef_enum;
  53. typedef enum
  54. {
  55. KEY_MODE_GPIO = 0,
  56. KEY_MODE_EXTI = 1
  57. } keymode_typedef_enum;
  58. /* eval board low layer led */
  59. #define LEDn 4U
  60. #define LED2_PIN GPIO_PIN_0
  61. #define LED2_GPIO_PORT GPIOF
  62. #define LED2_GPIO_CLK RCU_GPIOF
  63. #define LED3_PIN GPIO_PIN_1
  64. #define LED3_GPIO_PORT GPIOF
  65. #define LED3_GPIO_CLK RCU_GPIOF
  66. #define LED4_PIN GPIO_PIN_2
  67. #define LED4_GPIO_PORT GPIOF
  68. #define LED4_GPIO_CLK RCU_GPIOF
  69. #define LED5_PIN GPIO_PIN_3
  70. #define LED5_GPIO_PORT GPIOF
  71. #define LED5_GPIO_CLK RCU_GPIOF
  72. #define COMn 2U
  73. #define EVAL_COM1 USART0
  74. #define EVAL_COM1_CLK RCU_USART0
  75. #define EVAL_COM1_TX_PIN GPIO_PIN_9
  76. #define EVAL_COM1_RX_PIN GPIO_PIN_10
  77. #define EVAL_COM1_GPIO_PORT GPIOA
  78. #define EVAL_COM1_GPIO_CLK RCU_GPIOA
  79. #define EVAL_COM2 USART1
  80. #define EVAL_COM2_CLK RCU_USART1
  81. #define EVAL_COM2_TX_PIN GPIO_PIN_2
  82. #define EVAL_COM2_RX_PIN GPIO_PIN_3
  83. #define EVAL_COM2_GPIO_PORT GPIOA
  84. #define EVAL_COM2_GPIO_CLK RCU_GPIOA
  85. #define KEYn 4U
  86. /* wakeup push-button */
  87. #define WAKEUP_KEY_PIN GPIO_PIN_0
  88. #define WAKEUP_KEY_GPIO_PORT GPIOA
  89. #define WAKEUP_KEY_GPIO_CLK RCU_GPIOA
  90. #define WAKEUP_KEY_EXTI_LINE EXTI_0
  91. #define WAKEUP_KEY_EXTI_PORT_SOURCE GPIO_PORT_SOURCE_GPIOA
  92. #define WAKEUP_KEY_EXTI_PIN_SOURCE GPIO_PIN_SOURCE_0
  93. #define WAKEUP_KEY_EXTI_IRQn EXTI0_IRQn
  94. /* tamper push-button */
  95. #define TAMPER_KEY_PIN GPIO_PIN_13
  96. #define TAMPER_KEY_GPIO_PORT GPIOC
  97. #define TAMPER_KEY_GPIO_CLK RCU_GPIOC
  98. #define TAMPER_KEY_EXTI_LINE EXTI_13
  99. #define TAMPER_KEY_EXTI_PORT_SOURCE GPIO_PORT_SOURCE_GPIOC
  100. #define TAMPER_KEY_EXTI_PIN_SOURCE GPIO_PIN_SOURCE_13
  101. #define TAMPER_KEY_EXTI_IRQn EXTI10_15_IRQn
  102. /* user push-button */
  103. #define USER_KEY1_PIN GPIO_PIN_5
  104. #define USER_KEY1_GPIO_PORT GPIOF
  105. #define USER_KEY1_GPIO_CLK RCU_GPIOF
  106. #define USER_KEY1_EXTI_LINE EXTI_5
  107. #define USER_KEY1_EXTI_PORT_SOURCE GPIO_PORT_SOURCE_GPIOF
  108. #define USER_KEY1_EXTI_PIN_SOURCE GPIO_PIN_SOURCE_5
  109. #define USER_KEY1_EXTI_IRQn EXTI5_9_IRQn
  110. /* user push-button */
  111. #define USER_KEY2_PIN GPIO_PIN_4
  112. #define USER_KEY2_GPIO_PORT GPIOF
  113. #define USER_KEY2_GPIO_CLK RCU_GPIOF
  114. #define USER_KEY2_EXTI_LINE EXTI_4
  115. #define USER_KEY2_EXTI_PORT_SOURCE GPIO_PORT_SOURCE_GPIOF
  116. #define USER_KEY2_EXTI_PIN_SOURCE GPIO_PIN_SOURCE_4
  117. #define USER_KEY2_EXTI_IRQn EXTI4_IRQn
  118. /* function declarations */
  119. /* configure led GPIO */
  120. void gd_eval_led_init(led_typedef_enum lednum);
  121. /* turn on selected led */
  122. void gd_eval_led_on(led_typedef_enum lednum);
  123. /* turn off selected led */
  124. void gd_eval_led_off(led_typedef_enum lednum);
  125. /* toggle the selected led */
  126. void gd_eval_led_toggle(led_typedef_enum lednum);
  127. /* configure key */
  128. void gd_eval_key_init(key_typedef_enum key_num, keymode_typedef_enum key_mode);
  129. /* return the selected key state */
  130. uint8_t gd_eval_key_state_get(key_typedef_enum key);
  131. /* configure COM port */
  132. void gd_eval_com_init(uint32_t com);
  133. #ifdef __cplusplus
  134. }
  135. #endif
  136. #endif /* GD32F303E_EVAL_H */