Compare commits
12 Commits
therealpro
...
sh
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55e61c3291 | ||
|
|
e64e690512 | ||
|
|
f7a943f480 | ||
|
|
9c6b290e12 | ||
|
|
7e2bec66b7 | ||
|
|
4295bccf0e | ||
|
|
8f292e0f07 | ||
|
|
76d2e947a5 | ||
|
|
76cdd6a95b | ||
|
|
314e48537c | ||
|
|
d5abcf6d2a | ||
|
|
b02a67b5f9 |
@@ -1,13 +1,14 @@
|
|||||||
[package]
|
[package]
|
||||||
authors = ["{{authors}}"]
|
authors = ["{{authors}}"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
readme = "README.md"
|
||||||
name = "{{project-name}}"
|
name = "{{project-name}}"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cortex-m = "0.5.7"
|
cortex-m = "0.5.8"
|
||||||
cortex-m-rt = "0.6.3"
|
cortex-m-rt = "0.6.5"
|
||||||
cortex-m-semihosting = "0.3.1"
|
cortex-m-semihosting = "0.3.2"
|
||||||
panic-halt = "0.2.0"
|
panic-halt = "0.2.0"
|
||||||
|
|
||||||
# Uncomment for the panic example.
|
# Uncomment for the panic example.
|
||||||
|
|||||||
@@ -8,12 +8,9 @@ This project is developed and maintained by the [Cortex-M team][team].
|
|||||||
|
|
||||||
To build embedded programs using this template you'll need:
|
To build embedded programs using this template you'll need:
|
||||||
|
|
||||||
- Rust 1.30, 1.30-beta, nightly-2018-09-13 or a newer toolchain. e.g. `rustup
|
- Rust 1.31, 1.30-beta, nightly-2018-09-13 or a newer toolchain. e.g. `rustup
|
||||||
default beta`
|
default beta`
|
||||||
|
|
||||||
> **NOTE**: 1.30-beta is not out yet so you'll have to use the nightly channel
|
|
||||||
> in the meantime.
|
|
||||||
|
|
||||||
- The `cargo generate` subcommand. [Installation
|
- The `cargo generate` subcommand. [Installation
|
||||||
instructions](https://github.com/ashleygwilliams/cargo-generate#installation).
|
instructions](https://github.com/ashleygwilliams/cargo-generate#installation).
|
||||||
|
|
||||||
|
|||||||
@@ -14,16 +14,16 @@
|
|||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
extern crate panic_halt;
|
extern crate panic_halt;
|
||||||
|
|
||||||
|
use self::alloc::vec;
|
||||||
use core::alloc::Layout;
|
use core::alloc::Layout;
|
||||||
use core::fmt::Write;
|
|
||||||
|
|
||||||
use alloc::vec;
|
|
||||||
use alloc_cortex_m::CortexMHeap;
|
use alloc_cortex_m::CortexMHeap;
|
||||||
use cortex_m::asm;
|
use cortex_m::asm;
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use cortex_m_semihosting::hio;
|
use cortex_m_semihosting::hprintln;
|
||||||
|
|
||||||
// this is the allocator the application will use
|
// this is the allocator the application will use
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
@@ -39,8 +39,11 @@ fn main() -> ! {
|
|||||||
// Growable array allocated on the heap
|
// Growable array allocated on the heap
|
||||||
let xs = vec![0, 1, 2];
|
let xs = vec![0, 1, 2];
|
||||||
|
|
||||||
let mut stdout = hio::hstdout().unwrap();
|
hprintln!("{:?}", xs).unwrap();
|
||||||
writeln!(stdout, "{:?}", xs).unwrap();
|
|
||||||
|
// exit QEMU
|
||||||
|
// NOTE do not run this on hardware; it can corrupt OpenOCD state
|
||||||
|
debug::exit(debug::EXIT_SUCCESS);
|
||||||
|
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,11 +27,9 @@
|
|||||||
#[allow(unused_extern_crates)]
|
#[allow(unused_extern_crates)]
|
||||||
extern crate panic_halt;
|
extern crate panic_halt;
|
||||||
|
|
||||||
use core::fmt::Write;
|
|
||||||
|
|
||||||
use cortex_m::peripheral::syst::SystClkSource;
|
use cortex_m::peripheral::syst::SystClkSource;
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use cortex_m_semihosting::hio::{self, HStdout};
|
use cortex_m_semihosting::hprint;
|
||||||
use stm32f30x::{interrupt, Interrupt};
|
use stm32f30x::{interrupt, Interrupt};
|
||||||
|
|
||||||
#[entry]
|
#[entry]
|
||||||
@@ -53,19 +51,13 @@ fn main() -> ! {
|
|||||||
while !syst.has_wrapped() {}
|
while !syst.has_wrapped() {}
|
||||||
|
|
||||||
// trigger the `EXTI0` interrupt
|
// trigger the `EXTI0` interrupt
|
||||||
nvic.set_pending(Interrupt::EXTI0);
|
NVIC::pend(Interrupt::EXTI0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// try commenting out this line: you'll end in `default_handler` instead of in `exti0`
|
// try commenting out this line: you'll end in `default_handler` instead of in `exti0`
|
||||||
interrupt!(EXTI0, exti0, state: Option<HStdout> = None);
|
interrupt!(EXTI0, exti0);
|
||||||
|
|
||||||
fn exti0(state: &mut Option<HStdout>) {
|
fn exti0() {
|
||||||
if state.is_none() {
|
hprint!(".").unwrap();
|
||||||
*state = Some(hio::hstdout().unwrap());
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(hstdout) = state.as_mut() {
|
|
||||||
hstdout.write_str(".").unwrap();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,12 +12,10 @@
|
|||||||
|
|
||||||
extern crate panic_halt;
|
extern crate panic_halt;
|
||||||
|
|
||||||
use core::fmt::Write;
|
|
||||||
|
|
||||||
use cortex_m::peripheral::syst::SystClkSource;
|
use cortex_m::peripheral::syst::SystClkSource;
|
||||||
use cortex_m::Peripherals;
|
use cortex_m::Peripherals;
|
||||||
use cortex_m_rt::{entry, exception};
|
use cortex_m_rt::{entry, exception};
|
||||||
use cortex_m_semihosting::hio::{self, HStdout};
|
use cortex_m_semihosting::hprint;
|
||||||
|
|
||||||
#[entry]
|
#[entry]
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
@@ -35,13 +33,5 @@ fn main() -> ! {
|
|||||||
|
|
||||||
#[exception]
|
#[exception]
|
||||||
fn SysTick() {
|
fn SysTick() {
|
||||||
static mut STDOUT: Option<HStdout> = None;
|
hprint!(".").unwrap();
|
||||||
|
|
||||||
if STDOUT.is_none() {
|
|
||||||
*STDOUT = Some(hio::hstdout().unwrap());
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(hstdout) = STDOUT.as_mut() {
|
|
||||||
hstdout.write_str(".").unwrap();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,17 +5,15 @@
|
|||||||
|
|
||||||
extern crate panic_halt;
|
extern crate panic_halt;
|
||||||
|
|
||||||
use core::fmt::Write;
|
|
||||||
|
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use cortex_m_semihosting::{debug, hio};
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
|
||||||
#[entry]
|
#[entry]
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
let mut stdout = hio::hstdout().unwrap();
|
hprintln!("Hello, world!").unwrap();
|
||||||
writeln!(stdout, "Hello, world!").unwrap();
|
|
||||||
|
|
||||||
// exit QEMU or the debugger section
|
// exit QEMU
|
||||||
|
// NOTE do not run this on hardware; it can corrupt OpenOCD state
|
||||||
debug::exit(debug::EXIT_SUCCESS);
|
debug::exit(debug::EXIT_SUCCESS);
|
||||||
|
|
||||||
loop {}
|
loop {}
|
||||||
|
|||||||
13
memory.x
13
memory.x
@@ -19,3 +19,16 @@ MEMORY
|
|||||||
/* This is required only on microcontrollers that store some configuration right
|
/* This is required only on microcontrollers that store some configuration right
|
||||||
after the vector table */
|
after the vector table */
|
||||||
/* _stext = ORIGIN(FLASH) + 0x400; */
|
/* _stext = ORIGIN(FLASH) + 0x400; */
|
||||||
|
|
||||||
|
/* Example of putting non-initialized variables into custom RAM locations. */
|
||||||
|
/* This assumes you have defined a region RAM2 above, and in the Rust
|
||||||
|
sources added the attribute `#[link_section = ".ram2bss"]` to the data
|
||||||
|
you want to place there. */
|
||||||
|
/* Note that the section will not be zero-initialized by the runtime! */
|
||||||
|
/* SECTIONS {
|
||||||
|
.ram2bss (NOLOAD) : ALIGN(4) {
|
||||||
|
*(.ram2bss);
|
||||||
|
. = ALIGN(4);
|
||||||
|
} > RAM2
|
||||||
|
} INSERT AFTER .bss;
|
||||||
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user