mraa  0.4.5
Low Level Skeleton Library for Communication on GNU/Linux platforms
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
common.h
Go to the documentation of this file.
1 /*
2  * Author: Brendan Le Foll <brendan.le.foll@intel.com>
3  * Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
4  * Copyright © 2014 Intel Corporation
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22  * IN THE SOFTWARE.
23  */
24 
25 #pragma once
26 
27 #include "types.h"
28 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
42 typedef unsigned int mraa_boolean_t;
43 
47 typedef enum {
57 
61 typedef struct {
63  mraa_boolean_t valid:1;
64  mraa_boolean_t gpio:1;
65  mraa_boolean_t pwm:1;
66  mraa_boolean_t fast_gpio:1;
67  mraa_boolean_t spi:1;
68  mraa_boolean_t i2c:1;
69  mraa_boolean_t aio:1;
70  mraa_boolean_t uart:1;
73 
77 typedef struct {
79  unsigned int pin;
80  unsigned int value;
82 } mraa_mux_t;
83 
84 typedef struct {
85  mraa_boolean_t complex_pin:1;
86  mraa_boolean_t output_en:1;
87  mraa_boolean_t output_en_high:1;
88  mraa_boolean_t pullup_en:1;
89  mraa_boolean_t pullup_en_hiz:1;
91 
92 typedef struct {
94  unsigned int pinmap;
95  unsigned int parent_id;
96  unsigned int mux_total;
97  mraa_mux_t mux[6];
98  unsigned int output_enable;
99  unsigned int pullup_enable;
102 } mraa_pin_t;
103 
104 typedef struct {
106  char mem_dev[32];
107  unsigned int mem_sz;
108  unsigned int bit_pos;
112 
116 typedef struct {
118  char name[8];
129 
133 typedef struct {
135  unsigned int bus_id;
136  unsigned int scl;
137  unsigned int sda;
140 
144 typedef struct {
146  unsigned int bus_id;
147  unsigned int slave_s;
148  mraa_boolean_t three_wire;
149  unsigned int sclk;
150  unsigned int mosi;
151  unsigned int miso;
152  unsigned int cs;
155 
159 typedef struct {
161  unsigned int index;
162  int rx;
163  int tx;
166 
170 typedef struct {
172  unsigned int phy_pin_count;
173  unsigned int gpio_count;
174  unsigned int aio_count;
175  unsigned int i2c_bus_count;
176  mraa_i2c_bus_t i2c_bus[6];
177  unsigned int def_i2c_bus;
178  unsigned int spi_bus_count;
179  mraa_spi_bus_t spi_bus[6];
180  unsigned int def_spi_bus;
181  unsigned int adc_raw;
182  unsigned int adc_supported;
183  unsigned int def_uart_dev;
184  unsigned int uart_dev_count;
185  mraa_uart_dev_t uart_dev[6];
188 } mraa_board_t;
189 
197 #if (defined SWIGPYTHON) || (defined SWIG)
199 #else
200 // this sets a compiler attribute (supported by GCC & clang) to have mraa_init()
201 // be called as a constructor make sure your libc supports this! uclibc needs
202 // to be compiled with UCLIBC_CTOR_DTOR
203 mraa_result_t mraa_init() __attribute__((constructor));
204 #endif
205 
212 void mraa_deinit();
213 
221 mraa_boolean_t mraa_pin_mode_test(int pin, mraa_pinmodes_t mode);
222 
228 unsigned int mraa_adc_raw_bits();
229 
235 unsigned int mraa_adc_supported_bits();
236 
237 #ifdef __cplusplus
238 }
239 #endif
mraa_pininfo_t * pins
Definition: common.h:186
unsigned int slave_s
Definition: common.h:147
Definition: common.h:53
unsigned int adc_supported
Definition: common.h:182
unsigned int mraa_boolean_t
Definition: common.h:42
mraa_pin_t uart
Definition: common.h:126
unsigned int adc_raw
Definition: common.h:181
mraa_pin_t gpio
Definition: common.h:120
Definition: common.h:50
unsigned int output_enable
Definition: common.h:98
unsigned int def_i2c_bus
Definition: common.h:177
unsigned int i2c_bus_count
Definition: common.h:175
unsigned int bus_id
Definition: common.h:135
unsigned int mosi
Definition: common.h:150
Definition: common.h:77
mraa_boolean_t mraa_pin_mode_test(int pin, mraa_pinmodes_t mode)
unsigned int pin
Definition: common.h:79
unsigned int mraa_adc_supported_bits()
unsigned int value
Definition: common.h:80
Definition: common.h:51
unsigned int sclk
Definition: common.h:149
int tx
Definition: common.h:163
unsigned int def_spi_bus
Definition: common.h:180
Definition: common.h:159
mraa_pin_cap_complex_t complex_cap
Definition: common.h:100
unsigned int mux_total
Definition: common.h:96
Definition: common.h:84
unsigned int pinmap
Definition: common.h:94
mraa_pincapabilities_t capabilites
Definition: common.h:119
mraa_pin_t aio
Definition: common.h:122
Definition: common.h:144
unsigned int cs
Definition: common.h:152
Definition: common.h:170
unsigned int uart_dev_count
Definition: common.h:184
unsigned int spi_bus_count
Definition: common.h:178
void mraa_deinit()
unsigned int sda
Definition: common.h:137
mraa_result_t mraa_init() __attribute__((constructor))
Definition: common.h:92
Definition: common.h:49
unsigned int pullup_enable
Definition: common.h:99
mraa_pinmodes_t
Definition: common.h:47
int rx
Definition: common.h:162
unsigned int phy_pin_count
Definition: common.h:172
unsigned int bus_id
Definition: common.h:146
unsigned int bit_pos
Definition: common.h:108
mraa_pin_t spi
Definition: common.h:125
unsigned int mraa_adc_raw_bits()
Definition: common.h:104
mraa_boolean_t three_wire
Definition: common.h:148
unsigned int gpio_count
Definition: common.h:173
unsigned int scl
Definition: common.h:136
unsigned int index
Definition: common.h:161
mraa_result_t
Definition: types.h:49
mraa_mmap_pin_t mmap
Definition: common.h:123
Definition: common.h:48
mraa_pin_t pwm
Definition: common.h:121
mraa_pin_t gpio
Definition: common.h:109
Definition: common.h:54
mraa_pin_t i2c
Definition: common.h:124
Definition: common.h:55
Definition: common.h:61
Definition: common.h:133
unsigned int def_uart_dev
Definition: common.h:183
unsigned int aio_count
Definition: common.h:174
unsigned int miso
Definition: common.h:151
Definition: common.h:116
Definition: common.h:52