PicoWAN SDK Documentation
Functions
i2c.h File Reference

I2C driver. More...

#include <stdint.h>
#include <arch.h>

Go to the source code of this file.

Functions

void i2c_init (i2c_port_t i2c_port, uint32_t speed)
 Initializes an I2C port. More...
 
void i2c_deinit (i2c_port_t i2c_port)
 De-initializes an I2C port. More...
 
void i2c_power_up (i2c_port_t i2c_port)
 Powers up an I2C port. More...
 
void i2c_power_down (i2c_port_t i2c_port)
 Powers down an I2C port. More...
 
void i2c_write (i2c_port_t i2c_port, uint8_t addr, uint8_t *data, uint8_t len)
 Writes/sends I2C data to the given address. More...
 
void i2c_read (i2c_port_t i2c_port, uint8_t addr, uint8_t *data, uint8_t len)
 Reads/receives I2C data from the given address. More...
 

Detailed Description

I2C driver.

Copyright (c) 2018, Archos S.A. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND AND EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARCHOS S.A. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

void i2c_deinit ( i2c_port_t  i2c_port)

De-initializes an I2C port.

Parameters
i2c_portThe I2C port (I2C_PORT_n).
void i2c_init ( i2c_port_t  i2c_port,
uint32_t  speed 
)

Initializes an I2C port.

Parameters
i2c_portThe I2C port to initialize (I2C_PORT_n).
speedThe I2C speed in Hz.
void i2c_power_down ( i2c_port_t  i2c_port)

Powers down an I2C port.

Note
This should be done after de-initializing it.
Parameters
i2c_portThe I2C port (I2C_PORT_n).
void i2c_power_up ( i2c_port_t  i2c_port)

Powers up an I2C port.

Note
This should be done before initializing it.
Parameters
i2c_portThe I2C port (I2C_PORT_n).
void i2c_read ( i2c_port_t  i2c_port,
uint8_t  addr,
uint8_t *  data,
uint8_t  len 
)

Reads/receives I2C data from the given address.

Parameters
i2c_portThe I2C port (I2C_PORT_n).
addrThe address of the device to read from.
dataA pointer to the buffer that will hold the data read.
lenThe length of the data to read in bytes.
void i2c_write ( i2c_port_t  i2c_port,
uint8_t  addr,
uint8_t *  data,
uint8_t  len 
)

Writes/sends I2C data to the given address.

Parameters
i2c_portThe I2C port (I2C_PORT_n).
addrThe address of the device to write to.
dataA pointer to the buffer holding the data to write.
lenThe length of the data to write in bytes.