mraa  0.6.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
 All Data Structures Namespaces Files Functions 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 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 #include <stdlib.h>
43 #include <stdio.h>
44 #include <fcntl.h>
45 #include <stdint.h>
46 
47 #include "common.h"
48 #include "gpio.h"
49 
53 typedef struct _i2c* mraa_i2c_context;
54 
61 mraa_i2c_context mraa_i2c_init(int bus);
62 
69 mraa_i2c_context mraa_i2c_init_raw(unsigned int bus);
70 
78 mraa_result_t mraa_i2c_frequency(mraa_i2c_context dev, mraa_i2c_mode_t mode);
79 
89 int mraa_i2c_read(mraa_i2c_context dev, uint8_t *data, int length);
90 
98 uint8_t mraa_i2c_read_byte(mraa_i2c_context dev);
99 
107 uint8_t mraa_i2c_read_byte_data(mraa_i2c_context dev, const uint8_t command);
108 
116 uint16_t mraa_i2c_read_word_data(mraa_i2c_context dev, const uint8_t command);
117 
127 mraa_result_t mraa_i2c_write(mraa_i2c_context dev, const uint8_t *data, int length);
128 
136 mraa_result_t mraa_i2c_write_byte(mraa_i2c_context dev, const uint8_t data);
137 
146 mraa_result_t mraa_i2c_write_byte_data(mraa_i2c_context dev, const uint8_t data, const uint8_t command);
147 
156 mraa_result_t mraa_i2c_write_word_data(mraa_i2c_context dev, const uint16_t data, const uint8_t command);
157 
167 mraa_result_t mraa_i2c_address(mraa_i2c_context dev, uint8_t address);
168 
175 mraa_result_t mraa_i2c_stop(mraa_i2c_context dev);
176 
177 #ifdef __cplusplus
178 }
179 #endif
mraa_i2c_mode_t
Definition: types.h:180
mraa_result_t mraa_i2c_frequency(mraa_i2c_context dev, mraa_i2c_mode_t mode)
int mraa_i2c_read(mraa_i2c_context dev, uint8_t *data, int length)
mraa_i2c_context mraa_i2c_init(int bus)
uint8_t mraa_i2c_read_byte_data(mraa_i2c_context dev, const uint8_t command)
General Purpose IO.
mraa_result_t mraa_i2c_write_byte(mraa_i2c_context dev, const uint8_t data)
mraa_result_t mraa_i2c_write_byte_data(mraa_i2c_context dev, const uint8_t data, const uint8_t command)
uint16_t mraa_i2c_read_word_data(mraa_i2c_context dev, const uint8_t command)
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:53
mraa_result_t mraa_i2c_address(mraa_i2c_context dev, uint8_t address)
mraa_result_t mraa_i2c_stop(mraa_i2c_context dev)
uint8_t mraa_i2c_read_byte(mraa_i2c_context dev)
mraa_result_t
Definition: types.h:145
mraa_result_t mraa_i2c_write_word_data(mraa_i2c_context dev, const uint16_t data, const uint8_t command)