summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/adc.c9
-rw-r--r--firmware/drivers/lcd-h100-remote.c24
2 files changed, 30 insertions, 3 deletions
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 }