1
0
Fork 0
forked from len0rd/rockbox

Fuze V2: Fix hold switch behavior. Add a GPIOx_PIN_MASK macro to AS3525.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29096 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2011-01-20 14:26:58 +00:00
parent ee6ea59c76
commit 5f52f6ee01
2 changed files with 15 additions and 22 deletions

View file

@ -343,7 +343,6 @@ CE lines
/* GPIO registers */ /* GPIO registers */
#define GPIOA_DIR (*(volatile unsigned char*)(GPIOA_BASE+0x400)) #define GPIOA_DIR (*(volatile unsigned char*)(GPIOA_BASE+0x400))
#define GPIOA_IS (*(volatile unsigned char*)(GPIOA_BASE+0x404)) #define GPIOA_IS (*(volatile unsigned char*)(GPIOA_BASE+0x404))
#define GPIOA_IBE (*(volatile unsigned char*)(GPIOA_BASE+0x408)) #define GPIOA_IBE (*(volatile unsigned char*)(GPIOA_BASE+0x408))
@ -354,6 +353,7 @@ CE lines
#define GPIOA_IC (*(volatile unsigned char*)(GPIOA_BASE+0x41C)) #define GPIOA_IC (*(volatile unsigned char*)(GPIOA_BASE+0x41C))
#define GPIOA_AFSEL (*(volatile unsigned char*)(GPIOA_BASE+0x420)) #define GPIOA_AFSEL (*(volatile unsigned char*)(GPIOA_BASE+0x420))
#define GPIOA_PIN(a) (*(volatile unsigned char*)(GPIOA_BASE+(1<<((a)+2)))) #define GPIOA_PIN(a) (*(volatile unsigned char*)(GPIOA_BASE+(1<<((a)+2))))
#define GPIOA_PIN_MASK(m) (*(volatile unsigned char *)(GPIOA_BASE+(((m)&0xff)<<2)))
#define GPIOA_DATA (*(volatile unsigned char*)(GPIOA_BASE+(0xff<<2))) #define GPIOA_DATA (*(volatile unsigned char*)(GPIOA_BASE+(0xff<<2)))
@ -367,6 +367,7 @@ CE lines
#define GPIOB_IC (*(volatile unsigned char*)(GPIOB_BASE+0x41C)) #define GPIOB_IC (*(volatile unsigned char*)(GPIOB_BASE+0x41C))
#define GPIOB_AFSEL (*(volatile unsigned char*)(GPIOB_BASE+0x420)) #define GPIOB_AFSEL (*(volatile unsigned char*)(GPIOB_BASE+0x420))
#define GPIOB_PIN(a) (*(volatile unsigned char*)(GPIOB_BASE+(1<<((a)+2)))) #define GPIOB_PIN(a) (*(volatile unsigned char*)(GPIOB_BASE+(1<<((a)+2))))
#define GPIOB_PIN_MASK(m) (*(volatile unsigned char *)(GPIOB_BASE+(((m)&0xff)<<2)))
#define GPIOB_DATA (*(volatile unsigned char*)(GPIOB_BASE+(0xff<<2))) #define GPIOB_DATA (*(volatile unsigned char*)(GPIOB_BASE+(0xff<<2)))
#define GPIOC_DIR (*(volatile unsigned char*)(GPIOC_BASE+0x400)) #define GPIOC_DIR (*(volatile unsigned char*)(GPIOC_BASE+0x400))
@ -379,6 +380,7 @@ CE lines
#define GPIOC_IC (*(volatile unsigned char*)(GPIOC_BASE+0x41C)) #define GPIOC_IC (*(volatile unsigned char*)(GPIOC_BASE+0x41C))
#define GPIOC_AFSEL (*(volatile unsigned char*)(GPIOC_BASE+0x420)) #define GPIOC_AFSEL (*(volatile unsigned char*)(GPIOC_BASE+0x420))
#define GPIOC_PIN(a) (*(volatile unsigned char*)(GPIOC_BASE+(1<<((a)+2)))) #define GPIOC_PIN(a) (*(volatile unsigned char*)(GPIOC_BASE+(1<<((a)+2))))
#define GPIOC_PIN_MASK(m) (*(volatile unsigned char *)(GPIOC_BASE+(((m)&0xff)<<2)))
#define GPIOC_DATA (*(volatile unsigned char*)(GPIOC_BASE+(0xff<<2))) #define GPIOC_DATA (*(volatile unsigned char*)(GPIOC_BASE+(0xff<<2)))
#define GPIOD_DIR (*(volatile unsigned char*)(GPIOD_BASE+0x400)) #define GPIOD_DIR (*(volatile unsigned char*)(GPIOD_BASE+0x400))
@ -391,6 +393,7 @@ CE lines
#define GPIOD_IC (*(volatile unsigned char*)(GPIOD_BASE+0x41C)) #define GPIOD_IC (*(volatile unsigned char*)(GPIOD_BASE+0x41C))
#define GPIOD_AFSEL (*(volatile unsigned char*)(GPIOD_BASE+0x420)) #define GPIOD_AFSEL (*(volatile unsigned char*)(GPIOD_BASE+0x420))
#define GPIOD_PIN(a) (*(volatile unsigned char*)(GPIOD_BASE+(1<<((a)+2)))) #define GPIOD_PIN(a) (*(volatile unsigned char*)(GPIOD_BASE+(1<<((a)+2))))
#define GPIOD_PIN_MASK(m) (*(volatile unsigned char *)(GPIOD_BASE+(((m)&0xff)<<2)))
#define GPIOD_DATA (*(volatile unsigned char*)(GPIOD_BASE+(0xff<<2))) #define GPIOD_DATA (*(volatile unsigned char*)(GPIOD_BASE+(0xff<<2)))
/* ARM PL172 Memory Controller registers */ /* ARM PL172 Memory Controller registers */

