#include "cfg/cfg_i2c.h"#include <cfg/compiler.h>#include <cfg/macros.h>#include <cfg/debug.h>#include <cpu/attr.h>#include <PP_STRINGIZE(drv/PP_CAT3(i2c, _, CPU_ID).h)>Go to the source code of this file.
Defines | |
| #define | i2c_init(args...) PP_CAT(i2c_init ## _, COUNT_PARMS(args)) (args) |
| Initialize I2C module. | |
| #define | i2c_start_w(args...) PP_CAT(i2c_start_w ## _, COUNT_PARMS(args)) (args) |
| Start a write session. | |
| #define | i2c_start_r(args...) PP_CAT(i2c_start_r ## _, COUNT_PARMS(args)) (args) |
| Start a read session. | |
I2C error flags | |
| #define | I2C_OK 0 |
| I2C no errors flag. | |
| #define | I2C_DATA_NACK BV(4) |
| I2C generic error. | |
| #define | I2C_ERR BV(3) |
| I2C generic error. | |
| #define | I2C_ARB_LOST BV(2) |
| I2C arbitration lost error. | |
| #define | I2C_START_TIMEOUT BV(0) |
| I2C timeout error on start. | |
| #define | I2C_NO_ACK BV(1) |
| I2C no ack for sla start. | |
I2C command flags | |
| #define | I2C_NOSTOP 0 |
| Do not program the stop for current transition. | |
| #define | I2C_STOP BV(0) |
| Program the stop for current transition. | |
I2C Backends. | |
Sometimes your cpu does not have a builtin i2c driver or you don't want, for some reason, to use that. With this you can choose, at compile time, which backend to use. Set the CONFIG_I2C_BACKEND configuration variable in cfg_i2c.h | |
| #define | I2C_BACKEND_BUILTIN 0 |
| Uses cpu builtin i2c driver. | |
| #define | I2C_BACKEND_BITBANG 1 |
| Uses emulated bitbang driver. | |
Enumerations | |
I2C bitbang devices enum | |
| enum | { , I2C_BITBANG0 = 1000, I2C_BITBANG1 , I2C_BITBANG_CNT } |
Functions | |
| void | i2c_hw_init (I2c *i2c, int dev, uint32_t clock) |
| Initialize I2C module. | |
| void | i2c_hw_bitbangInit (I2c *i2c, int dev) |
| Initialize i2c module. | |
| bool | i2c_send (const void *_buf, size_t count) |
| Send a sequence of bytes in master transmitter mode to the selected slave device through the I2C bus. | |
| bool | i2c_recv (void *_buf, size_t count) |
| Receive a sequence of one or more bytes from the selected slave device in master receive mode through the I2C bus. | |
| void | i2c_init_0 (void) |
| Initialize I2C module (old API). | |
I2c builtin prototypes. | |
Do NOT use these function directly, instead, you can call the ones named without "_builtin_" and specify in cfg_i2c.h (CONFIG_I2C_BACKEND) that you want the builtin backend. | |
| bool | i2c_builtin_start_w (uint8_t id) |
| Send START condition and select slave for write. | |
| bool | i2c_builtin_start_r (uint8_t id) |
| Send START condition and select slave for read. | |
| void | i2c_builtin_stop (void) |
| Send STOP condition. | |
| bool | i2c_builtin_put (uint8_t _data) |
| Put a single byte in master transmitter mode to the selected slave device through the TWI bus. | |
| int | i2c_builtin_get (bool ack) |
| Get 1 byte from slave in master transmitter mode to the selected slave device through the TWI bus. | |
I2c bitbang prototypes. | |
Do NOT use these function directly, instead, you can call the ones named without "_bitbang_" and specify in cfg_i2c.h (CONFIG_I2C_BACKEND) that you want the bitbang backend. | |
| bool | i2c_bitbang_start_w (uint8_t id) |
| bool | i2c_bitbang_start_r (uint8_t id) |
| void | i2c_bitbang_stop (void) |
| bool | i2c_bitbang_put (uint8_t _data) |
| int | i2c_bitbang_get (bool ack) |
I2C interface functions | |
| #define | i2c_init_3(i2c, dev, clock) |
| Initialize I2C context structure. | |
| void | i2c_start_r_4 (I2c *i2c, uint16_t slave_addr, size_t size, int flags) |
| Start a read session. | |
| void | i2c_start_w_4 (I2c *i2c, uint16_t slave_addr, size_t size, int flags) |
| Start a write session. | |
| uint8_t | i2c_getc (I2c *i2c) |
| Read a byte from I2C bus. | |
| void | i2c_putc (I2c *i2c, uint8_t data) |
| Write the byte data into I2C port i2c. | |
| void | i2c_write (I2c *i2c, const void *_buf, size_t count) |
| Write count bytes to port i2c, reading from _buf. | |
| void | i2c_read (I2c *i2c, void *_buf, size_t count) |
| Read count bytes into buffer _buf from device i2c. | |
| int | i2c_error (I2c *i2c) |
| Return the error condition of the bus and clear errors. | |
Detailed Description
Definition in file i2c.h.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/bertos_logo.png)