From 6bb5aa643b05fca5783276f79a98acc596bb4414 Mon Sep 17 00:00:00 2001 From: rtlaka Date: Tue, 7 Nov 2017 08:43:56 +0100 Subject: [PATCH] pass AL event mask to interrupt worker function --- CMakeLists.txt | 2 +- README.md | 2 +- applications/rtl_xmc4_irq/slave.c | 33 +++++++++++++++++++------------ applications/rtl_xmc4_irq/slave.h | 12 ++++++++++- soes/hal/rt-kernel-xmc4/esc_hw.c | 3 ++- soes/include/sys/gcc/cc.h | 2 ++ 6 files changed, 37 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a9d872a..a9515ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") project (SOES) set (SOES_VERSION_MAJOR 2) -set (SOES_VERSION_MINOR 0) +set (SOES_VERSION_MINOR 1) set (SOES_VERSION_PATCH 0) # Generate version numbers diff --git a/README.md b/README.md index f8a7739..1f0945b 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ SOES is an EtherCAT slave stack written in c. Its purpose is to learn and to use. All users are invited to study the source to get an understanding how an EtherCAT slave functions. -Features as of 2.0.0: +Features as of 2.1.0: - Address offset based HAL for easy ESC read/write access via any interface - Mailbox with data link layer diff --git a/applications/rtl_xmc4_irq/slave.c b/applications/rtl_xmc4_irq/slave.c index 75dc189..20edb02 100644 --- a/applications/rtl_xmc4_irq/slave.c +++ b/applications/rtl_xmc4_irq/slave.c @@ -156,7 +156,7 @@ void DIG_process (uint8_t flags) CC_ATOMIC_SET(watchdog, ESCvar.watchdogcnt); if(ESCvar.dcsync > 0) { - CC_ATOMIC_ADD(ESCvar.synccounter,1); + CC_ATOMIC_ADD(ESCvar.synccounter, 1); } /* Set outputs */ cb_set_LEDgroup0(); @@ -174,7 +174,7 @@ void DIG_process (uint8_t flags) if((CC_ATOMIC_GET(ESCvar.App.state) & APPSTATE_OUTPUT) > 0) { - CC_ATOMIC_SUB(ESCvar.synccounter,1); + CC_ATOMIC_SUB(ESCvar.synccounter, 1); } if((ESCvar.dcsync > 0) && @@ -212,11 +212,11 @@ void DIG_process (uint8_t flags) } /** - * ISR function. It should be called from ISR for applications entirely driven by - * interrupts. - * Read and handle events for the EtherCAT state, status, mailbox and eeprom. + * Handler for SM change, SM0/1, AL CONTROL and EEPROM events, the application + * control what interrupts that should be served and re-activated with + * event mask argument */ -void ecat_slv_isr (void) +void ecat_slv_worker (uint32_t event_mask) { do { @@ -239,15 +239,22 @@ void ecat_slv_isr (void) (ESCvar.esc_hw_eep_handler)(); } - CC_ATOMIC_SET(ESCvar.ALevent,ESC_ALeventread()); + CC_ATOMIC_SET(ESCvar.ALevent, ESC_ALeventread()); - }while(ESCvar.ALevent & (ESCREG_ALEVENT_CONTROL | ESCREG_ALEVENT_SMCHANGE - | ESCREG_ALEVENT_SM0 | ESCREG_ALEVENT_SM1 | ESCREG_ALEVENT_EEP)); + }while(ESCvar.ALevent & event_mask); - ESC_ALeventmaskwrite(ESC_ALeventmaskread() - | (ESCREG_ALEVENT_CONTROL | ESCREG_ALEVENT_SMCHANGE - | ESCREG_ALEVENT_SM0 | ESCREG_ALEVENT_SM1 - | ESCREG_ALEVENT_EEP)); + ESC_ALeventmaskwrite(ESC_ALeventmaskread() | event_mask); +} + +/** + * ISR function. It should be called from ISR for applications entirely driven by + * interrupts. + * Read and handle events for the EtherCAT state, status, mailbox and eeprom. + */ +void ecat_slv_isr (void) +{ + ecat_slv_worker(ESCREG_ALEVENT_CONTROL | ESCREG_ALEVENT_SMCHANGE + | ESCREG_ALEVENT_SM0 | ESCREG_ALEVENT_SM1 | ESCREG_ALEVENT_EEP); } /** diff --git a/applications/rtl_xmc4_irq/slave.h b/applications/rtl_xmc4_irq/slave.h index dee7306..95c66eb 100644 --- a/applications/rtl_xmc4_irq/slave.h +++ b/applications/rtl_xmc4_irq/slave.h @@ -37,11 +37,21 @@ void cb_post_write_variableRW(int subindex); */ void DIG_process (uint8_t flags); +/** + * Handler for SM change, SM0/1, AL CONTROL and EEPROM events, the application + * control what interrupts that should be served and re-activated with + * event mask argument + * + * @param[in] event_mask = Event mask for interrupts to serve and re-activate + * after served + */ +void ecat_slv_worker (uint32_t event_mask); + /** * ISR for SM0/1, EEPROM and AL CONTROL events in a SM/DC * synchronization application */ -void ecat_slv_isr (void); +CC_DEPRECATED void ecat_slv_isr (void); /** * Poll SM0/1, EEPROM and AL CONTROL events in a SM/DC synchronization diff --git a/soes/hal/rt-kernel-xmc4/esc_hw.c b/soes/hal/rt-kernel-xmc4/esc_hw.c index 7221aa9..68ae824 100644 --- a/soes/hal/rt-kernel-xmc4/esc_hw.c +++ b/soes/hal/rt-kernel-xmc4/esc_hw.c @@ -237,7 +237,8 @@ static void isr_run(void * arg) while(1) { sem_wait(ecat_isr_sem); - ecat_slv_isr(); + ecat_slv_worker(ESCREG_ALEVENT_CONTROL | ESCREG_ALEVENT_SMCHANGE + | ESCREG_ALEVENT_SM0 | ESCREG_ALEVENT_SM1 | ESCREG_ALEVENT_EEP); } } diff --git a/soes/include/sys/gcc/cc.h b/soes/include/sys/gcc/cc.h index 9e6d448..b13c882 100644 --- a/soes/include/sys/gcc/cc.h +++ b/soes/include/sys/gcc/cc.h @@ -28,6 +28,8 @@ extern "C" #define CC_ASSERT(exp) assert (exp) #define CC_STATIC_ASSERT(exp) _Static_assert (exp, "") +#define CC_DEPRECATED __attribute__((deprecated)) + #define CC_SWAP32(x) __builtin_bswap32 (x) #define CC_SWAP16(x) ((uint16_t)(x) >> 8 | ((uint16_t)(x) & 0xFF) << 8)