Skip to content

Instantly share code, notes, and snippets.

#![deny(warnings)]
#![no_main]
#![no_std]
extern crate panic_semihosting;
use rtfm::app;
#[app(device = stm32f30x)]
const APP: () = {
#![no_std]
#![no_main]
#![feature(core_intrinsics)]
use core::intrinsics;
use core::panic::PanicInfo;
use cortex_m_rt::entry;
use hal::stm32f30x::{self, interrupt};
use hal::gpio::PullUp;
#![no_std]
#![no_main]
#![feature(core_intrinsics)]
use core::intrinsics;
use core::panic::PanicInfo;
use cortex_m_rt::entry;
use hal::stm32f30x::{self, interrupt};
use hal::serial;
let device = hal::stm32f30x::Peripherals::take().unwrap();
let mut core = Peripherals::take().unwrap();
// Configure PC13 as an input
device.RCC.ahbenr.modify(|_, w| w.iopcen().set_bit());
device.GPIOC.moder.modify(
|_, w| w.moder13().input()
);
device.GPIOC.pupdr.modify(|_, w| unsafe {
w.pupdr13().bits(0b01) // Pull-up
dps = 250.0 # Based on chip settings
d2r = 3.14159265359 / 180.0
gyro_scale = dps / 32767.5 * d2r
gyro_x = np.array(gyro_x) * gyro_scale
gyro_y = np.array(gyro_y) * gyro_scale
gyro_z = np.array(gyro_z) * gyro_scale
ar = 2.0 # Based on chip settings
acc_scale = 9.807 * ar / 32767.5
diff --git a/src/lib.rs b/src/lib.rs
index ecabc08..84e5233 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -257,6 +257,13 @@ where
})
}
+ /// Self test for gyroscope and accelerometer
+ pub fn self_test(&mut self) -> Result<(), E> {
#[export_name = "_reset"]
pub unsafe extern "C" fn reset() -> ! {
asm!("
cpsie i\n
movw r0, 0xd800\n
movt r0, 0x1fff\n
ldr r0, [r0]\n
msr MSP, r0" ::: "r0" : "volatile");
let f = 0x1FFFD804u32 as *const fn();
(*f)();
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_std]
extern crate cortex_m;
extern crate embedded_hal as ehal;
extern crate stm32f30x_hal as hal;
mod beeper;
@bofh
bofh / libra2hdo.py
Last active November 28, 2015 12:18
import pandas as pd
def read_libra(path):
data = pd.read_csv(path, skiprows=3, sep=';')
data.rename(columns={'#date':'date'}, inplace=True)
return data
def read_hdo(path):
tmp = pd.read_csv(path, encoding='latin-1', nrows=5, header=4)
cols = tmp.columns
import Foundation
import Darwin
func readInt() -> Int {
var res: Int = 0
withUnsafePointer(&res) {
vscanf("%d", getVaList([COpaquePointer($0)]))
}
return res
}