SAMA5D4 Xplained Ultra Board BSP
guowenxue
2019-08-27 69d0972fa8b82065a67566b74ecae8585d9c68c1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*********************************************************************************
 *      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_  ----- */