Uzetherm
Speaking thermometer with video output
Defines | Functions
i2c_software_master.c File Reference

I2C software master source code. More...

#include <avr/io.h>
#include <util/delay.h>
#include "kernel/uzebox.h"
Include dependency graph for i2c_software_master.c:

Defines

#define F_CPU   28000000UL
#define I2C_DDR   DDRD
 register definition for I2C communication
#define I2C_DDR_REG_BIT   DDD5
 SDA port definiton to set port direction.
#define I2C_PORT   PORTD
 I2C output port register.
#define SCL   PD3
 I2C clock port (SCL) definition.
#define SDA   PD5
 I2C data port (SDA) definition.
#define SDA_LESE_PIN   PIND
 I2C input port register.
#define SDA_LESE_BIT   SDA
 I2C input port signal.
#define I2C_SCL_LOW   I2C_PORT &= ~(1 << SCL)
#define I2C_SCL_HIGH   I2C_PORT |= (1 << SCL)
#define I2C_SDA_LOW   sda_low()
#define I2C_SDA_HIGH   sda_high()
#define ACK   0
#define NACK   1
#define S_DELAY   _delay_loop_1(10);
#define M_DELAY   _delay_us(10);
#define DELAY   _delay_ms(10);

Functions

void sda_low ()
void sda_high ()
unsigned char i2c_try_scl (unsigned char start_trials)
void i2c_master_stop (void)
void i2c_master_init (void)
void i2c_master_clk_toggle (void)
void i2c_master_start (void)
unsigned char i2c_master_write (unsigned char b)
unsigned char i2c_master_read (unsigned char a)

Detailed Description

I2C software master source code.

Author:
Artur Funk a_funk80@yahoo.de
Date:
16.11.2007

Function Documentation

void i2c_master_clk_toggle ( void  )

toggle clock signal (SCL)

Parameters:
void
Returns:
none

Here is the call graph for this function:

Here is the caller graph for this function:

void i2c_master_init ( void  )

init I2C master

Parameters:
void
Returns:
none

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned char i2c_master_read ( unsigned char  a)

read one byte from I2C device

Parameters:
statusof stop condition ACK or NACK
Returns:
byte read from I2C device

Here is the call graph for this function:

Here is the caller graph for this function:

void i2c_master_start ( void  )

start I2C master

Parameters:
void
Returns:
none

Here is the call graph for this function:

Here is the caller graph for this function:

void i2c_master_stop ( void  )

stop I2C master

Parameters:
void
Returns:
none

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned char i2c_master_write ( unsigned char  b)

Send one byte to I2C device

Parameters:
databyte to be transfered
Returns:
status of stop condition ACK or NACK

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned char i2c_try_scl ( unsigned char  start_trials)

wait 50 times if SCL is hold to low

Parameters:
startvalue
Return values:
0SCL is low
1SCL is high

Here is the caller graph for this function:

void sda_high ( )

set data signal high (input)

Parameters:
void
Returns:
none
void sda_low ( )

set data signal low (output)

Parameters:
void
Returns:
none
 All Data Structures Files Functions Variables Defines