embedded-trainings-2020/embedded-workshop-book/src/bsc-exercise.md

53 lines
2 KiB
Markdown
Raw Normal View History

2023-02-14 17:46:54 +00:00
# BSC Exercise
In this exercise you will learn how to write a board support crate.
2023-02-22 18:11:13 +00:00
The template `dk_bsc/src/lib.rs` already contains the LED and Timer implementations. You will implement the buttons and the UARTE peripheral.
2023-02-21 15:24:41 +00:00
2023-02-22 18:11:13 +00:00
Note: Introduction to the exercise is a guided tour through the template, and it's architecture. Make the participants aware of the placeholders for their implementations. run the hello example on the unmodified lib.
2023-02-14 17:46:54 +00:00
2023-02-22 18:11:13 +00:00
## You will learn how to
* modify the `init()` function that brings up the board's peripherals
* how to configure pins
* how to write a function that checks the state of a pin
* write methods for a `struct`
2023-02-21 15:24:41 +00:00
* UARTE implementation
2023-02-22 18:11:13 +00:00
* implement a Trait
* to document and generate docs for your own library!
2023-02-14 17:46:54 +00:00
2023-03-07 15:46:03 +00:00
## Prerequisites
[todo!]
2023-02-21 15:24:41 +00:00
## Tasks
* Write a button implementation. This entails the following steps
2023-03-07 15:46:03 +00:00
`struct Buttons` with 4 fields, that represents each of the four buttons
`struct Button` that is a wrapper for the pin that a single button is connected to
✅ a method `is_pushed` that checks if a single button is pushed.
✅ initialize the pins in `fn init()`
✅ add the `struct Button` to the definition and instantiation of `struct Board`.
✅ Run `apps/buttons.rs` to test.
2023-02-21 15:24:41 +00:00
* Write a UARTE implementation.
## Knowledge
## Representation of Peripherals
The boards peripherals are represented as nested structs. The `struct Board` contains fields that represent single peripherals or groups of peripherals as structs, which in turn either contain a field of the single peripheral or ...
You have to add structs to represent the buttons and the UARTE peripheral to the board struct.
2023-03-07 15:46:03 +00:00
[todo!]
2023-02-21 15:24:41 +00:00
## Comments
2023-03-07 15:46:03 +00:00
[todo!]
2023-02-21 15:24:41 +00:00
## impl blocks
2023-03-07 15:46:03 +00:00
[todo!]
## Visibility of structs, fields and functions: the pub keyword
[todo!]
2023-02-21 15:24:41 +00:00
## Hardware documentation for pin configuration
2023-02-14 17:46:54 +00:00
2023-03-07 15:46:03 +00:00
Go to [Nordic Infocenter](https://infocenter.nordicsemi.com/topic/ug_nrf52840_dk/UG/dk/intro.html) to download the User Guide. You can find all the information that is relevant to this exercise in there.
2023-02-14 17:46:54 +00:00