Skip to content

Commit

Permalink
[exti] Adapt library code to EXTI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Sep 29, 2021
1 parent 8e8bce6 commit c0aeaae
Show file tree
Hide file tree
Showing 49 changed files with 62 additions and 214 deletions.
1 change: 1 addition & 0 deletions examples/nucleo_f411re/radio/lbuild.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<extends>modm:nucleo-f411re</extends>
<modules>
<module>modm:driver:nrf24</module>
<module>modm:platform:exti</module>
<module>modm:platform:spi:2</module>
<module>modm:platform:spi:3</module>
<module>modm:platform:timer:2</module>
Expand Down
32 changes: 10 additions & 22 deletions examples/nucleo_f411re/radio/radio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,6 @@ using Nrf1Phy = modm::Nrf24Phy<Nrf1Spi, Nrf1Csn, Nrf1Ce>;
using Nrf1Config = modm::Nrf24Config<Nrf1Phy>;
using Nrf1Data = modm::Nrf24Data<Nrf1Phy, ClockUs>;


// 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;
Expand All @@ -81,13 +72,6 @@ using Nrf2Phy = modm::Nrf24Phy<Nrf2Spi, Nrf2Csn, Nrf2Ce>;
using Nrf2Config = modm::Nrf24Config<Nrf2Phy>;
using Nrf2Data = modm::Nrf24Data<Nrf2Phy, ClockUs>;

MODM_ISR(EXTI15_10) // From PB12
{
Nrf2Irq::acknowledgeExternalInterruptFlag();
Board::LedD13::toggle();
Nrf2Data::interruptHandler();
}

void inline
initializeSpi(uint8_t instances=0b11)
{
Expand Down Expand Up @@ -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<Nrf1Irq>(Exti::Trigger::FallingEdge, [](uint8_t)
{
Board::LedD13::toggle();
Nrf1Data::interruptHandler();
});
}
if (instances & 0b10)
{
Expand All @@ -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<Nrf2Irq>(Exti::Trigger::FallingEdge, [](uint8_t)
{
Board::LedD13::toggle();
Nrf2Data::interruptHandler();
});
}
}
6 changes: 6 additions & 0 deletions examples/stm32f469_discovery/blink/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ main()
uint32_t ms_counter{0};
uint32_t us_counter{0};

Exti::connect<Board::Button>(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)
{
{
Expand Down
5 changes: 4 additions & 1 deletion examples/stm32f469_discovery/blink/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
<option name="modm:build:build.path">../../../build/stm32f469_discovery/blink</option>
</options>
<modules>
<module>modm:platform:gpio</module>
<module>modm:platform:exti</module>
<module>modm:processing:timer</module>
<module>modm:build:scons</module>
</modules>
<collectors>
<collect name="modm:build:cppdefines">MODM_EXTI_HANDLER_STORAGE=12</collect>
</collectors>
</library>
5 changes: 2 additions & 3 deletions examples/stm32f469_discovery/touchscreen/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
49 changes: 13 additions & 36 deletions examples/stm32f4_discovery/exti/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,7 @@
#include <modm/architecture/interface/interrupt.hpp>

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
Expand All @@ -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<Button>(Exti::Trigger::RisingEdge, [](uint8_t)
{
LedBlue::set();
modm::delay(1ms);
LedBlue::reset();
});

// pull pin E11 low to see the orange led light up
Irq::setInput(Gpio::InputType::PullUp);
Irq::setInputTrigger(Irq::InputTrigger::BothEdges);
Irq::enableExternalInterrupt();
Irq::enableExternalInterruptVector(14);
Exti::connect<Irq>(Exti::Trigger::BothEdges, [](uint8_t)
{
LedOrange::set();
modm::delay(1ms);
LedOrange::reset();
});

while (true)
{
Expand Down
2 changes: 1 addition & 1 deletion examples/stm32f4_discovery/exti/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</options>
<modules>
<module>modm:architecture:interrupt</module>
<module>modm:platform:gpio</module>
<module>modm:platform:exti</module>
<module>modm:build:scons</module>
</modules>
</library>
3 changes: 0 additions & 3 deletions src/modm/board/devebox_stm32f4xx/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ initialize()
LedGreen::setOutput(modm::Gpio::Low);

Button::setInput(Gpio::InputType::PullDown);
Button::setInputTrigger(Gpio::InputTrigger::RisingEdge);
Button::enableExternalInterrupt();
// Button::enableExternalInterruptVector(12);
}


Expand Down
6 changes: 0 additions & 6 deletions src/modm/board/devebox_stm32h750vb/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,8 @@ initialize()
SysTickTimer::initialize<SystemClock>();

LedGreen::setOutput(modm::Gpio::Low);

ButtonK1::setInput(Gpio::InputType::PullUp);
ButtonK1::setInputTrigger(Gpio::InputTrigger::FallingEdge);
ButtonK1::enableExternalInterrupt();

ButtonK2::setInput(Gpio::InputType::PullUp);
ButtonK2::setInputTrigger(Gpio::InputTrigger::FallingEdge);
ButtonK2::enableExternalInterrupt();
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/modm/board/disco_f051r8/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ initialize()
LedBlue::setOutput(modm::Gpio::Low);

Button::setInput();
Button::setInputTrigger(Gpio::InputTrigger::RisingEdge);
Button::enableExternalInterrupt();
// Button::enableExternalInterruptVector(12);
}

} // namespace Board
Expand Down
11 changes: 0 additions & 11 deletions src/modm/board/disco_f072rb/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,25 +125,14 @@ initialize()
LedRight::setOutput(modm::Gpio::Low);

