Skip to content

Commit 4a87609

Browse files
author
Jorge Aparicio
committed
de-Rust-Belt-Rust-ify
1 parent 7b23cf5 commit 4a87609

File tree

153 files changed

+553
-1492
lines changed

Some content is hidden

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

153 files changed

+553
-1492
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ env:
2525

2626
branches:
2727
only:
28+
- auto
2829
- master
30+
- try
2931

3032
notifications:
3133
email:
3234
on_success: never
33-
webhooks: https://homu.herokuapp.com/travis

src/01-background/README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Background
2+
3+
## What's a microcontroller?
4+
5+
A microcontroller is a *system* on a chip. Whereas your laptop is made up of
6+
several discrete components: a processor, RAM sticks, a hard drive, an ethernet
7+
port, etc.; a microcontroller has all those components built into a single
8+
"chip" or package. This makes it possible to build systems with minimal part
9+
count.
10+
11+
## What can you do with a microcontroller?
12+
13+
Lots of things! Microcontrollers are the central part of systems known as
14+
*embedded* systems. These systems are everywhere but you don't usually notice
15+
them. These systems control the brakes of your car, wash your clothes, print
16+
your documents, keep you warm, keep you cool, optimize the fuel consumption of
17+
your car, etc.
18+
19+
The main trait of these systems is that they operate without user intervention
20+
even if they expose a user interface like a washing machine does; most of their
21+
operation is done on their own.
22+
23+
The other common trait of these systems is that they *control* a process. And
24+
for that these systems usually have one or more sensors and one or more
25+
actuators. For example, an HVAC system has several sensors, thermometers and
26+
humidy sensors spread across some area, and several actuators as well, heating
27+
elements and fans connected to ducts.
28+
29+
## When should I use a microcontroller?
30+
31+
All these application I've mentioned, you can probably implement with a
32+
Raspberry Pi, a computer that runs Linux. Why should I bother with a
33+
microcontroller that operates without an OS? Sounds like it would be harder to
34+
develop a program.
35+
36+
The main reason is cost. A microcontroller is much cheaper than a general
37+
purpose computer. Not only the microcontroller is cheaper; it also requires much
38+
less external electrical components to operate. This makes Printed Circuit
39+
Boards (PCB) smaller and cheaper to design and manufacture.
40+
41+
The other big reason is power consumption. A microcontroller consumes orders of
42+
magnitude less power than a full blown processor. If your application will
43+
run on batteries that makes a huge difference.
44+
45+
And last but not least: (hard) "real time" constraints. Some processes require
46+
their controllers to respond to some events within some time interval (e.g. a
47+
quadcopter/drone hit by a wind gust). If this "deadline" is not met, the process
48+
could end in catastrophic failure (e.g. the drone crashes to the ground). A
49+
general purpose computer running a general purpose OS has many services running
50+
in the background. This makes it hard to guarantee execution of a program within
51+
tight time constraints.
52+
53+
## When should I *not* use a microcontroller?
54+
55+
Where heavy computations are involved. To keep their power consumption low,
56+
microcontrollers have very limited computational resources available to them.
57+
For example, some microcontrollers don't even have hardware support for floating
58+
point operations. On those devices, performing a simple addition of single
59+
precision numbers can take hundreds of CPU cycles.
60+
61+
## Why use Rust and not C?
62+
63+
Hopefully, I don't need to convince you here as you are probably familiar with
64+
the language differences between Rust and C. One point I do want to bring up is
65+
package management. C lacks an official, widely accepted package management
66+
solution whereas Rust has Cargo. This makes development *much* easier. And, IMO,
67+
easy package management encourages code reuse because libraries can be easily
68+
integrated into an application which is also a good thing as libraries get more
69+
"battle testing".
70+
71+
## Why should I not use Rust?
72+
73+
Or why should I prefer C over Rust?
74+
75+
The C ecosystem is way more mature. Off the shelf solution for several problems
76+
already exist. If you need to control a time sensitive process, you can grab one
77+
of the existing commercial Real Time Operating Systems (RTOS) out there and
78+
solve your problem. There are no commercial, production-grade RTOSes in Rust yet
79+
so you would have to either create one yourself or try one of the ones that are
80+
in development.

src/01-installation-instructions/README.md

Lines changed: 0 additions & 135 deletions
This file was deleted.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Hardware requirements
2+
3+
To follow this material you'll need the following hardware:
4+
5+
(Some components are optional but recommended)
6+
7+
- A [STM32F3DISCOVERY] board.
8+
9+
[STM32F3DISCOVERY]: http://www.st.com/en/evaluation-tools/stm32f3discovery.html
10+
11+
<p align="center">
12+
<img title="STM32F3DISCOVERY" src="assets/f3.jpg">
13+
</p>
14+
15+
- OPTIONAL. A **3.3V** USB <-> Serial module. [This particular model][sparkfun]
16+
will be used throughout this material but you can use any other model as long
17+
as it operates at 3.3V.
18+
19+
[sparkfun]: https://www.sparkfun.com/products/9873
20+
21+
<p align="center">
22+
<img title="A 3.3v USB <-> Serial module" src="assets/serial.jpg">
23+
</p>
24+
25+
- OPTIONAL. A HC-05 Bluetooth module (with headers!). A HC-06 would work too.
26+
27+
<p align="center">
28+
<img title="The HC-05 Bluetooth module" src="assets/bluetooth.jpg">
29+
</p>
30+
31+
- Two mini-B USB cables. One is required to make the STM32F3DISCOVERY board
32+
work. The other is only required if you have the Serial <-> USB module.
33+
34+
<p align="center">
35+
<img title="mini-B USB cable" src="assets/usb-cable.jpg">
36+
</p>
37+
38+
> **NOTE** These are **not** the USB cables that ship with pretty much every
39+
> Android phone; those are *micro* USB cables. Make sure you have the right
40+
> thing!
41+
42+
- OPTIONAL. 4 Female/Female, 4 Male/Female and 1 Male/Male jumper wires. Only if
43+
you'll be using the USB <-> Serial and Bluetooth modules.
44+
45+
<p align="center">
46+
<img title="Jumper wires" src="assets/jumper-wires.jpg">
47+
</p>
48+
49+
> **FAQ**: Can I follow this material with a different development board?
50+
51+
Maybe? It depends mainly on two things: your previous experience with
52+
microcontrollers and/or whether there already exists a crate for your
53+
development board somewhere.
54+
55+
Regardless, with a different development board, this text would lost most if not
56+
all its beginner friendliness and "easy to follow"-ness, IMO.
57+
58+
If you have a different development board and you don't consider yourself a
59+
total beginner, you are better off reading the [Copper] book which approaches
60+
the Rust on microcontrollers topic in a bottom-up and device agnostic way. Or,
61+
maybe even just read the source of the [f3] crate.
62+
63+
[Copper]: https://japaric.github.io/copper
64+
[f3]: https://github.com/japaric/f3

0 commit comments

Comments
 (0)