aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-02-20 23:13:38 +0000
committerRobin Krahl <robin.krahl@ireas.org>2019-02-21 00:16:00 +0100
commit853e613769087a4bf67023e42f7fc4f3b92339fb (patch)
treeacfa941c5be18587d0299710b3e77e42666d3212 /src/main.rs
parent3e31f2f9f6d7d087b136299468a4a2babdf6ccfb (diff)
downloadntw-853e613769087a4bf67023e42f7fc4f3b92339fb.tar.gz
ntw-853e613769087a4bf67023e42f7fc4f3b92339fb.tar.bz2
Split struct Crc into trait Crc and struct Stm32Crc
There are different ways to implement the CRC check: For testing, we might want to calulate the CRC in the software. On STM32 MCUs, we want to use the CRC peripheral. This patch splits the struct Crc into the Crc trait and the Stm32Crc struct implementing Crc using the CRC peripheral. The Nitrokey struct can now accept any Crc implementation.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 7e364ab..eb01dd6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -19,7 +19,7 @@ use hal::prelude::*;
use stm32f103xx_usb::UsbBus;
use usb_device::class::UsbClass;
-use crate::crc::Crc;
+use crate::crc::Stm32Crc;
use crate::device::Nitrokey;
use crate::hid::HidClass;
@@ -28,7 +28,7 @@ fn main() -> ! {
let p = hal::stm32::Peripherals::take().unwrap();
p.RCC.ahbenr.modify(|_, w| w.crcen().set_bit());
- let crc = Crc::new(p.CRC);
+ let crc = Stm32Crc::new(p.CRC);
let mut flash = p.FLASH.constrain();
let mut rcc = p.RCC.constrain();