From b1a2d25642fe60056b3a274b977e088f4d950d03 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Thu, 2 Jan 2020 21:46:46 +0800 Subject: [PATCH] index: add example for rust Signed-off-by: Sean Cross --- index.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/index.html b/index.html index 18ff995..2d1a4d0 100644 --- a/index.html +++ b/index.html @@ -387,6 +387,20 @@ dq.o.eq(

SVD2Rust: Generating Safe Accessors

+
fn init(&mut self) {
+    self.registers
+        .ctrl
+        .write(|w| w.exe().bit(true).curren().bit(true).rgbleden().bit(true));
+    self.write(LEDDEN | FR250 | QUICK_STOP, LedRegister::LEDDCR0);
+
+    // Set clock register to 12 MHz / 64 kHz - 1
+    self.write(((12_000_000u32 / 64_000u32) - 1) as u8, LedRegister::LEDDBR);
+
+    self.write(
+        BREATHE_ENABLE | BREATHE_MODE_FIXED | breathe_rate_ms(128),
+        LedRegister::LEDDBCRR,
+    );
+}