summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/debug_menu.c9
-rw-r--r--firmware/drivers/adc.c9
-rw-r--r--firmware/drivers/lcd-h100-remote.c24
-rw-r--r--firmware/export/adc.h1
-rw-r--r--firmware/export/config-h100.h5
-rw-r--r--firmware/export/config-h120.h4
-rw-r--r--firmware/export/config-h300.h5
-rw-r--r--firmware/export/lcd-remote.h8
8 files changed, 61 insertions, 4 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 4c36eaa113..267f548d87 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -48,6 +48,7 @@
48#include "screens.h" 48#include "screens.h"
49#include "misc.h" 49#include "misc.h"
50#include "splash.h" 50#include "splash.h"
51#include "lcd-remote.h"
51 52
52#ifdef HAVE_LCD_BITMAP 53#ifdef HAVE_LCD_BITMAP
53#include "widgets.h" 54#include "widgets.h"
@@ -942,7 +943,7 @@ bool dbg_ports(void)
942 unsigned int gpio1_function; 943 unsigned int gpio1_function;
943 unsigned int gpio_enable; 944 unsigned int gpio_enable;
944 unsigned int gpio1_enable; 945 unsigned int gpio1_enable;
945 int adc_buttons, adc_remote, adc_battery; 946 int adc_buttons, adc_remote, adc_battery, adc_remotedetect;
946 char buf[128]; 947 char buf[128];
947 int button; 948 int button;
948 int line; 949 int line;
@@ -986,6 +987,7 @@ bool dbg_ports(void)
986 adc_buttons = adc_read(ADC_BUTTONS); 987 adc_buttons = adc_read(ADC_BUTTONS);
987 adc_remote = adc_read(ADC_REMOTE); 988 adc_remote = adc_read(ADC_REMOTE);
988 adc_battery = adc_read(ADC_BATTERY); 989 adc_battery = adc_read(ADC_BATTERY);
990 adc_remotedetect = adc_read(ADC_REMOTEDETECT);
989 991
990 snprintf(buf, sizeof(buf), "ADC_BUTTONS: %02x", adc_buttons); 992 snprintf(buf, sizeof(buf), "ADC_BUTTONS: %02x", adc_buttons);
991 lcd_puts(0, line++, buf); 993 lcd_puts(0, line++, buf);
@@ -993,6 +995,8 @@ bool dbg_ports(void)
993 lcd_puts(0, line++, buf); 995 lcd_puts(0, line++, buf);
994 snprintf(buf, sizeof(buf), "ADC_BATTERY: %02x", adc_battery); 996 snprintf(buf, sizeof(buf), "ADC_BATTERY: %02x", adc_battery);
995 lcd_puts(0, line++, buf); 997 lcd_puts(0, line++, buf);
998 snprintf(buf, sizeof(buf), "ADC_REMOTEDETECT: %02x", adc_remotedetect);
999 lcd_puts(0, line++, buf);
996 1000
997 battery_voltage = (adc_battery * BATTERY_SCALE_FACTOR) / 10000; 1001 battery_voltage = (adc_battery * BATTERY_SCALE_FACTOR) / 10000;
998 batt_int = battery_voltage / 100; 1002 batt_int = battery_voltage / 100;
@@ -1002,6 +1006,9 @@ bool dbg_ports(void)
1002 battery_level()); 1006 battery_level());
1003 lcd_puts(0, line++, buf); 1007 lcd_puts(0, line++, buf);
1004 1008
1009 snprintf(buf, sizeof(buf), "remotetype:: %d", remote_type());
1010 lcd_puts(0, line++, buf);
1011
1005 lcd_update(); 1012 lcd_update();
1006 button = button_get_w_tmo(HZ/10); 1013 button = button_get_w_tmo(HZ/10);
1007 1014
diff --git a/firmware/drivers/adc.c b/firmware/drivers/adc.c
index c9e11e0f56..b71583ca05 100644
--- a/firmware/drivers/adc.c
+++ b/firmware/drivers/adc.c
@@ -113,9 +113,10 @@ static unsigned char adcdata[NUM_ADC_CHANNELS];
113#ifdef IRIVER_H300_SERIES 113#ifdef IRIVER_H300_SERIES
114static int channelnum[] = 114static int channelnum[] =
115{ 115{
116 5, /* ADC_BUTTONS */ 116 5, /* ADC_BUTTONS (ADCIN2) */
117 6, /* ADC_REMOTE */ 117 6, /* ADC_REMOTE (ADCIN3) */
118 0, /* ADC_BATTERY */ 118 0, /* ADC_BATTERY (BATVOLT, resistive divider) */
119 2, /* ADC_REMOTEDETECT (ADCIN1, resistive divider) */
119}; 120};
120 121
121unsigned char adc_scan(int channel) 122unsigned char adc_scan(int channel)
@@ -212,6 +213,8 @@ static void adc_tick(void)
212 { 213 {
213 adc_counter = 0; 214 adc_counter = 0;
214 adc_scan(ADC_BATTERY); 215 adc_scan(ADC_BATTERY);
216 adc_scan(ADC_REMOTEDETECT); /* Temporary. Remove when the remote
217 detection feels stable. */
215 } 218 }
216} 219}
217 220
diff --git a/firmware/drivers/lcd-h100-remote.c b/firmware/drivers/lcd-h100-remote.c
index 0b9edf6c99..6bbe01a4c9 100644
--- a/firmware/drivers/lcd-h100-remote.c
+++ b/firmware/drivers/lcd-h100-remote.c
@@ -446,10 +446,19 @@ static void remote_lcd_init(void)
446 lcd_remote_roll(cached_roll); 446 lcd_remote_roll(cached_roll);
447} 447}
448 448
449static int _remote_type = 0;
450
451int remote_type(void)
452{
453 return _remote_type;
454}
455
449/* Monitor remote hotswap */ 456/* Monitor remote hotswap */
450static void remote_tick(void) 457static void remote_tick(void)
451{ 458{
452 bool current_status; 459 bool current_status;
460 int val;
461 int level;
453 462
454 current_status = ((GPIO_READ & 0x40000000) == 0); 463 current_status = ((GPIO_READ & 0x40000000) == 0);
455 /* Only report when the status has changed */ 464 /* Only report when the status has changed */
@@ -468,6 +477,20 @@ static void remote_tick(void)
468 { 477 {
469 if (current_status) 478 if (current_status)
470 { 479 {
480 /* Determine which type of remote it is.
481 The number 8 is just a fudge factor. */
482 level = set_irq_level(HIGHEST_IRQ_LEVEL);
483 val = adc_scan(ADC_REMOTEDETECT);
484 set_irq_level(level);
485
486 if(val < (ADCVAL_H100_LCD_REMOTE + 8))
487 if(val < (ADCVAL_H300_LCD_REMOTE + 8))
488 _remote_type = REMOTETYPE_H300_LCD;
489 else
490 _remote_type = REMOTETYPE_H100_LCD;
491 else
492 _remote_type = REMOTETYPE_H300_NONLCD;
493
471 init_remote = true; 494 init_remote = true;
472 /* request init in scroll_thread */ 495 /* request init in scroll_thread */
473 } 496 }
@@ -476,6 +499,7 @@ static void remote_tick(void)
476 CLK_LO; 499 CLK_LO;
477 CS_HI; 500 CS_HI;
478 remote_initialized = false; 501 remote_initialized = false;
502 _remote_type = 0;
479 } 503 }
480 } 504 }
481 } 505 }
diff --git a/firmware/export/adc.h b/firmware/export/adc.h
index 8364cdb012..4082e4b39b 100644
--- a/firmware/export/adc.h
+++ b/firmware/export/adc.h
@@ -27,6 +27,7 @@
27#define ADC_BUTTONS 0 27#define ADC_BUTTONS 0
28#define ADC_REMOTE 1 28#define ADC_REMOTE 1
29#define ADC_BATTERY 2 29#define ADC_BATTERY 2
30#define ADC_REMOTEDETECT 3
30#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ 31#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */
31 32
32#elif defined(IRIVER_IFP7XX) 33#elif defined(IRIVER_IFP7XX)
diff --git a/firmware/export/config-h100.h b/firmware/export/config-h100.h
index b9677b5fb2..87598c208e 100644
--- a/firmware/export/config-h100.h
+++ b/firmware/export/config-h100.h
@@ -114,3 +114,8 @@
114/* Define this if you can control the S/PDIF power */ 114/* Define this if you can control the S/PDIF power */
115#define HAVE_SPDIF_POWER 115#define HAVE_SPDIF_POWER
116#define SPDIF_POWER_INVERTED 116#define SPDIF_POWER_INVERTED
117
118/* ADC values for different remote control types */
119#define ADCVAL_H100_LCD_REMOTE 0x6a
120#define ADCVAL_H300_LCD_REMOTE 0x50
121#define ADCVAL_H300_NONLCD_REMOTE 0xfc
diff --git a/firmware/export/config-h120.h b/firmware/export/config-h120.h
index 252d3c1af8..fd62243d8a 100644
--- a/firmware/export/config-h120.h
+++ b/firmware/export/config-h120.h
@@ -109,3 +109,7 @@
109/* Define this if you can control the S/PDIF power */ 109/* Define this if you can control the S/PDIF power */
110#define HAVE_SPDIF_POWER 110#define HAVE_SPDIF_POWER
111 111
112/* ADC values for different remote control types */
113#define ADCVAL_H100_LCD_REMOTE 0x6a
114#define ADCVAL_H300_LCD_REMOTE 0x50
115#define ADCVAL_H300_NONLCD_REMOTE 0xfc
diff --git a/firmware/export/config-h300.h b/firmware/export/config-h300.h
index 88feb9d649..45d3265010 100644
--- a/firmware/export/config-h300.h
+++ b/firmware/export/config-h300.h
@@ -113,4 +113,9 @@
113/* define this if the unit can be powered or charged via USB */ 113/* define this if the unit can be powered or charged via USB */
114#define HAVE_USB_POWER 114#define HAVE_USB_POWER
115 115
116/* ADC values for different remote control types */
117#define ADCVAL_H100_LCD_REMOTE 0x3c
118#define ADCVAL_H300_LCD_REMOTE 0x2b
119#define ADCVAL_H300_NONLCD_REMOTE 0x8e
120
116#endif 121#endif
diff --git a/firmware/export/lcd-remote.h b/firmware/export/lcd-remote.h
index 8e5fa950b1..c27a0d4e73 100644
--- a/firmware/export/lcd-remote.h
+++ b/firmware/export/lcd-remote.h
@@ -23,12 +23,20 @@
23#include <stdbool.h> 23#include <stdbool.h>
24#include "cpu.h" 24#include "cpu.h"
25#include "config.h" 25#include "config.h"
26#include "adc.h"
26 27
27#ifdef HAVE_REMOTE_LCD 28#ifdef HAVE_REMOTE_LCD
28 29
29#define STYLE_DEFAULT 0 30#define STYLE_DEFAULT 0
30#define STYLE_INVERT 1 31#define STYLE_INVERT 1
31 32
33#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
34#define REMOTETYPE_H100_LCD 1
35#define REMOTETYPE_H300_LCD 2
36#define REMOTETYPE_H300_NONLCD 3
37extern int remote_type(void);
38#endif
39
32extern void lcd_remote_init(void); 40extern void lcd_remote_init(void);
33extern int lcd_remote_default_contrast(void); 41extern int lcd_remote_default_contrast(void);
34extern void lcd_remote_set_contrast(int val); 42extern void lcd_remote_set_contrast(int val);