This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![deny(warnings)] | |
#![no_main] | |
#![no_std] | |
extern crate panic_semihosting; | |
use rtfm::app; | |
#[app(device = stm32f30x)] | |
const APP: () = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[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)(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Darwin | |
func readInt() -> Int { | |
var res: Int = 0 | |
withUnsafePointer(&res) { | |
vscanf("%d", getVaList([COpaquePointer($0)])) | |
} | |
return res | |
} |