|
1 |
| -# `cortex-m-quickstart` |
2 |
| - |
3 |
| -> A template for building applications for ARM Cortex-M microcontrollers |
4 |
| -
|
5 |
| -This project is developed and maintained by the [Cortex-M team][team]. |
6 |
| - |
7 |
| -## Dependencies |
8 |
| - |
9 |
| -To build embedded programs using this template you'll need: |
10 |
| - |
11 |
| -- Rust 1.31, 1.30-beta, nightly-2018-09-13 or a newer toolchain. e.g. `rustup |
12 |
| - default beta` |
13 |
| - |
14 |
| -- The `cargo generate` subcommand. [Installation |
15 |
| - instructions](https://github.com/ashleygwilliams/cargo-generate#installation). |
16 |
| - |
17 |
| -- `rust-std` components (pre-compiled `core` crate) for the ARM Cortex-M |
18 |
| - targets. Run: |
19 |
| - |
20 |
| -``` console |
21 |
| -$ rustup target add thumbv6m-none-eabi thumbv7m-none-eabi thumbv7em-none-eabi thumbv7em-none-eabihf |
22 |
| -``` |
23 |
| - |
24 |
| -## Using this template |
25 |
| - |
26 |
| -**NOTE**: This is the very short version that only covers building programs. For |
27 |
| -the long version, which additionally covers flashing, running and debugging |
28 |
| -programs, check [the embedded Rust book][book]. |
29 |
| - |
30 |
| -[book]: https://rust-embedded.github.io/book |
31 |
| - |
32 |
| -0. Before we begin you need to identify some characteristics of the target |
33 |
| - device as these will be used to configure the project: |
34 |
| - |
35 |
| -- The ARM core. e.g. Cortex-M3. |
36 |
| - |
37 |
| -- Does the ARM core include an FPU? Cortex-M4**F** and Cortex-M7**F** cores do. |
38 |
| - |
39 |
| -- How much Flash memory and RAM does the target device has? e.g. 256 KiB of |
40 |
| - Flash and 32 KiB of RAM. |
41 |
| - |
42 |
| -- Where are Flash memory and RAM mapped in the address space? e.g. RAM is |
43 |
| - commonly located at address `0x2000_0000`. |
44 |
| - |
45 |
| -You can find this information in the data sheet or the reference manual of your |
46 |
| -device. |
47 |
| - |
48 |
| -In this example we'll be using the STM32F3DISCOVERY. This board contains an |
49 |
| -STM32F303VCT6 microcontroller. This microcontroller has: |
50 |
| - |
51 |
| -- A Cortex-M4F core that includes a single precision FPU |
52 |
| - |
53 |
| -- 256 KiB of Flash located at address 0x0800_0000. |
54 |
| - |
55 |
| -- 40 KiB of RAM located at address 0x2000_0000. (There's another RAM region but |
56 |
| - for simplicity we'll ignore it). |
57 |
| - |
58 |
| -1. Instantiate the template. |
59 |
| - |
60 |
| -``` console |
61 |
| -$ cargo generate --git https://github.com/rust-embedded/cortex-m-quickstart |
62 |
| - Project Name: app |
63 |
| - Creating project called `app`... |
64 |
| - Done! New project created /tmp/app |
65 |
| - |
66 |
| -$ cd app |
67 |
| -``` |
68 |
| - |
69 |
| -2. Set a default compilation target. There are four options as mentioned at the |
70 |
| - bottom of `.cargo/config`. For the STM32F303VCT6, which has a Cortex-M4F |
71 |
| - core, we'll pick the `thumbv7em-none-eabihf` target. |
72 |
| - |
73 |
| -``` console |
74 |
| -$ tail -n6 .cargo/config |
75 |
| -``` |
76 |
| - |
77 |
| -``` toml |
78 |
| -[build] |
79 |
| -# Pick ONE of these compilation targets |
80 |
| -# target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+ |
81 |
| -# target = "thumbv7m-none-eabi" # Cortex-M3 |
82 |
| -# target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU) |
83 |
| -target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU) |
84 |
| -``` |
85 |
| - |
86 |
| -3. Enter the memory region information into the `memory.x` file. |
87 |
| - |
88 |
| -``` console |
89 |
| -$ cat memory.x |
90 |
| -/* Linker script for the STM32F303VCT6 */ |
91 |
| -MEMORY |
92 |
| -{ |
93 |
| - /* NOTE 1 K = 1 KiBi = 1024 bytes */ |
94 |
| - FLASH : ORIGIN = 0x08000000, LENGTH = 256K |
95 |
| - RAM : ORIGIN = 0x20000000, LENGTH = 40K |
96 |
| -} |
97 |
| -``` |
98 |
| - |
99 |
| -4. Build the template application or one of the examples. |
100 |
| - |
101 |
| -``` console |
102 |
| -$ cargo build |
103 |
| -``` |
104 |
| - |
105 |
| -## VS Code |
106 |
| - |
107 |
| -This template includes launch configurations for debugging CortexM programs with Visual Studio Code located in the `.vscode/` directory. |
108 |
| -See [.vscode/README.md](./.vscode/README.md) for more information. |
109 |
| -If you're not using VS Code, you can safely delete the directory from the generated project. |
110 |
| - |
111 |
| -# License |
112 |
| - |
113 |
| -This template is licensed under either of |
114 |
| - |
115 |
| -- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or |
116 |
| - http://www.apache.org/licenses/LICENSE-2.0) |
| 1 | +# stm32f411re-embedded-rust-interrupt |
117 | 2 |
|
118 |
| -- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) |
| 3 | +This is based on the [cortex-m-quickstart](https://github.com/rust-embedded/cortex-m-quickstart) project. |
119 | 4 |
|
120 |
| -at your option. |
| 5 | +The code is for the stm32-f411re processor, and is meant for the nucleo-f411re board. Pressed the **user b1 button** on **Pin GPIOC 17 (PC17)** will cause the led on **Pin GPIOA 5 (PA5)** to light up. This example also illustrates how to check pin state in a loop and share that resource with the interrupt through a mutex. |
121 | 6 |
|
122 |
| -## Contribution |
| 7 | +I've included some resources that have helped me along the way. |
123 | 8 |
|
124 |
| -Unless you explicitly state otherwise, any contribution intentionally submitted |
125 |
| -for inclusion in the work by you, as defined in the Apache-2.0 license, shall be |
126 |
| -dual licensed as above, without any additional terms or conditions. |
| 9 | + |
127 | 10 |
|
128 |
| -## Code of Conduct |
| 11 | + |
129 | 12 |
|
130 |
| -Contribution to this crate is organized under the terms of the [Rust Code of |
131 |
| -Conduct][CoC], the maintainer of this crate, the [Cortex-M team][team], promises |
132 |
| -to intervene to uphold that code of conduct. |
133 | 13 |
|
134 |
| -[CoC]: https://www.rust-lang.org/policies/code-of-conduct |
135 |
| -[team]: https://github.com/rust-embedded/wg#the-cortex-m-team |
136 |
| -# stm32f411re-embedded-rust-interrupt |
| 14 | + |
0 commit comments