You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/guides/c_tutorials/create_project.mdx
+2-7Lines changed: 2 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
---
2
2
title: Creating a Project
3
3
description: This tutorial will guide you through creating a new project with a simple hello world program.
4
+
code_folder: examples/guides/creating_project/
4
5
---
5
6
importContactfrom'@components/contact.astro';
6
7
importGitSetupfrom'@components/gitsetup.mdx';
@@ -19,12 +20,9 @@ Now that Visual Studio Code is open, we create a new file called `main.c` and ad
19
20
20
21
```c
21
22
#include<stdio.h>
22
-
#include"ztimer.h"
23
23
24
24
intmain(void)
25
25
{
26
-
ztimer_sleep(ZTIMER_SEC, 3);
27
-
28
26
puts("Hello World!");
29
27
30
28
return0;
@@ -33,7 +31,7 @@ int main(void)
33
31
34
32

35
33
36
-
This program will print "Hello World!" to the console after sleeping for 3 seconds. We use the `ztimer_sleep` function to sleep for 3 seconds otherwise we will most likely miss the output before connecting to our device. This function is part of the `ztimer` module, which is part of RIOT. The `puts` function is part of the standard C library and is used to print a string to the console.
34
+
This program will print "Hello World!" to the console when it is run. The `#include <stdio.h>` line includes the standard input/output library, which allows us to use the `puts` function to print to the console.
37
35
38
36
## Step 3: Creating the Makefile
39
37
@@ -54,9 +52,6 @@ RIOTBASE ?= $(CURDIR)/RIOT
54
52
# development process:
55
53
DEVELHELP ?= 1
56
54
57
-
# This board requires a start sleep to actually catch the printed output
58
-
USEMODULE += ztimer_sec
59
-
60
55
# Change this to 0 show compiler invocation lines by default:
Copy file name to clipboardExpand all lines: doc/guides/c_tutorials/saul.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
---
2
2
title: Sensors/Actuators using SAUL
3
3
description: Learn how to use sensors and actuators with RIOT
4
+
code_folder: examples/guides/saul/
4
5
---
5
6
6
7
In the previous chapter we learned how to interact with the GPIO directly, but RIOT provides a more abstract way to interact with sensors and actuators. RIOT calls this the SAUL (Sensors/Actuators Abstraction Layer) system.
@@ -87,7 +88,6 @@ which then stores the result in a `phydat_t` struct we provide.
87
88
// and store the result in the temperature variable
88
89
// saul_reg_read returns the dimension of the data read (1 in this case)
89
90
int dimension = saul_reg_read(temperature_sensor, &temperature);
90
-
}
91
91
```
92
92
93
93
Once again, since C doesn't have exceptions, we need to check if the sensor was read correctly.
Copy file name to clipboardExpand all lines: doc/guides/c_tutorials/shell.md
+9-6Lines changed: 9 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
---
2
2
title: Shell Commands
3
3
description: This tutorial explains how to use the RIOT shell.
4
+
code_folder: examples/guides/shell/
4
5
---
5
6
6
7
The shell is a powerful tool in RIOT that allows you to interact with your application at runtime.
@@ -22,9 +23,11 @@ This line tells the build system to include the shell module in our application.
22
23
23
24
Now we can start the shell in our main function by calling the `shell_init` function. Go into your `main.c` file and include the following code:
24
25
25
-
```c
26
+
```c title="The include so we can use the shell"
26
27
#include"shell.h"
28
+
```
27
29
30
+
```c title="The main function"
28
31
intmain(void)
29
32
{
30
33
// Buffer to store command line input
@@ -57,9 +60,11 @@ RIOT provides a set of macros to make this process easier.
57
60
58
61
Let's create a simple shell command that echoes back the input. Go into your `main.c` file and include the following code:
59
62
60
-
```c
63
+
```c title="The include so we can print to the console"
61
64
#include <stdio.h>
65
+
```
62
66
67
+
```c title="The function that implements the echo command"
63
68
intecho_command(int argc, char **argv)
64
69
{
65
70
for (int i = 1; i < argc; i++) {
@@ -75,10 +80,8 @@ This function takes two arguments: `argc` and `argv`. `argc` is the number of ar
75
80
76
81
Now all that is left is to register the command with the shell. Go back to your `main.c` file and include the following code _outside_ of the `main` function:
77
82
78
-
```c
79
-
SHELL_COMMAND(echo,
80
-
"Echoes back the input",
81
-
echo_command);
83
+
```c title="Register the command with the shell"
84
+
SHELL_COMMAND(echo,"Echo a message", echo_command);
82
85
```
83
86
84
87
This macro takes three arguments: the name of the command, a short description of the command, and the function that implements the command.
Copy file name to clipboardExpand all lines: doc/guides/c_tutorials/timers.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
---
2
2
title: Timers and Callbacks
3
3
description: This tutorial explains how to use timers and callbacs in RIOT.
4
+
code_folder: examples/guides/timers/
4
5
---
5
6
6
7
Timers and interrupts are essential concepts in embedded systems programming. In this tutorial, we will take a look at how to use timers and interrupts in RIOT.
@@ -47,7 +48,6 @@ int main(void)
47
48
.callback = timer_callback,
48
49
.arg = "3 seconds have passed!"
49
50
};
50
-
}
51
51
```
52
52
53
53
This code creates a timer and initializes it with the callback function we created earlier and a message that will be printed when the timer expires.
@@ -71,9 +71,10 @@ instead of constantly checking if the timer has expired. For example, lets use o
0 commit comments