From c0782fa1ab4b3d250e4cd88ea835bd5d67f570f0 Mon Sep 17 00:00:00 2001 From: Domonoky Date: Sat, 25 Oct 2008 15:57:18 +0000 Subject: [PATCH] fill in button and backlight functions for m200 "v2" git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18874 a1c6a512-1295-4272-9138-f99709370657 --- .../arm/as3525/sansa-m200v2/backlight-target.h | 3 ++ .../target/arm/as3525/sansa-m200v2/button-m200v2.c | 60 ++++++++++++++++++++-- .../target/arm/as3525/sansa-m200v2/button-target.h | 3 +- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/firmware/target/arm/as3525/sansa-m200v2/backlight-target.h b/firmware/target/arm/as3525/sansa-m200v2/backlight-target.h index 9533d0a6b..50404f709 100644 --- a/firmware/target/arm/as3525/sansa-m200v2/backlight-target.h +++ b/firmware/target/arm/as3525/sansa-m200v2/backlight-target.h @@ -23,15 +23,18 @@ static inline bool _backlight_init(void) { + GPIOD_DIR |= (1<<1); return true; } static inline void _backlight_on(void) { + GPIOD_PIN(1) = (1<<1); } static inline void _backlight_off(void) { + GPIOD_PIN(1) = 0x00; } #endif diff --git a/firmware/target/arm/as3525/sansa-m200v2/button-m200v2.c b/firmware/target/arm/as3525/sansa-m200v2/button-m200v2.c index cd31d0672..c5d6c4941 100644 --- a/firmware/target/arm/as3525/sansa-m200v2/button-m200v2.c +++ b/firmware/target/arm/as3525/sansa-m200v2/button-m200v2.c @@ -26,18 +26,68 @@ void button_init_device(void) { - + GPIOA_DIR &= ~((1<<3) | (1<<2) | (1<<1) | (1<<0)); /* A3-A0 is input */ + GPIOA_DIR |= ((1<<6) | (1<<5) | (1<<4)); /* A4-A6 row outputs */ } int button_read_device(void) { - int btn = BUTTON_NONE; + int result = BUTTON_NONE; + + /* direct GPIO connections */ + if (GPIOA_PIN(3)) + result |= BUTTON_MENU; + + /* This is a keypad using A4-A6 as columns and A0-A2 as rows */ + GPIOA_PIN(4) = (1<<4); + + /* A4A0 is unused */ + + if (GPIOA_PIN(1)) + result |= BUTTON_VOLDOWN; + + if (GPIOA_PIN(2)) + result |= BUTTON_PLAYPAUSE; + + GPIOA_PIN(4) = 0x00; + + GPIOA_PIN(5) = (1<<5); + + if (GPIOA_PIN(0)) + result |= BUTTON_LEFT; + + if (GPIOA_PIN(1)) + result |= BUTTON_SELECT; + + if (GPIOA_PIN(2)) + result |= BUTTON_RIGHT; + + GPIOA_PIN(5) = 0x00; + + + GPIOA_PIN(6) = (1<<6); + + if (GPIOA_PIN(0)) + result |= BUTTON_REPEATAB; + + if (GPIOA_PIN(1)) + result |= BUTTON_VOLUP; + + if (GPIOA_PIN(2)) + result |= BUTTON_HOLD; + GPIOA_PIN(6) = 0x00; - return btn; + return result; } bool button_hold(void) { - /* TODO */ - return false; + bool ret = false; + + GPIOA_PIN(6) = (1<<6); + if (GPIOA_PIN(2)) + ret = true; + GPIOA_PIN(6) = 0x00; + + return ret; } diff --git a/firmware/target/arm/as3525/sansa-m200v2/button-target.h b/firmware/target/arm/as3525/sansa-m200v2/button-target.h index acf80b2ed..779f7400b 100644 --- a/firmware/target/arm/as3525/sansa-m200v2/button-target.h +++ b/firmware/target/arm/as3525/sansa-m200v2/button-target.h @@ -40,10 +40,11 @@ bool button_hold(void); #define BUTTON_LEFT 0x00000020 #define BUTTON_RIGHT 0x00000040 #define BUTTON_SELECT 0x00000080 +#define BUTTON_HOLD 0x00000100 #define BUTTON_MAIN (BUTTON_MENU|BUTTON_VOLUP|BUTTON_VOLDOWN\ |BUTTON_PLAYPAUSE|BUTTON_REPEATAB|BUTTON_LEFT\ - |BUTTON_RIGHT|BUTTON_SELECT) + |BUTTON_RIGHT|BUTTON_SELECT|BUTTON_HOLD) #define BUTTON_REMOTE 0 -- 2.11.4.GIT