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