at32f413_board.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /**
  2. **************************************************************************
  3. * @file at32f413_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 __AT32F413_BOARD_H
  26. #define __AT32F413_BOARD_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. #include "stdio.h"
  31. #include "at32f413.h"
  32. /** @addtogroup AT32F413_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-f413 v1.x board
  44. * if define AT_START_F413_V1, the header file support at-start-f413 v1.x board
  45. */
  46. #if !defined (AT_START_F413_V1)
  47. #error "please select first the board at-start device used in your application (in at32f413_board.h file)"
  48. #endif
  49. /******************** define led ********************/
  50. typedef enum
  51. {
  52. LED2 = 0,
  53. LED3 = 1,
  54. LED4 = 2
  55. } led_type;
  56. #define LED_NUM 3
  57. #if defined (AT_START_F413_V1)
  58. #define LED2_PIN GPIO_PINS_2
  59. #define LED2_GPIO GPIOC
  60. #define LED2_GPIO_CRM_CLK CRM_GPIOC_PERIPH_CLOCK
  61. #define LED3_PIN GPIO_PINS_3
  62. #define LED3_GPIO GPIOC
  63. #define LED3_GPIO_CRM_CLK CRM_GPIOC_PERIPH_CLOCK
  64. #define LED4_PIN GPIO_PINS_5
  65. #define LED4_GPIO GPIOC
  66. #define LED4_GPIO_CRM_CLK CRM_GPIOC_PERIPH_CLOCK
  67. #endif
  68. /**************** define print uart ******************/
  69. #define PRINT_UART USART1
  70. #define PRINT_UART_CRM_CLK CRM_USART1_PERIPH_CLOCK
  71. #define PRINT_UART_TX_PIN GPIO_PINS_9
  72. #define PRINT_UART_TX_GPIO GPIOA
  73. #define PRINT_UART_TX_GPIO_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
  74. /******************* define button *******************/
  75. typedef enum
  76. {
  77. USER_BUTTON = 0,
  78. NO_BUTTON = 1
  79. } button_type;
  80. #define USER_BUTTON_PIN GPIO_PINS_0
  81. #define USER_BUTTON_PORT GPIOA
  82. #define USER_BUTTON_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
  83. /**
  84. * @}
  85. */
  86. /** @defgroup BOARD_exported_functions
  87. * @{
  88. */
  89. /******************** functions ********************/
  90. void at32_board_init(void);
  91. /* led operation function */
  92. void at32_led_init(led_type led);
  93. void at32_led_on(led_type led);
  94. void at32_led_off(led_type led);
  95. void at32_led_toggle(led_type led);
  96. /* button operation function */
  97. void at32_button_init(void);
  98. button_type at32_button_press(void);
  99. uint8_t at32_button_state(void);
  100. /* delay function */
  101. void delay_init(void);
  102. void delay_us(uint32_t nus);
  103. void delay_ms(uint16_t nms);
  104. void delay_sec(uint16_t sec);
  105. /* printf uart init function */
  106. void uart_print_init(uint32_t baudrate);
  107. /**
  108. * @}
  109. */
  110. /**
  111. * @}
  112. */
  113. /**
  114. * @}
  115. */
  116. #ifdef __cplusplus
  117. }
  118. #endif
  119. #endif