Commit ad2fedcd authored by Michael Watzko's avatar Michael Watzko
Browse files

Update to latest rust / stm32f103xx-hal changes

parent 4ed81155
......@@ -12,7 +12,7 @@
[package]
name = "bluepill_sensor"
version = "0.3.2"
version = "0.3.3"
authors = ["Michael Watzko <michael@watzko.de>"]
description = "Stm32f103/Bluepill with W5500 ethernet chip, OneWire interface and sensor_common communication"
keywords = ["arm", "cortex-m", "onewire", "ethernet"]
......@@ -30,11 +30,20 @@ debug = false
[dependencies]
vcell = "0.1.0"
bare-metal = "0.1.1"
embedded-hal = "0.1.2"
stm32f103xx = "0.8.0"
bare-metal = "0.2.0"
cortex-m = "0.5.2"
embedded-hal = "0.2.1"
byteorder = { version = "1.2.1", default-features = false }
nb = "0.1.1"
panic-abort = "0.2.0"
[dependencies.stm32f103xx]
version = "0.10.0"
features = ["rt"]
[dependencies.cortex-m-rt]
version = "0.5.1"
[dependencies.w5500]
......@@ -50,20 +59,9 @@ version = "0.1.3"
path = "../pcd8544"
[dependencies.sensor_common]
version = "*"
path = "../sensor_common"
[dependencies.stm32f103xx-hal]
version = "0.1.0"
path = "../stm32f103xx-hal"
[dependencies.cortex-m]
version = "0.4.3"
[dependencies.cortex-m-rt]
version = "0.3.12"
features = ["abort-on-panic"]
[dependencies.cortex-m-semihosting]
version = "0.2.0"
//! Prints "Hello, world!" on the OpenOCD console using semihosting
//!
//! ---
#![feature(core_intrinsics)]
#![feature(lang_items)]
#![feature(used)]
#![no_std]
#![no_main]
extern crate cortex_m;
#[macro_use(entry, exception)]
extern crate cortex_m_rt;
extern crate cortex_m_semihosting;
extern crate panic_abort;
extern crate stm32f103xx;
extern crate stm32f103xx_hal;
......@@ -53,7 +52,6 @@ use core::fmt::Write;
use core::result::*;
use cortex_m::asm;
use self::cortex_m_semihosting::hio;
use onewire::*;
use onewire::compute_partial_crc8 as crc8;
......@@ -67,43 +65,32 @@ use byteorder::NetworkEndian;
use ds93c46::*;
use platform::*;
#[cfg(debug_assertions)]
fn stdout<A, F: FnOnce(&mut hio::HStdout) -> A>(f: F) {
/*
static mut STDOUT : Option<hio::HStdout> = None;
unsafe {
if STDOUT.is_none() {
STDOUT = match hio::hstdout() {
Ok(stdout) => Some(stdout),
Err(_) => None
};
}
if let Some(ref mut stdout) = STDOUT {
f(stdout);
}
}
*/
}
#[cfg(not(debug_assertions))]
fn stdout<A, F: FnOnce(&mut hio::HStdout) -> A>(_f: F) {
// do nothing
entry!(main);
// define the hard fault handler
exception!(HardFault, hard_fault);
fn hard_fault(ef: &cortex_m_rt::ExceptionFrame) -> ! {
panic!("HardFault at {:#?}", ef);
}
fn main() {
// define the default exception handler
exception!(*, default_handler);
stdout(|out| writeln!(out, "Hello World!"));
fn default_handler(irqn: i16) {
panic!("Unhandled exception (IRQn = {})", irqn);
}
pub fn main() -> ! {
let mut cp = cortex_m::Peripherals::take().unwrap();
let mut peripherals = stm32f103xx::Peripherals::take().unwrap();
let mut flash = peripherals.FLASH.constrain();
let mut rcc = peripherals.RCC.constrain();
let mut speed = 500_u16;
// rcc.cfgr = rcc.cfgr.sysclk(stm32f103xx_hal::time::Hertz(7_200_000_u32));
let clocks = rcc.cfgr.freeze(&mut flash.acr);
let mut delay = stm32f103xx_hal::delay::Delay::new(cp.SYST, clocks);
......@@ -112,7 +99,7 @@ fn main() {
let mut gpioc = peripherals.GPIOC.split(&mut rcc.apb2);
let mut led = gpioc.pc13.into_push_pull_output(&mut gpioc.crh);//.into_push_pull_output(&mut gpioc.crh);//.into_floating_input().is_high();
let mut one : PCx<Output<OpenDrain>> = gpioc.pc15.into_open_drain_output(&mut gpioc.crh).downgrade();//.into_push_pull_output(&mut gpioc.crh);//.into_floating_input().is_high();
let mut one = gpioc.pc15.into_open_drain_output(&mut gpioc.crh).downgrade();//.into_push_pull_output(&mut gpioc.crh);//.into_floating_input().is_high();
let mut pcd_gnd = gpiob.pb12.into_push_pull_output(&mut gpiob.crh);
......@@ -189,7 +176,7 @@ fn main() {
if platform.load_network_configuration().is_err() {
for _ in 0..4 {
platform.delay.delay_ms(1000_u16);
if led.is_low() {
if led.is_set_low() {
led.set_high();
} else {
led.set_low();
......@@ -205,7 +192,7 @@ fn main() {
loop {
if tick % 100 == 0 {
if led.is_low() {
if led.is_set_low() {
led.set_high();
} else {
led.set_low();
......@@ -484,15 +471,6 @@ impl From<onewire::Error> for HandleError {
}
// As we are not using interrupts, we just register a dummy catch all handler
#[link_section = ".vector_table.interrupts"]
#[used]
static INTERRUPTS: [extern "C" fn(); 240] = [default_handler; 240];
extern "C" fn default_handler() {
// asm::bkpt();
}
const MAGIC_EEPROM_CRC_START : u8 = 0x42;
pub struct NetworkConfiguration {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment