gd32f303e_eval.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*!
  2. \file gd32f303e_eval.h
  3. \brief definitions for GD32f303E_EVAL's leds, keys and COM ports hardware resources
  4. */
  5. /*
  6. Copyright (C) 2017 GigaDevice
  7. 2017-05-19, V1.0.0, demo for GD32F30x
  8. */
  9. #ifndef GD32F303E_EVAL_H
  10. #define GD32F303E_EVAL_H
  11. #ifdef cplusplus
  12. extern "C" {
  13. #endif
  14. #include "gd32f30x.h"
  15. /* exported types */
  16. typedef enum
  17. {
  18. LED2 = 0,
  19. LED3 = 1,
  20. LED4 = 2,
  21. LED5 = 3
  22. } led_typedef_enum;
  23. typedef enum
  24. {
  25. KEY_WAKEUP = 0,
  26. KEY_TAMPER = 1,
  27. KEY_USER1 = 2,
  28. KEY_USER2 = 3
  29. } key_typedef_enum;
  30. typedef enum
  31. {
  32. KEY_MODE_GPIO = 0,
  33. KEY_MODE_EXTI = 1
  34. } keymode_typedef_enum;
  35. /* eval board low layer led */
  36. #define LEDn 4U
  37. #define LED2_PIN GPIO_PIN_0
  38. #define LED2_GPIO_PORT GPIOF
  39. #define LED2_GPIO_CLK RCU_GPIOF
  40. #define LED3_PIN GPIO_PIN_1
  41. #define LED3_GPIO_PORT GPIOF
  42. #define LED3_GPIO_CLK RCU_GPIOF
  43. #define LED4_PIN GPIO_PIN_2
  44. #define LED4_GPIO_PORT GPIOF
  45. #define LED4_GPIO_CLK RCU_GPIOF
  46. #define LED5_PIN GPIO_PIN_3
  47. #define LED5_GPIO_PORT GPIOF
  48. #define LED5_GPIO_CLK RCU_GPIOF
  49. #define COMn 2U
  50. #define EVAL_COM1 USART0
  51. #define EVAL_COM1_CLK RCU_USART0
  52. #define EVAL_COM1_TX_PIN GPIO_PIN_9
  53. #define EVAL_COM1_RX_PIN GPIO_PIN_10
  54. #define EVAL_COM1_GPIO_PORT GPIOA
  55. #define EVAL_COM1_GPIO_CLK RCU_GPIOA
  56. #define EVAL_COM2 USART1
  57. #define EVAL_COM2_CLK RCU_USART1
  58. #define EVAL_COM2_TX_PIN GPIO_PIN_2
  59. #define EVAL_COM2_RX_PIN GPIO_PIN_3
  60. #define EVAL_COM2_GPIO_PORT GPIOA
  61. #define EVAL_COM2_GPIO_CLK RCU_GPIOA
  62. #define KEYn 4U
  63. /* wakeup push-button */
  64. #define WAKEUP_KEY_PIN GPIO_PIN_0
  65. #define WAKEUP_KEY_GPIO_PORT GPIOA
  66. #define WAKEUP_KEY_GPIO_CLK RCU_GPIOA
  67. #define WAKEUP_KEY_EXTI_LINE EXTI_0
  68. #define WAKEUP_KEY_EXTI_PORT_SOURCE GPIO_PORT_SOURCE_GPIOA
  69. #define WAKEUP_KEY_EXTI_PIN_SOURCE GPIO_PIN_SOURCE_0
  70. #define WAKEUP_KEY_EXTI_IRQn EXTI0_IRQn
  71. /* tamper push-button */
  72. #define TAMPER_KEY_PIN GPIO_PIN_13
  73. #define TAMPER_KEY_GPIO_PORT GPIOC
  74. #define TAMPER_KEY_GPIO_CLK RCU_GPIOC
  75. #define TAMPER_KEY_EXTI_LINE EXTI_13
  76. #define TAMPER_KEY_EXTI_PORT_SOURCE GPIO_PORT_SOURCE_GPIOC
  77. #define TAMPER_KEY_EXTI_PIN_SOURCE GPIO_PIN_SOURCE_13
  78. #define TAMPER_KEY_EXTI_IRQn EXTI10_15_IRQn
  79. /* user push-button */
  80. #define USER_KEY1_PIN GPIO_PIN_5
  81. #define USER_KEY1_GPIO_PORT GPIOF
  82. #define USER_KEY1_GPIO_CLK RCU_GPIOF
  83. #define USER_KEY1_EXTI_LINE EXTI_5
  84. #define USER_KEY1_EXTI_PORT_SOURCE GPIO_PORT_SOURCE_GPIOF
  85. #define USER_KEY1_EXTI_PIN_SOURCE GPIO_PIN_SOURCE_5
  86. #define USER_KEY1_EXTI_IRQn EXTI5_9_IRQn
  87. /* user push-button */
  88. #define USER_KEY2_PIN GPIO_PIN_4
  89. #define USER_KEY2_GPIO_PORT GPIOF
  90. #define USER_KEY2_GPIO_CLK RCU_GPIOF
  91. #define USER_KEY2_EXTI_LINE EXTI_4
  92. #define USER_KEY2_EXTI_PORT_SOURCE GPIO_PORT_SOURCE_GPIOF
  93. #define USER_KEY2_EXTI_PIN_SOURCE GPIO_PIN_SOURCE_4
  94. #define USER_KEY2_EXTI_IRQn EXTI4_IRQn
  95. /* function declarations */
  96. /* configure led GPIO */
  97. void gd_eval_led_init(led_typedef_enum lednum);
  98. /* turn on selected led */
  99. void gd_eval_led_on(led_typedef_enum lednum);
  100. /* turn off selected led */
  101. void gd_eval_led_off(led_typedef_enum lednum);
  102. /* toggle the selected led */
  103. void gd_eval_led_toggle(led_typedef_enum lednum);
  104. /* configure key */
  105. void gd_eval_key_init(key_typedef_enum key_num, keymode_typedef_enum key_mode);
  106. /* return the selected key state */
  107. uint8_t gd_eval_key_state_get(key_typedef_enum key);
  108. /* configure COM port */
  109. void gd_eval_com_init(uint32_t com);
  110. #ifdef cplusplus
  111. }
  112. #endif
  113. #endif /* GD32F303E_EVAL_H */