1. Index: rockbox-c240v2/firmware/target/arm/lcd-c200_c200v2.c
  2. ===================================================================
  3. --- rockbox-c240v2/firmware/target/arm/lcd-c200_c200v2.c    (revision 27113)
  4. +++ rockbox-c240v2/firmware/target/arm/lcd-c200_c200v2.c    (working copy)
  5. @@ -27,6 +27,7 @@
  6.  #include "system.h"
  7.  #ifdef SANSA_C200V2
  8.  #include "dbop-as3525.h"
  9. +#include "button-target.h"
  10.  #endif
  11.  
  12.  /* Display status */
  13. @@ -129,6 +130,7 @@
  14.  /* send LCD data */
  15.  void lcd_write_data(const fb_data *data, int width)
  16.  {
  17. +    button_prohibit_updates(1);
  18.      do {
  19.          DBOP_DOUT = *data << 8 | *data >> 8;
  20.          data++;
  21. @@ -139,11 +141,13 @@
  22.  
  23.      /* While push fifo is not empty */
  24.      while ((DBOP_STAT & (1<<10)) == 0);
  25. +    button_prohibit_updates(0);
  26.  }
  27.  
  28.  /* send LCD command */
  29.  static void lcd_send_command(unsigned char cmd, unsigned char val)
  30.  {
  31. +    button_prohibit_updates(1);
  32.      DBOP_TIMPOL_23 = 0xa167006e;
  33.  
  34.      DBOP_DOUT = cmd | val << 8;
  35. @@ -151,6 +155,7 @@
  36.      while ((DBOP_STAT & (1<<10)) == 0);
  37.  
  38.      DBOP_TIMPOL_23 = 0xa167e06f;
  39. +    button_prohibit_updates(0);
  40.  }
  41.  
  42.  static inline void as3525_dbop_init(void)
  43. Index: rockbox-c240v2/firmware/target/arm/as3525/sansa-c200v2/button-target.h
  44. ===================================================================
  45. --- rockbox-c240v2/firmware/target/arm/as3525/sansa-c200v2/button-target.h  (revision 27113)
  46. +++ rockbox-c240v2/firmware/target/arm/as3525/sansa-c200v2/button-target.h  (working copy)
  47. @@ -30,6 +30,7 @@
  48.  bool button_hold(void);
  49.  void button_init_device(void);
  50.  int button_read_device(void);
  51. +void button_prohibit_updates(int prohibit);
  52.  
  53.  /* Sandisk Sansa c200 button codes */
  54.  
  55. Index: rockbox-c240v2/firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c
  56. ===================================================================
  57. --- rockbox-c240v2/firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c  (revision 27113)
  58. +++ rockbox-c240v2/firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c  (working copy)
  59. @@ -27,6 +27,9 @@
  60.  #include "dbop-as3525.h"
  61.  
  62.  static unsigned short _dbop_din;
  63. +static unsigned int   button_state    = BUTTON_NONE;
  64. +static unsigned int   button_prohibit = 0;
  65. +static unsigned int   button_last_update;
  66.  
  67.  static bool hold_button     = false;
  68.  #ifndef BOOTLOADER
  69. @@ -43,10 +46,7 @@
  70.      return hold_button;
  71.  }
  72.  
  73. -/*
  74. - * Get button pressed from hardware
  75. - */
  76. -int button_read_device(void)
  77. +static void button_update_state(void)
  78.  {
  79.      int btn = BUTTON_NONE;
  80.  
  81. @@ -63,7 +63,8 @@
  82.      }
  83.  #endif /* BOOTLOADER */
  84.      if (hold_button) {
  85. -        return 0;
  86. +        button_state = 0;
  87. +        return;
  88.      }
  89.  
  90.      /* direct GPIO connections */
  91. @@ -88,5 +89,32 @@
  92.      if(!(_dbop_din & (1<<15)))
  93.          btn |= BUTTON_REC;
  94.  
  95. -    return btn;
  96. +    button_last_update = current_tick;
  97. +    button_state = btn;
  98.  }
  99. +
  100. +void button_prohibit_updates(int prohibit)
  101. +{
  102. +    if (prohibit)
  103. +        button_prohibit++;
  104. +    else
  105. +        button_prohibit--;
  106. +
  107. +    if (prohibit != 0)
  108. +        return;
  109. +
  110. +    if (button_last_update != current_tick)
  111. +        button_update_state();
  112. +}
  113. +
  114. +
  115. +/*
  116. + * Get button pressed from hardware
  117. + */
  118. +int button_read_device(void)
  119. +{
  120. +    if (!button_prohibit)
  121. +        button_update_state();
  122. +
  123. +    return button_state;
  124. +}