RTEMS: cpukit/include/dev/i2c/gpio-nxp-pca9535.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
gpio-nxp-pca9535.h
Go to the documentation of this file.
1
9/*
10 * Copyright (c) 2014 embedded brains GmbH. All rights reserved.
11 *
12 * embedded brains GmbH
13 * Dornierstr. 4
14 * 82178 Puchheim
15 * Germany
16 * <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.org/license/LICENSE.
21 */
22
23#ifndef _DEV_I2C_GPIO_NXP_PCA9539_H
24#define _DEV_I2C_GPIO_NXP_PCA9539_H
25
26#include <dev/i2c/i2c.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif /* __cplusplus */
31
42int i2c_dev_register_gpio_nxp_pca9535(
43 const char *bus_path,
44 const char *dev_path,
45 uint16_t address
46);
47
48#define GPIO_NXP_PCA9535_GET_INPUT (I2C_DEV_IO_CONTROL + 0)
49
50#define GPIO_NXP_PCA9535_GET_OUTPUT (I2C_DEV_IO_CONTROL + 1)
51
52#define GPIO_NXP_PCA9535_SET_OUTPUT (I2C_DEV_IO_CONTROL + 2)
53
54#define GPIO_NXP_PCA9535_CLEAR_AND_SET_OUTPUT (I2C_DEV_IO_CONTROL + 3)
55
56#define GPIO_NXP_PCA9535_GET_POL_INV (I2C_DEV_IO_CONTROL + 4)
57
58#define GPIO_NXP_PCA9535_SET_POL_INV (I2C_DEV_IO_CONTROL + 5)
59
60#define GPIO_NXP_PCA9535_GET_CONFIG (I2C_DEV_IO_CONTROL + 6)
61
62#define GPIO_NXP_PCA9535_SET_CONFIG (I2C_DEV_IO_CONTROL + 7)
63
64static inline int gpio_nxp_pca9535_get_input(int fd, uint16_t *val)
65{
66 return ioctl(fd, GPIO_NXP_PCA9535_GET_INPUT, val);
67}
68
69static inline int gpio_nxp_pca9535_get_output(int fd, uint16_t *val)
70{
71 return ioctl(fd, GPIO_NXP_PCA9535_GET_OUTPUT, val);
72}
73
74static inline int gpio_nxp_pca9535_set_output(int fd, uint16_t val)
75{
76 return ioctl(fd, GPIO_NXP_PCA9535_SET_OUTPUT, (void *)(uintptr_t) val);
77}
78
79static inline int gpio_nxp_pca9535_clear_and_set_output(
80 int fd,
81 uint16_t clear,
82 uint16_t set
83)
84{
85 uint32_t clear_and_set = ((uint32_t) set << 16) | (uint32_t) clear;
86
87 return ioctl(
88 fd,
89 GPIO_NXP_PCA9535_CLEAR_AND_SET_OUTPUT,
90 (void *)(uintptr_t) clear_and_set
91 );
92}
93
94static inline int gpio_nxp_pca9535_get_polarity_inversion(
95 int fd,
96 uint16_t *val
97)
98{
99 return ioctl(fd, GPIO_NXP_PCA9535_GET_POL_INV, val);
100}
101
102static inline int gpio_nxp_pca9535_set_polarity_inversion(int fd, uint16_t val)
103{
104 return ioctl(fd, GPIO_NXP_PCA9535_SET_POL_INV, (void *)(uintptr_t) val);
105}
106
107static inline int gpio_nxp_pca9535_get_config(int fd, uint16_t *val)
108{
109 return ioctl(fd, GPIO_NXP_PCA9535_GET_CONFIG, val);
110}
111
112static inline int gpio_nxp_pca9535_set_config(int fd, uint16_t val)
113{
114 return ioctl(fd, GPIO_NXP_PCA9535_SET_CONFIG, (void *)(uintptr_t) val);
115}
116
119#ifdef __cplusplus
120}
121#endif /* __cplusplus */
122
123#endif /* _DEV_I2C_GPIO_NXP_PCA9539_H */
i2c.h
Inter-Integrated Circuit (I2C) Driver API.