You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
4.1 KiB
C
98 lines
4.1 KiB
C
/******************************************************************************
|
|
* file include/common.h
|
|
* author YuLiang
|
|
* version 1.0.0
|
|
* date 24-Nov-2021
|
|
* brief This file provides all the headers of the gpio functions.
|
|
|
|
******************************************************************************
|
|
* Attention
|
|
*
|
|
* <h2><center>© COPYRIGHT(c) 2021 LandPower</center></h2>
|
|
*
|
|
* 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 124
|
|
#define GPIO_SYNC 22
|
|
#define GPIO_SYNC_PPS 119
|
|
#define GPIO_ERR1 123
|
|
#define GPIO_ERR2 88
|
|
#define GPIO_ALARM 18
|
|
|
|
#define GPIO_DAU1_POW 114
|
|
#define GPIO_DAU2_POW 0
|
|
|
|
#define GPIO_CPLD_CS 86
|
|
#define GPIO_CPLD_SCLK 85
|
|
#define GPIO_CPLD_MOSI 4
|
|
#define GPIO_CPLD_MISO 5
|
|
|
|
/* 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_DAU1_POW_ON gpio_val_set(gpio_dau1_pow_idx, 1)
|
|
#define GPIO_DAU1_POW_OFF gpio_val_set(gpio_dau1_pow_idx, 0)
|
|
#define GPIO_DAU2_POW_ON gpio_val_set(gpio_dau2_pow_idx, 1)
|
|
#define GPIO_DAU2_POW_OFF gpio_val_set(gpio_dau2_pow_idx, 0)
|
|
|
|
#define GPIO_RUN_LED(_v_) gpio_val_set(gpio_run_idx, _v_)
|
|
#define GPIO_SYNC_LED(_v_) gpio_val_set(gpio_sync_idx, _v_)
|
|
#define GPIO_ERR1_LED(_v_) gpio_val_set(gpio_err1_idx, _v_)
|
|
|
|
/* Extern global variables ---------------------------------------------------*/
|
|
extern int32_t gpio_dau1_pow_idx;
|
|
extern int32_t gpio_dau2_pow_idx;
|
|
extern int32_t gpio_run_idx;
|
|
extern int32_t gpio_sync_idx;
|
|
extern int32_t gpio_err1_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 ****************/
|