gd32f3x0_eval.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*!
  2. \file gd32f3x0_eval.h
  3. \brief definitions for GD32f3x0_EVAL's leds, keys and COM ports hardware resources
  4. */
  5. /*
  6. Copyright (C) 2017 GigaDevice
  7. 2017-06-06, V1.0.0, firmware for GD32F3x0
  8. */
  9. #ifndef GD32F3X0_EVAL_H
  10. #define GD32F3X0_EVAL_H
  11. #ifdef cplusplus
  12. extern "C" {
  13. #endif
  14. #include "gd32f3x0.h"
  15. /* exported types */
  16. typedef enum
  17. {
  18. LED1 = 0,
  19. LED2 = 1,
  20. LED3 = 2,
  21. LED4 = 3
  22. }led_typedef_enum;
  23. typedef enum
  24. {
  25. KEY_WAKEUP = 0,
  26. KEY_TAMPER = 1,
  27. KEY_USER = 2
  28. }key_typedef_enum;
  29. typedef enum
  30. {
  31. KEY_MODE_GPIO = 0,
  32. KEY_MODE_EXTI = 1
  33. }keymode_typedef_enum;
  34. /* eval board low layer led */
  35. #define LEDn 4U
  36. #define LED1_PIN GPIO_PIN_10
  37. #define LED1_GPIO_PORT GPIOC
  38. #define LED1_GPIO_CLK RCU_GPIOC
  39. #define LED2_PIN GPIO_PIN_11
  40. #define LED2_GPIO_PORT GPIOC
  41. #define LED2_GPIO_CLK RCU_GPIOC
  42. #define LED3_PIN GPIO_PIN_12
  43. #define LED3_GPIO_PORT GPIOC
  44. #define LED3_GPIO_CLK RCU_GPIOC
  45. #define LED4_PIN GPIO_PIN_2
  46. #define LED4_GPIO_PORT GPIOC
  47. #define LED4_GPIO_CLK RCU_GPIOC
  48. /* eval board low layer button */
  49. #define KEYn 3U
  50. /* wakeup push-button */
  51. #define WAKEUP_KEY_PIN GPIO_PIN_0
  52. #define WAKEUP_KEY_GPIO_PORT GPIOA
  53. #define WAKEUP_KEY_GPIO_CLK RCU_GPIOA
  54. #define WAKEUP_KEY_EXTI_LINE EXTI_0
  55. #define WAKEUP_KEY_EXTI_PORT_SOURCE EXTI_SOURCE_GPIOA
  56. #define WAKEUP_KEY_EXTI_PIN_SOURCE EXTI_SOURCE_PIN0
  57. #define WAKEUP_KEY_EXTI_IRQn EXTI0_1_IRQn
  58. /* tamper push-button */
  59. #define TAMPER_KEY_PIN GPIO_PIN_13
  60. #define TAMPER_KEY_GPIO_PORT GPIOC
  61. #define TAMPER_KEY_GPIO_CLK RCU_GPIOC
  62. #define TAMPER_KEY_EXTI_LINE EXTI_13
  63. #define TAMPER_KEY_EXTI_PORT_SOURCE EXTI_SOURCE_GPIOC
  64. #define TAMPER_KEY_EXTI_PIN_SOURCE EXTI_SOURCE_PIN13
  65. #define TAMPER_KEY_EXTI_IRQn EXTI4_15_IRQn
  66. /* user push-button */
  67. #define USER_KEY_PIN GPIO_PIN_7
  68. #define USER_KEY_GPIO_PORT GPIOF
  69. #define USER_KEY_GPIO_CLK RCU_GPIOF
  70. #define USER_KEY_EXTI_LINE EXTI_7
  71. #define USER_KEY_EXTI_PORT_SOURCE EXTI_SOURCE_GPIOF
  72. #define USER_KEY_EXTI_PIN_SOURCE EXTI_SOURCE_PIN7
  73. #define USER_KEY_EXTI_IRQn EXTI4_15_IRQn
  74. /* eval board low layer COM */
  75. #define COMn 1U
  76. /* definition for COM1, connected to USART0 */
  77. #define EVAL_COM1 USART0
  78. #define EVAL_COM1_CLK RCU_USART0
  79. #define EVAL_COM1_TX_PIN GPIO_PIN_9
  80. #define EVAL_COM1_RX_PIN GPIO_PIN_10
  81. #define EVAL_COM_GPIO_PORT GPIOA
  82. #define EVAL_COM_GPIO_CLK RCU_GPIOA
  83. #define EVAL_COM_AF GPIO_AF_1
  84. /* function declarations */
  85. /* configure led GPIO */
  86. void gd_eval_led_init(led_typedef_enum lednum);
  87. /* turn on selected led */
  88. void gd_eval_led_on(led_typedef_enum lednum);
  89. /* turn off selected led */
  90. void gd_eval_led_off(led_typedef_enum lednum);
  91. /* toggle the selected led */
  92. void gd_eval_led_toggle(led_typedef_enum lednum);
  93. /* configure key */
  94. void gd_eval_key_init(key_typedef_enum keynum, keymode_typedef_enum keymode);
  95. /* return the selected key state */
  96. uint8_t gd_eval_key_state_get(key_typedef_enum keynum);
  97. /* configure COM port */
  98. void gd_eval_com_init(uint32_t com);
  99. #ifdef cplusplus
  100. }
  101. #endif
  102. #endif /* GD32F3x0_EVAL_H */