Button::setInput();
Button::setInputTrigger(Gpio::InputTrigger::RisingEdge);
Button::enableExternalInterrupt();
// Button::enableExternalInterruptVector(12);
}


inline void
initializeL3g()
{
l3g::Int1::setInput();
l3g::Int1::setInputTrigger(Gpio::InputTrigger::RisingEdge);
l3g::Int1::enableExternalInterrupt();
// l3g::Int1::enableExternalInterruptVector(12);

l3g::Int2::setInput();
l3g::Int2::setInputTrigger(Gpio::InputTrigger::RisingEdge);
l3g::Int2::enableExternalInterrupt();
// l3g::Int2::enableExternalInterruptVector(12);

l3g::Cs::setOutput(modm::Gpio::High);

l3g::SpiMaster::connect<l3g::Sck::Sck, l3g::Mosi::Mosi, l3g::Miso::Miso>();
Expand Down
3 changes: 0 additions & 3 deletions src/modm/board/disco_f100rb/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ initialize()
LedBlue::setOutput(modm::Gpio::Low);

Button::setInput();
Button::setInputTrigger(Gpio::InputTrigger::RisingEdge);
Button::enableExternalInterrupt();
// Button::enableExternalInterruptVector(12);
}

}
Expand Down
22 changes: 0 additions & 22 deletions src/modm/board/disco_f303vc/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,25 +171,14 @@ initialize()
Leds::setOutput(modm::Gpio::Low);

Button::setInput();
Button::setInputTrigger(Gpio::InputTrigger::RisingEdge);
Button::enableExternalInterrupt();
// Button::enableExternalInterruptVector(12);
}


