//-------------------------------------------------------------------------- // // Interrupt Service Routines // //-------------------------------------------------------------------------- // $Archive: /WirelessUSB/WUSB Kits/CY4632 LS KBM RDK/DocSrc/CD_Root/Firmware/Source Code/RDK Keyboard/isr.c $ // $Modtime: 6/16/9/29/04 2:0519p $ // $Revision: 78 $ //-------------------------------------------------------------------------- // // 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 "ls_config.h" #include "radio.h" #include "bind.h" //-------------------------------------- // Local Definitions and Types //-------------------------------------- #define NUM_PORTS 2 //-------------------------------------- // Local Function Declarations //-------------------------------------- void isr_set_port_ie(void); //-------------------------------------- // Local Definitions //-------------------------------------- KEYBOARD_ISR enabled_isrs; 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_KEYS ) if( GPIO_ISR_KEYS_IE_PORT & GPIO_ISR_KEYS_INT ) { UINT8 temp; // Read to clear interrupt temp = KB_ROW_PORT; // Indicate wakeup hid.status &= ~KEYBOARD_SLEEP; gpio_isr_redirector(keyboard_isr); } if( enabled_isrs & INT_BIND ) { #ifndef BIND_BASIC if (SW1_MASK & ~RADIO_PORT) { hid.status |= BIND_BUTTON; // Wait for button to be released. while (SW1_MASK & ~RADIO_PORT) if( GPIO_ISR_BIND_IE_PORT & GPIO_ISR_BIND_INT ) { RADIO_PORT |= SW1_MASK; } } #endif // BIND_BASIC RADIO_PORT |= SW1_MASK; gpio_isr_redirector(bind_button_isr); } } //-------------------------------------------------------------------------- // isr_init //-------------------------------------------------------------------------- void isr_init(void) { // Disable GPIO Interrupts enabled_isrs PRT0IE = 0; shadow[0] = 0x0; shadow[1] = 0x0; // Enable/disable GPIO pin interrupts based upon enabled_isrs isr_set_port_ie(); // Disable the battery level GPIO pin interrupt BATT_LEV_PORT_IE = 0x0; PRT1IE = 0; PRT2IE = 0; PRT3IE = 0; PRT4IE = 0; PRT5IE = 0; // Enable GPIO and Sleep interrupt mask M8C_EnableIntMask(INT_MSK0, INT_MSK0_GPIO | INT_MSK0_SLEEP); // Enable global interrupt M8C_EnableGInt; } //-------------------------------------------------------------------------- // isr_enable //-------------------------------------------------------------------------- void isr_enable(KEYBOARD_ISR isr) { enabled_isrs |= isr; isr_set_port_ie(); } //-------------------------------------------------------------------------- // isr_disable //-------------------------------------------------------------------------- void isr_disable(KEYBOARD_ISR isr) { enabled_isrs &= ~isr; isr_set_port_ie(); } //-------------------------------------------------------------------------- // isr_is_enabled //-------------------------------------------------------------------------- BOOL isr_is_enabled(KEYBOARD_ISR isr) { return (enabled_isrs & isr) ? TRUE : FALSE; } //-------------------------------------------------------------------------- // isr_set_port_ie //-------------------------------------------------------------------------- void isr_set_port_ie(void) { // Radio interrupt if( enabled_isrs & INT_RADIO ) { shadow[0] |= ( IRQ_MASK ); } else { shadow[0] &= ~( IRQ_MASK ); } // Bind interrupt if( enabled_isrs & INT_BIND ) { shadow[0] |= ( SW1_MASK ); } else { shadow[0] &= ~( SW1_MASK ); } // Keys interrupts if( enabled_isrs & INT_KEYS ) { shadow[1] |= ( ROW1_MASK | ROW2_MASK | ROW3_MASK | ROW4_MASK | ROW5_MASK | ROW6_MASK | ROW7_MASK | ROW8_MASK ); } else { shadow[1] = 0x0; } // Set interrupt enable registers RADIO_PORT_IE = shadow[0]; KB_ROW_PORT_IE = shadow[1]; }