File tree Expand file tree Collapse file tree 5 files changed +30
-23
lines changed Expand file tree Collapse file tree 5 files changed +30
-23
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ $(LIBNAME)_SRCS += $(wildcard $($(LIBNAME)_DIR)/kernel/*.c)
16
16
$(LIBNAME)_SRCS += $(wildcard $($(LIBNAME ) _DIR) /net/* .c)
17
17
$(LIBNAME)_SRCS += $(wildcard $($(LIBNAME ) _DIR) /peripherals/* .c)
18
18
$(LIBNAME)_SRCS += $(wildcard $($(LIBNAME ) _DIR) /sensors/* .c)
19
+ $(LIBNAME)_SRCS += $(wildcard $($(LIBNAME ) _DIR) /sensors/syscalls/* .c)
19
20
$(LIBNAME)_SRCS += $(wildcard $($(LIBNAME ) _DIR) /services/* .c)
20
21
$(LIBNAME)_SRCS += $(wildcard $($(LIBNAME ) _DIR) /storage/* .c)
21
22
Original file line number Diff line number Diff line change
1
+ #include "temperature_syscalls.h"
2
+
3
+ returncode_t libtocksync_temperature_yield_wait_for (int * temp ) {
4
+ yield_waitfor_return_t ret ;
5
+ ret = yield_wait_for (DRIVER_NUM_TEMPERATURE , 0 );
6
+
7
+ * temp = (int ) ret .data0 ;
8
+ return RETURNCODE_SUCCESS ;
9
+ }
Original file line number Diff line number Diff line change
1
+ #pragma once
2
+
3
+ #include <libtock/sensors/syscalls/temperature_syscalls.h>
4
+ #include <libtock/tock.h>
5
+
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ // Wait for a temperature read to finish.
11
+ returncode_t libtocksync_temperature_yield_wait_for (int * temp );
12
+
13
+ #ifdef __cplusplus
14
+ }
15
+ #endif
Original file line number Diff line number Diff line change 1
1
#include "temperature.h"
2
2
3
- struct data {
4
- bool fired ;
5
- int temp ;
6
- returncode_t result ;
7
- };
8
-
9
- static struct data result = { .fired = false };
10
-
11
- static void temp_cb (returncode_t ret , int temperature ) {
12
- result .temp = temperature ;
13
- result .fired = true;
14
- result .result = ret ;
15
- }
16
-
17
3
returncode_t libtocksync_temperature_read (int * temperature ) {
18
4
returncode_t err ;
19
- result .fired = false;
20
5
21
- err = libtock_temperature_read ( temp_cb );
6
+ err = libtock_temperature_command_read ( );
22
7
if (err != RETURNCODE_SUCCESS ) return err ;
23
8
24
- // Wait for the callback.
25
- yield_for (& result .fired );
26
- if (result .result != RETURNCODE_SUCCESS ) return result .result ;
27
-
28
- * temperature = result .temp ;
9
+ // Wait for the operation to finish.
10
+ err = libtocksync_temperature_yield_wait_for (temperature );
29
11
30
- return RETURNCODE_SUCCESS ;
12
+ return err ;
31
13
}
Original file line number Diff line number Diff line change 1
1
#pragma once
2
2
3
- #include <libtock/sensors/temperature.h>
3
+ #include "syscalls/temperature_syscalls.h"
4
4
#include <libtock/tock.h>
5
5
6
6
#ifdef __cplusplus
You can’t perform that action at this time.
0 commit comments