inline void
initializeL3g()
{
l3g::Int1::setInput();
l3g::Int1::setInputTrigger(Gpio::InputTrigger::RisingEdge);
l3g::Int1::enableExternalInterrupt();
// l3g::Int1::enableExternalInterruptVector(12);

l3g::Int2::setInput();
l3g::Int2::setInputTrigger(Gpio::InputTrigger::RisingEdge);
l3g::Int2::enableExternalInterrupt();
// l3g::Int2::enableExternalInterruptVector(12);

l3g::Cs::setOutput(modm::Gpio::High);

l3g::SpiMaster::connect<l3g::Sck::Sck, l3g::Mosi::Mosi, l3g::Miso::Miso>();
Expand All @@ -202,19 +191,8 @@ inline void
initializeLsm3()
{
lsm3::Int1::setInput();
lsm3::Int1::setInputTrigger(Gpio::InputTrigger::RisingEdge);
lsm3::Int1::enableExternalInterrupt();
// lsm3::Int1::enableExternalInterruptVector(12);

lsm3::Int2::setInput();
lsm3::Int2::setInputTrigger(Gpio::InputTrigger::RisingEdge);
lsm3::Int2::enableExternalInterrupt();
// lsm3::Int2::enableExternalInterruptVector(12);

lsm3::Drdy::setInput();
lsm3::Drdy::setInputTrigger(Gpio::InputTrigger::RisingEdge);
lsm3::Drdy::enableExternalInterrupt();
// lsm3::Drdy::enableExternalInterruptVector(12);

lsm3::I2cMaster::connect<lsm3::Scl::Scl, lsm3::Sda::Sda>();
lsm3::I2cMaster::initialize<SystemClock, 400_kHz>();
Expand Down
7 changes: 0 additions & 7 deletions src/modm/board/disco_f407vg/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,12 @@ initialize()
Leds::setOutput(modm::Gpio::Low);

Button::setInput();
Button::setInputTrigger(Gpio::InputTrigger::RisingEdge);
Button::enableExternalInterrupt();
// Button::enableExternalInterruptVector(12);
}

inline void
initializeLis3()
{
lis3::Int::setInput();
lis3::Int::setInputTrigger(Gpio::InputTrigger::RisingEdge);
lis3::Int::enableExternalInterrupt();
// lis3::Int::enableExternalInterruptVector(12);

lis3::Cs::setOutput(modm::Gpio::High);

lis3::SpiMaster::connect<lis3::Sck::Sck, lis3::Mosi::Mosi, lis3::Miso::Miso>();
Expand Down
11 changes: 0 additions & 11 deletions src/modm/board/disco_f429zi/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,25 +228,14 @@ initialize()
LedRed::setOutput(modm::Gpio::Low);

Button::setInput();
Button::setInputTrigger(Gpio::InputTrigger::RisingEdge);
Button::enableExternalInterrupt();
// Button::enableExternalInterruptVector(12);
}


inline void
initializeL3g()
{
l3g::Int1::setInput();
l3g::Int1::setInputTrigger(Gpio::InputTrigger::RisingEdge);
l3g::Int1::enableExternalInterrupt();
// l3g::Int1::enableExternalInterruptVector(12);

l3g::Int2::setInput();
l3g::Int2::setInputTrigger(Gpio::InputTrigger::RisingEdge);
l3g::Int2::enableExternalInterrupt();
// l3g::Int2::enableExternalInterruptVector(12);

l3g::Cs::setOutput(modm::Gpio::High);

l3g::SpiMaster::connect<l3g::Sck::Sck, l3g::Mosi::Mosi, l3g::Miso::Miso>();
Expand Down
6 changes: 0 additions & 6 deletions src/modm/board/disco_f469ni/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,6 @@ inline void
initializeTouchscreen()
{
ft6::Int::setInput();
ft6::Int::setInputTrigger(Gpio::InputTrigger::FallingEdge);
ft6::Int::enableExternalInterrupt();
// ft6::Int::enableExternalInterruptVector(12);

ft6::I2cMaster::connect<ft6::Scl::Scl, ft6::Sda::Sda>();
ft6::I2cMaster::initialize<SystemClock, 360_kHz>();
Expand Down Expand Up @@ -228,9 +225,6 @@ initialize()
LedOrange::setOutput(modm::Gpio::Low);

Button::setInput();
Button::setInputTrigger(Gpio::InputTrigger::RisingEdge);
Button::enableExternalInterrupt();
// Button::enableExternalInterruptVector(12);
}

inline void
Expand Down
3 changes: 0 additions & 3 deletions src/modm/board/disco_f746ng/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,6 @@ initialize()
stlink::Uart::initialize<SystemClock, 115200_Bd>();

Button::setInput();
Button::setInputTrigger(Gpio::InputTrigger::RisingEdge);
Button::enableExternalInterrupt();
// Button::enableExternalInterruptVector(12);

// Disable Backlight
GpioK3::setOutput(modm::Gpio::Low);
Expand Down
3 changes: 0 additions & 3 deletions src/modm/board/disco_f769ni/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@ initialize()
stlink::Uart::initialize<SystemClock, 115200_Bd>();

Button::setInput();
Button::setInputTrigger(Gpio::InputTrigger::RisingEdge);
Button::enableExternalInterrupt();
// Button::enableExternalInterruptVector(12);
}

}
Expand Down
3 changes: 0 additions & 3 deletions src/modm/board/disco_l476vg/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ initialize()
LedRed::setOutput(modm::Gpio::Low);

Button::setInput();
Button::setInputTrigger(Gpio::InputTrigger::RisingEdge);
Button::enableExternalInterrupt();
// Button::enableExternalInterruptVector(12);
}

/// You must take out the LCD screen and close SB24 and SB25 for USB to work
Expand Down
Loading

0 comments on commit c0aeaae

Please sign in to comment.