• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 // Copyright (C) 2022 Beken Corporation
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #pragma once
16 #include "gpio_hal.h"
17 
18 typedef enum {
19        GPIO_SDIO_MAP_MODE0 = 0,			/**<GPIO2~GPIO5  GPIO10~GPIO11 is used for SDIO   HOST/SLAVE */
20        GPIO_SDIO_MAP_MODE1,			    /**<GPIO14~GPIO19 is used for SDIO HOST/SLAVE */
21        GPIO_SDIO_MAP_MODE_MAX,			/**< Invalid sdio mode */
22 } gpio_sdio_map_mode_t;
23 
24 
25 typedef enum {
26        GPIO_SPI_MAP_MODE0 = 0,		       /**<GPIO14~GPIO17 is used for SPI module */
27        GPIO_SPI_MAP_MODE1,                 /**<GPIO44~GPIO47 is used for SPI module*/
28        GPIO_SPI_MAP_MODE_MAX ,		       /**< Invalid spi mode */
29 } gpio_spi1_map_mode_t;
30 
31 typedef enum {
32        GPIO_I2C1_MAP_MODE0 = 0,			/**<GPIO0~GPIO1 is used for I2C1 */
33        GPIO_I2C1_MAP_MODE1,			/**<GPIO42~GPIO43 is used for I2C1 */
34        GPIO_I2C1_MAP_MODE_MAX,		       /**< Invalid mode*/
35 } gpio_i2c1_map_mode_t;
36 
37 typedef enum {
38        GPIO_I2S_MAP_MODE = 0,	       /**<GPIO6~GPIO9 is used for I2S */
39        GPIO_I2S_MAP_MODE1,		       /**<GPIO40~GPIO43 is used for I2S */
40        GPIO_I2S_MAP_MODE_MAX,			/**< Invalid mode*/
41 } gpio_i2s_map_mode_t;
42 
43 typedef enum {
44        GPIO_JTAG_MAP_MODE = 0,	       /**<GPIO20~GPIO21 is used for jtag */
45        GPIO_JTAG_MAP_MODE1,		       /**<GPIO0~GPIO1 is used for jtag */
46        GPIO_JTAG_MAP_MODE_MAX,			/**< Invalid mode*/
47 } gpio_jtag_map_mode_t;
48 
49 
50 bk_err_t gpio_dev_map(gpio_id_t gpio_id, gpio_dev_t dev);
51 bk_err_t gpio_dev_unmap(gpio_id_t gpio_id);
52 bk_err_t gpio_spi_sel(gpio_spi1_map_mode_t gpio_spi_sel_mode);
53 bk_err_t gpio_sdio_sel(gpio_sdio_map_mode_t gpio_sdio_sel_mode);
54 bk_err_t gpio_sdio_one_line_sel(gpio_sdio_map_mode_t gpio_sdio_sel_mode);
55 bk_err_t gpio_i2c1_sel(gpio_i2c1_map_mode_t gpio_i2c1_sel_mode);
56 bk_err_t gpio_i2s_sel(gpio_i2s_map_mode_t gpio_i2s_sel_mode);
57 bk_err_t gpio_jtag_sel(gpio_jtag_map_mode_t gpio_jtag_sel_mode);
58 
59 
60 #if CONFIG_GPIO_WAKEUP_SUPPORT
61 bk_err_t gpio_enter_low_power(void *param);
62 bk_err_t gpio_exit_low_power(void *param);
63 void gpio_get_interrupt_status(uint32_t *h_status, uint32_t *l_status);
64 #endif
65 
66 #if CONFIG_GPIO_SIMULATE_UART_WRITE
67 /**
68  * @brief	  Uses specifies GPIO to simulate UART write data
69  *
70  * This API Uses specifies GPIO to simulate UART write data:
71  *	 - Uses CPU poll wait to do delay, so it blocks CPU.
72  *	 - The caller should confirm the specifies GPIO is not used by other APP.
73  *
74  * @param *buff  Which buffers will be write with GPIO.
75  * @param len    How many bytes data will be wrote.
76  * @param gpio_id  Which GPIO will be simulated as UART write data.
77  * @param div    Baud rate == 1Mbps/(1+div)
78  *
79  * @attention 1. As this function just simulate uart write, it blocks the CPU,
80  *               so please don't write too much data.
81  *
82  * @return
83  */
84 void gpio_simulate_uart_write(unsigned char *buff, uint32_t len, gpio_id_t gpio_id, uint32_t div);
85 #endif
86 
87