CLEON  Version 1
Cloud-Offloaded GPS Receiver
sys_sensors.h
Go to the documentation of this file.
1 
7 #ifndef __SYS_SENSORS_H__
8 #define __SYS_SENSORS_H__
9 
10 #define SIZE_OF_SENSOR_DATA_IN_BYTE 8
11 
15 //------------------------------- DATA & SCK -----------------------------------
16 #define SHT11_SDA_SET_TO_OUTPUT_PIN() (SENSOR_SHT11_PORT(DIR) |= BV(SENSOR_SHT11_SDA_PIN)) /* SDA Output=0 */
17 #define SHT11_SDA_SET_TO_INPUT_PIN() (SENSOR_SHT11_PORT(DIR) &= ~BV(SENSOR_SHT11_SDA_PIN)) /* SDA Input */
18 #define SHT11_IS_SDA_HIGH (SENSOR_SHT11_PORT(IN) & BV(SENSOR_SHT11_SDA_PIN))
19 
20 #define SHT11_SCL_LOW() (SENSOR_SHT11_PORT(OUT) &= ~BV(SENSOR_SHT11_SCL_PIN)) /* SCL Output=0 */
21 #define SHT11_SCL_HIGH() (SENSOR_SHT11_PORT(OUT) |= BV(SENSOR_SHT11_SCL_PIN)) /* SCL Output=1 */
22 
23 // (n * 1ms) delay @ 12MHz
24 #define SHT11_TIMING_DELAY(n) do{ \
25  for(int z = 0 ; z < n ; z++){ \
26  __delay_cycles(12000); \
27  } \
28 }while(0)
29 
30 //----------------------------- SHT11 commands ---------------------------------
31 #define STATUS_REG_W 0x06
32 #define STATUS_REG_R 0x07
33 #define MEASURE_TEMP 0x03
34 #define MEASURE_HUMI 0x05
35 #define RESET 0x1E
36 
37 typedef struct{
38  unsigned int uiTemperature; // 2 bytes
39  unsigned int uiHumidity; // 2 bytes
40  unsigned int uiLightTSR; // 2 bytes
41  unsigned int uiLightPAR; // 2 bytes
42 }sensors_s; // 8 bytes
43 
44 typedef union{
45  sensors_s stSensors; // 8 bytes
46  unsigned char ucSingleByte[8]; // 8 bytes
47 }cleon_sensor_data_u; // 8 bytes
48 
49 void SYS_SENSORS_Init(void);
50 void SYS_SENSORS_SHT11_Init(void);
51 void SYS_SENSORS_SHT11_On(void);
52 void SYS_SENSORS_SHT11_Off(void);
53 unsigned int SYS_SENSORS_SHT11_ReadTemperature(void);
54 unsigned int SYS_SENSORS_SHT11_ReadHumidity(void);
55 unsigned int SYS_SENSORS_SHT11_Command(unsigned char ucCommand);
56 
60 void SYS_SENSORS_S1087_Init(void);
61 unsigned int SYS_SENSORS_S1087_Read(void);
62 
66 void SYS_SENSORS_S108701_Init(void);
67 unsigned int SYS_SENSORS_S108701_Read(void);
68 
69 
70 #endif