InPlay API
I2C driver

HAL_I2C. More...

Functions

void * hal_i2c_open (int id, i2c_init_t *init)
 Open the I2c driver. More...
 
void hal_i2c_close (void *hdl)
 Close the I2c driver. More...
 
int hal_mi2c_read (void *hdl, uint8_t tar, uint8_t *buffer, uint16_t buffer_len)
 I2c master read function. More...
 
int hal_mi2c_write (void *hdl, uint8_t tar, uint8_t *buffer, uint16_t buffer_len)
 I2c master write function. More...
 
int hal_mi2c_mix_tran_start_poll (void *hdl, int speed, uint8_t tar, int dir_write, uint8_t *buffer, uint16_t buffer_len)
 Start of I2c master read/write mixed function. More...
 
int hal_mi2c_mix_tran_continue_poll (void *hdl, uint8_t tar, int dir_write, int restart, uint8_t *buffer, uint16_t buffer_len)
 Continue of I2c master read/write mixed function. More...
 
int hal_mi2c_mix_tran_end_poll (void *hdl, uint8_t tar, int dir_write, int restart, uint8_t *buffer, uint16_t buffer_len)
 End of I2c master read/write mixed function. More...
 
int hal_si2c_read (void *hdl, uint8_t sar, uint8_t *buffer, uint16_t buffer_len)
 I2c slave read function. More...
 
int hal_si2c_write (void *hdl, uint8_t sar, uint8_t *buffer, uint16_t buffer_len)
 I2c slave write function. More...
 
int hal_mi2c_write_read (void *hdl, uint8_t tar, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
 I2c master write and read function. More...
 
int hal_i2c_set_tmo (void *hdl, uint32_t tmo)
 Set the I2c timeout. More...
 

Detailed Description

HAL_I2C.

Function Documentation

◆ hal_i2c_close()

void hal_i2c_close ( void *  hdl)

Close the I2c driver.

Parameters
[in]hdlThe handle from the previous "open" function.
Returns
This function has no return.

◆ hal_i2c_open()

void* hal_i2c_open ( int  id,
i2c_init_t *  init 
)

Open the I2c driver.

Parameters
[in]idThe I2c controller ID,
See also
enum i2c_id.
Parameters
[in]initThe I2c initialization structure,
See also
struct i2c_init.
Returns
Handle to the I2c driver, NULL means open failed.

◆ hal_i2c_set_tmo()

int hal_i2c_set_tmo ( void *  hdl,
uint32_t  tmo 
)

Set the I2c timeout.

Parameters
[in]hdlThe handle from the previous "open" function.
[in]tmoTimeout in ms.
Returns
See also
enum i2c_error for the possible return code.

◆ hal_mi2c_mix_tran_continue_poll()

int hal_mi2c_mix_tran_continue_poll ( void *  hdl,
uint8_t  tar,
int  dir_write,
int  restart,
uint8_t *  buffer,
uint16_t  buffer_len 
)

Continue of I2c master read/write mixed function.

Parameters
[in]hdlThe handle from the previous "open" function.
[in]tarThe slave address.
[in]dir_writeDirection of the transaction on the I2C bus, 1: Write, 0: Read
[in]restartIssue a new start condition on the I2C bus, 1: Generate Re-Start bit, 0: informs the master function to continue to the next operation. This must done after writing transmit data or reading received data.
[in]bufferThe pointer to the transaction buffer.
[in]buffer_lenThe transaction buffer length.
Returns
See also
enum i2c_error for the possible return code.

◆ hal_mi2c_mix_tran_end_poll()

int hal_mi2c_mix_tran_end_poll ( void *  hdl,
uint8_t  tar,
int  dir_write,
int  restart,
uint8_t *  buffer,
uint16_t  buffer_len 
)

End of I2c master read/write mixed function.

Parameters
[in]hdlThe handle from the previous "open" function.
[in]tarThe slave address.
[in]dir_writeDirection of the last transaction on the I2C bus, 1: Write, 0: Read
[in]restartIssue a new start condition on the I2C bus, 1: Generate a re-start bit, 0: informs the master function to continue to the next operation. This must done after writing transmit data or reading received data.
[in]bufferThe pointer to the transaction buffer.
[in]buffer_lenThe transaction buffer length.
Returns
See also
enum i2c_error for the possible return code.

◆ hal_mi2c_mix_tran_start_poll()

int hal_mi2c_mix_tran_start_poll ( void *  hdl,
int  speed,
uint8_t  tar,
int  dir_write,
uint8_t *  buffer,
uint16_t  buffer_len 
)

Start of I2c master read/write mixed function.

Parameters
[in]hdlThe handle from the previous "open" function.
[in]speedThe I2c serial clock rate,
See also
enum i2c_scl.
Parameters
[in]tarThe slave address.
[in]dir_writeDirection of the first transaction on the I2C bus, 1: Write, 0: Read
[in]bufferThe pointer to the transaction buffer.
[in]buffer_lenThe transaction buffer length.
Returns
See also
enum i2c_error for the possible return code.

◆ hal_mi2c_read()

int hal_mi2c_read ( void *  hdl,
uint8_t  tar,
uint8_t *  buffer,
uint16_t  buffer_len 
)

I2c master read function.

Parameters
[in]hdlThe handle from the previous "open" function.
[in]tarThe slave address.
[in]bufferThe pointer to the received buffer.
[in]buffer_lenThe receive buffer length.
Returns
See also
enum i2c_error for the possible return code.

◆ hal_mi2c_write()

int hal_mi2c_write ( void *  hdl,
uint8_t  tar,
uint8_t *  buffer,
uint16_t  buffer_len 
)

I2c master write function.

Parameters
[in]hdlThe handle from the previous "open" function.
[in]tarThe slave address.
[in]bufferThe pointer to the transmit buffer.
[in]buffer_lenThe transmit buffer length.
Returns
See also
enum i2c_error for the possible return code.

◆ hal_mi2c_write_read()

int hal_mi2c_write_read ( void *  hdl,
uint8_t  tar,
uint8_t *  wr_buf,
uint16_t  wr_len,
uint8_t *  rd_buf,
uint16_t  rd_len 
)

I2c master write and read function.

Note
This function write wr_len bytes, then read rd_len bytes. It doesn't send STOP after write.
Parameters
[in]hdlThe handle from the previous "open" function.
[in]tarThe slave address.
[in]wr_bufThe pointer to the write buffer.
[in]wr_lenThe write buffer length.
[out]rd_bufThe pointer to the read buffer.
[in]rd_lenThe read buffer length.
Returns
See also
enum i2c_error for the possible return code.

◆ hal_si2c_read()

int hal_si2c_read ( void *  hdl,
uint8_t  sar,
uint8_t *  buffer,
uint16_t  buffer_len 
)

I2c slave read function.

Parameters
[in]hdlThe handle from the previous "open" function.
[in]sarThe slave address.
[in]bufferThe pointer to the receive buffer.
[in]buffer_lenThe receive buffer length.
Returns
See also
enum i2c_error for the possible return code.

◆ hal_si2c_write()

int hal_si2c_write ( void *  hdl,
uint8_t  sar,
uint8_t *  buffer,
uint16_t  buffer_len 
)

I2c slave write function.

Parameters
[in]hdlThe handle from the previous "open" function.
[in]sarThe slave address.
[in]bufferThe pointer to the transmit buffer.
[in]buffer_lenThe transmit buffer length.
Returns
See also
enum i2c_error for the possible return code.