View file

@ -196,31 +196,26 @@ void button_init_device(void)
#endif #endif
} }
/* read the 2 bits at the same time */
#define GPIOA_PIN76_offset ((1<<(6+2)) | (1<<(7+2)))
#define GPIOA_PIN76 (*(volatile unsigned char*)(GPIOA_BASE+GPIOA_PIN76_offset))
void button_gpioa_isr(void) void button_gpioa_isr(void)
{ {
#if defined(HAVE_SCROLLWHEEL) #if defined(HAVE_SCROLLWHEEL)
/* scroll wheel handling */ /* scroll wheel handling */
if (GPIOA_MIS & SCROLLWHEEL_BITS) if (GPIOA_MIS & SCROLLWHEEL_BITS)
scrollwheel(GPIOA_PIN76 >> 6); scrollwheel(GPIOA_PIN_MASK(0xc0) >> 6);
/* ack interrupt */ /* ack interrupt */
GPIOA_IC = SCROLLWHEEL_BITS; GPIOA_IC = SCROLLWHEEL_BITS;
#endif #endif
} }
/* /*
* Get button pressed from hardware * Get button pressed from hardware
*/ */
int button_read_device(void) int button_read_device(void)
{ {
int btn = 0; int btn = 0;
static bool hold_button_old = false;
static long power_counter = 0; static long power_counter = 0;
bool hold = false;
unsigned gpiod6; unsigned gpiod6;
/* if we don't wait for the fifo to empty, we'll see screen corruption /* if we don't wait for the fifo to empty, we'll see screen corruption
@ -264,14 +259,9 @@ int button_read_device(void)
{ /* power/hold is on the same pin. we know it's hold if the bit isn't { /* power/hold is on the same pin. we know it's hold if the bit isn't
* set now anymore */ * set now anymore */
if (GPIOD_PIN(6) & 1<<6) if (GPIOD_PIN(6) & 1<<6)
{
hold_button = false;
btn |= BUTTON_POWER; btn |= BUTTON_POWER;
}
else else
{ hold = true;
hold_button = true;
}
} }
if(gpiob_pin0_dir) if(gpiob_pin0_dir)
@ -283,21 +273,21 @@ int button_read_device(void)
#ifdef HAS_BUTTON_HOLD #ifdef HAS_BUTTON_HOLD
#ifndef BOOTLOADER #ifndef BOOTLOADER
/* light handling */ /* light handling */
if (hold_button != hold_button_old) if (hold != hold_button)
{ {
hold_button_old = hold_button; hold_button = hold;
backlight_hold_changed(hold_button); backlight_hold_changed(hold);
/* mask scrollwheel irq so we don't need to check for /* mask scrollwheel irq so we don't need to check for
* the hold button in the isr */ * the hold button in the isr */
if (hold_button) if (hold)
GPIOA_IE &= ~SCROLLWHEEL_BITS; GPIOA_IE &= ~SCROLLWHEEL_BITS;
else else
GPIOA_IE |= SCROLLWHEEL_BITS; GPIOA_IE |= SCROLLWHEEL_BITS;
} }
#else #else
(void)hold_button_old; hold_button = hold;
#endif #endif /* BOOTLOADER */
if (hold_button) if (hold)
{ {
power_counter = HZ; power_counter = HZ;
return 0; return 0;
@ -311,7 +301,7 @@ int button_read_device(void)
power_counter--; power_counter--;
btn &= ~BUTTON_POWER; btn &= ~BUTTON_POWER;
} }
#endif #endif /* HAS_BUTTON_HOLD */
return btn; return btn;
} }