gd32f450z_eval.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*!
  2. \file gd32f450z_eval.h
  3. \brief definitions for GD32F450_EVAL's leds, keys and COM ports hardware resources
  4. */
  5. /*
  6. Copyright (C) 2016 GigaDevice
  7. 2016-10-19, V1.0.0, firmware for GD32F450Z
  8. */
  9. #ifndef GD32F450Z_EVAL_H
  10. #define GD32F450Z_EVAL_H
  11. #ifdef cplusplus
  12. extern "C" {
  13. #endif
  14. #include "gd32f4xx.h"
  15. /* exported types */
  16. typedef enum
  17. {
  18. LED1 = 0,
  19. LED2 = 1,
  20. LED3 = 2
  21. } led_typedef_enum;
  22. typedef enum
  23. {
  24. KEY_WAKEUP = 0,
  25. KEY_TAMPER = 1,
  26. KEY_USER = 2
  27. } key_typedef_enum;
  28. typedef enum
  29. {
  30. KEY_MODE_GPIO = 0,
  31. KEY_MODE_EXTI = 1
  32. } keymode_typedef_enum;
  33. /* eval board low layer led */
  34. #define LEDn 3U
  35. #define LED1_PIN GPIO_PIN_4
  36. #define LED1_GPIO_PORT GPIOD
  37. #define LED1_GPIO_CLK RCU_GPIOD
  38. #define LED2_PIN GPIO_PIN_5
  39. #define LED2_GPIO_PORT GPIOD
  40. #define LED2_GPIO_CLK RCU_GPIOD
  41. #define LED3_PIN GPIO_PIN_3
  42. #define LED3_GPIO_PORT GPIOG
  43. #define LED3_GPIO_CLK RCU_GPIOG
  44. #define COMn 1U
  45. #define EVAL_COM1 USART0
  46. #define EVAL_COM1_CLK RCU_USART0
  47. #define EVAL_COM1_TX_PIN GPIO_PIN_9
  48. #define EVAL_COM1_RX_PIN GPIO_PIN_10
  49. #define EVAL_COM_GPIO_PORT GPIOA
  50. #define EVAL_COM_GPIO_CLK RCU_GPIOA
  51. #define EVAL_COM_AF GPIO_AF_7
  52. #define KEYn 3U
  53. /* tamper push-button */
  54. #define TAMPER_KEY_PIN GPIO_PIN_13
  55. #define TAMPER_KEY_GPIO_PORT GPIOC
  56. #define TAMPER_KEY_GPIO_CLK RCU_GPIOC
  57. #define TAMPER_KEY_EXTI_LINE EXTI_13
  58. #define TAMPER_KEY_EXTI_PORT_SOURCE EXTI_SOURCE_GPIOC
  59. #define TAMPER_KEY_EXTI_PIN_SOURCE EXTI_SOURCE_PIN13
  60. #define TAMPER_KEY_EXTI_IRQn EXTI10_15_IRQn
  61. /* wakeup push-button */
  62. #define WAKEUP_KEY_PIN GPIO_PIN_0
  63. #define WAKEUP_KEY_GPIO_PORT GPIOA
  64. #define WAKEUP_KEY_GPIO_CLK RCU_GPIOA
  65. #define WAKEUP_KEY_EXTI_LINE EXTI_0
  66. #define WAKEUP_KEY_EXTI_PORT_SOURCE EXTI_SOURCE_GPIOA
  67. #define WAKEUP_KEY_EXTI_PIN_SOURCE EXTI_SOURCE_PIN0
  68. #define WAKEUP_KEY_EXTI_IRQn EXTI0_IRQn
  69. /* user push-button */
  70. #define USER_KEY_PIN GPIO_PIN_14
  71. #define USER_KEY_GPIO_PORT GPIOB
  72. #define USER_KEY_GPIO_CLK RCU_GPIOB
  73. #define USER_KEY_EXTI_LINE EXTI_14
  74. #define USER_KEY_EXTI_PORT_SOURCE EXTI_SOURCE_GPIOB
  75. #define USER_KEY_EXTI_PIN_SOURCE EXTI_SOURCE_PIN14
  76. #define USER_KEY_EXTI_IRQn EXTI10_15_IRQn
  77. /* function declarations */
  78. /* configures led GPIO */
  79. void gd_eval_led_init(led_typedef_enum lednum);
  80. /* turn on selected led */
  81. void gd_eval_led_on(led_typedef_enum lednum);
  82. /* turn off selected led */
  83. void gd_eval_led_off(led_typedef_enum lednum);
  84. /* toggle the selected led */
  85. void gd_eval_led_toggle(led_typedef_enum lednum);
  86. /* configure key */
  87. void gd_eval_key_init(key_typedef_enum key_num, keymode_typedef_enum key_mode);
  88. /* return the selected button state */
  89. uint8_t gd_eval_key_state_get(key_typedef_enum button);
  90. /* configure COM port */
  91. void gd_eval_com_init(uint32_t com);
  92. #ifdef cplusplus
  93. }
  94. #endif
  95. #endif /* GD32F450Z_EVAL_H */