/*
 Author: Obrtac Tomas  
 Mail: obrtac.tomas@gmail.com
 2017
 */


#ifndef SHT75
#define	SHT75

#include <xc.h> // include processor files - each processor file is guarded.  
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <math.h>

#define READ_WAIT    20
#define	LOW_DATA     LATD2=0
#define CAPTURE_DATA TRISD2=0
			
#define RELEASE_DATA TRISD2=1
#define DATA         RD2
#define	SCK          LATD3
#define LOW_SCK      TRISD3=0
#define SCK_UP       TRISD3=1 
#define DATA_LAT     LATD2

#define noACK 0
#define ACK   1
                            //adr  command  r/w
#define STATUS_REG_W 0x06   //000   0011    0
#define STATUS_REG_R 0x07   //000   0011    1
#define MEASURE_TEMP 0x03   //000   0001    1
#define MEASURE_HUMI 0x05   //000   0010    1
#define SHT_RESET    0x1e   //000   1111    0

#define _XTAL_FREQ 20000000


uint16_t SHT_Read_Humidity(void);
uint16_t SHT_Read_Temperature(void);
float SHT75_Humidity(void);
float SHT75_Temperature(void);
float SHT_Humidity_With_Compensation(float temperature);
unsigned char s_Write_ByteSHT(unsigned char value);
unsigned char s_Read_ByteSHT(unsigned char ack);
void Send_StartBit_SHT75(void);
void SHT75_Configuration(void);
void Send_I2C_ACK(void);
void Send_I2C_NAK(void);

#endif	/* XC_HEADER_TEMPLATE_H */

