-
Notifications
You must be signed in to change notification settings - Fork 190
Peripherals Chapter #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
jamesmunns
commented
Aug 22, 2018
- Still needs heavy expansion and editing
- Move "singleton" to "peripherals"
I have a four hour flight tomorrow, I hope to bring some more structure and detail to this, it still really looks like presenter notes. CC @rust-embedded/resources, let me know if you do or do not like the content and structure. For reference, my conference talk is here: https://ferrous-systems.github.io/rustconf-james-2018 |
I'd say there are two strategies here:
Open to suggestions, but I'm done for the evening. |
src/portability/traits.md
Outdated
} | ||
``` | ||
|
||
> this goes in your chip crate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: Make the wording (and presentation) consistent - use "Device Crate", include links to all example crates, consistent structuring.
I like this. I'd merge it on the grounds that something is better than nothing, and there's definitely value in here even if it does have gaps. |
bb4442a
to
4a2c521
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found a few nits but otherwise that looks really good to me.
src/peripherals/a-first-attempt.md
Outdated
} | ||
``` | ||
|
||
Although this works it is subjectively a little messy, so the first reaction might be to wrap these related things up in to a `struct` to better organize them. A second attempt could come up with something like this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 prepositions after one another are maybe a bit excessive, I'd probably strike up and merge "in" and "to" into "into".
src/peripherals/borrowck.md
Outdated
|
||
## The Borrow Checker | ||
|
||
The last two of these rules sound suspiciously exactly like what the Borrow Checker does already! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"suspiciously exactly like" has a weird ring to it. Maybe "suspiciously similar to"?
src/peripherals/peripherals.md
Outdated
|
||
## What are Peripherals? | ||
|
||
Most Microcontrollers have more than just a CPU, RAM, or Flash Memory - they contain sections of silicon which are used for interacting with systems outside of the microcontroller. These components are collectively known as Peripherals, and are often used to manage communication with sensors, Bluetooth radios, screens, or touch pads. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe be a more general about what peripherals are: They're not just useful for interacting with other systems but to interface with the surroundings in the world, e.g. sensors, actors, humans and other systems.
src/peripherals/peripherals.md
Outdated
|
||
These peripherals are useful because they allow a developer to offload processing to them, avoiding having to handle everything in software. Similar to how a desktop developer would offload graphics processing to a video card, embedded developers can offload some tasks to peripherals allowing the CPU to spend it's time doing something else important, or doing nothing in order to save power. | ||
|
||
However, unlike graphics cards, which typically have a Software API like Vulkan, Metal, or OpenGL, peripherals are exposed to our CPU with a hardware interface, which is mapped to a chunk of the memory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MCU
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My use of CPU here was generally that "MCU = CPU + RAM + Flash + Peripherals" or such. Though, either way I should clarify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to agree, but there's a certain understanding of what goes into a CPU nowadays and that's a lot more than a plain ALU as it used to be 30 years ago so to avoid confusion I would not use the term CPU.
src/peripherals/peripherals.md
Outdated
|
||
On a desktop system, access to memory is tightly controlled by the MMU, or Memory Management Unit. This component has two major responsibilities: enforcing access permission to sections of memory (preventing one thread from reading or modifying the memory of another thread); and re-mapping segments of the physical memory to virtual memory ranges used in software. Microcontrollers do not typically have an MMU, and instead only use real physical addresses in software. | ||
|
||
Although 32 bit microcontrollers have a real and linear address space from `0x0000_0000`, and `0xFFFF_FFFF`, they generally only use a few hundred kilobytes of that range for actual memory. This leaves a significant about of address space remaining. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amount instead of about
src/portability/traits.md
Outdated
CS: OutputPin, | ||
{ | ||
/// Creates a new driver from a SPI peripheral | ||
/// and a NCS pin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spell out NCS (or CS) so people can guess what that does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do. This is a direct copy/paste from the embedded hal code. I'll make it more verbose to be readable out of context.
In | ||
|
||
```rust | ||
struct GpioPin; struct InputGpio; struct OutputGpio; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fan out and maybe put it in a comment or fictionally import them.
``` | ||
|
||
* Use type transitions to enforce setup steps | ||
* Like the builder pattern in "normal" rust |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rust -> Rust
|
||
```rust | ||
pub struct PushPull; // good for general usage | ||
pub struct OpenDrain; // better for high power LEDs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a MCU the main usage of OpenDrain GPIOs is communication with several devices on one bus. The internal MOSFETs in MCUs typically do not have a very high power rating, often not even higher than what a PP configuration can sink or source and also the maximum power is usually limited by the general sinking capabilities of the MCU which usually is in the order of a few hundred mA.
} | ||
``` | ||
|
||
* Nested zero sized types are still zero sized, no matter how deep you nest it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it -> them
* Still needs heavy expansion and editing * Move "singleton" to "peripherals"
4d0a4be
to
df8e2e8
Compare
Reping @rust-embedded/resources, I have stripped this down to just the peripherals chapter, and should be ready to merge if there are no further review comments. |
@therealprof addressed changes, dismissing old review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Thanks! bors r+ |
15: Peripherals Chapter r=jamesmunns a=jamesmunns * Still needs heavy expansion and editing * Move "singleton" to "peripherals" Co-authored-by: James Munns <[email protected]> Co-authored-by: James Munns <[email protected]>
Build succeeded |
15: Peripherals Chapter r=jamesmunns a=jamesmunns * Still needs heavy expansion and editing * Move "singleton" to "peripherals" Co-authored-by: James Munns <[email protected]> Co-authored-by: James Munns <[email protected]>