|
1 | | -# `cortex-m-quickstart` |
| 1 | +# `ST7920` |
2 | 2 |
|
3 | | -> A template for building applications for ARM Cortex-M microcontrollers |
| 3 | +This is a Rust driver library for LCD displays using the [ST7920] controller. It supports graphics mode of the controller, 128x64 in 1bpp. SPI connection to MCU is supported. |
4 | 4 |
|
5 | | -This project is developed and maintained by the [Cortex-M team][team]. |
| 5 | +It implements [embedded-graphics] driver API. |
6 | 6 |
|
7 | | -## Dependencies |
| 7 | +It is platform independent as it uses [embedded-hal] APIs to access hardware. |
8 | 8 |
|
9 | | -To build embedded programs using this template you'll need: |
| 9 | +The examples are based on the [stm32f4xx_hal] implementation of embedded-hal. |
10 | 10 |
|
11 | | -- Rust 1.31, 1.30-beta, nightly-2018-09-13 or a newer toolchain. e.g. `rustup |
12 | | - default beta` |
13 | 11 |
|
14 | | -- The `cargo generate` subcommand. [Installation |
15 | | - instructions](https://github.com/ashleygwilliams/cargo-generate#installation). |
16 | 12 |
|
17 | | -- `rust-std` components (pre-compiled `core` crate) for the ARM Cortex-M |
18 | | - targets. Run: |
| 13 | +# Documentation |
19 | 14 |
|
20 | | -``` console |
21 | | -$ rustup target add thumbv6m-none-eabi thumbv7m-none-eabi thumbv7em-none-eabi thumbv7em-none-eabihf |
22 | | -``` |
| 15 | +See [examples]. |
23 | 16 |
|
24 | | -## Using this template |
| 17 | +The controller supports 1 bit-per-pixel displays, so an off-screen buffer has to be used to provide random access to pixels. |
| 18 | +Size of the buffer is 1024 bytes. |
25 | 19 |
|
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 | | -``` |
| 20 | +The buffer has to be flushed to update the display after a group of draw calls has been completed. The flush is not part of embedded-graphics API. |
104 | 21 |
|
105 | 22 | # License |
106 | 23 |
|
107 | | -This template is licensed under either of |
108 | | - |
109 | | -- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or |
110 | | - http://www.apache.org/licenses/LICENSE-2.0) |
111 | | - |
112 | | -- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) |
113 | | - |
114 | | -at your option. |
115 | | - |
116 | | -## Contribution |
117 | | - |
118 | | -Unless you explicitly state otherwise, any contribution intentionally submitted |
119 | | -for inclusion in the work by you, as defined in the Apache-2.0 license, shall be |
120 | | -dual licensed as above, without any additional terms or conditions. |
121 | | - |
122 | | -## Code of Conduct |
123 | | - |
124 | | -Contribution to this crate is organized under the terms of the [Rust Code of |
125 | | -Conduct][CoC], the maintainer of this crate, the [Cortex-M team][team], promises |
126 | | -to intervene to uphold that code of conduct. |
| 24 | +This library is licensed under MIT license ([LICENSE](LICENSE) or http://opensource.org/licenses/MIT) |
127 | 25 |
|
128 | | -[CoC]: https://www.rust-lang.org/policies/code-of-conduct |
129 | | -[team]: https://github.com/rust-embedded/wg#the-cortex-m-team |
| 26 | +[embedded-graphics]: https://docs.rs/embedded-graphics/0.6.0-alpha.2/embedded_graphics/ |
| 27 | +[embedded-hal]: https://docs.rs/embedded-hal/0.2.3/embedded_hal/ |
| 28 | +[stm32f4xx_hal]: https://docs.rs/stm32f4xx-hal/0.5.0/stm32f4xx_hal/ |
| 29 | +[examples]: https://github.com/wjakobczyk/st7920/tree/master/examples |
| 30 | +[ST7920]: https://www.lcd-module.de/eng/pdf/zubehoer/st7920_chinese.pdf |
0 commit comments