at32f403a_407_board.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /**
  2. **************************************************************************
  3. * @file at32f403a_407_board.h
  4. * @brief header file for at-start board. set of firmware functions to
  5. * manage leds and push-button. initialize delay function.
  6. **************************************************************************
  7. * Copyright notice & Disclaimer
  8. *
  9. * The software Board Support Package (BSP) that is made available to
  10. * download from Artery official website is the copyrighted work of Artery.
  11. * Artery authorizes customers to use, copy, and distribute the BSP
  12. * software and its related documentation for the purpose of design and
  13. * development in conjunction with Artery microcontrollers. Use of the
  14. * software is governed by this copyright notice and the following disclaimer.
  15. *
  16. * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  17. * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  18. * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  19. * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  20. * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  22. *
  23. **************************************************************************
  24. */
  25. #ifndef __AT32F403A_407_BOARD_H
  26. #define __AT32F403A_407_BOARD_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. #include "stdio.h"
  31. #include "at32f403a_407.h"
  32. /** @addtogroup AT32F403A_407_board
  33. * @{
  34. */
  35. /** @addtogroup BOARD
  36. * @{
  37. */
  38. /** @defgroup BOARD_pins_definition
  39. * @{
  40. */
  41. /**
  42. * this header include define support list:
  43. * 1. at-start-f403a v1.x board
  44. * 2. at-start-f407 v1.x board
  45. * if define AT_START_F403A_V1, the header file support at-start-f403a v1.x board
  46. * if define AT_START_F407_V1, the header file support at-start-f407 v1.x board
  47. */
  48. #if !defined (AT_START_F403A_V1)&& !defined (AT_START_F407_V1)
  49. #error "please select first the board at-start device used in your application (in at32f403a_407_board.h file)"
  50. #endif
  51. /******************** define led ********************/
  52. typedef enum
  53. {
  54. LED2 = 0,
  55. LED3 = 1,
  56. LED4 = 2
  57. } led_type;
  58. #define LED_NUM 3
  59. #if defined (AT_START_F403A_V1) || defined (AT_START_F407_V1)
  60. #define LED2_PIN GPIO_PINS_13
  61. #define LED2_GPIO GPIOD
  62. #define LED2_GPIO_CRM_CLK CRM_GPIOD_PERIPH_CLOCK
  63. #define LED3_PIN GPIO_PINS_14
  64. #define LED3_GPIO GPIOD
  65. #define LED3_GPIO_CRM_CLK CRM_GPIOD_PERIPH_CLOCK
  66. #define LED4_PIN GPIO_PINS_15
  67. #define LED4_GPIO GPIOD
  68. #define LED4_GPIO_CRM_CLK CRM_GPIOD_PERIPH_CLOCK
  69. #endif
  70. /**************** define print uart ******************/
  71. #define PRINT_UART USART1
  72. #define PRINT_UART_CRM_CLK CRM_USART1_PERIPH_CLOCK
  73. #define PRINT_UART_TX_PIN GPIO_PINS_9
  74. #define PRINT_UART_TX_GPIO GPIOA
  75. #define PRINT_UART_TX_GPIO_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
  76. /*
  77. #define PRINT_UART USART3
  78. #define PRINT_UART_CRM_CLK CRM_USART3_PERIPH_CLOCK
  79. #define PRINT_UART_TX_PIN GPIO_PINS_8
  80. #define PRINT_UART_TX_GPIO GPIOD
  81. #define PRINT_UART_TX_GPIO_CRM_CLK CRM_GPIOD_PERIPH_CLOCK
  82. */
  83. /******************* define button *******************/
  84. typedef enum
  85. {
  86. USER_BUTTON = 0,
  87. NO_BUTTON = 1
  88. } button_type;
  89. #define USER_BUTTON_PIN GPIO_PINS_0
  90. #define USER_BUTTON_PORT GPIOA
  91. #define USER_BUTTON_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
  92. /**
  93. * @}
  94. */
  95. /** @defgroup BOARD_exported_functions
  96. * @{
  97. */
  98. /******************** functions ********************/
  99. void at32_board_init(void);
  100. /* led operation function */
  101. void at32_led_init(led_type led);
  102. void at32_led_on(led_type led);
  103. void at32_led_off(led_type led);
  104. void at32_led_toggle(led_type led);
  105. /* button operation function */
  106. void at32_button_init(void);
  107. button_type at32_button_press(void);
  108. uint8_t at32_button_state(void);
  109. /* delay function */
  110. void delay_init(void);
  111. void delay_us(uint32_t nus);
  112. void delay_ms(uint16_t nms);
  113. void delay_sec(uint16_t sec);
  114. /* printf uart init function */
  115. void uart_print_init(uint32_t baudrate);
  116. /**
  117. * @}
  118. */
  119. /**
  120. * @}
  121. */
  122. /**
  123. * @}
  124. */
  125. #ifdef __cplusplus
  126. }
  127. #endif
  128. #endif