Contiki 3.x
ms-io.h
1 /**
2  * Common mountain sensing interface to all sensors.
3  */
4 #ifndef MS_IO_H
5 #define MS_IO_H
6 
7 #include <stdint.h>
8 #include <stdbool.h>
9 
10 /**
11  * Epoch indicating an error occured.
12  */
13 #define ERROR_EPOCH 12345
14 
15 /**
16  * Initialize any hardware required for sampling,
17  * and disable sense power.
18  */
19 void ms_init(void);
20 
21 /**
22  * Turn on power to external sensors.
23  */
24 void ms_sense_on(void);
25 
26 /**
27  * Turn off power to external sensors.
28  */
29 void ms_sense_off(void);
30 
31 /**
32  * Get the current time.
33  * @param seconds Pointer to write the number of seconds since the Unix epoch. On error, ERROR_EPOCH will be written to it.
34  * @return True on success, False otherwise
35  *
36  * @note Unix epoch is taken as 1970-01-01 00:00:00 UTC.
37  */
38 bool ms_get_time(uint32_t *seconds);
39 
40 /**
41  * Set the current time.
42  * @param seconds The number of seconds since the Unix epoch.
43  * @return True on success, False otherwise
44  *
45  * @note Unix epoch is taken as 1970-01-01 00:00:00 UTC.
46  */
47 bool ms_set_time(uint32_t seconds);
48 
49 /**
50  * Get the battery voltage, in V.
51  * @param batt Pointer to write the battery voltage to
52  * @return True on success, False otherwise
53  */
54 bool ms_get_batt(float *batt);
55 
56 /**
57  * Get the temperature, in degrees Celcius.
58  * @param temp Pointer to write the temperature to
59  * @return True on success, False otherwise
60  */
61 bool ms_get_temp(float *temp);
62 
63 /**
64  * Get the humidit, in percentage.
65  * @param humid Pointer to write the humidity to
66  * @return True on success, False otherwise
67  */
68 bool ms_get_humid(float *humid);
69 
70 /**
71  * Get the value of adc1.
72  * @param adc1 Pointer to write the value of adc1 to
73  * @return True on success, False otherwise
74  */
75 bool ms_get_adc1(uint32_t *adc1);
76 
77 /**
78  * Get the value of adc2
79  * @param adc2 Pointer to write the value of adc2 to
80  * @return True on success, False otherwise
81  */
82 bool ms_get_adc2(uint32_t *adc2);
83 
84 /**
85  * Get the number of rain bucket tips, and reset the count.
86  * @param rain Pointer to write the rain tips to
87  * @return True on success, False otherwise
88  */
89 bool ms_get_rain(uint32_t *rain);
90 
91 /**
92  * Get the value of the accelerometers.
93  * @param x Pointer to write the x axis acceleration to
94  * @param y Pointer to write the y axis acceleration to
95  * @param z Pointer to write the z axis acceleration to
96  * @return True on success, False otherwise
97  */
98 bool ms_get_acc(int32_t *x, int32_t *y, int32_t *z);
99 
100 /**
101  * Get the number of reboot counts.
102  * Depending on the implementation, this could either be the
103  * number of reboots since flash, or since ms_reset_reboot was called.
104  */
105 bool ms_get_reboot(uint16_t *reboot);
106 
107 /**
108  * Reset the reboot counter.
109  */
110 bool ms_reset_reboot(void);
111 
112 #endif // #ifndef MS_IO_ARCH_H