Skip to content

Commit ca48e29

Browse files
authored
Merge pull request #542 from tock/syscalls-separate
libtock: Do not include `_syscalls.h` automatically for each driver
2 parents b613b36 + 17e91e5 commit ca48e29

File tree

275 files changed

+870
-181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

275 files changed

+870
-181
lines changed

doc/guide.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,13 @@ There must be a function to check for syscall driver existence.
170170
Signature:
171171

172172
```
173-
bool libtock_[name]_exists(void);
173+
bool libtock_[name]_driver_exists(void);
174174
```
175175

176176
Example:
177177

178178
```c
179-
bool libtock_[name]_exists(void) {
179+
bool libtock_[name]_driver_exists(void) {
180180
return driver_exists(DRIVER_NUM_[NAME]);
181181
}
182182
```
@@ -202,7 +202,6 @@ The `[name].h` header file must look like:
202202
#pragma once
203203

204204
#include "../tock.h"
205-
#include "syscalls/[name]_syscalls.h"
206205

207206
#ifdef __cplusplus
208207
extern "C" {
@@ -215,7 +214,8 @@ extern "C" {
215214
#endif
216215
```
217216

218-
The `[name].h` header file must include the syscalls header.
217+
The `[name].h` header file must NOT include the syscalls header. Applications
218+
wanting to use the syscalls directly must include the syscalls header.
219219

220220
### Defining a Callback for Asynchronous Operations
221221

@@ -236,6 +236,24 @@ they should have the last argument be a callback function pointer.
236236
returncode_t libtock_[name]_[desc](<arguments>, libtock_[name]_callback_[desc] cb);
237237
```
238238

239+
#### Exists
240+
241+
There must be a function to check for syscall driver existence.
242+
243+
Signature:
244+
245+
```
246+
bool libtock_[name]_exists(void);
247+
```
248+
249+
Example:
250+
251+
```c
252+
bool libtock_[name]_exists(void) {
253+
return libtock_[name]_driver_exists();
254+
}
255+
```
256+
239257
### Example:
240258

241259

@@ -309,7 +327,6 @@ file is used in a C++ app.
309327
#pragma once
310328
311329
#include <libtock/tock.h>
312-
#include <libtock/[category]/syscalls/[name]_syscalls.h>
313330
314331
#ifdef __cplusplus
315332
extern "C" {
@@ -379,7 +396,6 @@ The libtock-sync `[name].h` header file must look like:
379396
```c
380397
#pragma once
381398

382-
#include "syscalls/temperature_syscalls.h"
383399
#include <libtock/tock.h>
384400

385401
#ifdef __cplusplus

examples/lvgl/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <libtock-sync/display/screen.h>
66
#include <libtock-sync/services/alarm.h>
7+
#include <libtock/peripherals/syscalls/alarm_syscalls.h>
78

89
#include "lvgl_driver.h"
910

examples/sensors/main.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ int main(void) {
7272
printf("[Sensors] All available sensors on the platform will be sampled.\n");
7373

7474
/* *INDENT-OFF* */
75-
light = libtock_ambient_light_exists();
76-
temperature = libtock_temperature_exists();
77-
humidity = libtock_humidity_exists();
78-
ninedof = libtock_ninedof_exists();
79-
proximity = libtock_proximity_exists();
80-
sound_pressure = libtock_sound_pressure_exists();
81-
moisture = libtock_moisture_exists();
82-
rainfall = libtock_rainfall_exists();
75+
light = libtocksync_ambient_light_exists();
76+
temperature = libtocksync_temperature_exists();
77+
humidity = libtocksync_humidity_exists();
78+
ninedof = libtocksync_ninedof_exists();
79+
proximity = libtocksync_proximity_exists();
80+
sound_pressure = libtocksync_sound_pressure_exists();
81+
moisture = libtocksync_moisture_exists();
82+
rainfall = libtocksync_rainfall_exists();
8383
/* *INDENT-ON* */
8484

8585
if (ninedof) {
@@ -103,7 +103,7 @@ int main(void) {
103103
/* *INDENT-ON* */
104104

105105
if (sound_pressure) {
106-
libtock_sound_pressure_command_enable();
106+
libtocksync_sound_pressure_enable();
107107
}
108108

109109
// Setup periodic alarm to sample the sensors.

examples/services/ble-env-sense/test-with-sensors/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static void do_sensing_cb(__attribute__ ((unused)) uint32_t now,
4545
int temp = 0;
4646
int humi = 0;
4747

48-
if (driver_exists(DRIVER_NUM_AMBIENT_LIGHT)) {
48+
if (libtocksync_ambient_light_exists()) {
4949
libtocksync_ambient_light_read_intensity(&light);
5050

5151
update->type = SENSOR_IRRADIANCE;
@@ -55,7 +55,7 @@ static void do_sensing_cb(__attribute__ ((unused)) uint32_t now,
5555
yield_for(&_ipc_done);
5656
}
5757

58-
if (driver_exists(DRIVER_NUM_TEMPERATURE)) {
58+
if (libtocksync_temperature_exists()) {
5959
libtocksync_temperature_read(&temp);
6060

6161
update->type = SENSOR_TEMPERATURE;
@@ -65,7 +65,7 @@ static void do_sensing_cb(__attribute__ ((unused)) uint32_t now,
6565
yield_for(&_ipc_done);
6666
}
6767

68-
if (driver_exists(DRIVER_NUM_HUMIDITY)) {
68+
if (libtocksync_humidity_exists()) {
6969
libtocksync_humidity_read(&humi);
7070

7171
update->type = SENSOR_HUMIDITY;

examples/servo/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
#include <stdlib.h>
33

44
#include <libtock-sync/services/alarm.h>
5+
#include <libtock/interface/syscalls/servo_syscalls.h>
56
#include <libtock/tock.h>
67

7-
#include "../../libtock/interface/syscalls/servo_syscalls.h"
88

99
int main(void) {
1010
// Checks if the driver exists and, if not, returns -1.
11-
if (!libtock_servo_exists()) {
11+
if (!libtock_servo_driver_exists()) {
1212
printf("There is no available servo\n");
1313
return -1;
1414
}

examples/tests/adc/adc/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <libtock-sync/peripherals/adc.h>
77
#include <libtock-sync/services/alarm.h>
88
#include <libtock/interface/console.h>
9+
#include <libtock/peripherals/syscalls/adc_syscalls.h>
910
#include <libtock/tock.h>
1011

1112
int reference_voltage;

examples/tests/aes/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <string.h>
44

55
#include <libtock/crypto/aes.h>
6+
#include <libtock/crypto/syscalls/aes_syscalls.h>
67

78
#define KEY_LEN 16
89
#define IV_LEN 16

examples/tests/alarms/multi_alarm_simple_overflow_test/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <stdlib.h>
33

44
#include <libtock-sync/services/alarm.h>
5+
#include <libtock/peripherals/syscalls/alarm_syscalls.h>
56

67
static void event_cb(uint32_t now, uint32_t expiration, void* ud) {
78
int i = (int)ud;

examples/tests/analog_comparator/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <libtock-sync/services/alarm.h>
66
#include <libtock/peripherals/analog_comparator.h>
7+
#include <libtock/peripherals/syscalls/analog_comparator_syscalls.h>
78
#include <libtock/tock.h>
89

910
static int callback_channel;

examples/tests/callback_remove_test01/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <stdlib.h>
33

44
#include <libtock-sync/services/alarm.h>
5+
#include <libtock/peripherals/syscalls/alarm_syscalls.h>
56

67
volatile int a = 0;
78
int b = 0;

0 commit comments

Comments
 (0)