2 * Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
3 * Author: Brendan Le Foll <brendan.le.foll@intel.com>
4 * Copyright (c) 2014 Intel Corporation.
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // general status failures for internal functions
32 #define MRAA_PLATFORM_NO_INIT -3
33 #define MRAA_IO_SETUP_FAILURE -2
34 #define MRAA_NO_SUCH_IO -1
37 * A structure representing a gpio pin.
41 int pin; /**< the pin number, as known to the os. */
42 int phy_pin; /**< pin passed to clean init. -1 none and raw*/
43 int value_fp; /**< the file pointer to the value of the gpio */
44 void (* isr)(void *); /**< the interupt service request */
45 void *isr_args; /**< args return when interupt service request triggered */
46 pthread_t thread_id; /**< the isr handler thread id */
47 int isr_value_fp; /**< the isr file pointer on the value */
48 mraa_boolean_t owner; /**< If this context originally exported the pin */
49 mraa_result_t (*mmap_write) (mraa_gpio_context dev, int value);
50 int (*mmap_read) (mraa_gpio_context dev);
55 * A structure representing a I2C bus
59 int busnum; /**< the bus number of the /dev/i2c-* device */
60 int fh; /**< the file handle to the /dev/i2c-* device */
61 int addr; /**< the address of the i2c slave */
67 * A structure representing a PWM pin
71 int pin; /**< the pin number, as known to the os. */
72 int chipid; /**< the chip id, which the pwm resides */
73 int duty_fp; /**< File pointer to duty file */
74 mraa_boolean_t owner; /**< Owner of pwm context*/
79 * A structure representing a Analog Input Channel
82 unsigned int channel; /**< the channel as on board and ADC module */
83 int adc_in_fp; /**< File Pointer to raw sysfs */
84 int value_bit; /**< 10 bits by default. Can be increased if board */
88 * A structure representing a UART device
92 int index; /**< the uart index, as known to the os. */