|
|
|
@ -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) -> ! { |
|
|
|
|