binary Clock
Functions
i2c_drvr_4313.c File Reference

Low level I2C driver functions for the ATtiny4313. More...

#include "i2c_drvr_4313.h"
#include "i2c.h"
#include <avr/io.h>
#include <avr/cpufunc.h>
#include <stdint.h>

Functions

retval_t check_ack (void)
 
void set_SDA (uint8_t val)
 
void set_SCL (uint8_t val)
 
uint8_t read_SDA (void)
 
void write_ack (uint8_t val)
 
retval_t i2c_drvr_init (void)
 
retval_t i2c_drvr_start (uint8_t addr_with_mode)
 
retval_t i2c_drvr_end (void)
 
retval_t i2c_drvr_write_byte (uint8_t byte_to_tx)
 
retval_t i2c_drvr_read_byte (uint8_t *byte_read_ptr, uint8_t ack)
 

Detailed Description

Low level I2C driver functions for the ATtiny4313.

Function Documentation

◆ check_ack()

retval_t check_ack ( void  )

Checks is the slave asserts an acknowledge condition on the I2C bus.

Parameters
[out]retval(retval_t): Returns if the slave acknowledged.

◆ i2c_drvr_end()

retval_t i2c_drvr_end ( void  )

Creates an end condition and returns if it was successful.

Parameters
[out]retval(retval_t): Returns if the end condition worked.

◆ i2c_drvr_init()

retval_t i2c_drvr_init ( void  )

Initializes the I2C lines.

Parameters
[out]retval(retval_t): Returns if the initialization worked.

◆ i2c_drvr_read_byte()

retval_t i2c_drvr_read_byte ( uint8_t *  byte_read_ptr,
uint8_t  ack 
)

Reads a byte of information to from the I2C line.

Parameters
[in]byte_read_ptr(uint8_t *): Location to return the read back value.
[in]ack(uint8_t): Whether or not to acknowledge the byte.
[out]retval(retval_t): Returns if the read was successful.

◆ i2c_drvr_start()

retval_t i2c_drvr_start ( uint8_t  addr_with_mode)

Creates a start condition, addresses the chip and returns if it was successful.

Parameters
[in]addr_with_mode(uint8_t): Address of the chip with mode set.
[out]retval(retval_t): Returns if the start condition worked.

◆ i2c_drvr_write_byte()

retval_t i2c_drvr_write_byte ( uint8_t  byte_to_tx)

Writes a byte of information to the I2C line.

Parameters
[in]byte_to_tx(uint8_t): Byte to transmit.
[out]retval(retval_t): Returns if the byte write was acknowledged.

◆ read_SDA()

uint8_t read_SDA ( void  )

Reads the state of the SDA line.

Parameters
[out]SDA_state(uint8_t): State of the SDA line.

◆ set_SCL()

void set_SCL ( uint8_t  val)

Drives the SCL line low or lets it go high.

Parameters
[in]val(uint8_t): Value to set the SCL line to. (high or low)

◆ set_SDA()

void set_SDA ( uint8_t  val)

Drives the SDA line low or lets it go high.

Parameters
[in]val(uint8_t): Value to set the SDA line to. (high or low)

◆ write_ack()

void write_ack ( uint8_t  val)

Writes an acknowledge or neg-ack to the I2C bus.

Parameters
[in]ack(uint8_t): Whether or not to acknowledge
[out]retval(retval_t): Returns if the read was successful.