//-------------------------------------------------------------------------- // // This module provides a mechanism to manage multiple GPIO interrupt // sources. // //-------------------------------------------------------------------------- // $Archive: /WirelessUSB/WUSB Kits/CY4632 LS KBM RDK/DocSrc/CD_Root/Firmware/Source Code/RDK Mouse/isr.c $ // $Modtime: 6/16/04 4:38p10/01/04 1:18p $ // $Revision: 910 $ //-------------------------------------------------------------------------- // // Copyright 2003-2004, Cypress Semiconductor Corporation. // // This software is owned by Cypress Semiconductor Corporation (Cypress) // and is protected by and subject to worldwide patent protection (United // States and foreign), United States copyright laws and international // treaty provisions. Cypress hereby grants to licensee a personal, // non-exclusive, non-transferable license to copy, use, modify, create // derivative works of, and compile the Cypress Source Code and derivative // works for the sole purpose of creating custom software in support of // licensee product to be used only in conjunction with a Cypress integrated // circuit as specified in the applicable agreement. Any reproduction, // modification, translation, compilation, or representation of this // software except as specified above is prohibited without the express // written permission of Cypress. // // Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, // WITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // Cypress reserves the right to make changes without further notice to the // materials described herein. Cypress does not assume any liability arising // out of the application or use of any product or circuit described herein. // Cypress does not authorize its products for use as critical components in // life-support systems where a malfunction or failure may reasonably be // expected to result in significant injury to the user. The inclusion of // Cypress’ product in a life-support systems application implies that the // manufacturer assumes all risk of such use and in doing so indemnifies // Cypress against all charges. // // Use may be limited by and subject to the applicable Cypress software // license agreement. // //-------------------------------------------------------------------------- //-------------------------------------- // Included files //-------------------------------------- #include "globalparams.h" #include "psocgpioint.h" #include "appconfig.h" #include PLATFORM_H #include "isr.h" #include "radio.h" #include "wheel.h" #include "buttons.h" //-------------------------------------- // Local Definitions and Types //-------------------------------------- #define NUM_PORTS 3 //-------------------------------------- // Local Function Declarations //-------------------------------------- static void isr_set_port_ie(void); //-------------------------------------- // Local Definitions //-------------------------------------- //static MOUSE_ISR enabled_isrs; MOUSE_ISR enabled_isrs; //static UINT8 shadow[NUM_PORTS]; UINT8 shadow[NUM_PORTS]; //-------------------------------------------------------------------------- // isr_gpio //-------------------------------------------------------------------------- void isr_gpio(void) { if( enabled_isrs & INT_RADIO ) if( GPIO_ISR_RADIO_IE_PORT & GPIO_ISR_RADIO_INT ) { gpio_isr_redirector(radio_rx_isr(); } if( enabled_isrs & INT_ZWHEEL ) if( GPIO_ISR_ZWHEEL_IE_PORT & GPIO_ISR_ZWHEEL_INT ) { gpio_isr_redirector(wheel_isr(); } if( enabled_isrs & INT_BUTTON ) if( GPIO_ISR_BUTTON_IE_PORT & GPIO_ISR_BUTTON_INT ) { gpio_isr_redirector(buttons_isr(); } #ifdef MOUSE_MOTION_NOT_TIME_SLEEP if( enabled_isrs & INT_MOTION ) if( GPIO_ISR_MOTION_IE_PORT & GPIO_ISR_MOTION_INT ) { gpio_isr_redirector(motion_isr(); } #endif if( enabled_isrs & INT_BIND ) if( GPIO_ISR_BIND_IE_PORT & GPIO_ISR_BIND_INT ) { bind_button_isr(); gpio_isr_redirector(bind_button_isr); } } //-------------------------------------------------------------------------- // isr_init //-------------------------------------------------------------------------- void isr_init(void) { // Disable all GPIO interrupt enables enabled_isrsPRT0IE = 0; shadow[0] = PORT_0_INTENABLE; shadow[1] = PORT_1_INTENABLE; shadow[2] = PORT_2_INTENABLE; // Enable/disable GPIO pin interrupts based upon enabled_isrs isr_set_port_ie(); PRT1IE = 0; PRT2IE = 0; // Enable GPIO interrupt mask // M8C_EnableIntMask(INT_MSK0, INT_MSK0_GPIO ); M8C_EnableIntMask(INT_MSK0, INT_MSK0_GPIO | INT_MSK0_SLEEP); // Enable global interrupt M8C_EnableGInt; } //-------------------------------------------------------------------------- // isr_enable //-------------------------------------------------------------------------- void isr_enable(MOUSE_ISR isr) { enabled_isrs |= isr; isr_set_port_ie(); } //-------------------------------------------------------------------------- // isr_disable //-------------------------------------------------------------------------- void isr_disable(MOUSE_ISR isr) { enabled_isrs &= ~isr; isr_set_port_ie(); } //-------------------------------------------------------------------------- // isr_is_enabled //-------------------------------------------------------------------------- BOOL isr_is_enabled(MOUSE_ISR isr) { if( enabled_isrs & isr ) { return TRUE; } return FALSE; } //-------------------------------------------------------------------------- // isr_set_port_ie //-------------------------------------------------------------------------- static void isr_set_port_ie(void) { // ZWheel interrupt if( enabled_isrs & INT_ZWHEEL ) { shadow[MOUSE_ZWHEEL_IE_PORT] |= ( ZWheel1_MASK | ZWheel2_MASK ); } else { shadow[MOUSE_ZWHEEL_IE_PORT] &= ~( ZWheel1_MASK | ZWheel2_MASK ); } // 3 button interrupt if( enabled_isrs & INT_BUTTON ) { shadow[MOUSE_BUTTON_IE_PORT] |= ( LF_SW_MASK | MID_SW_MASK | RT_SW_MASK ); } else { shadow[MOUSE_BUTTON_IE_PORT] &= ~( LF_SW_MASK | MID_SW_MASK | RT_SW_MASK ); } // Radio interrupt if( enabled_isrs & INT_RADIO ) { shadow[MOUSE_RADIO_IE_PORT] |= ( R_IRQ_MASK ); } else { shadow[MOUSE_RADIO_IE_PORT] &= ~( R_IRQ_MASK ); } // Motion detect interrupt if( enabled_isrs & INT_MOTION ) { shadow[MOUSE_MOTION_IE_PORT] |= ( Motion_MASK ); } else { shadow[MOUSE_MOTION_IE_PORT] &= ~( Motion_MASK ); } // Bind button detect interrupt if( enabled_isrs & INT_BIND ) { shadow[MOUSE_BIND_IE_PORT] |= ( MOUSE_BUTTON_BIND ); } else { shadow[MOUSE_BIND_IE_PORT] &= ~( MOUSE_BUTTON_BIND ); } // Battery line detect interrupt if( enabled_isrs & INT_BATT ) { shadow[MOUSE_BATT_IE_PORT] |= ( BATT_LEV1_MASK ); } else { shadow[MOUSE_BATT_IE_PORT] &= ~( BATT_LEV1_MASK ); } // Set interrupt enable registers PRT0IE = shadow[0]; PRT1IE = shadow[1]; PRT2IE = shadow[2]; }