void button_init_device(void) { /* Enable all buttons */ GPIO_CLEAR_BITWISE(GPIOF_OUTPUT_EN, 0xff); GPIO_SET_BITWISE(GPIOF_ENABLE, 0xff); /* Scrollwheel light - enable control through GPIOG pin 7 and set timeout */ GPIO_SET_BITWISE(GPIOG_OUTPUT_EN, 0x80); GPIO_SET_BITWISE(GPIOG_ENABLE, 0x80); #ifndef BOOTLOADER /* Mask these before performing init ... because init has possibly occurred before */ GPIO_CLEAR_BITWISE(GPIOF_INT_EN, 0xff); GPIO_CLEAR_BITWISE(GPIOH_INT_EN, 0xc0); GPIO_CLEAR_BITWISE(GPIOH_OUTPUT_EN, 0xc0); GPIO_SET_BITWISE(GPIOH_ENABLE, 0xc0); /* Read initial buttons */ button_int(); /* Read initial wheel value (bit 6-7 of GPIOH) */ read_wheel_keycode(); /* Enable button interrupts */ GPIO_SET_BITWISE(GPIOF_INT_EN, 0xff); GPIO_SET_BITWISE(GPIOH_INT_EN, 0xc0); CPU_INT_EN = HI_MASK; CPU_HI_INT_EN = GPIO1_MASK; #endif /* BOOTLOADER */ }
void __attribute__((interrupt("IRQ"))) irq_handler(void) { if(CURRENT_CORE == CPU) { if (CPU_INT_STAT & TIMER1_MASK) { TIMER1(); } else if (CPU_INT_STAT & TIMER2_MASK) { TIMER2(); } #ifdef HAVE_USBSTACK /* Rather high priority - place near front */ else if (CPU_INT_STAT & USB_MASK) { usb_drv_int(); } #endif #if defined(IPOD_MINI) /* Mini 1st gen only, mini 2nd gen uses iPod 4G code */ else if (CPU_HI_INT_STAT & GPIO0_MASK) { if ((GPIOA_INT_STAT & 0x3f) || (GPIOB_INT_STAT & 0x30)) ipod_mini_button_int(); if (GPIOC_INT_STAT & 0x02) firewire_insert_int(); if (GPIOD_INT_STAT & 0x08) usb_insert_int(); } /* end IPOD_MINI */ #elif CONFIG_KEYPAD == IPOD_4G_PAD /* except Mini 1st gen, handled above */ else if (CPU_HI_INT_STAT & I2C_MASK) { ipod_4g_button_int(); } #if defined(IPOD_COLOR) || defined(IPOD_MINI2G) || defined(IPOD_4G) else if (CPU_HI_INT_STAT & GPIO0_MASK) { if (GPIOC_INT_STAT & 0x02) firewire_insert_int(); if (GPIOD_INT_STAT & 0x08) usb_insert_int(); } #elif defined(IPOD_NANO) || defined(IPOD_VIDEO) else if (CPU_HI_INT_STAT & GPIO2_MASK) { if (GPIOL_INT_STAT & 0x10) usb_insert_int(); } #endif /* end CONFIG_KEYPAD == IPOD_4G_PAD */ #elif defined(IRIVER_H10) || defined(IRIVER_H10_5GB) else if (CPU_HI_INT_STAT & GPIO2_MASK) { if (GPIOL_INT_STAT & 0x04) usb_insert_int(); } /* end IRIVER_H10 || IRIVER_H10_5GB */ #elif defined(SANSA_E200) else if (CPU_HI_INT_STAT & GPIO0_MASK) { #ifdef HAVE_HOTSWAP if (GPIOA_INT_STAT & 0x80) microsd_int(); #endif if (GPIOB_INT_STAT & 0x10) usb_insert_int(); } else if (CPU_HI_INT_STAT & GPIO1_MASK) { if (GPIOF_INT_STAT & 0xff) button_int(); if (GPIOH_INT_STAT & 0xc0) clickwheel_int(); } /* end SANSA_E200 */ #elif defined(SANSA_C200) else if (CPU_HI_INT_STAT & GPIO1_MASK) { if (GPIOH_INT_STAT & 0x02) usb_insert_int(); } #ifdef HAVE_HOTSWAP else if (CPU_HI_INT_STAT & GPIO2_MASK) { if (GPIOL_INT_STAT & 0x08) microsd_int(); } #endif /* end SANSA_C200 */ #elif defined(MROBE_100) else if (CPU_HI_INT_STAT & GPIO0_MASK) { if (GPIOD_INT_STAT & 0x02) button_int(); if (GPIOD_INT_STAT & 0x80) headphones_int(); } else if (CPU_HI_INT_STAT & GPIO2_MASK) { if (GPIOL_INT_STAT & 0x04) usb_insert_int(); } /* end MROBE_100 */ #elif defined(PHILIPS_SA9200) else if (CPU_HI_INT_STAT & GPIO0_MASK) { if (GPIOD_INT_STAT & 0x02) button_int(); if (GPIOB_INT_STAT & 0x40) usb_insert_int(); } /* end PHILIPS_SA9200 */ #elif defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330) else if (CPU_HI_INT_STAT & GPIO0_MASK) { if (GPIOA_INT_STAT & 0x20) button_int(); } else if (CPU_HI_INT_STAT & GPIO1_MASK) { if (GPIOE_INT_STAT & 0x04) usb_insert_int(); } /* end PHILIPS_HDD1630 || PHILIPS_HDD6330 */ #elif defined(SAMSUNG_YH820) || defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925) else if (CPU_HI_INT_STAT & GPIO0_MASK) { if (GPIOD_INT_STAT & 0x10) usb_insert_int(); } /* end SAMSUNG_YHxxx */ #elif defined(PBELL_VIBE500) else if (CPU_HI_INT_STAT & GPIO0_MASK) { if (GPIOA_INT_STAT & 0x20) button_int(); } else if (CPU_HI_INT_STAT & GPIO2_MASK) { if (GPIOL_INT_STAT & 0x04) usb_insert_int(); } /* end PBELL_VIBE500 */ #endif #ifdef IPOD_ACCESSORY_PROTOCOL else if (CPU_HI_INT_STAT & SER0_MASK) { SERIAL0(); } #endif } else { if (COP_INT_STAT & TIMER2_MASK) TIMER2(); } }