File indexing completed on 2025-05-11 08:23:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 #ifndef __GPIOLIB_H__
0031 #define __GPIOLIB_H__
0032
0033 #ifdef __cplusplus
0034 extern "C" {
0035 #endif
0036
0037
0038 struct gpiolib_config {
0039 char mask;
0040 char irq_level;
0041 char irq_polarity;
0042 };
0043
0044 #define GPIOLIB_IRQ_EDGE 0
0045 #define GPIOLIB_IRQ_LEVEL 1
0046
0047 #define GPIOLIB_IRQ_POL_LOW 0
0048 #define GPIOLIB_IRQ_POL_HIGH 1
0049
0050
0051 extern int gpiolib_initialize(void);
0052
0053
0054
0055 extern void *gpiolib_open(int port);
0056 extern void *gpiolib_open_by_name(char *devName);
0057 extern void gpiolib_close(void *handle);
0058
0059
0060
0061
0062
0063
0064
0065 extern void gpiolib_show(int port, void *handle);
0066
0067 extern int gpiolib_set_config(void *handle, struct gpiolib_config *cfg);
0068 extern int gpiolib_set(void *handle, int dir, int val);
0069 extern int gpiolib_get(void *handle, int *inval);
0070 extern int gpiolib_irq_clear(void *handle);
0071 extern int gpiolib_irq_enable(void *handle);
0072 extern int gpiolib_irq_disable(void *handle);
0073 extern int gpiolib_irq_mask(void *handle);
0074 extern int gpiolib_irq_unmask(void *handle);
0075 extern int gpiolib_irq_force(void *handle);
0076 extern int gpiolib_irq_register(void *handle, void *func, void *arg);
0077
0078
0079
0080 struct gpiolib_info {
0081 char devName[80];
0082 };
0083
0084 struct gpiolib_drv_ops {
0085 int (*config)(void *handle, struct gpiolib_config *cfg);
0086 int (*get)(void *handle, int *val);
0087 int (*irq_opts)(void *handle, unsigned int options);
0088 int (*irq_register)(void *handle, void *func, void *arg);
0089 int (*open)(void *handle);
0090 int (*set)(void *handle, int dir, int outval);
0091 int (*show)(void *handle);
0092 int (*get_info)(void *handle, struct gpiolib_info *pinfo);
0093 };
0094
0095 #define GPIOLIB_IRQ_ENABLE 0x01
0096 #define GPIOLIB_IRQ_DISABLE 0x02
0097 #define GPIOLIB_IRQ_CLEAR 0x04
0098 #define GPIOLIB_IRQ_FORCE 0x08
0099 #define GPIOLIB_IRQ_MASK 0x10
0100 #define GPIOLIB_IRQ_UNMASK 0x20
0101
0102 struct gpiolib_drv {
0103 struct gpiolib_drv_ops *ops;
0104 };
0105
0106
0107 extern int gpiolib_drv_register(struct gpiolib_drv *drv, void *handle);
0108
0109 #ifdef __cplusplus
0110 }
0111 #endif
0112
0113 #endif