• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*!
2     \file    gd32vf103c_start.h
3     \brief   definitions for GD32VF103C_START's leds, keys and COM ports hardware resources
4 
5     \version 2019-06-05, V1.0.0, demo for GD32VF103
6 */
7 
8 /*
9     Copyright (c) 2019, GigaDevice Semiconductor Inc.
10 
11     Redistribution and use in source and binary forms, with or without modification,
12 are permitted provided that the following conditions are met:
13 
14     1. Redistributions of source code must retain the above copyright notice, this
15        list of conditions and the following disclaimer.
16     2. Redistributions in binary form must reproduce the above copyright notice,
17        this list of conditions and the following disclaimer in the documentation
18        and/or other materials provided with the distribution.
19     3. Neither the name of the copyright holder nor the names of its contributors
20        may be used to endorse or promote products derived from this software without
21        specific prior written permission.
22 
23     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32 OF SUCH DAMAGE.
33 */
34 
35 #ifndef GD32VF103C_RVSTART_H
36 #define GD32VF103C_RVSTART_H
37 
38 #ifdef __cplusplus
39  extern "C" {
40 #endif
41 
42 #include "nuclei_sdk_soc.h"
43 
44 /* exported types */
45 typedef enum
46 {
47     LED1 = 0,
48     LED2 = 1,
49     LED3 = 2,
50     LED_1 = 0,
51     LED_2 = 1,
52     LED_3 = 2
53 }led_typedef_enum;
54 
55 typedef enum
56 {
57     KEY_WAKEUP = 0,
58 }key_typedef_enum;
59 
60 typedef enum
61 {
62     KEY_MODE_GPIO = 0,
63     KEY_MODE_EXTI = 1
64 }keymode_typedef_enum;
65 
66 
67 /* rvstar board low layer led */
68 #define LEDn                             3U
69 
70 #define LEDG_PIN                         GPIO_PIN_1
71 #define LEDG_GPIO_PORT                   GPIOA
72 #define LEDG_GPIO_CLK                    RCU_GPIOA
73 
74 #define LEDB_PIN                         GPIO_PIN_3
75 #define LEDB_GPIO_PORT                   GPIOA
76 #define LEDB_GPIO_CLK                    RCU_GPIOA
77 
78 #define LEDR_PIN                         GPIO_PIN_2
79 #define LEDR_GPIO_PORT                   GPIOA
80 #define LEDR_GPIO_CLK                    RCU_GPIOA
81 
82 /* rvstar board UART com port */
83 #define GD32_COM0                        UART4
84 #define GD32_COM_CLK                     RCU_UART4
85 #define GD32_COM_TX_PIN                  GPIO_PIN_12
86 #define GD32_COM_RX_PIN                  GPIO_PIN_2
87 #define GD32_COM_TX_GPIO_PORT            GPIOC
88 #define GD32_COM_RX_GPIO_PORT            GPIOD
89 #define GD32_COM_TX_GPIO_CLK             RCU_GPIOC
90 #define GD32_COM_RX_GPIO_CLK             RCU_GPIOD
91 
92 /* rvstar board low layer button */
93 #define KEYn                             (1U)
94 
95 /* wakeup push-button */
96 #define WAKEUP_KEY_PIN                   GPIO_PIN_0
97 #define WAKEUP_KEY_GPIO_PORT             GPIOA
98 #define WAKEUP_KEY_GPIO_CLK              RCU_GPIOA
99 #define WAKEUP_KEY_EXTI_LINE             EXTI_0
100 #define WAKEUP_KEY_EXTI_PORT_SOURCE      GPIO_PORT_SOURCE_GPIOA
101 #define WAKEUP_KEY_EXTI_PIN_SOURCE       GPIO_PIN_SOURCE_0
102 #define WAKEUP_KEY_EXTI_IRQn             EXTI0_IRQn
103 
104 /* function declarations */
105 /* configure led GPIO */
106 void gd_led_init(led_typedef_enum lednum);
107 /* turn on selected led */
108 void gd_led_on(led_typedef_enum lednum);
109 /* turn off selected led */
110 void gd_led_off(led_typedef_enum lednum);
111 /* toggle the selected led */
112 void gd_led_toggle(led_typedef_enum lednum);
113 /* configure key */
114 void gd_key_init(key_typedef_enum keynum, keymode_typedef_enum keymode);
115 /* return the selected key state */
116 uint8_t gd_key_state_get(key_typedef_enum keynum);
117 /* configure COM port */
118 void gd_com_init(uint32_t usart_periph);
119 
120 /* Defines for LED functions Defines for LED / Key functions to new / general API */
121 #define gd_rvstar_led_init         gd_led_init
122 #define gd_rvstar_led_on           gd_led_on
123 #define gd_rvstar_led_off          gd_led_off
124 #define gd_rvstar_led_toggle       gd_led_toggle
125 
126 #define gd_rvstar_key_init         gd_key_init
127 #define gd_rvstar_key_state_get    gd_key_state_get
128 
129 #ifdef __cplusplus
130 }
131 #endif
132 
133 #endif /* GD32VF103V_RVSTART_H */
134 
135