mraa  2.0.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
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 
88 int mraa_i2c_read(mraa_i2c_context dev, uint8_t* data, int length);
89 
96 int mraa_i2c_read_byte(mraa_i2c_context dev);
97 
105 int mraa_i2c_read_byte_data(mraa_i2c_context dev, const uint8_t command);
106 
114 int mraa_i2c_read_word_data(mraa_i2c_context dev, const uint8_t command);
115 
125 int mraa_i2c_read_bytes_data(mraa_i2c_context dev, uint8_t command, uint8_t* data, int length);
126 
136 mraa_result_t mraa_i2c_write(mraa_i2c_context dev, const uint8_t* data, int length);
137 
145 mraa_result_t mraa_i2c_write_byte(mraa_i2c_context dev, const uint8_t data);
146 
155 mraa_result_t mraa_i2c_write_byte_data(mraa_i2c_context dev, const uint8_t data, const uint8_t command);
156 
165 mraa_result_t mraa_i2c_write_word_data(mraa_i2c_context dev, const uint16_t data, const uint8_t command);
166 
174 mraa_result_t mraa_i2c_address(mraa_i2c_context dev, uint8_t address);
175 
182 mraa_result_t mraa_i2c_stop(mraa_i2c_context dev);
183 
184 #ifdef __cplusplus
185 }
186 #endif
mraa_i2c_mode_t
Definition: types.h:246
int mraa_i2c_read_byte(mraa_i2c_context dev)
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)
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)
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
int mraa_i2c_read_word_data(mraa_i2c_context dev, const uint8_t command)
mraa_result_t mraa_i2c_address(mraa_i2c_context dev, uint8_t address)
mraa_result_t mraa_i2c_stop(mraa_i2c_context dev)
int mraa_i2c_read_bytes_data(mraa_i2c_context dev, uint8_t command, uint8_t *data, int length)
mraa_result_t
Definition: types.h:209
int mraa_i2c_read_byte_data(mraa_i2c_context dev, const uint8_t command)
mraa_result_t mraa_i2c_write_word_data(mraa_i2c_context dev, const uint16_t data, const uint8_t command)