rfLPC
A low level library for using NXP's LPC17xx SoC. Config is given for MBED prototyping board
i2c.h
Go to the documentation of this file.
1 /* This file is part of rflpc. Copyright 2010-2011 Michael Hauspie
2  *
3  * rflpc is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * rflpc is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with rflpc. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
21 #ifndef __RFLPC_I2C_H__
22 #define __RFLPC_I2C_H__
23 
24 /*
25  Author: Christophe Bacara <christophe.bacara@etudiant.univ-lille1.fr>
26 */
27 
28 #ifdef RFLPC_CONFIG_ENABLE_I2C
29 
30 #include <stdint.h> /* uint8_t */
31 
40 typedef enum {
41  RFLPC_I2C_PORT0,
42  RFLPC_I2C_PORT1,
43  RFLPC_I2C_PORT2
45 
47 typedef enum {
48  RFLPC_I2C_MODE_MASTER,
49  RFLPC_I2C_MODE_SLAVE
51 
53 typedef enum {
54  RFLPC_I2C_SUCCESSFUL_TRANSMISSION = 0,
55  RFLPC_I2C_SIZE_EQUAL_TO_ZERO,
56  RFLPC_I2C_SLAVE_IS_BUSY,
57  RFLPC_I2C_SLAVE_DID_NOT_ACKNOWLEDGED_DATA,
58  RFLPC_I2C_MASTER_DID_NOT_ACKNOWLEDGED_DATA,
59  RFLPC_I2C_STOP_CONDITION_RECEIVED,
60  RFLPC_I2C_SLAVE_TRANSMITTED_DATA,
61  RFLPC_I2C_UNKNOWN_ERROR,
62  RFLPC_I2C_NOT_YET_IMPLEMENTED
64 
75 extern int rflpc_i2c_init(rflpc_i2c_port_t port, rflpc_i2c_mode_t mode, uint8_t addr);
76 
88 extern uint16_t rflpc_i2c_write(rflpc_i2c_port_t port, uint8_t addr,
89  uint8_t *data, uint8_t nbytes, uint8_t stop);
90 
115 extern uint16_t rflpc_i2c_read(rflpc_i2c_port_t port, uint8_t addr,
116  uint8_t *data, uint8_t nbytes, uint8_t stop);
117 
124 extern void rflpc_i2c_set_slave_transmitter_config(uint8_t *data, uint8_t size);
125 
128 #endif /* ENABLE_I2C */
129 
130 #endif
rflpc_i2c_mode_t
Defines the operating mode of the I2C bus.
Definition: i2c.h:47
int rflpc_i2c_init(rflpc_i2c_port_t port, rflpc_i2c_mode_t mode, uint8_t addr)
Inits a given I2C port on a given mode.
rflpc_i2c_port_t
These constants selects which port the driver functions manipulate.
Definition: i2c.h:40
uint16_t rflpc_i2c_read(rflpc_i2c_port_t port, uint8_t addr, uint8_t *data, uint8_t nbytes, uint8_t stop)
Reads data from the I2C bus.
uint16_t rflpc_i2c_write(rflpc_i2c_port_t port, uint8_t addr, uint8_t *data, uint8_t nbytes, uint8_t stop)
Send bytes on the I2C bus.
void rflpc_i2c_set_slave_transmitter_config(uint8_t *data, uint8_t size)
Set data's location and size to be transmitted as slave.
rflpc_i2c_status_t
Defines the return status of the I2C driver.
Definition: i2c.h:53