diff --git a/README.md b/README.md index 43c37ee9ce..348713298e 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Here is a table with all device families and the peripheral drivers they support - ✅ Implemented as a software driver in modm. - ○ Available in hardware but missing a software driver in modm. -- ✗ Unavailable in hardware or device with that peripheral not supported by modm. +- ✕ Unavailable in hardware or device with that peripheral not supported by modm. Note that this is a summary overview and your specific device may not have all the peripherals in this table. @@ -146,26 +146,26 @@ Please [discover modm's peripheral drivers for your specific device][discover]. ✅ ✅ ✅ -✗ +✕ ✅ ○ -✗ -✗ +✕ +✕ ✅ -✗ -✗ +✕ +✕ ○ ○ ○ -✗ +✕ Comparator ○ -✗ -✗ +✕ +✕ ✅ -✗ -✗ +✕ +✕ ○ ✅ ○ @@ -173,7 +173,7 @@ Please [discover modm's peripheral drivers for your specific device][discover]. ○ ✅ ○ -✗ +✕ ○ ○ ○ @@ -193,11 +193,11 @@ Please [discover modm's peripheral drivers for your specific device][discover]. ✅ ✅ ○ -✗ +✕ ○ -✗ +✕ ○ -✗ +✕ DMA ✅ @@ -213,31 +213,31 @@ Please [discover modm's peripheral drivers for your specific device][discover]. ✅ ✅ ○ -✗ +✕ ○ -✗ -✗ -✗ +✕ +✕ +✕ Ethernet -✗ +✕ ○ ○ -✗ +✕ ○ ✅ -✗ -✗ +✕ +✕ ○ -✗ -✗ -✗ -✗ -✗ -✗ -✗ -✗ -✗ +✕ +✕ +✕ +✕ +✕ +✕ +✕ +✕ +✕ External Interrupt ✅ @@ -253,31 +253,31 @@ Please [discover modm's peripheral drivers for your specific device][discover]. ✅ ✅ ✅ -✗ -✗ +○ +○ ✅ ✅ ✅ External Memory -✗ +✕ ✅ ✅ -✗ +✕ ✅ ○ -✗ +✕ ○ ○ -✗ -✗ +✕ +✕ ○ -✗ -✗ +✕ +✕ ○ -✗ -✗ -✗ +✕ +✕ +✕ GPIO ✅ @@ -335,29 +335,29 @@ Please [discover modm's peripheral drivers for your specific device][discover]. ○ ○ ○ -✗ -✗ -✗ +✕ +✕ +✕ Random Generator -✗ -✗ +✕ +✕ ✅ -✗ +✕ ✅ ✅ ✅ ✅ ✅ ✅ -✗ +✕ ✅ -✗ -✗ +✕ +✕ ○ -✗ -✗ -✗ +✕ +✕ +✕ SPI ✅ @@ -393,11 +393,11 @@ Please [discover modm's peripheral drivers for your specific device][discover]. ✅ ✅ ✅ -✗ -✗ -✗ -✗ -✗ +✕ +✕ +✕ +✕ +✕ Timer ✅ @@ -452,12 +452,12 @@ Please [discover modm's peripheral drivers for your specific device][discover]. ✅ ✅ ✅ -✗ -✗ -✗ -✗ -✗ -✗ +✕ +✕ +✕ +✕ +✕ +✕ USB ✅ @@ -466,7 +466,7 @@ Please [discover modm's peripheral drivers for your specific device][discover]. ✅ ✅ ✅ -✗ +✕ ✅ ✅ ✅ @@ -475,9 +475,9 @@ Please [discover modm's peripheral drivers for your specific device][discover]. ✅ ✅ ○ -✗ -✗ -✗ +✕ +✕ +✕ diff --git a/docs/src/how-modm-works.md b/docs/src/how-modm-works.md index 64e7c430ca..7f9e987ecc 100644 --- a/docs/src/how-modm-works.md +++ b/docs/src/how-modm-works.md @@ -284,9 +284,6 @@ bool state = Button::read(); // Depending on your targets, additional functions are available Led::setOutput(Gpio::OutputType::OpenDrain); Button::setInput(Gpio::InputType::PullUp); -Button::setInputTrigger(Gpio::InputTrigger::RisingEdge); -Button::enableExternalInterrupt(); -Button::acknowledgeExternalInterruptFlag(); ``` You can use these GPIOs as building blocks for more complex drivers and diff --git a/examples/nucleo_f411re/radio/lbuild.xml b/examples/nucleo_f411re/radio/lbuild.xml index c411b50221..8e2b34d6ac 100644 --- a/examples/nucleo_f411re/radio/lbuild.xml +++ b/examples/nucleo_f411re/radio/lbuild.xml @@ -2,6 +2,7 @@ modm:nucleo-f411re modm:driver:nrf24 + modm:platform:exti modm:platform:spi:2 modm:platform:spi:3 modm:platform:timer:2 diff --git a/examples/nucleo_f411re/radio/radio.hpp b/examples/nucleo_f411re/radio/radio.hpp index 5217049d67..ae18b25f45 100644 --- a/examples/nucleo_f411re/radio/radio.hpp +++ b/examples/nucleo_f411re/radio/radio.hpp @@ -60,15 +60,6 @@ using Nrf1Phy = modm::Nrf24Phy; using Nrf1Config = modm::Nrf24Config; using Nrf1Data = modm::Nrf24Data; - -// This must normally be declared in a .cpp file, NOT a header file -MODM_ISR(EXTI9_5) // From PA9 -{ - Nrf1Irq::acknowledgeExternalInterruptFlag(); - Board::LedD13::toggle(); - Nrf1Data::interruptHandler(); -} - using Nrf2Spi = SpiMaster2; using Nrf2Sck = GpioB13; using Nrf2Mosi = GpioB15; @@ -81,13 +72,6 @@ using Nrf2Phy = modm::Nrf24Phy; using Nrf2Config = modm::Nrf24Config; using Nrf2Data = modm::Nrf24Data; -MODM_ISR(EXTI15_10) // From PB12 -{ - Nrf2Irq::acknowledgeExternalInterruptFlag(); - Board::LedD13::toggle(); - Nrf2Data::interruptHandler(); -} - void inline initializeSpi(uint8_t instances=0b11) { @@ -138,9 +122,11 @@ initializeNrf(uint8_t instances=0b11, uint8_t address1=nrf_address1, uint8_t add Nrf1Config::setCrc(Nrf1Config::Crc::Crc2Byte); Nrf1Irq::setInput(Nrf1Irq::InputType::PullUp); - Nrf1Irq::setInputTrigger(Nrf1Irq::InputTrigger::FallingEdge); - Nrf1Irq::enableExternalInterrupt(); - Nrf1Irq::enableExternalInterruptVector(4); + Exti::connect(Exti::Trigger::FallingEdge, [](uint8_t) + { + Board::LedD13::toggle(); + Nrf1Data::interruptHandler(); + }); } if (instances & 0b10) { @@ -155,8 +141,10 @@ initializeNrf(uint8_t instances=0b11, uint8_t address1=nrf_address1, uint8_t add Nrf2Config::setCrc(Nrf2Config::Crc::Crc2Byte); Nrf2Irq::setInput(Nrf2Irq::InputType::PullUp); - Nrf2Irq::setInputTrigger(Nrf2Irq::InputTrigger::FallingEdge); - Nrf2Irq::enableExternalInterrupt(); - Nrf2Irq::enableExternalInterruptVector(5); + Exti::connect(Exti::Trigger::FallingEdge, [](uint8_t) + { + Board::LedD13::toggle(); + Nrf2Data::interruptHandler(); + }); } } diff --git a/examples/stm32f469_discovery/blink/main.cpp b/examples/stm32f469_discovery/blink/main.cpp index 8aad0e1025..9954d6117d 100644 --- a/examples/stm32f469_discovery/blink/main.cpp +++ b/examples/stm32f469_discovery/blink/main.cpp @@ -37,6 +37,12 @@ main() uint32_t ms_counter{0}; uint32_t us_counter{0}; + Exti::connect(Exti::Trigger::FallingEdge, [count = uint32_t(0)](uint8_t line) mutable + { + count++; + MODM_LOG_INFO << "Button called " << count << " times on line " << line << modm::endl; + }); + while (true) { { diff --git a/examples/stm32f469_discovery/blink/project.xml b/examples/stm32f469_discovery/blink/project.xml index 96fac5c54b..729234da1e 100644 --- a/examples/stm32f469_discovery/blink/project.xml +++ b/examples/stm32f469_discovery/blink/project.xml @@ -4,8 +4,11 @@ - modm:platform:gpio + modm:platform:exti modm:processing:timer modm:build:scons + + MODM_EXTI_HANDLER_STORAGE=12 + diff --git a/examples/stm32f469_discovery/touchscreen/main.cpp b/examples/stm32f469_discovery/touchscreen/main.cpp index 13444a6321..0bd3fb1e86 100644 --- a/examples/stm32f469_discovery/touchscreen/main.cpp +++ b/examples/stm32f469_discovery/touchscreen/main.cpp @@ -38,11 +38,10 @@ class LineDrawer : public modm::pt::Protothread { do { // Wait for either touchscreen interrupt or clear screen button - PT_WAIT_UNTIL(Int::getExternalInterruptFlag() or Button::read()); + PT_WAIT_UNTIL(Int::read() or Button::read()); if (Button::read()) display.clear(); - } while (not Int::getExternalInterruptFlag()); + } while (not Int::read()); - Int::acknowledgeExternalInterruptFlag(); LedRed::set(); PT_CALL(touch.readTouches()); diff --git a/examples/stm32f4_discovery/exti/main.cpp b/examples/stm32f4_discovery/exti/main.cpp index bbe899dfaf..9644e4750b 100644 --- a/examples/stm32f4_discovery/exti/main.cpp +++ b/examples/stm32f4_discovery/exti/main.cpp @@ -26,36 +26,7 @@ #include using namespace Board; - -typedef GpioInputE11 Irq; - - -/* When you choose a different pin you must choose the corresponding - * interrupt handler: (x in A, B, C, D, E, F, G, H, I) - * Px0: EXTI0 - * Px1: EXTI1 - * Px2: EXTI2 - * Px3: EXTI3 - * Px4: EXTI4 - * Px5 to Px9: EXTI9_5 - * Px10 to Px15: EXTI15_10 - */ -MODM_ISR(EXTI0) -{ - Button::acknowledgeExternalInterruptFlag(); - LedBlue::set(); - modm::delay(1ms); - LedBlue::reset(); -} - - -MODM_ISR(EXTI15_10) -{ - Irq::acknowledgeExternalInterruptFlag(); - LedOrange::set(); - modm::delay(1ms); - LedOrange::reset(); -} +using Irq = GpioInputE11; // ---------------------------------------------------------------------------- int @@ -73,15 +44,21 @@ main() // push the button to see the blue led light up Button::setInput(Gpio::InputType::Floating); - Button::setInputTrigger(Button::InputTrigger::RisingEdge); - Button::enableExternalInterrupt(); - Button::enableExternalInterruptVector(14); + Exti::connect