mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-10 05:32:40 -05:00
Classic/6G: hold switch detection using GPIO
Configures GPIO ports to detect holdswitch status instead of polling the PMU via I2C, this fixes some random crashes Change-Id: I407c9ca4c2c9203842f9e774b1c8d0455d59048c Reviewed-on: http://gerrit.rockbox.org/194 Reviewed-by: Michael Giacomelli <giac2000@hotmail.com>
This commit is contained in:
parent
1d5a505019
commit
7ec426e497
1 changed files with 14 additions and 21 deletions
|
|
@ -39,7 +39,7 @@
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
#include "powermgmt.h"
|
#include "powermgmt.h"
|
||||||
#if defined(IPOD_NANO2G) || defined(IPOD_6G)
|
#ifdef IPOD_NANO2G
|
||||||
#include "pmu-target.h"
|
#include "pmu-target.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -87,11 +87,6 @@ static int int_btn = BUTTON_NONE;
|
||||||
static struct semaphore button_init_wakeup;
|
static struct semaphore button_init_wakeup;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_CPU==S5L8702
|
|
||||||
static long holdswitch_last_read;
|
|
||||||
static bool holdswitch_last_value;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CPU_PP
|
#ifdef CPU_PP
|
||||||
static void opto_i2c_init(void)
|
static void opto_i2c_init(void)
|
||||||
{
|
{
|
||||||
|
|
@ -367,7 +362,10 @@ static void s5l_clickwheel_init(void)
|
||||||
WHEEL04 |= 1;
|
WHEEL04 |= 1;
|
||||||
PDAT10 &= ~2;
|
PDAT10 &= ~2;
|
||||||
#elif CONFIG_CPU==S5L8702
|
#elif CONFIG_CPU==S5L8702
|
||||||
//TODO: Implement
|
/* enable external (CY8C21x34) wheel controller */
|
||||||
|
GPIOCMD = 0xe040f;
|
||||||
|
|
||||||
|
/* TODO: enable and init internal (s5l8702) wheel controller */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -377,8 +375,9 @@ void button_init_device(void)
|
||||||
#if CONFIG_CPU==S5L8701
|
#if CONFIG_CPU==S5L8701
|
||||||
INTMSK |= (1<<26);
|
INTMSK |= (1<<26);
|
||||||
#elif CONFIG_CPU==S5L8702
|
#elif CONFIG_CPU==S5L8702
|
||||||
holdswitch_last_read = USEC_TIMER;
|
/* configure GPIO E2 as pull-up input */
|
||||||
holdswitch_last_value = (pmu_read(0x87) & 2) == 0;
|
GPIOCMD = 0xe0200;
|
||||||
|
PUNB(14) |= (1 << 2);
|
||||||
#endif
|
#endif
|
||||||
s5l_clickwheel_init();
|
s5l_clickwheel_init();
|
||||||
semaphore_wait(&button_init_wakeup, HZ / 10);
|
semaphore_wait(&button_init_wakeup, HZ / 10);
|
||||||
|
|
@ -393,15 +392,7 @@ bool button_hold(void)
|
||||||
else PCON15 = (PCON15 & ~0xffff0000) | 0x22220000;
|
else PCON15 = (PCON15 & ~0xffff0000) | 0x22220000;
|
||||||
return value;
|
return value;
|
||||||
#elif CONFIG_CPU==S5L8702
|
#elif CONFIG_CPU==S5L8702
|
||||||
if (USEC_TIMER - holdswitch_last_read > 100000)
|
return ((PDATE & (1 << 2)) == 0);
|
||||||
{
|
|
||||||
holdswitch_last_read = USEC_TIMER;
|
|
||||||
holdswitch_last_value = (pmu_read(0x87) & 2) == 0;
|
|
||||||
}
|
|
||||||
if (holdswitch_last_value)
|
|
||||||
PCON(14) = PCON(14) & ~0xffffff00;
|
|
||||||
else PCON(14) = (PCON(14) & ~0xffffff00) | 0x22222200;
|
|
||||||
return holdswitch_last_value;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -411,7 +402,6 @@ bool headphones_inserted(void)
|
||||||
return ((PDAT14 & (1 << 5)) != 0);
|
return ((PDAT14 & (1 << 5)) != 0);
|
||||||
#elif CONFIG_CPU==S5L8702
|
#elif CONFIG_CPU==S5L8702
|
||||||
return ((PDATA & (1 << 6)) != 0);
|
return ((PDATA & (1 << 6)) != 0);
|
||||||
return false;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -445,7 +435,10 @@ int button_read_device(void)
|
||||||
WHEEL10 = 0;
|
WHEEL10 = 0;
|
||||||
PWRCONEXT |= 1;
|
PWRCONEXT |= 1;
|
||||||
#elif CONFIG_CPU==S5L8702
|
#elif CONFIG_CPU==S5L8702
|
||||||
//TODO: Implement
|
/* disable external (CY8C21x34) wheel controller */
|
||||||
|
GPIOCMD = 0xe040e;
|
||||||
|
|
||||||
|
/* TODO: disable internal (s5l8702) wheel controller */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -458,7 +451,7 @@ int button_read_device(void)
|
||||||
pmu_ldo_power_on(1); /* enable clickwheel power supply */
|
pmu_ldo_power_on(1); /* enable clickwheel power supply */
|
||||||
s5l_clickwheel_init();
|
s5l_clickwheel_init();
|
||||||
#elif CONFIG_CPU==S5L8702
|
#elif CONFIG_CPU==S5L8702
|
||||||
//TODO: Implement
|
s5l_clickwheel_init();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue