From ea907b31ae6595fc2b92e2da5da3cb12d4a6abff Mon Sep 17 00:00:00 2001 From: Tobias Diedrich Date: Tue, 6 Apr 2010 18:32:47 +0000 Subject: Detect C200v2 variant by reading A7, use A5 or A7 to control backlight and buttonlight depending on the result. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25499 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/as3525/system-as3525.c | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'firmware/target/arm/as3525/system-as3525.c') diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c index c51d84469f..5a7d25a1f7 100644 --- a/firmware/target/arm/as3525/system-as3525.c +++ b/firmware/target/arm/as3525/system-as3525.c @@ -163,6 +163,41 @@ void fiq_handler(void) ); } +#if defined(SANSA_C200V2) +#include "dbop-as3525.h" + +int c200v2_variant = 0; + +static void check_model_variant(void) +{ + unsigned int i; + unsigned int saved_dir = GPIOA_DIR; + + /* Make A7 input */ + GPIOA_DIR &= ~(1<<7); + /* wait a little to allow the pullup/pulldown resistor + * to charge the input capacitance */ + for (i=0; i<1000; i++) asm volatile ("nop\n"); + /* read the pullup/pulldown value on A7 to determine the variant */ + if (GPIOA_PIN(7) == 0) { + /* + * Backlight on A7. + */ + c200v2_variant = 1; + } else { + /* + * Backlight on A5. + */ + c200v2_variant = 0; + } + GPIOA_DIR = saved_dir; +} +#else +static inline void check_model_variant(void) +{ +} +#endif /* SANSA_C200V2*/ + #if defined(BOOTLOADER) static void sdram_delay(void) { @@ -319,6 +354,7 @@ void system_init(void) fmradio_i2c_init(); #endif #endif /* !BOOTLOADER */ + check_model_variant(); } void system_reboot(void) -- cgit v1.2.3