/*! \file 
*	\details This is header file for SRF08 handling.
*
*	\ingroup WheelchairControl
*	@{
*
*	\defgroup SRF08 SRF08 ultrasonic range finders.
*	\details Library functions for handling SRF08 range finders.
*
*	\addtogroup SRF08
*	@{
*/

#ifndef _SRF08	//define once
#define _SRF08

//Libraries
#include "Defines.h"
#include <util/twi.h>

//Functions

/*!
* Initializes I2C.
*/
void I2C_Init(void);

/*!
* Sends stop sequence.
*/ 
void I2C_Stop(void);

/*!
* Sends start sequence and addresses device.
*/ 
uint8_t I2C_Start(uint8_t addr);

/*!
* Writes data to the previously addressed device.
*/ 
uint8_t I2C_Write(uint8_t data);

/*!
* Reads data from the previously addressed device, generates ACK bit.
*/ 
uint8_t I2C_ReadAck(void);	

/*!
* Reads data from the previously addressed device, generates NACK bit.
*/ 
uint8_t I2C_ReadNak(void);	

/*!
* Writes data to the register of the assigned device.
*
* \param address Device address.
* \param reg Device register to write to. 
* \param data 1 byte of data to write.
* \returns FALSE if write is successful / TRUE if write fails.	
*/ 
uint8_t SRF08_Write(uint8_t address, uint8_t reg, uint8_t data); 

/*!
* Reads data from the register of the assigned device.
*
* \param address Device address.
* \param reg Device register to read from.
* \returns Data from the register / 0 on error.
*/ 
uint8_t SRF08_Read(uint8_t address, uint8_t reg);

#endif //_SRF_08
/*! @} */
/*! @} */
