/*********************************************************************************
|
* Copyright: (C) 2019 LingYun IoT System Studio
|
* All rights reserved.
|
*
|
* Filename: at91_sysGpio.h
|
* Description: This file si GPIO API operatore on /sys/class/gpio/xxx
|
*
|
* Version: 1.0.0(2019年08月26日)
|
* Author: Guo Wenxue <guowenxue@gmail.com>
|
* ChangeLog: 1, Release initial version on "2019年08月26日 22时28分19秒"
|
*
|
********************************************************************************/
|
|
#ifndef _AT91_SYSGPIO_H_
|
#define _AT91_SYSGPIO_H_
|
|
#include "at91_sysGpioDef.h"
|
|
#define SYSFILE_LEN 64
|
|
#define SYSGPIO_PATH "/sys/class/gpio/"
|
|
#define SYSGPIO_EXPORT_PATH SYSGPIO_PATH"export"
|
#define SYSGPIO_UNEXPORT_PATH SYSGPIO_PATH"unexport"
|
|
//#define GPIO_DEBUG_PRINT
|
|
#ifdef GPIO_DEBUG_PRINT
|
#define gpio_print(format,args...) printf(format, ##args)
|
#else
|
#define gpio_print(format,args...) do{} while(0);
|
#endif
|
|
|
/* export $port in /sys/class/gpio/export */
|
extern int gpio_export(const char *port);
|
|
|
/* unexport $port in /sys/class/gpio/unexport */
|
extern int gpio_unexport(const char *port);
|
|
|
#define M_IN "in" /* set GPIO as input mode */
|
#define M_OUT "out" /* set GPIO as output mode */
|
#define M_HIGH "high" /* set GPIO as output mode and value be high<1> */
|
#define M_LOW "low" /* set GPIO as output mode and value be low<0> */
|
/* configure $port direction as $mode */
|
extern int gpio_config(const char *port, const char *mode);
|
|
|
#define V_HIGH "1"
|
#define V_LOW "0"
|
/* write $value into GPIO $port */
|
extern int gpio_write(const char *port, const char *value);
|
|
|
/* read gpio value from $port */
|
extern int gpio_read(const char *port);
|
|
#endif /* ----- #ifndef _AT91_SYSGPIO_H_ ----- */
|