1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 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 16 #ifndef __FLASHBOOT_IO_H__ 17 #define __FLASHBOOT_IO_H__ 18 #include<hi_boot_rom.h> 19 20 /** 21 * @ingroup iot_io 22 * 23 * I/O drive capability.CNcomment:IO驱动能力。CNend 24 * Note: The HI_IO_NAME_GPIO_0~HI_IO_NAME_GPIO_11 and HI_IO_NAME_GPIO_13~HI_IO_NAME_GPIO_14 driver capabilities are 25 * optional.The value range is HI_IO_DRIVER_STRENGTH_0~HI_IO_DRIVER_STRENGTH_3, and the other I/O ranges are 26 * HI_IO_DRIVER_STRENGTH_0~HI_IO_DRIVER_STRENGTH_7.CNcomment:注意:HI_IO_NAME_GPIO_0~HI_IO_NAME_GPIO_11、 27 * HI_IO_NAME_GPIO_13~HI_IO_NAME_GPIO_14驱动能力可选范围是HI_IO_DRIVER_STRENGTH_0~HI_IO_DRIVER_STRENGTH_3, 28 * 其余IO范围是HI_IO_DRIVER_STRENGTH_0~HI_IO_DRIVER_STRENGTH_7。CNend 29 */ 30 typedef enum { 31 HI_IO_DRIVER_STRENGTH_0 = 0, /**< Drive strength level 0 (highest). 32 CNcomment:驱动能力0级,驱动能力最高CNend */ 33 HI_IO_DRIVER_STRENGTH_1, /**< Drive strength level 1.CNcomment:驱动能力1级CNend */ 34 HI_IO_DRIVER_STRENGTH_2, /**< Drive strength level 2.CNcomment:驱动能力2级CNend */ 35 HI_IO_DRIVER_STRENGTH_3, /**< Drive strength level 3.CNcomment:驱动能力3级CNend */ 36 HI_IO_DRIVER_STRENGTH_4, /**< Drive strength level 4.CNcomment:驱动能力4级CNend */ 37 HI_IO_DRIVER_STRENGTH_5, /**< Drive strength level 5.CNcomment:驱动能力5级CNend */ 38 HI_IO_DRIVER_STRENGTH_6, /**< Drive strength level 6.CNcomment:驱动能力6级CNend */ 39 HI_IO_DRIVER_STRENGTH_7, /**< Drive strength level 7 (lowest). 40 CNcomment:驱动能力7级,驱动能力最低CNend */ 41 HI_IO_DRIVER_STRENGTH_MAX, 42 } hi_io_driver_strength; 43 44 /** 45 * @ingroup iot_io 46 * @brief Obtains the GPIO pull-up status.CNcomment:获取某个GPIO上下拉状态。CNend 47 * 48 * @par 描述: 49 * Obtains the GPIO pull-up status.CNcomment:获取某个GPIO上下拉状态。CNend 50 * 51 * @attention None 52 * @param id [IN] type #hi_io_name,I/O index.CNcomment:硬件管脚。CNend 53 * @param val [OUT] type #hi_io_pull*,pull-up status.CNcomment:获取到的上下拉状态。CNend. 54 * 55 * @retval 0 Success 56 * @retval #HI_ERR_GPIO_INVALID_PARAMETER Failure. Input invalid. 57 * @par 依赖: 58 * @li hi_io.h:Describes I/O APIs.CNcomment:文件用于描述IO相关接口。CNend 59 * @see hi_io_set_pull。 60 */ 61 hi_u32 hi_io_get_pull(hi_io_name id, hi_io_pull *val); 62 63 /** 64 * @ingroup iot_io 65 * @brief Obtains the I/O multiplexing.CNcomment:获取某个IO复用功能。CNend 66 * 67 * @par 描述: 68 * Obtains the I/O multiplexing.CNcomment:获取某个IO复用功能。CNend 69 * 70 * @attention None 71 * @param id [IN] type #hi_io_name,I/O index.CNcomment:硬件管脚。CNend 72 * @param val [OUT] type #hi_u8*,I/O multiplexing.CNcomment:IO复用功能。CNend 73 * 74 * @retval 0 Success 75 * @retval #HI_ERR_GPIO_INVALID_PARAMETER Failure. Input invalid. 76 * @par 依赖: 77 * @li hi_io.h:Describes I/O APIs.CNcomment:文件用于描述IO相关接口。CNend 78 * @see hi_io_set_func。 79 */ 80 hi_u32 hi_io_get_func(hi_io_name id, hi_u8 *val); 81 82 /** 83 * @ingroup iot_io 84 * @brief Sets the I/O drive strength.CNcomment:设置某个IO驱动能力。CNend 85 * 86 * @par 描述: 87 * The I/O drive strength is closely related to hardware design. For details, see SoC data sheet. 88 CNcomment:设置某个IO驱动能力,与硬件设计强相关,详细配置参考芯片手册。CNend 89 * 90 * @attention None 91 * @param id [IN] type #hi_io_name,I/O index.CNcomment:硬件管脚。CNend 92 * @param level [IN] type #hi_io_driver_strength,I/O drive strength level.CNcomment:IO驱动能力级别。CNend 93 * 94 * @retval #0 Success. 95 * @retval #Other Failure. For details, see hi_errno.h. 96 * @par 依赖: 97 * @li hi_io.h:Describes I/O APIs.CNcomment:文件用于描述IO相关接口。CNend 98 * @see None 99 */ 100 hi_u32 hi_io_set_driver_strength(hi_io_name id, hi_io_driver_strength val); 101 102 /** 103 * @ingroup iot_io 104 * @brief Obtains the I/O drive strength.CNcomment:获取某个IO驱动能力。CNend 105 * 106 * @par 描述: 107 * Obtains the I/O drive strength.CNcomment:获取某个IO驱动能力。CNend 108 * 109 * @attention None 110 * @param id [IN] type #hi_io_name,I/O index.CNcomment:硬件管脚。CNend 111 * @param val [OUT] type #hi_io_driver_strength*,I/O drive strength level.CNcomment:IO驱动能力级别。CNend 112 * 113 * @retval #0 Success. 114 * @retval #Other Failure. For details, see hi_errno.h. 115 * @par 依赖: 116 * @li hi_io.h:Describes I/O APIs.CNcomment:文件用于描述IO相关接口。CNend 117 * @see None 118 */ 119 hi_u32 hi_io_get_driver_strength(hi_io_name id, hi_io_driver_strength *val); 120 121 /** 122 * @ingroup iot_io 123 * @brief Set the I/O input enable status.CNcomment:设置某个IO输入使能的状态。CNend 124 * 125 * @par 描述: 126 * Set the I/O input enable status.CNcomment:设置某个IO输入使能的状态。CNend 127 * 128 * @attention If the input enable status of an IO is set to FALSE in the input state, the CPU can't read the IO changes. 129 CNcomment:如果某个IO的输入使能设置为FALSE,CPU将读取不到该IO的变化。CNend 130 * @param id [IN] type #hi_io_name,I/O index.CNcomment:硬件管脚。CNend 131 * @param state [IN] type #hi_bool,IO input enable state.CNcomment:要设置的输入使能状态。CNend 132 * 133 * @retval #0 Success. 134 * @retval #Other Failure. For details, see hi_errno.h. 135 * @par 依赖: 136 * @li hi_io.h:Describes I/O APIs.CNcomment:文件用于描述IO相关接口。CNend 137 * @see None 138 */ 139 hi_u32 hi_io_set_input_enable(hi_io_name id, hi_bool state); 140 141 /** 142 * @ingroup iot_io 143 * @brief Get the I/O input enable status.CNcomment:获取某个IO输入使能的状态。CNend 144 * 145 * @par 描述: 146 * Get the I/O input enable status.CNcomment:获取某个IO输入使能的状态。CNend 147 * 148 * @attention None 149 * @param id [IN] type #hi_io_name,I/O index.CNcomment:硬件管脚。CNend 150 * @param state [OUT] type #hi_bool *,IO input enable state.CNcomment:IO的输入使能状态。CNend 151 * 152 * @retval #0 Success. 153 * @retval #Other Failure. For details, see hi_errno.h. 154 * @par 依赖: 155 * @li hi_io.h:Describes I/O APIs.CNcomment:文件用于描述IO相关接口。CNend 156 * @see None 157 */ 158 hi_u32 hi_io_get_input_enable(hi_io_name id, hi_bool *state); 159 160 #endif 161