Skip to content
Snippets Groups Projects
Verified Commit 972c9c91 authored by Jonathan Brouwer's avatar Jonathan Brouwer
Browse files

Merge branch 'remove_pin20' into 2-read-imu

parents 7629ef93 258bddb5
No related branches found
No related tags found
4 merge requests!11Resolve "Reading MPU over I2C hangs",!10Resolve "Reading MPU over I2C hangs": Attempt 4,!9Resolve "Reading MPU over I2C hangs",!8Resolve "Template code hangs on reading yaw, pitch, and roll."
Pipeline #818197 passed
[package]
name = "tudelft-quadrupel"
version = "2.0.0"
version = "2.0.1"
edition = "2021"
authors = [
"Anne Stijns <anstijns@gmail.com>",
......
......@@ -97,7 +97,6 @@ pub fn initialize(heap_memory: &'static mut [MaybeUninit<u8>], debug: bool) {
&mut cortex_m_peripherals.NVIC,
&mut nrf51_peripherals.PPI,
&mut nrf51_peripherals.GPIOTE,
gpio.p0_20,
);
if debug {
let _ = send_bytes(b"MOTOR driver initialized\n");
......
use crate::mutex::Mutex;
use crate::nrf51_hal::prelude::OutputPin;
use crate::once_cell::OnceCell;
use cortex_m::peripheral::NVIC;
use nrf51_hal::gpio::p0::P0_20;
use nrf51_hal::gpio::{Disconnected, Level, Output, PushPull};
use nrf51_pac::{interrupt, Interrupt, GPIOTE, PPI};
struct Motors {
......@@ -11,7 +8,6 @@ struct Motors {
motor_max: u16,
timer1: nrf51_pac::TIMER1,
timer2: nrf51_pac::TIMER2,
pin20: P0_20<Output<PushPull>>,
}
const MOTOR_0_PIN: u8 = 21;
......@@ -63,18 +59,13 @@ pub(crate) fn initialize(
nvic: &mut NVIC,
ppi: &mut PPI,
gpiote: &mut GPIOTE,
pin20: P0_20<Disconnected>,
) {
// Configure pin20
let pin20 = pin20.into_push_pull_output(Level::Low);
MOTORS.modify(|motors| {
motors.initialize(Motors {
motor_values: [0; 4],
motor_max: 400,
timer1,
timer2,
pin20,
});
// Configure GPIOTE. GPIOTE is stands for GPIO tasks and events.
......@@ -270,11 +261,9 @@ unsafe fn TIMER1() {
motors.timer1.tasks_capture[2].write(|w| w.bits(1));
if motors.timer1.cc[2].read().bits() < 500 {
motors.pin20.set_high().unwrap();
// Safety: Any time is allowed
motors.timer1.cc[0].write(|w| w.bits(u32::from(1000 + motors.motor_values[0])));
motors.timer1.cc[1].write(|w| w.bits(u32::from(1000 + motors.motor_values[1])));
motors.pin20.set_low().unwrap();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment