Skip to content

Commit

Permalink
PowerTypes prototype generalized to Tock registers
Browse files Browse the repository at this point in the history
Tock registers power aware write/on/off not yet implemented
but all the pieces for this are there.
  • Loading branch information
tyler-potyondy committed Aug 8, 2024
1 parent a3a1f9d commit 30442d2
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 202 deletions.
4 changes: 2 additions & 2 deletions boards/nordic/nrf52840dk/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use kernel::debug::IoWrite;
use kernel::hil::uart;
use kernel::hil::uart::Configure;

use nrf52840::uart::{Uarte, UARTE0_BASE};
use nrf52840::uart::{Uarte, UART0_BASE_ADDR};

enum Writer {
WriterUart(/* initialized */ bool),
Expand Down Expand Up @@ -44,7 +44,7 @@ impl IoWrite for Writer {
// Here, we create a second instance of the Uarte struct.
// This is okay because we only call this during a panic, and
// we will never actually process the interrupts
let uart = Uarte::new(UARTE0_BASE);
let uart = Uarte::new(UART0_BASE_ADDR);
if !*initialized {
*initialized = true;
let _ = uart.configure(uart::Parameters {
Expand Down
6 changes: 0 additions & 6 deletions boards/nordic/nrf52_components/src/startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ use kernel::component::Component;
use nrf52::gpio::Pin;
use nrf52::uicr::Regulator0Output;

use kernel::utilities::StaticRef;

pub struct NrfStartupComponent<'a> {
nfc_as_gpios: bool,
button_rst_pin: Pin,
Expand Down Expand Up @@ -191,21 +189,18 @@ pub struct UartChannelComponent {
uart_channel: UartChannel<'static>,
mux_alarm: &'static MuxAlarm<'static, nrf52::rtc::Rtc<'static>>,
uarte0: &'static nrf52::uart::Uarte<'static>,
uart_power: nrf52::uart::PowerOff<StaticRef<nrf52::uart::UarteRegisters>>,
}

impl UartChannelComponent {
pub fn new(
uart_channel: UartChannel<'static>,
mux_alarm: &'static MuxAlarm<'static, nrf52::rtc::Rtc<'static>>,
uarte0: &'static nrf52::uart::Uarte<'static>,
uart_power: nrf52::uart::PowerOff<StaticRef<nrf52::uart::UarteRegisters>>,
) -> Self {
Self {
uart_channel,
mux_alarm,
uarte0,
uart_power,
}
}
}
Expand All @@ -224,7 +219,6 @@ impl Component for UartChannelComponent {
UartChannel::Pins(uart_pins) => {
unsafe {
self.uarte0.initialize(
self.uart_power,
nrf52::pinmux::Pinmux::new(uart_pins.txd as u32),
nrf52::pinmux::Pinmux::new(uart_pins.rxd as u32),
uart_pins.cts.map(|x| nrf52::pinmux::Pinmux::new(x as u32)),
Expand Down
4 changes: 2 additions & 2 deletions boards/nordic/nrf52dk/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use kernel::debug::IoWrite;
use kernel::hil::led;
use kernel::hil::uart::{self, Configure};
use nrf52832::gpio::Pin;
use nrf52832::uart::{Uarte, UARTE0_BASE};
use nrf52832::uart::{Uarte, UART0_BASE_ADDR};

use crate::CHIP;
use crate::PROCESSES;
Expand All @@ -33,7 +33,7 @@ impl IoWrite for Writer {
// Here, we create a second instance of the Uarte struct.
// This is okay because we only call this during a panic, and
// we will never actually process the interrupts
let uart = Uarte::new(UARTE0_BASE);
let uart = Uarte::new(UART0_BASE_ADDR);
if !self.initialized {
self.initialized = true;
let _ = uart.configure(uart::Parameters {
Expand Down
8 changes: 2 additions & 6 deletions chips/nrf52/src/chip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use core::fmt::Write;
use cortexm4::{nvic, CortexM4, CortexMVariant};
use kernel::platform::chip::InterruptService;

use crate::uart::UarteRegisters;
use kernel::utilities::StaticRef;
use crate::uart::UART0_BASE_ADDR;

pub struct NRF52<'a, I: InterruptService + 'a> {
mpu: cortexm4::mpu::MPU,
Expand Down Expand Up @@ -42,7 +41,6 @@ pub struct Nrf52DefaultPeripherals<'a> {
pub timer1: crate::timer::TimerAlarm<'a>,
pub timer2: crate::timer::Timer,
pub uarte0: crate::uart::Uarte<'a>,
pub uart_power: crate::uart::PowerOff<StaticRef<UarteRegisters>>,
pub spim0: crate::spi::SPIM<'a>,
pub twi1: crate::i2c::TWI<'a>,
pub spim2: crate::spi::SPIM<'a>,
Expand All @@ -54,7 +52,6 @@ pub struct Nrf52DefaultPeripherals<'a> {

impl<'a> Nrf52DefaultPeripherals<'a> {
pub fn new() -> Self {
let (uart_peripheral, uart_power) = crate::uart::Uarte::new(crate::uart::UARTE0_BASE);
Self {
acomp: crate::acomp::Comparator::new(),
ecb: crate::aes::AesECB::new(),
Expand All @@ -66,8 +63,7 @@ impl<'a> Nrf52DefaultPeripherals<'a> {
timer0: crate::timer::TimerAlarm::new(0),
timer1: crate::timer::TimerAlarm::new(1),
timer2: crate::timer::Timer::new(2),
uarte0: uart_peripheral,
uart_power: uart_power,
uarte0: crate::uart::Uarte::new(UART0_BASE_ADDR),
spim0: crate::spi::SPIM::new(0),
twi1: crate::i2c::TWI::new_twi1(),
spim2: crate::spi::SPIM::new(2),
Expand Down
Loading

0 comments on commit 30442d2

Please sign in to comment.