MiraOS  1.22
Enumerations | Functions
mira_i2c.h File Reference

MiraOS I2C driver. More...

#include <stdint.h>

Go to the source code of this file.

Enumerations

enum  MiraI2CSpeed { MIRA_I2C_NORMAL_BUS_SPEED = 100000, MIRA_I2C_FAST_BUS_SPEED = 400000 }
 Supported I2C bus speeds. More...
 
enum  MiraI2CPullupMode { MIRA_I2C_NO_PULLUPS = 0, MIRA_I2C_USE_PULLUPS = 1 }
 Supported pull-up options for the I2C bus. More...
 
enum  MiraI2CErrorCodeFlags {
  MIRA_I2C_MASTER_ERR_NONE = 0x00, MIRA_I2C_MASTER_ERR_ADDR_ACK = 0x04, MIRA_I2C_MASTER_ERR_DATA_ACK = 0x08, MIRA_I2C_MASTER_ERR_ARB_LOST = 0x10,
  MIRA_I2C_MASTER_ERR_TIMEOUT = 0x80
}
 Error codes for I2C master. Note that combination of errors can exist, in that case error codes are OR'd in the result code. More...
 

Functions

void mira_i2c_init (MiraI2CSpeed speed, MiraI2CPullupMode pullups)
 Initialize the I2C driver. More...
 
MiraI2CErrorCodeFlags mira_i2c_single_send (uint8_t address, uint8_t data)
 Send a single byte. More...
 
MiraI2CErrorCodeFlags mira_i2c_single_receive (uint8_t address, uint8_t *data_pointer)
 Receive a single byte. More...
 
MiraI2CErrorCodeFlags mira_i2c_burst_send (uint8_t address, uint8_t *data_pointer, uint8_t length)
 Send multiple bytes. More...
 
MiraI2CErrorCodeFlags mira_i2c_burst_receive (uint8_t address, uint8_t *data_pointer, uint8_t length)
 Receive multiple bytes. More...
 
MiraI2CErrorCodeFlags mira_i2c_generic_single_send (uint8_t address, uint8_t data, uint8_t send_start_and_address, uint8_t send_stop)
 Send a byte with optional start and stop conditions. Send a byte with optional start and stop conditions. A transmission can only occur if a start condition is sent or if a transmission previously has been initiated by sending a start condition. More...
 
MiraI2CErrorCodeFlags mira_i2c_generic_single_receive (uint8_t address, uint8_t *data_pointer, uint8_t send_start_and_address, uint8_t send_stop)
 Read a byte with optional start and stop conditions. Read a byte with optional start and stop conditions. A transmission can only occur if a start condition is sent or if a transmission previously has been initiated by sending a start condition. More...
 

Detailed Description

MiraOS I2C driver.

Author
LumenRadio AB
Date
19 Aug 2016 The MiraOS library provides functions for controlling the Mira radio module, sending/receiving messages, controlling peripherals, etc.
See also
http://docs.lumenrad.io/mira

Enumeration Type Documentation

Error codes for I2C master. Note that combination of errors can exist, in that case error codes are OR'd in the result code.

Enumerator
MIRA_I2C_MASTER_ERR_NONE 

Success

MIRA_I2C_MASTER_ERR_ADDR_ACK 

No ack on address

MIRA_I2C_MASTER_ERR_DATA_ACK 

No ack on data

MIRA_I2C_MASTER_ERR_ARB_LOST 

Arbitration lost

MIRA_I2C_MASTER_ERR_TIMEOUT 

Transmission timed out after 225 ms

Supported pull-up options for the I2C bus.

Enumerator
MIRA_I2C_NO_PULLUPS 

Do not enable internal pull-ups (external pull-up must be present)

MIRA_I2C_USE_PULLUPS 

Enable internal pull-ups

Supported I2C bus speeds.

Enumerator
MIRA_I2C_NORMAL_BUS_SPEED 

100KHz I2C

MIRA_I2C_FAST_BUS_SPEED 

400KHz I2C

Function Documentation

MiraI2CErrorCodeFlags mira_i2c_burst_receive ( uint8_t  address,
uint8_t *  data_pointer,
uint8_t  length 
)

Receive multiple bytes.

Parameters
address7 bit I2C chip address (without R/W bit)
data_pointerpointer to where to write received byte
lengthnumber of bytes
Returns
MiraI2CErrorCodeFlags
MiraI2CErrorCodeFlags mira_i2c_burst_send ( uint8_t  address,
uint8_t *  data_pointer,
uint8_t  length 
)

Send multiple bytes.

Parameters
address7 bit I2C chip address (without R/W bit)
data_pointerpointer to data to send
lengthnumber of bytes
Returns
MiraI2CErrorCodeFlags
MiraI2CErrorCodeFlags mira_i2c_generic_single_receive ( uint8_t  address,
uint8_t *  data_pointer,
uint8_t  send_start_and_address,
uint8_t  send_stop 
)

Read a byte with optional start and stop conditions. Read a byte with optional start and stop conditions. A transmission can only occur if a start condition is sent or if a transmission previously has been initiated by sending a start condition.

Parameters
address7 bit I2C chip address (without R/W bit)
data_pointerpointer to where to write received byte
send_start_and_addresssend a start condition and address before the data is received
send_stopsend a stop condition after the data has been received
Returns
MiraI2CErrorCodeFlags
MiraI2CErrorCodeFlags mira_i2c_generic_single_send ( uint8_t  address,
uint8_t  data,
uint8_t  send_start_and_address,
uint8_t  send_stop 
)

Send a byte with optional start and stop conditions. Send a byte with optional start and stop conditions. A transmission can only occur if a start condition is sent or if a transmission previously has been initiated by sending a start condition.

Parameters
address7 bit I2C chip address (without R/W bit)
datadata byte to send
send_start_and_addresssend a start condition and address before the data is sent
send_stopsend a stop condition after the data has been sent
Returns
void
void mira_i2c_init ( MiraI2CSpeed  speed,
MiraI2CPullupMode  pullups 
)

Initialize the I2C driver.

Parameters
speedBus speed
pullupsUse internal pull-ups
Returns
void
MiraI2CErrorCodeFlags mira_i2c_single_receive ( uint8_t  address,
uint8_t *  data_pointer 
)

Receive a single byte.

Parameters
address7 bit I2C chip address (without R/W bit)
data_pointerpointer to where to write received byte
Returns
MiraI2CErrorCodeFlags
MiraI2CErrorCodeFlags mira_i2c_single_send ( uint8_t  address,
uint8_t  data 
)

Send a single byte.

Parameters
address7 bit I2C chip address (without R/W bit)
datadata byte to send
Returns
void