Redefining an Interrupt Handler

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

   

I am looking for help with redefining a PSoC 4 interrupt handler that is generated automatically by PSoC Creator. Specifically, I would like to redefine the auto-generated interrupt handler for the UART wakeup from Deep Sleep. The code for this interrupt is below.

   
    

CY_ISR(UART_1_UART_WAKEUP_ISR)

    

{

    

/* Clear interrupt source: the event becomes multi triggered and is

    

* only disabled by UART_1_UartRestoreConfig() call.

    

*/

    

#if(UART_1_SCB_MODE_UNCONFIG_CONST_CFG)

    

#if(UART_1_MOSI_SCL_RX_WAKE_PIN)

    

(void) UART_1_uart_rx_wake_i2c_sda_spi_mosi_ClearInterrupt();

    

#endif /* (UART_1_MOSI_SCL_RX_WAKE_PIN) */

    

#else

    

#if(UART_1_UART_RX_WAKE_PIN)

    

(void) UART_1_rx_wake_ClearInterrupt();

    

#endif /* (UART_1_UART_RX_WAKE_PIN) */

    

#endif /* (UART_1_SCB_MODE_UNCONFIG_CONST_CFG) */

    

}

   
   

The main part of what I want to do is to get the returned uint8 value back from UART_1_rx_wake_ClearInterrupt(). It returns a "1" if the UART was what woke the chip up, and a "0" otherwise. Additionally, I would like to include a header at the top of the file, so that I have access to an external variable to store the value. In summary, I would like the code to look like this:

   
    

...

    

#include "sleep.h"    // My own custom file

    

...

    

CY_ISR(UART_1_UART_WAKEUP_ISR){

    

...

    

WakeSourceIsUart = UART_1_rx_wake_ClearInterrupt();    // Store the value for my own use

    

...

    

}

   
   

Currently, if I include this code, the compiler removes it when I clean and build. I would like to keep it in this file every time I compile, or, alternately, I would like to write an entirely new interrupt handler function.

   

I am programming on a CYBLE-022001-00 chip, using PSoC Creator 3.2. Any help would be appreciated!

0 Likes
3 Replies
Anonymous
Not applicable

In Creator 3.3, we have a feature called callback for all interrupts to have custom interrupt handlers,

   

CY_ISR(UART_1_UART_WAKEUP_ISR)
    {
    #ifdef UART_1_UART_WAKEUP_ISR_ENTRY_CALLBACK
        UART_1_UART_WAKEUP_ISR_EntryCallback();
    #endif /* UART_1_UART_WAKEUP_ISR_ENTRY_CALLBACK */

   

        /* Clear interrupt source: the event becomes multi triggered and is
        * only disabled by UART_1_UartRestoreConfig() call.
        */
    #if(UART_1_SCB_MODE_UNCONFIG_CONST_CFG)
        #if(UART_1_MOSI_SCL_RX_WAKE_PIN)
            (void) UART_1_uart_rx_wake_i2c_sda_spi_mosi_ClearInterrupt();
        #endif /* (UART_1_MOSI_SCL_RX_WAKE_PIN) */
    #else
        #if(UART_1_UART_RX_WAKE_PIN)
            (void) UART_1_rx_wake_ClearInterrupt();
        #endif /* (UART_1_UART_RX_WAKE_PIN) */
    #endif /* (UART_1_SCB_MODE_UNCONFIG_CONST_CFG) */

   

    #ifdef UART_1_UART_WAKEUP_ISR_EXIT_CALLBACK
        UART_1_UART_WAKEUP_ISR_ExitCallback();
    #endif /* UART_1_UART_WAKEUP_ISR_EXIT_CALLBACK */
    }

   

 

   

In Creator 3.2, one way to edit this code is, import the component and modify the source files. Then use the modified component.

   

http://www.cypress.com/knowledge-base-article/avoiding-changes-source-file-get-overwritten-psoc-crea...

   

 

   

Thanks,

   

Keerthi

0 Likes
Anonymous
Not applicable

I have the same question for the EZI2C component in PSoC 3.3.  I see the 'hooks', but what is NOT explained is how the macros XXX_ISR_ENTRY_CALLBACK and XXX_ISR_EXIT_CALLBACK are defined so that the user's handler functions get called.  I've searched and read but cannot find any reference to those two macros...

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You have to

   

#define XXX_ISR_EXIT_CALLBACK

   

and to provide a

   

void XXX_ISR_ExitCallback(void)

   

 

   

Have a look at the generated code snippet from UART_1 component:

   

    #ifdef UART_1_UART_WAKEUP_ISR_ENTRY_CALLBACK
        UART_1_UART_WAKEUP_ISR_EntryCallback();
    #endif /* UART_1_UART_WAKEUP_ISR_ENTRY_CALLBACK */

   

 

   

Bob

0 Likes