Skip to content

Conversation

@mmurray22
Copy link
Owner

@mmurray22 mmurray22 commented Apr 12, 2020

Pull Request Overview

This pull request adds the QDEC peripheral functionality to TockOS. This includes an addition of HIL and Capsule files. The associated documentation that helped guide the design and implementation of the qdec can be found here.

Testing Strategy

There is a corresponding userspace application which actively tests the full end-to-end functionality of the QDEC peripheral. In order to test the QDEC, a rotary encoder, nrf52840dk board, and three wires hooked up between the rotary encoder and the GPIO Pins 02, 29, and GND.

This pull request was tested and verified by Michaela Murray (author) and Hudson Ayers.

Documentation Updated

  • Any documentation related to listing all available peripherals may need to be updated.

Formatting

  • Ran make formatall.

@mmurray22 mmurray22 assigned mmurray22 and hudson-ayers and unassigned mmurray22 Apr 12, 2020
Copy link
Collaborator

@hudson-ayers hudson-ayers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Michaela, I made some notes throughout about (mostly small) changes I think are needed -- let me know if you have any questions. I think the most important test of this will be whether you are able to build a usable userspace QDEC application with this interface -- I am a little concerned that the interrupt focused interface could fall apart if the encoder fires quickly, and interrupts could be dropped before callbacks are delivered to userspace

@mmurray22
Copy link
Owner Author

How does it look now? I will run userspace tests later tonight/tomorrow morning.

Comment on lines 57 to 116
peripheral_interrupts::SPI0_TWI0 => {
// SPI0 and TWI0 share interrupts.
// Dispatch the correct handler.
match (spi::SPIM0.is_enabled(), i2c::TWIM0.is_enabled()) {
(false, false) => (),
(true, false) => spi::SPIM0.handle_interrupt(),
(false, true) => i2c::TWIM0.handle_interrupt(),
(true, true) => debug_assert!(
false,
"SPIM0 and TWIM0 cannot be \
enabled at the same time."
),
}
}
peripheral_interrupts::SPI1_TWI1 => {
// SPI1 and TWI1 share interrupts.
// Dispatch the correct handler.
match (spi::SPIM1.is_enabled(), i2c::TWIM1.is_enabled()) {
(false, false) => (),
(true, false) => spi::SPIM1.handle_interrupt(),
(false, true) => i2c::TWIM1.handle_interrupt(),
(true, true) => debug_assert!(
false,
"SPIM1 and TWIM1 cannot be \
enabled at the same time."
),
}
}
peripheral_interrupts::SPIM2_SPIS2_SPI2 => spi::SPIM2.handle_interrupt(),
peripheral_interrupts::ADC => adc::ADC.handle_interrupt(),
peripheral_interrupts::QDEC => qdec::QDEC.handle_interrupt(),
_ => debug!("NvicIdx not supported by Tock"),
// match interrupt {
// peripheral_interrupts::ECB => nrf5x::aes::AESECB.handle_interrupt(),
// peripheral_interrupts::GPIOTE => self.gpio_port.handle_interrupt(),
// peripheral_interrupts::POWER_CLOCK => power::POWER.handle_interrupt(),
// peripheral_interrupts::RADIO => {
// match (
// ieee802154_radio::RADIO.is_enabled(),
// ble_radio::RADIO.is_enabled(),
// ) {
// (false, false) => (),
// (true, false) => ieee802154_radio::RADIO.handle_interrupt(),
// (false, true) => ble_radio::RADIO.handle_interrupt(),
// (true, true) => debug!(
// "nRF 802.15.4 and BLE radios cannot be simultaneously enabled!"
// ),
// }
// }
// peripheral_interrupts::RNG => nrf5x::trng::TRNG.handle_interrupt(),
// peripheral_interrupts::RTC1 => nrf5x::rtc::RTC.handle_interrupt(),
// peripheral_interrupts::TEMP => nrf5x::temperature::TEMP.handle_interrupt(),
// peripheral_interrupts::TIMER0 => nrf5x::timer::TIMER0.handle_interrupt(),
// peripheral_interrupts::TIMER1 => nrf5x::timer::ALARM1.handle_interrupt(),
// peripheral_interrupts::TIMER2 => nrf5x::timer::TIMER2.handle_interrupt(),
// peripheral_interrupts::UART0 => uart::UARTE0.handle_interrupt(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You commented out all interrupts!

for cntr in self.apps.iter() {
cntr.enter(|app, _| {
if app.subscribed {
app.subscribed = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't set to false here -- apps want to continue receiving interrupts without resubscribing

@mmurray22 mmurray22 changed the title Qdec HIL and Capsule QDEC Peripheral incorporated into tockOS Sep 15, 2020
Copy link
Collaborator

@hudson-ayers hudson-ayers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really close! If you want to make these few changes I am happy to go ahead and rebase this PR on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants