Marc Poulhiès 3 years ago
parent
commit
3d57a4e323
  1. 45
      .cargo/config
  2. 30
      src/main.rs

45
.cargo/config

@ -1,47 +1,3 @@
[target.thumbv6m-none-eabi]
runner = 'arm-none-eabi-gdb'
rustflags = [
# LLD (shipped with the Rust toolchain) is used as the default linker
"-C", "link-arg=-Tlink.x"
# if you run into problems with LLD switch to the GNU linker by commenting out
# this line
# "-C", "linker=arm-none-eabi-ld",
# if you need to link to pre-compiled C libraries provided by a C toolchain
# use GCC as the linker by commenting out both lines above and then
# uncommenting the three lines below
# "-C", "linker=arm-none-eabi-gcc",
# "-C", "link-arg=-Wl,-Tlink.x",
# "-C", "link-arg=-nostartfiles",
]
[target.thumbv7m-none-eabi]
runner = 'arm-none-eabi-gdb'
rustflags = [
# the comments under `[target.thumbv6m-none-eabi]` also apply here
"-C", "link-arg=-Tlink.x",
# "-C", "linker=arm-none-eabi-ld",
# "-C", "linker=arm-none-eabi-gcc",
# "-C", "link-arg=-Wl,-Tlink.x",
# "-C", "link-arg=-nostartfiles",
]
[target.thumbv7em-none-eabi]
runner = 'arm-none-eabi-gdb'
rustflags = [
# the comments under `[target.thumbv6m-none-eabi]` also apply here
"-C", "link-arg=-Tlink.x",
# "-C", "linker=arm-none-eabi-ld",
# "-C", "linker=arm-none-eabi-gcc",
# "-C", "link-arg=-Wl,-Tlink.x",
# "-C", "link-arg=-nostartfiles",
]
[target.thumbv7em-none-eabihf]
runner = 'arm-none-eabi-gdb'
rustflags = [
@ -49,7 +5,6 @@ rustflags = [
"-C", "link-arg=-Tlink.x", "-C", "inline-threshold=255",
# "-C", "linker=arm-none-eabi-ld",
# "-C", "linker=arm-none-eabi-gcc",
# "-C", "link-arg=-Wl,-Tlink.x",
# "-C", "link-arg=-nostartfiles",

30
src/main.rs

@ -1,7 +1,3 @@
//! Prints "Hello, world!" on the OpenOCD console using semihosting
//!
//! ---
#![no_main]
#![no_std]
@ -15,12 +11,8 @@ extern crate panic_semihosting;
extern crate embedded_hal;
extern crate tm4c123x_hal;
//extern crate nb;
extern crate ds323x ;
//use ds323x::{ Ds323x, DateTime, Hours };
//use tm4c123x_hal::i2c::{I2c};
use tm4c123x_hal::sysctl::{self, SysctlExt};
use tm4c123x_hal::gpio::{AF2};
@ -30,9 +22,6 @@ use tm4c123x_hal::time::U32Ext;
use core::fmt::Write;
use embedded_hal as hal;
//use hal::spi::FullDuplex;
//use nb::block;
extern crate smart_leds;
extern crate ws2812_spi;
@ -41,7 +30,7 @@ use ws2812_spi as ws2812;
//use crate::ws2812::Ws2812;
//use crate::ws2812::prerendered::Timing;
use smart_leds::{colors, RGB8, SmartLedsWrite};
use smart_leds::{colors, SmartLedsWrite};
use tm4c123x_hal::spi::{Spi};
pub use crate::hal::spi::{MODE_0, MODE_1, MODE_2, MODE_3};
@ -70,7 +59,7 @@ fn main() -> ! {
(portd.pd0.into_af_push_pull::<AF2>(&mut portd.control), // SCK
portd.pd2.into_af_push_pull::<AF2>(&mut portd.control), // Miso
portd.pd3.into_af_pull_down::<AF2>(&mut portd.control)), // Mosi
ws2812::MODE,
ws2812::MODE,
3_000_000.hz(),
&clocks,
&sc.power_control
@ -79,26 +68,26 @@ fn main() -> ! {
// ws2812
const MAX: usize = 6;
// let mut rendered_data = [0; MAX * 3 * 5];
// let mut rendered_data = [0; MAX * 3 * 5];
// let mut ws = ws2812::prerendered::Ws2812::new(spi, Timing::new(3_000_000).unwrap(), &mut rendered_data);
// let mut ws = ws2812::prerendered::Ws2812::new(spi, Timing::new(3_000_000).unwrap(), &mut rendered_data);
let mut ws = ws2812::Ws2812::new(spi);
let mut data = [colors::BLUE, colors::GREEN,colors::GREEN,colors::GREEN,colors::GREEN,colors::GREEN ]; //, colors::WHITE, colors::GREEN, colors::WHITE, colors::PURPLE, colors::WHITE];
let mut data = [colors::BLUE, colors::GREEN,colors::GREEN,colors::GREEN,colors::GREEN,colors::GREEN ];
let mut count = 0;
let mut dir = true;
loop {
ws.write(data.iter().cloned()).unwrap();
if dir {
if ! dir {
data.rotate_left(1);
} else {
data.rotate_right(1);
}
if count+1==MAX {
writeln!(stdout, "swap").unwrap();
if count+2==MAX {
// writeln!(stdout, "swap").unwrap();
dir = !dir;
count = 0;
} else {
@ -109,9 +98,6 @@ fn main() -> ! {
}
}
#[exception]
/// The hard fault handler
fn HardFault(ef: &cortex_m_rt::ExceptionFrame) -> ! {

Loading…
Cancel
Save