/****************************************************************************** * file include/hwgpio.h * author YuLiang * version 1.0.0 * date 24-Nov-2021 * brief This file provides all the headers of the gpio functions. ****************************************************************************** * Attention * *

© COPYRIGHT(c) 2021 LandPower

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of LandPower nor the names of its contributors may be used to * endorse or promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ******************************************************************************/ #ifndef _HWGPIO_H_ #define _HWGPIO_H_ /* Includes ------------------------------------------------------------------*/ /* Define --------------------------------------------------------------------*/ #define GPIO_DIR_IN 1 #define GPIO_DIR_OUT 2 #define GPIO_RUN 79 #define GPIO_WDG 123 /* Exported types ------------------------------------------------------------*/ /* 记录每个打开的gpio信息 */ typedef struct { uint16_t index; /* gpio在数组中的索引 */ uint16_t gpio; /* gpio号 gpio2-15 = (2 - 1) * 32 + 15 = 47 */ uint8_t is_export; /* 是否已导出 */ uint8_t curr_dir; /* 方向当前值 1-in 2-out */ uint8_t curr_val; /* 电平当前值 针对dir==out时 ,当dir为in时,每次都需要读文件 */ } gpio_node_t; /* Exported macro ------------------------------------------------------------*/ #define GPIO_RUN_LED(_v_) gpio_val_set(gpio_run_idx, _v_) #define GPIO_WATCHDOG(_v_) gpio_val_set(gpio_wdg_idx, _v_) /* Extern global variables ---------------------------------------------------*/ extern int32_t gpio_run_idx; extern int32_t gpio_wdg_idx; /* Extern functions ----------------------------------------------------------*/ extern int32_t gpio_val_set(uint16_t gpio, uint8_t value); extern int32_t gpio_val_get(uint16_t gpio, uint8_t *value); extern int32_t gpio_dir_set(uint16_t gpio, uint8_t dir); extern int32_t gpio_export(uint16_t gpio); extern int32_t gpio_init(void); #endif /************************ (C) COPYRIGHT LandPower ***** END OF FILE ****************/