Contiki-NG
Loading...
Searching...
No Matches

Files

file  i2c-arch.c
 Implementation of the I2C HAL driver for CC13xx/CC26xx.
 
file  i2c-arch.h
 Implementation of the I2C HAL driver for CC13xx/CC26xx.
 

Functions

bool i2c_arch_write_read (I2C_Handle i2c_handle, uint_least8_t slave_addr, void *wbuf, size_t wcount, void *rbuf, size_t rcount)
 Setup and peform an I2C transaction.
 
void i2c_arch_release (I2C_Handle i2c_handle)
 Release the I2C Peripheral for other modules to use.
 
I2C_Handle i2c_arch_acquire (uint_least8_t index)
 Open and lock the I2C Peripheral for use.
 
static void i2c_arch_init (void)
 One-time initialisation of the I2C Driver.
 
static bool i2c_arch_write (I2C_Handle i2c_handle, uint_least8_t slave_addr, void *wbuf, size_t wcount)
 Perform a write-only I2C transaction.
 
static bool i2c_arch_read (I2C_Handle i2c_handle, uint_least8_t slave_addr, void *rbuf, size_t rcount)
 Perform a read-only I2C transaction.
 

Detailed Description

Function Documentation

◆ i2c_arch_acquire()

I2C_Handle i2c_arch_acquire ( uint_least8_t index)

Open and lock the I2C Peripheral for use.

Parameters
indexThe index of the I2C controller
Returns
An I2C Handle if successful, or NULL if an error occurs

Must be called before each I2C transaction.

When the function returns successfully, i2c_handle will be non-NULL and can be used in subsequent calls to perform an I2C transaction, for example with i2c_arch_write_read().

index can take values among Board_I2Cx e.g. Board_I2C0

At the end of the transaction, the caller should call i2c_arch_release() in order to allow other code files to use the I2C module

Definition at line 84 of file i2c-arch.c.

Referenced by configure(), enable_sensor(), enable_sensor(), init(), notify_ready(), notify_ready_cb(), read_data(), read_data(), sensor_enable(), sensor_init(), start(), value(), and value().

◆ i2c_arch_init()

static void i2c_arch_init ( void )
inlinestatic

One-time initialisation of the I2C Driver.

This function must be called before any other I2C driver calls.

Definition at line 71 of file i2c-arch.h.

◆ i2c_arch_read()

static bool i2c_arch_read ( I2C_Handle i2c_handle,
uint_least8_t slave_addr,
void * rbuf,
size_t rcount )
inlinestatic

Perform a read-only I2C transaction.

Parameters
i2c_handleThe I2C handle to use for this transaction
slave_addrThe address of the slave device on the I2C bus
rbufInput buffer during the I2C transaction.
rcountHow many bytes to read into rbuf.
Return values
trueThe I2C operation was successful
falseThe I2C operation failed

Definition at line 144 of file i2c-arch.h.

References i2c_arch_write_read().

Referenced by notify_ready().

◆ i2c_arch_release()

void i2c_arch_release ( I2C_Handle i2c_handle)

Release the I2C Peripheral for other modules to use.

Parameters
i2c_handleA pointer to an I2C handle

Must be called after the end of each I2C transaction in order to allow other modules to use the I2C controller. The i2c_handle is obtained by an earlier call to i2c_arch_acquire()

Definition at line 74 of file i2c-arch.c.

Referenced by configure(), enable_sensor(), enable_sensor(), init(), notify_ready(), notify_ready_cb(), read_data(), read_data(), sensor_enable(), sensor_init(), start(), value(), and value().

◆ i2c_arch_write()

static bool i2c_arch_write ( I2C_Handle i2c_handle,
uint_least8_t slave_addr,
void * wbuf,
size_t wcount )
inlinestatic

Perform a write-only I2C transaction.

Parameters
i2c_handleThe I2C handle to use for this transaction
slave_addrThe address of the slave device on the I2C bus
wbufWrite buffer during the I2C transaction.
wcountHow many bytes in the write buffer
Return values
trueThe I2C operation was successful
falseThe I2C operation failed

Definition at line 128 of file i2c-arch.h.

References i2c_arch_write_read().

Referenced by enable_sensor(), enable_sensor(), init(), sensor_enable(), sensor_init(), sensor_sleep(), sensor_wakeup(), and start().

◆ i2c_arch_write_read()

bool i2c_arch_write_read ( I2C_Handle i2c_handle,
uint_least8_t slave_addr,
void * wbuf,
size_t wcount,
void * rbuf,
size_t rcount )

Setup and peform an I2C transaction.

Parameters
i2c_handleThe I2C handle to use for this transaction
slave_addrThe address of the slave device on the I2C bus
wbufWrite buffer during the I2C transation.
wcountHow many bytes in the write buffer
rbufInput buffer during the I2C transation.
rcountHow many bytes to read into rbuf.
Return values
trueThe I2C operation was successful
falseThe I2C operation failed

Definition at line 53 of file i2c-arch.c.

Referenced by acc_read(), gyro_read(), i2c_arch_read(), i2c_arch_write(), init(), notify_ready(), notify_ready_cb(), read_data(), read_data(), sensor_data_ready(), sensor_wakeup(), and value().