8000 Lower Profile Changes to make Crate and Examples build with Rust 1.44 by sirhcel · Pull Request #111 · japaric/f3 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Lower Profile Changes to make Crate and Examples build with Rust 1.44 #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ lsm303dlhc = "0.2.0"
stm32f30x-hal = "0.2.0"

[dev-dependencies]
aligned = "0.2.0"
cortex-m = "0.5.0"
aligned = "0.3.2"
as-slice = "0.1.3"
cortex-m = "0.6.2"
cortex-m-rt = "0.6.5"
cortex-m-semihosting = "0.3.2"
madgwick = "0.1.1"
Expand Down
5 changes: 4 additions & 1 deletion examples/l3gd20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ fn main() -> ! {
let mut nss = gpioe
.pe3
.into_push_pull_output(&mut gpioe.moder, &mut gpioe.otyper);
nss.set_high();
{
#![allow(deprecated)]
nss.set_high();
}

// The `L3gd20` abstraction exposed by the `f3` crate requires a specific pin configuration to
// be used and won't accept any configuration other than the one used here. Trying to use a
Expand Down
12 changes: 8 additions & 4 deletions examples/log-sensors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ extern crate panic_semihosting;

use core::ptr;

use aligned::Aligned;
use aligned::{Aligned, A4};
use as_slice::AsMutSlice;
use byteorder::{ByteOrder, LE};
use cortex_m::{asm, itm};
use cortex_m_rt::entry;
Expand Down Expand Up @@ -120,7 +121,10 @@ fn main() -> ! {
let mut nss = gpioe
.pe3
.into_push_pull_output(&mut gpioe.moder, &mut gpioe.otyper);
nss.set_high();
{
#![allow(deprecated)]
nss.set_high();
}
let sck = gpioa.pa5.into_af5(&mut gpioa.moder, &mut gpioa.afrl);
let miso = gpioa.pa6.into_af5(&mut gpioa.moder, &mut gpioa.afrl);
let mosi = gpioa.pa7.into_af5(&mut gpioa.moder, &mut gpioa.afrl);
Expand All @@ -145,7 +149,7 @@ fn main() -> ! {
itm::write_all(&mut cp.ITM.stim[0], &[0]);

// Capture N samples
let mut tx_buf: Aligned<u32, [u8; 20]> = Aligned([0; 20]);
let mut tx_buf: Aligned<A4, [u8; 20]> = Aligned([0; 20]);
for _ in 0..NSAMPLES {
block!(timer.wait()).unwrap();

Expand Down Expand Up @@ -179,7 +183,7 @@ fn main() -> ! {
LE::write_i16(&mut buf[start..start + 2], g.z);

// Log data
cobs::encode(&buf, &mut tx_buf);
cobs::encode(&buf, tx_buf.as_mut_slice());

itm::write_aligned(&mut cp.ITM.stim[0], &tx_buf);
}
Expand Down
18 changes: 13 additions & 5 deletions examples/madgwick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ extern crate panic_semihosting;

use core::{f32::consts::PI, ptr};

use aligned::Aligned;
use aligned::{Aligned, A4};
use as_slice::AsMutSlice;
use byteorder::{ByteOrder, LE};
use cast::{f32, i32};
use cortex_m::itm;
Expand Down Expand Up @@ -130,7 +131,11 @@ fn main() -> ! {
let mut nss = gpioe
.pe3
.into_push_pull_output(&mut gpioe.moder, &mut gpioe.otyper);
nss.set_high();
{
#![allow(deprecated)]
nss.set_high();
}

let mut led = gpioe
.pe9
.into_push_pull_output(&mut gpioe.moder, &mut gpioe.otyper);
Expand Down Expand Up @@ -182,12 +187,15 @@ fn main() -> ! {
let ar_bias_z = (ar_bias_z / NSAMPLES) as i16;

// Turn on the LED after calibrating the gyroscope
led.set_high();
{
#![allow(deprecated)]
led.set_high();
}

let mut marg = Marg::new(BETA, 1. / f32(SAMPLE_FREQ));
let mut timer = Timer::tim2(timer.free(), SAMPLE_FREQ.hz(), clocks, &mut rcc.apb1);

let mut tx_buf: Aligned<u32, [u8; 18]> = Aligned([0; 18]);
let mut tx_buf: Aligned<A4, [u8; 18]> = Aligned([0; 18]);
loop {
block!(timer.wait()).unwrap();

Expand Down Expand Up @@ -241,7 +249,7 @@ fn main() -> ! {
// start += 4;

// Log data
cobs::encode(&buf, &mut tx_buf.array);
cobs::encode(&buf, tx_buf.as_mut_slice());

itm::write_aligned(&mut cp.ITM.stim[0], &tx_buf);
}
Expand Down
2 changes: 2 additions & 0 deletions src/led.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,13 @@ ctor!(LD3, LD4, LD5, LD6, LD7, LD8, LD9, LD10);
impl Led {
/// Turns the LED off
pub fn off(&mut self) {
#![allow(deprecated)]
self.pex.set_low()
}

/// Turns the LED on
pub fn on(&mut self) {
#![allow(deprecated)]
self.pex.set_high()
}
}
9 changes: 9 additions & 0 deletions viz/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[build]
# Configure the build target to your host platform. See
# https://forge.rust-lang.org/release/platform-support.html#tier-1 for details
# and uncomment or add the appropriate line for your host below.
#
# target = "x86_64-apple-darwin"
# target = "x86_64-pc-windows-gnu"
# target = "x86_64-unknown-linux-gnu"

4 changes: 2 additions & 2 deletions viz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ version = "0.1.0"
[dependencies]
byteorder = "1.2.1"
cobs = "0.1.3"
kiss3d = "0.13.0"
nalgebra = "0.14.0"
kiss3d = "0.24.1"
nalgebra = "0.21.1"
21 changes: 21 additions & 0 deletions viz/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# `f3` Madgwick Example Visualization

This is the visualization application for `../examples/madgwick.rs` to run on
your host.


## Building

The `f3` crate already configures its build target to `thumbv7em-none-eabihf`
and so we have to explicitly specify it when building and running the
visualization in place.

The most convenient way is likely to edit `./.cargo/config` to select your host
platform.

Alternatively you can explicitly specify it when building and running the
application. For example for Linux x86\_64:
```
$ cargo build --target x86_64-unknown-linux-gnu
$ cargo run --target x86_64-unknown-linux-gnu
```
2 changes: 1 addition & 1 deletion viz/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn main() {
fn parse(sender: &mut Sender<(f32, f32, f32, f32)>) {
let stdin = io::stdin();

for mut frame in BufReader::new(stdin.lock()).split(0) {
for frame in BufReader::new(stdin.lock()).split(0) {
let mut frame = frame.unwrap();
if let Ok(n) = cobs::decode_in_place(&mut frame) {
if n == 16 {
Expand Down
0