Index: firmware/target/arm/as3525/sansa-fuze/button-fuze.c =================================================================== --- firmware/target/arm/as3525/sansa-fuze/button-fuze.c (Revision 19440) +++ firmware/target/arm/as3525/sansa-fuze/button-fuze.c (Arbeitskopie) @@ -31,8 +31,10 @@ #define WHEEL_FAST_OFF_INTERVAL 60000 #define WHEELCLICKS_PER_ROTATION 48 /* wheelclicks per full rotation */ +extern struct mutex lcd_mutex; /* Clickwheel */ -#ifndef BOOTLOADER +#if !defined(BOOTLOADER) +#if defined(SCROLLWHEEL) static unsigned int old_wheel_value = 0; static unsigned int wheel_repeat = BUTTON_NONE; static unsigned int wheel_click_count = 0; @@ -42,6 +44,7 @@ static unsigned long wheel_velocity = 0; static long last_wheel_post = 0; static long next_backlight_on = 0; +#endif /* Buttons */ static bool hold_button = false; static bool hold_button_old = false; @@ -61,65 +64,71 @@ } /* clickwheel */ -#ifndef BOOTLOADER +#if defined(BOOTLOADER) && defined(SCROLLWHEEL) void clickwheel_int(void) { } -#endif /* BOOTLOADER */ +#endif /* defined(BOOTLOADER) && defined(SCROLLWHEEL) */ /* device buttons */ - -/* device buttons */ void button_int(void) { - int dir_save_b = 0; - int afsel_save_b = 0; - int dir_save_c = 0; - int afsel_save_c = 0; + if(lcd_mutex.locked) + return; int_btn = BUTTON_NONE; /* Save the current direction and afsel */ - dir_save_b = GPIOB_DIR; - afsel_save_b = GPIOB_AFSEL; - dir_save_c = GPIOC_DIR; - afsel_save_c = GPIOC_AFSEL; - GPIOB_DIR = 0; - GPIOB_AFSEL = 0; - GPIOC_DIR = 0; - GPIOC_AFSEL = 0; + GPIOB_AFSEL &= ~(1<<4); + GPIOC_AFSEL &= ~(1<<2|1<<3|1<<4|1<<5|1<<6); - /* These should not be needed with button event interupts */ - /* they are necessary now to clear out lcd data */ - GPIOC_PIN(0) |= 1; - GPIOC_PIN(1) |= 1; - GPIOC_PIN(2) |= 1; - GPIOC_PIN(3) |= 1; - GPIOC_PIN(4) |= 1; - GPIOC_PIN(5) |= 1; - GPIOC_PIN(6) |= 1; - GPIOC_PIN(7) |= 1; + + GPIOB_DIR &= ~(1<<4); + GPIOC_DIR |= (1<<2|1<<3|1<<4|1<<5|1<<6); + GPIOC_PIN(2) |= (1<<2); + GPIOC_PIN(3) |= (1<<3); + GPIOC_PIN(4) |= (1<<4); + GPIOC_PIN(5) |= (1<<5); + GPIOC_PIN(6) |= (1<<6); + + GPIOC_DIR &= ~(1<<2|1<<3|1<<4|1<<5|1<<6); + + int delay = 50; + while(delay >0) delay--; + /* direct GPIO connections */ + if (!GPIOC_PIN(3)) + { + int_btn |= BUTTON_LEFT; + } + if (!GPIOC_PIN(2)) + { + int_btn |= BUTTON_UP; + } + if (!GPIOC_PIN(6)) + { + int_btn |= BUTTON_DOWN; + } if (GPIOB_PIN(4)) + { int_btn |= BUTTON_POWER; - if (!GPIOC_PIN(6)) - int_btn |= BUTTON_DOWN; + } if (!GPIOC_PIN(5)) + { int_btn |= BUTTON_RIGHT; + } if (!GPIOC_PIN(4)) + { int_btn |= BUTTON_SELECT; - if (!GPIOC_PIN(3)) - int_btn |= BUTTON_LEFT; - if (!GPIOC_PIN(2)) - int_btn |= BUTTON_UP; + } + /* return to settings needed for lcd */ + GPIOB_DIR |= (1<<4); + GPIOC_DIR |= (1<<2|1<<3|1<<4|1<<5|1<<6); + GPIOB_AFSEL |= (1<<4); + GPIOC_AFSEL |= (1<<2|1<<3|1<<4|1<<5|1<<6); - /* return to settings needed for lcd */ - GPIOB_DIR = dir_save_b; - GPIOB_AFSEL = afsel_save_b; - GPIOC_DIR = dir_save_c; - GPIOC_AFSEL = afsel_save_c; } /* @@ -127,10 +136,8 @@ */ int button_read_device(void) { -#ifdef BOOTLOADER - /* Read buttons directly in the bootloader */ button_int(); -#else +#ifndef BOOTLOADER /* light handling */ if (hold_button != hold_button_old) { Index: firmware/export/config-fuze.h =================================================================== --- firmware/export/config-fuze.h (Revision 19440) +++ firmware/export/config-fuze.h (Arbeitskopie) @@ -106,12 +112,14 @@ #define HAVE_BACKLIGHT #define HAVE_BACKLIGHT_BRIGHTNESS +#if 0 /* define this if the unit uses a scrollwheel for navigation */ #define HAVE_SCROLLWHEEL /* define from which rotation speed [degree/sec] on the acceleration starts */ #define WHEEL_ACCEL_START 540 /* define type of acceleration (1 = ^2, 2 = ^3, 3 = ^4) */ #define WHEEL_ACCELERATION 1 +#endif /* define this if you have a flash memory storage */ #define HAVE_FLASH_STORAGE