Contiki-NG
Files | Macros | Functions

Files

file  board-i2c.c
 Board-specific I2C driver for the Sensortags.
 
file  board-i2c.h
 Header file for the Sensortag I2C Driver.
 

Macros

#define board_i2c_deselect()   board_i2c_select(BOARD_I2C_INTERFACE_0, 0)
 Put the I2C controller in a known state. More...
 

Functions

void board_i2c_wakeup (void)
 Enables the I2C peripheral with defaults. More...
 
void board_i2c_shutdown (void)
 Stops the I2C peripheral and restores pins to s/w control. More...
 
bool board_i2c_write (uint8_t *buf, uint8_t len)
 Burst write to an I2C device. More...
 
bool board_i2c_write_single (uint8_t data)
 Single write to an I2C device. More...
 
bool board_i2c_read (uint8_t *buf, uint8_t len)
 Burst read from an I2C device. More...
 
bool board_i2c_write_read (uint8_t *wdata, uint8_t wlen, uint8_t *rdata, uint8_t rlen)
 Write and read in one operation. More...
 
void board_i2c_select (uint8_t interface, uint8_t slave_addr)
 Select an I2C slave. More...
 

Detailed Description

Macro Definition Documentation

◆ board_i2c_deselect

#define board_i2c_deselect ( )    board_i2c_select(BOARD_I2C_INTERFACE_0, 0)

Put the I2C controller in a known state.

In this state, pins SDA and SCL will be under i2c control and pins SDA HP and SCL HP will be configured as gpio inputs. This is equal to selecting BOARD_I2C_INTERFACE_0, but without selecting a slave device address

Definition at line 58 of file board-i2c.h.

Function Documentation

◆ board_i2c_read()

bool board_i2c_read ( uint8_t *  buf,
uint8_t  len 
)

Burst read from an I2C device.

Parameters
bufPointer to a buffer where the read data will be stored
lenNumber of bytes to read
Returns
True on success

Definition at line 207 of file board-i2c.c.

◆ board_i2c_select()

void board_i2c_select ( uint8_t  interface,
uint8_t  slave_addr 
)

Select an I2C slave.

Parameters
interfaceThe I2C interface to be used (BOARD_I2C_INTERFACE_0 or _1)
slave_addrThe slave's address

The various sensors on the sensortag are connected either on interface 0 or

  1. All sensors are connected to interface 0, with the exception of the MPU that is connected to 1.

Definition at line 310 of file board-i2c.c.

Referenced by select_on_bus().

◆ board_i2c_shutdown()

void board_i2c_shutdown ( void  )

Stops the I2C peripheral and restores pins to s/w control.

This function is called automatically by the board's LPM logic, but it can also be called explicitly.

Definition at line 114 of file board-i2c.c.

◆ board_i2c_wakeup()

void board_i2c_wakeup ( void  )

Enables the I2C peripheral with defaults.

This function is called to wakeup and initialise the I2C.

This function can be called explicitly, but it will also be called automatically by board_i2c_select() when required. One of those two functions MUST be called before any other I2C operation after a chip sleep / wakeup cycle or after a call to board_i2c_shutdown(). Failing to do so will lead to a bus fault.

Definition at line 83 of file board-i2c.c.

◆ board_i2c_write()

bool board_i2c_write ( uint8_t *  buf,
uint8_t  len 
)

Burst write to an I2C device.

Parameters
bufPointer to the buffer to be written
lenNumber of bytes to write
Returns
True on success

Definition at line 145 of file board-i2c.c.

◆ board_i2c_write_read()

bool board_i2c_write_read ( uint8_t *  wdata,
uint8_t  wlen,
uint8_t *  rdata,
uint8_t  rlen 
)

Write and read in one operation.

Parameters
wdataPointer to the buffer to be written
wlenNumber of bytes to write
rdataPointer to a buffer where the read data will be stored
rlenNumber of bytes to read
Returns
True on success

Definition at line 247 of file board-i2c.c.

◆ board_i2c_write_single()

bool board_i2c_write_single ( uint8_t  data)

Single write to an I2C device.

Parameters
dataThe byte to write
Returns
True on success

Definition at line 188 of file board-i2c.c.