... | ... | @@ -2,8 +2,8 @@ If the test [LED Blink](LED-Blink) worked, everything is set up correctly. This |
|
|
|
|
|
## Header file
|
|
|
|
|
|
To get started, create a folder called `led` in `src/shared/drivers`.
|
|
|
|
|
|
To get started, create a folder called `led` in `src/shared/drivers`.
|
|
|
|
|
|
In it, create a file called `SimpleLed.h` and write:
|
|
|
|
|
|
```cpp
|
... | ... | @@ -137,7 +137,7 @@ void SimpleLed::switchToState(bool newState) |
|
|
}
|
|
|
|
|
|
```
|
|
|
As you can see, `PD14` is set as an `output` pin in the constructor and its digital value can be set to `high` or `low`.
|
|
|
As you can see, `PD14` is set as an `output` pin in the constructor and its digital value can be set to `high` or `low`.
|
|
|
You can find more information about how to use the GPIO and what pins you can use, in the [GPIO Usage](GPIO-Usage-&-Used-Pins) page.
|
|
|
|
|
|
## Create your entrypoint
|
... | ... | @@ -145,7 +145,7 @@ You can find more information about how to use the GPIO and what pins you can us |
|
|
To write a program that uses this driver, an entrypoint is needed as before: in `src/entrypoints` add a file called `test-led-driver.cpp` and write:
|
|
|
|
|
|
```cpp
|
|
|
#include <Common.h>
|
|
|
#include <Common.h>board
|
|
|
#include <drivers/led/SimpleLed.h>
|
|
|
|
|
|
using namespace miosix;
|
... | ... | @@ -165,7 +165,7 @@ int main() |
|
|
## Compile with SBS
|
|
|
|
|
|
Just as before we have to add what we wrote to `sbs.conf`. This time though
|
|
|
we will also have to compile `SimpleLed.cpp` with our entrypoint. The way to do this is:
|
|
|
we will also have to compile `SimpleLed.cpp` with our entrypoint.
|
|
|
|
|
|
Add a new `srcfiles` group in `sbs.conf`, after `#srcfiles`:
|
|
|
|
... | ... | @@ -175,7 +175,7 @@ Type: srcfiles |
|
|
Files: src/shared/drivers/led/SimpleLed.cpp
|
|
|
```
|
|
|
|
|
|
Now you can add the entrypoint (a.k.a *board*, because it's a software that will
|
|
|
Now you can add the entrypoint (a.k.a _board_, because it's a software that will
|
|
|
run on a board).
|
|
|
|
|
|
```
|
... | ... | |