From 14c7900383bd2082494ce1cfa3e191bc34a44b3a Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Thu, 14 Apr 2005 11:40:41 +0000 Subject: [PATCH] Low-level driver for the H100 remote control LCD, by Richard S. La Charite III git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6283 a1c6a512-1295-4272-9138-f99709370657 --- docs/CREDITS | 1 + firmware/SOURCES | 1 + firmware/drivers/lcd-h100-remote.c | 194 +++++++++++++++++++++++++++++ firmware/export/lcd.h | 3 + 4 files changed, 199 insertions(+) create mode 100644 firmware/drivers/lcd-h100-remote.c diff --git a/docs/CREDITS b/docs/CREDITS index b654e30d4b..e2d75c60ec 100644 --- a/docs/CREDITS +++ b/docs/CREDITS @@ -104,3 +104,4 @@ Michiel van der Kolk Tony Motakis Andy Young Alexandre Bourget +Richard S. La Charité III diff --git a/firmware/SOURCES b/firmware/SOURCES index 8279f812d1..d3d3b1c656 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -114,6 +114,7 @@ drivers/lcd.S #ifdef IRIVER_H100 #ifndef SIMULATOR drivers/uda1380.c +drivers/lcd-h100-remote.c pcm_playback.c #endif #endif diff --git a/firmware/drivers/lcd-h100-remote.c b/firmware/drivers/lcd-h100-remote.c new file mode 100644 index 0000000000..8b0cd393c7 --- /dev/null +++ b/firmware/drivers/lcd-h100-remote.c @@ -0,0 +1,194 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 by Richard S. La Charité III + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "config.h" +#include "cpu.h" +#include "kernel.h" +#include "thread.h" + +#if CONFIG_CPU == MCF5249 + +#define CS_LO GPIO_OUT &= ~0x00000004 +#define CS_HI GPIO_OUT |= 0x00000004 +#define CLK_LO GPIO_OUT &= ~0x10000000 +#define CLK_HI GPIO_OUT |= 0x10000000 +#define DATA_LO GPIO_OUT &= ~0x00040000 +#define DATA_HI GPIO_OUT |= 0x00040000 +#define RS_LO GPIO_OUT &= ~0x00010000 +#define RS_HI GPIO_OUT |= 0x00010000 + +/* delay loop */ +#define DELAY do { int _x; for(_x=0;_x<3;_x++);} while (0) + +void lcd_remote_write_command(int cmd) +{ + int i; + + CS_LO; + RS_LO; + + for (i = 0; i < 8; i++) + { + if (cmd & 0x80) + DATA_HI; + else + DATA_LO; + + CLK_HI; + cmd <<= 1; + DELAY; + + CLK_LO; + } + + CS_HI; +} + +void lcd_remote_write_data(const unsigned char* p_bytes, int count) +{ + int i, j; + int data; + + CS_LO; + RS_HI; + + for (i = 0; i < count; i++) + { + data = p_bytes[i]; + + for (j = 0; j < 8; j++) + { + if (data & 0x80) + DATA_HI; + else + DATA_LO; + + CLK_HI; + data <<= 1; + DELAY; + + CLK_LO; + } + } + + CS_HI; +} + +void lcd_remote_write_command_ex(int cmd, int data1, int data2) +{ + int i; + + CS_LO; + RS_LO; + + for (i = 0; i < 8; i++) + { + if (cmd & 0x80) + DATA_HI; + else + DATA_LO; + + CLK_HI; + cmd <<= 1; + DELAY; + + CLK_LO; + } + + RS_HI; + + for (i = 0; i < 8; i++) + { + if (data1 & 0x80) + DATA_HI; + else + DATA_LO; + + CLK_HI; + data1 <<= 1; + DELAY; + + CLK_LO; + } + + if (data2 != -1) + { + for (i = 0; i < 8; i++) + { + if (data2 & 0x80) + DATA_HI; + else + DATA_LO; + + CLK_HI; + data2 <<= 1; + DELAY; + + CLK_LO; + } + } + + CS_HI; +} + +#define LCD_REMOTE_ADC_NORMAL 0xa0 +#define LCD_REMOTE_ADC_REVERSE 0xa1 + +#define LCD_REMOTE_SHL_NORMAL 0xc0 +#define LCD_REMOTE_SHL_REVERSE 0xc8 + +#define LCD_REMOTE_DISPLAY_OFF 0xae +#define LCD_REMOTE_DISPLAY_ON 0xaf + +#define LCD_REMOTE_REVERSE_OFF 0xa6 +#define LCD_REMOTE_REVERSE_ON 0xa7 + +#define LCD_REMOTE_DISPLAY_NORMAL 0xa4 +#define LCD_REMOTE_DISPLAY_ENTIRE 0xa5 + +#define LCD_REMOTE_NO_OPERATION 0xe3 + +#define LCD_REMOTE_POWER_CONTROL 0x2b + +void lcd_remote_init(void) +{ + GPIO_FUNCTION |= 0x10010000; /* GPIO16: RS + GPIO28: CLK */ + + GPIO1_FUNCTION |= 0x00040004; /* GPIO34: CS + GPIO50: Data */ + GPIO_ENABLE |= 0x10010000; + GPIO1_ENABLE |= 0x00040004; + + CLK_LO; + CS_HI; +} + +/* + lcd_remote_write_command(LCD_REMOTE_ADC_NORMAL); + lcd_remote_write_command(LCD_REMOTE_SHL_NORMAL); + lcd_remote_write_command(0xA2); // Bias 0 + lcd_remote_write_command(LCD_REMOTE_POWER_CONTROL | 0x4); // Convertor + // 1ms + lcd_remote_write_command(LCD_REMOTE_POWER_CONTROL | 0x2); // Regulator + // 1ms + lcd_remote_write_command(LCD_REMOTE_POWER_CONTROL | 0x1); // Follower + // 1ms +*/ + +#endif diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h index 98e2a58a53..9fe3ca2a8a 100644 --- a/firmware/export/lcd.h +++ b/firmware/export/lcd.h @@ -65,6 +65,9 @@ extern void lcd_update_rect(int x, int y, int width, int height); #define lcd_update_rect(x,y,w,h) #endif +#ifdef IRIVER_H100 +void lcd_remote_init(void); +#endif #ifdef HAVE_LCD_CHARCELLS /* Icon definitions for lcd_icon() */