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
i2c.h
Go to the documentation of this file.
1 /*
2  * Author: Brendan Le Foll <brendan.le.foll@intel.com>
3  * Copyright (c) 2014 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #pragma once
26 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 #include <stdlib.h>
45 #include <stdio.h>
46 #include <fcntl.h>
47 #include <stdint.h>
48 
49 #include "common.h"
50 #include "gpio.h"
51 
55 typedef struct _i2c* mraa_i2c_context;
56 
63 mraa_i2c_context mraa_i2c_init(int bus);
64 
71 mraa_i2c_context mraa_i2c_init_raw(unsigned int bus);
72 
80 mraa_result_t mraa_i2c_frequency(mraa_i2c_context dev, int hz);
81 
90 int mraa_i2c_read(mraa_i2c_context dev, uint8_t *data, int length);
91 
98 uint8_t mraa_i2c_read_byte(mraa_i2c_context dev);
99 
108 mraa_result_t mraa_i2c_write(mraa_i2c_context dev, const uint8_t *data, int length);
109 
117 mraa_result_t mraa_i2c_write_byte(mraa_i2c_context dev, const uint8_t data);
118 
128 mraa_result_t mraa_i2c_address(mraa_i2c_context dev, int address);
129 
136 mraa_result_t mraa_i2c_stop(mraa_i2c_context dev);
137 
138 #ifdef __cplusplus
139 }
140 #endif
int mraa_i2c_read(mraa_i2c_context dev, uint8_t *data, int length)
mraa_i2c_context mraa_i2c_init(int bus)
General Purpose IO.
mraa_result_t mraa_i2c_write_byte(mraa_i2c_context dev, const uint8_t data)
mraa_result_t mraa_i2c_write(mraa_i2c_context dev, const uint8_t *data, int length)
mraa_i2c_context mraa_i2c_init_raw(unsigned int bus)
struct _i2c * mraa_i2c_context
Definition: i2c.h:55
mraa_result_t mraa_i2c_stop(mraa_i2c_context dev)
mraa_result_t mraa_i2c_frequency(mraa_i2c_context dev, int hz)
uint8_t mraa_i2c_read_byte(mraa_i2c_context dev)
mraa_result_t
Definition: types.h:49
mraa_result_t mraa_i2c_address(mraa_i2c_context dev, int address)