SDK3.5
This document shows Ameba SDK 3.5 APIs
|
I2C functions. More...
Ameba Common | |
enum | { I2C_ERROR_NO_SLAVE = -1, I2C_ERROR_BUS_BUSY = -2 } |
typedef struct i2c_s | i2c_t |
void | i2c_init (i2c_t *obj, PinName sda, PinName scl) |
Initializes the I2C device, include clock/function/I2C registers. More... | |
void | i2c_frequency (i2c_t *obj, int hz) |
Set i2c frequency. More... | |
int | i2c_start (i2c_t *obj) |
Start i2c device. More... | |
int | i2c_stop (i2c_t *obj) |
Stop i2c device. More... | |
void | i2c_reset (i2c_t *obj) |
Deinitializes the I2C device. More... | |
int | i2c_byte_read (i2c_t *obj, int last) |
I2C master receive single byte. More... | |
int | i2c_byte_write (i2c_t *obj, int data) |
I2C master send single byte. More... | |
void | i2c_slave_mode (i2c_t *obj, int enable_slave) |
Set i2c device to be slave. More... | |
int | i2c_slave_receive (i2c_t *obj) |
Get i2c slave state. More... | |
void | i2c_slave_address (i2c_t *obj, int idx, uint32_t address, uint32_t mask) |
Set i2c slave address. More... | |
int | i2c_read (i2c_t *obj, int address, char *data, int length, int stop) |
I2C master read in poll mode. More... | |
int | i2c_write (i2c_t *obj, int address, const char *data, int length, int stop) |
I2C master write in poll mode. More... | |
int | i2c_slave_read (i2c_t *obj, char *data, int length) |
I2C slave read in poll mode. More... | |
int | i2c_slave_write (i2c_t *obj, const char *data, int length) |
I2C slave write in poll mode. More... | |
int | i2c_slave_set_for_rd_req (i2c_t *obj, int set) |
Set/clear i2c slave RD_REQ interrupt mask. More... | |
int | i2c_slave_set_for_data_nak (i2c_t *obj, int set_nak) |
Set/clear i2c slave NAK or ACK data part in transfer. More... | |
AmebaZ Only | |
int | i2c_repeatread (i2c_t *obj, int address, u8 *pWriteBuf, int Writelen, u8 *pReadBuf, int Readlen) |
I2C master send data and read data in poll mode. More... | |
I2C functions.
int i2c_byte_read | ( | i2c_t * | obj, |
int | last | ||
) |
I2C master receive single byte.
obj | i2c object define in application software. |
last | hold the received data. |
the received data. |
int i2c_byte_write | ( | i2c_t * | obj, |
int | data | ||
) |
I2C master send single byte.
obj | i2c object define in application software. |
data | the data to be sent. |
result. |
void i2c_frequency | ( | i2c_t * | obj, |
int | hz | ||
) |
Set i2c frequency.
obj | i2c object define in application software. |
hz | i2c clock(unit is Hz). |
none |
void i2c_init | ( | i2c_t * | obj, |
PinName | sda, | ||
PinName | scl | ||
) |
Initializes the I2C device, include clock/function/I2C registers.
obj | i2c object define in application software. |
sda | SDA PinName according to pinmux spec. |
scl | SCL PinName according to pinmux spec. |
none |
int i2c_read | ( | i2c_t * | obj, |
int | address, | ||
char * | data, | ||
int | length, | ||
int | stop | ||
) |
I2C master read in poll mode.
obj | i2c object define in application software. |
address | slave address which will be transmitted. |
data | point to the buffer to hold the received data. |
length | the length of data that to be received. |
stop | specifies whether a STOP is issued after all the bytes are received. |
the length of data received. |
int i2c_repeatread | ( | i2c_t * | obj, |
int | address, | ||
u8 * | pWriteBuf, | ||
int | Writelen, | ||
u8 * | pReadBuf, | ||
int | Readlen | ||
) |
I2C master send data and read data in poll mode.
obj | i2c object define in application software. |
address | slave address which will be transmitted. |
pWriteBuf | point to the data to be sent. |
Writelen | the length of data that to be sent. |
pReadBuf | point to the buffer to hold the received data. |
Readlen | the length of data that to be received. |
the | length of data received. |
void i2c_reset | ( | i2c_t * | obj | ) |
Deinitializes the I2C device.
obj | i2c object define in application software. |
none |
void i2c_slave_address | ( | i2c_t * | obj, |
int | idx, | ||
uint32_t | address, | ||
uint32_t | mask | ||
) |
Set i2c slave address.
obj | i2c object define in application software. |
idx | i2c index, this parameter can be one of the following values:
|
address | slave address. |
mask | the mask of address |
none |
void i2c_slave_mode | ( | i2c_t * | obj, |
int | enable_slave | ||
) |
Set i2c device to be slave.
obj | i2c object define in application software. |
enable_slave | enable slave function, this parameter can be one of the following values:
|
none |
int i2c_slave_read | ( | i2c_t * | obj, |
char * | data, | ||
int | length | ||
) |
I2C slave read in poll mode.
obj | i2c object define in application software. |
data | point to the buffer to hold the received data. |
length | the length of data that to be received. |
the length of data received. |
int i2c_slave_receive | ( | i2c_t * | obj | ) |
Get i2c slave state.
obj | i2c object define in application software. |
the state of i2c slave. |
int i2c_slave_set_for_data_nak | ( | i2c_t * | obj, |
int | set_nak | ||
) |
Set/clear i2c slave NAK or ACK data part in transfer.
obj | i2c object define in application software. |
set_nak | set or clear for data NAK. |
1 | SUCCESS |
int i2c_slave_set_for_rd_req | ( | i2c_t * | obj, |
int | set | ||
) |
Set/clear i2c slave RD_REQ interrupt mask.
obj | i2c object define in application software. |
set | set or clear for read request. |
1 | SUCCESS |
int i2c_slave_write | ( | i2c_t * | obj, |
const char * | data, | ||
int | length | ||
) |
I2C slave write in poll mode.
obj | i2c object define in application software. |
data | point to the data to be sent. |
length | the length of data that to be sent. |
0 | FAIL |
1 | SUCCESS |
int i2c_start | ( | i2c_t * | obj | ) |
Start i2c device.
obj | i2c object define in application software. |
0 |
int i2c_stop | ( | i2c_t * | obj | ) |
Stop i2c device.
obj | i2c object define in application software. |
0 |
int i2c_write | ( | i2c_t * | obj, |
int | address, | ||
const char * | data, | ||
int | length, | ||
int | stop | ||
) |
I2C master write in poll mode.
obj | i2c object define in application software. |
address | slave address which will be transmitted. |
data | point to the data to be sent. |
length | the length of data that to be sent. |
stop | specifies whether a STOP is issued after all the bytes are sent. |
the length of data send. |