diff options
author | Rob Purchase <shotofadds@rockbox.org> | 2009-10-08 15:47:43 +0000 |
---|---|---|
committer | Rob Purchase <shotofadds@rockbox.org> | 2009-10-08 15:47:43 +0000 |
commit | 292a53da4b862dcb942b02eb47664efaf294d8c9 (patch) | |
tree | 613ea37b76ce89abb9235fa1587978177c708998 /firmware/drivers/pcf50606.c | |
parent | 5a435e62d062c7bc75c27a324e89de06cc4543f9 (diff) | |
download | rockbox-292a53da4b862dcb942b02eb47664efaf294d8c9.tar.gz rockbox-292a53da4b862dcb942b02eb47664efaf294d8c9.zip |
D2: Use a common function for reading ADC values from the PMU
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23007 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/pcf50606.c')
-rw-r--r-- | firmware/drivers/pcf50606.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/firmware/drivers/pcf50606.c b/firmware/drivers/pcf50606.c index 6a98b0d021..8592c005fe 100644 --- a/firmware/drivers/pcf50606.c +++ b/firmware/drivers/pcf50606.c | |||
@@ -62,3 +62,26 @@ void pcf50606_reset_timeout(void) | |||
62 | pcf50606_write(PCF5060X_OOCC1, pcf50606_read(PCF5060X_OOCC1) | TOTRST); | 62 | pcf50606_write(PCF5060X_OOCC1, pcf50606_read(PCF5060X_OOCC1) | TOTRST); |
63 | restore_irq(level); | 63 | restore_irq(level); |
64 | } | 64 | } |
65 | |||
66 | void pcf50606_read_adc(int adc, short* res1, short* res2) | ||
67 | { | ||
68 | int adcs1 = 0, adcs2 = 0, adcs3 = 0; | ||
69 | |||
70 | int level = disable_irq_save(); | ||
71 | |||
72 | pcf50606_write(PCF5060X_ADCC2, (adc<<1) | 1); /* ADC start */ | ||
73 | |||
74 | do { | ||
75 | adcs2 = pcf50606_read(PCF5060X_ADCS2); | ||
76 | } while (!(adcs2 & 0x80)); /* Busy wait on ADCRDY flag */ | ||
77 | |||
78 | adcs1 = pcf50606_read(PCF5060X_ADCS1); | ||
79 | if (res2 != NULL) adcs3 = pcf50606_read(PCF5060X_ADCS3); | ||
80 | |||
81 | pcf50606_write(PCF5060X_ADCC2, 0); /* ADC stop */ | ||
82 | |||
83 | restore_interrupt(level); | ||
84 | |||
85 | if (res1 != NULL) *res1 = (adcs1 << 2) | (adcs2 & 3); | ||
86 | if (res2 != NULL) *res2 = (adcs3 << 2) | ((adcs2 & 0xC) >> 2); | ||
87 | } | ||