Skip to content
Snippets Groups Projects
Verified Commit a7b1735a authored by Jana Dönszelmann's avatar Jana Dönszelmann :sparkling_heart:
Browse files

release v3.0.0 for year 23/24

parent 43b522a9
No related branches found
No related tags found
No related merge requests found
Pipeline #993207 failed
[package]
name = "tudelft-quadrupel"
version = "2.1.0"
version = "3.0.0"
edition = "2021"
authors = [
"Anne Stijns <anstijns@gmail.com>",
"Jonathan Brouwer <jonathantbrouwer@gmail.com>",
"Jonathan Dönszelmann <jonabent@gmail.com>",
"Victor Roest <victor@xirion.net>",
"Vivian Roest <v@0x76.dev>",
]
license = "MIT"
description = "Hardware support library for the quadrupel drone project (embedded systems lab)."
......@@ -18,13 +18,15 @@ keywords = ["tudelft"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
ringbuffer = "0.12.0"
cortex-m = "0.7.6"
alloc-cortex-m = "0.4.3"
cortex-m-rt = "0.7.3"
nrf51-hal = "0.16.0"
nrf51-pac = "0.12.2"
void = { version = "1.0.2", default-features = false }
embedded-hal = { version = "0.2.7", features = ["unproven"] }
fixed = { version = "1.20" }
nb = "1.0.0"
ringbuffer = "0.15.0"
cortex-m = "=0.7.6"
alloc-cortex-m = "=0.4.3"
cortex-m-rt = "=0.7.3"
nrf51-hal = "=0.16.0"
nrf51-pac = "=0.12.2"
void = { version = "1", default-features = false }
embedded-hal = "1"
fixed = "1"
nb = "1"
......@@ -13,7 +13,7 @@ static INITIALIZED: Mutex<bool> = Mutex::new(false);
static ALLOCATOR: CortexMHeap = CortexMHeap::empty();
/// Initialize the drone board. This should be run at boot.
//t/
///
/// `heap_memory` should be a pointer to statically allocated memory.
/// Care should be taken that the mutable reference given here *really* is the
/// only mutable reference to that area of memory. That should of course be guaranteed by
......@@ -27,7 +27,10 @@ static ALLOCATOR: CortexMHeap = CortexMHeap::empty();
///
/// # Panics
/// This function will panic when called twice. Make sure this is only called once on boot
pub fn initialize(heap_memory: &'static mut [MaybeUninit<u8>], debug: bool) {
///
/// # Safety
/// safe is heap_memory is a valid pointer to memory
pub unsafe fn initialize(heap_memory: *const [MaybeUninit<u8>], debug: bool) {
// Allow time for PC to start up. The drone board starts running code immediately after upload,
// but at that time the PC may not be listening on UART etc.
assembly_delay(2_500_000);
......@@ -42,11 +45,13 @@ pub fn initialize(heap_memory: &'static mut [MaybeUninit<u8>], debug: bool) {
let mut nrf51_peripherals = Peripherals::take().unwrap();
let mut cortex_m_peripherals = cortex_m::Peripherals::take().unwrap();
// Safety: heap_memory is a valid pointer by the safety requirements of this function
assert!(!unsafe{(*heap_memory).is_empty()});
// Safety: `init` is safe when
// * only called once --> the global INITIALIZED flag is set, and we panic above if called twice
// * Heap is not empty, see the assert
assert!(!heap_memory.is_empty());
unsafe { ALLOCATOR.init(heap_memory.as_ptr().addr(), heap_memory.len()) }
// * heap_memory is a valid pointer by the safety requirements of this function
unsafe { ALLOCATOR.init(heap_memory.addr(), (*heap_memory).len()) }
let gpio = nrf51_hal::gpio::p0::Parts::new(nrf51_peripherals.GPIO);
led::initialize(gpio.p0_22, gpio.p0_24, gpio.p0_28, gpio.p0_30);
......
......
......@@ -7,8 +7,7 @@ use crate::mpu::structs::{Accel, Gyro};
use crate::time::delay_ms_assembly;
use crate::twi::TwiWrapper;
use core::marker::PhantomData;
use core::time::Duration;
use embedded_hal::blocking::i2c::{Write, WriteRead};
use embedded_hal::i2c::I2c as _;
const MPU6050_ADDRESS: u8 = 0x68;
......@@ -19,7 +18,7 @@ pub(crate) struct Mpu6050(PhantomData<()>);
impl Mpu6050 {
/// Construct a new i2c driver for the MPU-6050
pub fn new(i2c: &mut I2c) -> Self {
let mut sensor = Self(PhantomData::default());
let mut sensor = Self(PhantomData);
sensor.disable_sleep(i2c);
......
......
......@@ -2,7 +2,7 @@ use crate::mutex::Mutex;
use crate::once_cell::OnceCell;
use cortex_m::peripheral::NVIC;
use nrf51_pac::interrupt;
use ringbuffer::{ConstGenericRingBuffer, RingBuffer, RingBufferRead, RingBufferWrite};
use ringbuffer::{ConstGenericRingBuffer, RingBuffer};
const BUFFER_SIZE: usize = 256;
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment