From da50fa4de121e07225b9512c20b6ae002db9e9bf Mon Sep 17 00:00:00 2001 From: Vasily Davydov Date: Thu, 27 Apr 2023 00:47:32 +0300 Subject: [PATCH] rotary:[#9] enable interrupts on three pins --- source/shoh/src/peripherals/DigitalIoPin.cpp | 8 ++++---- source/shoh/src/threads/rotary/Rotary.cpp | 14 +++++++------- source/shoh/src/threads/rotary/Rotary.h | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/source/shoh/src/peripherals/DigitalIoPin.cpp b/source/shoh/src/peripherals/DigitalIoPin.cpp index b56c1e0..51d4021 100644 --- a/source/shoh/src/peripherals/DigitalIoPin.cpp +++ b/source/shoh/src/peripherals/DigitalIoPin.cpp @@ -75,16 +75,16 @@ DigitalIoPin::setIsr () Chip_Clock_SetIOCONFiltClockDiv(0, 64); Chip_IOCON_PinMuxSet (LPC_IOCON, _io._port, _io._pin, - (_io.IOCON_mode | _io.DigitalEn - | _io.IOCON_inv | IOCON_CLKDIV(0) - | IOCON_S_MODE(3))); + (_io.IOCON_mode | _io.DigitalEn + | _io.IOCON_inv | IOCON_CLKDIV(0) + | IOCON_S_MODE(3))); /** False direction equals input */ Chip_GPIO_SetPinDIR (LPC_GPIO, _io._port, _io._pin, direction); /* Enable PININT clock if it was not enabled before */ if ((LPC_SYSCTL->SYSAHBCLKCTRL & (1 << SYSCTL_CLOCK_PINT)) == 0) { - Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_PINT); + Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_PINT); } /* Configure interrupt channel for the GPIO pin in SysCon block */ Chip_SYSCTL_SetPinInterrupt(_io.isr_i, _io._port, _io._pin); diff --git a/source/shoh/src/threads/rotary/Rotary.cpp b/source/shoh/src/threads/rotary/Rotary.cpp index 9e5d12b..f35cbd9 100644 --- a/source/shoh/src/threads/rotary/Rotary.cpp +++ b/source/shoh/src/threads/rotary/Rotary.cpp @@ -13,24 +13,21 @@ extern "C" void PIN_INT0_IRQHandler (void) { - //portEND_SWITCHING_ISR (); + Chip_PININT_ClearIntStatus (LPC_PININT, PININTCH (PIN_INT0_IRQn)); } void PIN_INT1_IRQHandler (void) { - //portEND_SWITCHING_ISR (); + Chip_PININT_ClearIntStatus (LPC_PININT, PININTCH (PIN_INT1_IRQn)); } void PIN_INT2_IRQHandler (void) { - //portEND_SWITCHING_ISR (); + Chip_PININT_ClearIntStatus (LPC_PININT, PININTCH (PIN_INT2_IRQn)); } } -// For example -#define GPIO_PININT_PIN 1 /* GPIO pin number mapped to PININT */ -#define GPIO_PININT_PORT 0 /* GPIO port number mapped to PININT */ Rotary::Rotary(ThreadCommon::QueueManager* qm) : _qm(qm) { @@ -44,7 +41,10 @@ void Rotary::taskFunction() Event data(Event::Null, 0); Event* e = new Event(Event::Rotary, ThreadCommon::RotaryAction::Idle); _qm->send(ThreadCommon::QueueManager::master_event_all, e, 10); - for (;;) {} + for (;;) + { + vTaskDelay(500); + } } void rotary_thread(void* pvParams) diff --git a/source/shoh/src/threads/rotary/Rotary.h b/source/shoh/src/threads/rotary/Rotary.h index d67bd4a..b47e38c 100644 --- a/source/shoh/src/threads/rotary/Rotary.h +++ b/source/shoh/src/threads/rotary/Rotary.h @@ -20,7 +20,7 @@ public: private: Event* message; ThreadCommon::QueueManager* _qm; - DigitalIoPin signal[3] = { { 0, 6, true, false, false, true, PIN_INT0_IRQn}, + DigitalIoPin signal[3] = { { 0, 1, true, true, false, true, PIN_INT0_IRQn}, { 0, 5, true, false, false, true, PIN_INT1_IRQn}, { 1, 8, true, false, false, true, PIN_INT2_IRQn} }; };