1 /**
2   ******************************************************************************
3   * @file    bl808_gpio.h
4   * @version V1.0
5   * @date    2020-11-06
6   * @brief   This file is the description of.IP register
7   ******************************************************************************
8   * @attention
9   *
10   * <h2><center>&copy; COPYRIGHT(c) 2020 Bouffalo Lab</center></h2>
11   *
12   * Redistribution and use in source and binary forms, with or without modification,
13   * are permitted provided that the following conditions are met:
14   *   1. Redistributions of source code must retain the above copyright notice,
15   *      this 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 Bouffalo Lab nor the names of its contributors
20   *      may be used to endorse or promote products derived from this software
21   *      without 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
25   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
27   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33   *
34   ******************************************************************************
35   */
36 #ifndef __BL808_GPIO_H__
37 #define __BL808_GPIO_H__
38 
39 typedef enum {
40     GLB_GPIO_PIN_0 = 0,
41     GLB_GPIO_PIN_1,
42     GLB_GPIO_PIN_2,
43     GLB_GPIO_PIN_3,
44     GLB_GPIO_PIN_4,
45     GLB_GPIO_PIN_5,
46     GLB_GPIO_PIN_6,
47     GLB_GPIO_PIN_7,
48     GLB_GPIO_PIN_8,
49     GLB_GPIO_PIN_9,
50     GLB_GPIO_PIN_10,
51     GLB_GPIO_PIN_11,
52     GLB_GPIO_PIN_12,
53     GLB_GPIO_PIN_13,
54     GLB_GPIO_PIN_14,
55     GLB_GPIO_PIN_15,
56     GLB_GPIO_PIN_16,
57     GLB_GPIO_PIN_17,
58     GLB_GPIO_PIN_18,
59     GLB_GPIO_PIN_19,
60     GLB_GPIO_PIN_20,
61     GLB_GPIO_PIN_21,
62     GLB_GPIO_PIN_22,
63     GLB_GPIO_PIN_23,
64     GLB_GPIO_PIN_24,
65     GLB_GPIO_PIN_25,
66     GLB_GPIO_PIN_26,
67     GLB_GPIO_PIN_27,
68     GLB_GPIO_PIN_28,
69     GLB_GPIO_PIN_29,
70     GLB_GPIO_PIN_30,
71     GLB_GPIO_PIN_31,
72     GLB_GPIO_PIN_32,
73     GLB_GPIO_PIN_33,
74     GLB_GPIO_PIN_34,
75     GLB_GPIO_PIN_35,
76     GLB_GPIO_PIN_36,
77     GLB_GPIO_PIN_37,
78     GLB_GPIO_PIN_38,
79     GLB_GPIO_PIN_39,
80     GLB_GPIO_PIN_40,
81     GLB_GPIO_PIN_41,
82     GLB_GPIO_PIN_42,
83     GLB_GPIO_PIN_43,
84     GLB_GPIO_PIN_44,
85     GLB_GPIO_PIN_45,
86     GLB_GPIO_PIN_MAX,
87 } GLB_GPIO_Type;
88 
89 #define GPIO_MODE_INPUT            ((uint32_t)0x00000000U) /*!< Input Floating Mode                   */
90 #define GPIO_MODE_OUTPUT           ((uint32_t)0x00000001U) /*!< Output Push Pull Mode                 */
91 #define GPIO_MODE_AF               ((uint32_t)0x00000002U) /*!< Alternate function                    */
92 #define GPIO_MODE_ANALOG           ((uint32_t)0x00000003U) /*!< Analog function                       */
93 #define GPIO_PULL_UP               ((uint32_t)0x00000000U) /*!< GPIO pull up                          */
94 #define GPIO_PULL_DOWN             ((uint32_t)0x00000001U) /*!< GPIO pull down                        */
95 #define GPIO_PULL_NONE             ((uint32_t)0x00000002U) /*!< GPIO no pull up or down               */
96 #define GPIO_OUTPUT_VALUE_MODE     ((uint8_t)0x00U) /*!< GPIO Output by reg_gpio_x_o Value                             */
97 #define GPIO_SET_CLR_MODE          ((uint8_t)0x01U) /*!< GPIO Output set by reg_gpio_x_set and clear by reg_gpio_x_clr */
98 #define GPIO_DMA_OUTPUT_VALUE_MODE ((uint8_t)0x02U) /*!< GPIO Output value by gpio_dma_o                               */
99 #define GPIO_DMA_SET_CLR_MODE      ((uint8_t)0x03U) /*!< GPIO Outout value by gpio_dma_set/gpio_dma_clr                */
100 
101 typedef enum {
102     GPIO_FUN_SDH = 0,
103     GPIO_FUN_SPI0 = 1,
104     GPIO_FUN_FLASH = 2,
105     GPIO_FUN_I2S = 3,
106     GPIO_FUN_PDM = 4,
107     GPIO_FUN_I2C0 = 5,
108     GPIO_FUN_I2C1 = 6,
109     GPIO_FUN_UART = 7,
110     GPIO_FUN_ETHER_MAC = 8,
111     GPIO_FUN_CAM = 9,
112     GPIO_FUN_ANALOG = 10,
113     GPIO_FUN_GPIO = 11,
114     GPIO_FUN_PWM0 = 16,
115     GPIO_FUN_PWM1 = 17,
116     GPIO_FUN_SPI1 = 18,
117     GPIO_FUN_I2C2 = 19,
118     GPIO_FUN_I2C3 = 20,
119     GPIO_FUN_MM_UART = 21,
120     GPIO_FUN_DBI_B = 22,
121     GPIO_FUN_DBI_C = 23,
122     GPIO_FUN_DPI = 24,
123     GPIO_FUN_JTAG_LP = 25,
124     GPIO_FUN_JTAG_M0 = 26,
125     GPIO_FUN_JTAG_D0 = 27,
126     GPIO_FUN_CLOCK_OUT = 31,
127 
128     GPIO_FUN_CLOCK_OUT_X_CAM_REF_CLK = 0xE0,
129     GPIO_FUN_CLOCK_OUT_X_I2S_REF_CLK = 0xE1,
130     GPIO_FUN_CLOCK_OUT_0_1_AUDIO_ADC_CLK = 0xE2,
131     GPIO_FUN_CLOCK_OUT_0_1_AUDIO_DAC_CLK = 0xE3,
132     GPIO_FUN_CLOCK_OUT_2_ANA_XTAL_CLK = 0xE2,
133     GPIO_FUN_CLOCK_OUT_2_PLL_32M_CLK = 0xE3,
134     GPIO_FUN_CLOCK_OUT_3_NONE = 0xE2,
135     GPIO_FUN_CLOCK_OUT_3_PLL_48M_CLK = 0xE3,
136 
137     GPIO_FUN_UART0_RTS = 0xF0,
138     GPIO_FUN_UART0_CTS = 0xF1,
139     GPIO_FUN_UART0_TX = 0xF2,
140     GPIO_FUN_UART0_RX = 0xF3,
141     GPIO_FUN_UART1_RTS = 0xF4,
142     GPIO_FUN_UART1_CTS = 0xF5,
143     GPIO_FUN_UART1_TX = 0xF6,
144     GPIO_FUN_UART1_RX = 0xF7,
145     GPIO_FUN_UART2_RTS = 0xF8,
146     GPIO_FUN_UART2_CTS = 0xF9,
147     GPIO_FUN_UART2_TX = 0xFA,
148     GPIO_FUN_UART2_RX = 0xFB,
149 
150     GPIO_FUN_UART3 = 21,
151 
152     GPIO_FUN_UNUSED = 0xFF,
153 } GLB_GPIO_FUNC_Type;
154 
155 typedef struct
156 {
157     uint8_t gpioPin;
158     uint8_t gpioFun;
159     uint8_t gpioMode;
160     uint8_t pullType;
161     uint8_t drive;
162     uint8_t smtCtrl;
163     uint8_t outputMode;
164 } GLB_GPIO_Cfg_Type;
165 
166 #endif /*__BL808_GPIO_H__ */
167