Open Garden  0.10.1-21
Macros | Functions
i2c.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define START   1
 
#define STOP   2
 
#define SLA   3
 
#define DATA   4
 
#define ACK   5
 
#define NACK   6
 
#define WRITE   0
 
#define READ   1
 

Functions

uint8_t i2c_send (const uint8_t code, const uint8_t data)
 
void i2c_init (void)
 
void i2c_shut (void)
 
uint8_t i2c_master_send_b (const uint8_t addr, const uint8_t data)
 
uint8_t i2c_master_send_w (const uint8_t addr, const uint8_t msb, const uint8_t lsb)
 i2c master send a word. Send a word to the i2c slave with stop at the end. More...
 
uint8_t i2c_master_read_b (const uint8_t addr, uint8_t *byte)
 i2c master read byte. More...
 
uint8_t i2c_master_read_w (const uint8_t addr, uint16_t *code)
 

Macro Definition Documentation

◆ ACK

#define ACK   5

define the i2c ACK value

◆ DATA

#define DATA   4

define the i2c DATA value

◆ NACK

#define NACK   6

define the i2c NACK value

◆ READ

#define READ   1

define READ value

◆ SLA

#define SLA   3

define the i2c SLA value

◆ START

#define START   1

define the i2c START value

◆ STOP

#define STOP   2

define the i2c STOP value

◆ WRITE

#define WRITE   0

define WRITE value

Function Documentation

◆ i2c_init()

void i2c_init ( void  )

Initialize the i2c bus

◆ i2c_master_read_b()

uint8_t i2c_master_read_b ( const uint8_t  addr,
uint8_t *  byte 
)

i2c master read byte.

Read a byte from the slave with a stop at the end.

Parameters
addraddress of the slave.
byteptr to a pre-allocated byte.
Returns
1 - value OK, 0 - Error.

◆ i2c_master_read_w()

uint8_t i2c_master_read_w ( const uint8_t  addr,
uint16_t *  code 
)

Read a word (2 byte) from the slave.

Parameters
addraddress of the slave.
codeptr to a pre-allocated word.
Returns
1 - value OK, 0 - Error.

◆ i2c_master_send_b()

uint8_t i2c_master_send_b ( const uint8_t  addr,
const uint8_t  data 
)

Send a byte to the i2c slave.

Parameters
addraddress of the slave.
databyte to send.

◆ i2c_master_send_w()

uint8_t i2c_master_send_w ( const uint8_t  addr,
const uint8_t  msb,
const uint8_t  lsb 
)

i2c master send a word. Send a word to the i2c slave with stop at the end.

Parameters
addraddress of the slave.
msbbyte to send first.
lsbbyte to send last.
Returns
0 - OK, 1 - Error

◆ i2c_send()

uint8_t i2c_send ( const uint8_t  code,
const uint8_t  data 
)

Send the i2c status to the bus.

Parameters
codethe i2c code to send.
datathe byte to send.

◆ i2c_shut()

void i2c_shut ( void  )

Shutdown the i2c bus