Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
humid_sht.h
Go to the documentation of this file.
1 #ifndef HUMID_SHT_H
2 #define HUMID_SHT_H
3 
4 #include "std.h"
5 
6 #ifdef STM32
7 #error LPC21_only
8 #endif
9 
10 /* GPIO P0.x defaults */
11 #ifndef DAT_PIN
12 /* ADC1 Port, ADC_4, P0.30 */
13 #define DAT_PIN 30
14 /* IRH Port, IRH_2, P0.25 */
15 // #define DAT_PIN 25
16 #endif
17 
18 #ifndef SCK_PIN
19 /* ADC1 Port, ADC_3, P0.4 */
20 #define SCK_PIN 4
21 /* IRH Port, IRH_1, P0.22 */
22 // #define SCK_PIN 22
23 #endif
24 
25 #define noACK 0
26 #define ACK 1
27 #define TEMP 0
28 #define HUMI 1
29 
30 //adr command r/w
31 //000 0011 0
32 #define STATUS_REG_W 0x06
33 //000 0011 1
34 #define STATUS_REG_R 0x07
35 //000 0001 1
36 #define MEASURE_TEMP 0x03
37 //000 0010 1
38 #define MEASURE_HUMI 0x05
39 //000 1111 0
40 #define RESET 0x1e
41 
42 // set data pin to input and set to low
43 #define DATA_INIT (IO0DIR &= ~(_BV(DAT_PIN)); IO0CLR=_BV(DAT_PIN))
44 // set data pin to input
45 #define DATA_SET (IO0DIR &= ~(_BV(DAT_PIN)))
46 // set data pin to output
47 #define DATA_CLR (IO0DIR |= _BV(DAT_PIN))
48 // get data pin
49 #define DATA_IN ((IO0PIN & _BV(DAT_PIN))>>DAT_PIN)
50 
51 // set clock pin to output and set to low
52 #define SCK_INIT (IO0DIR=_BV(SCK_PIN); IO0CLR=_BV(SCK_PIN))
53 // set clock pin to high
54 #define SCK_SET (IO0SET=_BV(SCK_PIN))
55 // set clock pin to low
56 #define SCK_CLR (IO0CLR=_BV(SCK_PIN))
57 
58 #define SHT_IDLE 0
59 #define SHT_MEASURING_HUMID 1
60 #define SHT_MEASURING_TEMP 2
61 
62 extern uint16_t humidsht, tempsht;
63 extern float fhumidsht, ftempsht;
64 extern bool_t humid_sht_available;
66 
67 void humid_sht_init( void );
68 void humid_sht_periodic(void);
69 
70 #endif /* HUMID_SHT_H */
void humid_sht_periodic(void)
Definition: humid_sht.c:285
unsigned short uint16_t
Definition: types.h:16
uint16_t humidsht
Definition: humid_sht.c:22
bool_t humid_sht_available
Definition: humid_sht.c:24
float fhumidsht
Definition: humid_sht.c:23
unsigned char uint8_t
Definition: types.h:14
uint8_t humid_sht_status
Definition: humid_sht.c:25
uint16_t tempsht
Definition: humid_sht.c:22
void humid_sht_init(void)
Definition: humid_sht.c:238
float ftempsht
Definition: humid_sht.c:23