Skip to content

Commit a8a02d9

Browse files
committed
v0.2.1
1 parent affd24f commit a8a02d9

File tree

3 files changed

+61
-12
lines changed

3 files changed

+61
-12
lines changed

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55

66
## [Unreleased]
77

8+
## [v0.2.1] - 2017-07-14
9+
10+
### Added
11+
12+
- Troubleshooting documentation: how to fix the error of overwriting the
13+
`.cargo/config` file when you meant to append text to it.
14+
15+
### Changed
16+
17+
- Xargo.toml: Changed the source of the `compiler-builtins` crate from git to
18+
the `rust-src` component.
19+
20+
- Expanded the `device` example to do some I/O.
21+
822
## [v0.2.0] - 2017-07-07
923

1024
### Changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ keywords = ["arm", "cortex-m", "template"]
66
license = "MIT OR Apache-2.0"
77
name = "cortex-m-quickstart"
88
repository = "https://github.com/japaric/cortex-m-quickstart"
9-
version = "0.2.0"
9+
version = "0.2.1"
1010

1111
[dependencies]
1212
cortex-m = "0.3.0"
1313
cortex-m-semihosting = "0.2.0"
1414

1515
[dependencies.cortex-m-rt]
1616
features = ["abort-on-panic"]
17-
version = "0.3.2"
17+
version = "0.3.3"
1818

1919
[profile.release]
2020
debug = true

src/examples/_5_device.rs

+45-10
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,57 @@
2626
//!
2727
//! ```
2828
//!
29+
//! #![deny(warnings)]
30+
//! #![feature(const_fn)]
2931
//! #![no_std]
3032
//!
3133
//! extern crate cortex_m;
34+
//! extern crate cortex_m_semihosting;
3235
//! #[macro_use(exception, interrupt)]
3336
//! extern crate stm32f103xx;
3437
//!
35-
//! use cortex_m::interrupt;
38+
//! use core::cell::RefCell;
39+
//! use core::fmt::Write;
40+
//!
41+
//! use cortex_m::interrupt::{self, Mutex};
42+
//! use cortex_m::peripheral::SystClkSource;
43+
//! use cortex_m_semihosting::hio::{self, HStdout};
44+
//! use stm32f103xx::Interrupt;
45+
//!
46+
//! static HSTDOUT: Mutex<RefCell<Option<HStdout>>> =
47+
//! Mutex::new(RefCell::new(None));
3648
//!
3749
//! fn main() {
3850
//! interrupt::free(|cs| {
39-
//! let _gpioa = stm32f103xx::GPIOA.borrow(cs);
40-
//! // do something with GPIOA
51+
//! let hstdout = HSTDOUT.borrow(cs);
52+
//! if let Ok(fd) = hio::hstdout() {
53+
//! *hstdout.borrow_mut() = Some(fd);
54+
//! }
55+
//!
56+
//! let nvic = stm32f103xx::NVIC.borrow(cs);
57+
//! nvic.enable(Interrupt::TIM2);
58+
//!
59+
//! let syst = stm32f103xx::SYST.borrow(cs);
60+
//! syst.set_clock_source(SystClkSource::Core);
61+
//! syst.set_reload(8_000_000); // 1s
62+
//! syst.enable_counter();
63+
//! syst.enable_interrupt();
4164
//! });
4265
//! }
4366
//!
44-
//! exception!(SYS_TICK, tick, locals: {
45-
//! ticks: u32 = 0;
46-
//! });
67+
//! exception!(SYS_TICK, tick);
68+
//!
69+
//! fn tick() {
70+
//! interrupt::free(|cs| {
71+
//! let hstdout = HSTDOUT.borrow(cs);
72+
//! if let Some(hstdout) = hstdout.borrow_mut().as_mut() {
73+
//! writeln!(*hstdout, "Tick").ok();
74+
//! }
75+
//!
76+
//! let nvic = stm32f103xx::NVIC.borrow(cs);
4777
//!
48-
//! fn tick(l: &mut SYS_TICK::Locals) {
49-
//! l.ticks += 1;
50-
//! // ..
78+
//! nvic.set_pending(Interrupt::TIM2);
79+
//! });
5180
//! }
5281
//!
5382
//! interrupt!(TIM2, tock, locals: {
@@ -56,7 +85,13 @@
5685
//!
5786
//! fn tock(l: &mut TIM2::Locals) {
5887
//! l.tocks += 1;
59-
//! // ..
88+
//!
89+
//! interrupt::free(|cs| {
90+
//! let hstdout = HSTDOUT.borrow(cs);
91+
//! if let Some(hstdout) = hstdout.borrow_mut().as_mut() {
92+
//! writeln!(*hstdout, "Tock ({})", l.tocks).ok();
93+
//! }
94+
//! });
6095
//! }
6196
//! ```
6297
// Auto-generated. Do not modify.

0 commit comments

Comments
 (0)