Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Mine
Friday, September 4th, 2009 at 7:00:55pm UTC 

  1. Index: firmware/target/arm/lcd-c200_c200v2.c
  2. ===================================================================
  3. --- firmware/target/arm/lcd-c200_c200v2.c       (revision 22622)
  4. +++ firmware/target/arm/lcd-c200_c200v2.c       (working copy)
  5. @@ -29,6 +29,7 @@
  6.  #ifdef SANSA_C200V2
  7.  /* button driver needs to know if a lcd operation is in progress */
  8.  static bool lcd_busy = false;
  9. +static unsigned short dbop_input = 0xFFFF;
  10.  #endif
  11.  
  12.  /* Display status */
  13. @@ -171,35 +172,61 @@
  14.      DBOP_TIMPOL_23 = 0xe167006e;
  15.      DBOP_CTRL = 0x40008;
  16.  
  17. -    GPIOB_AFSEL = 0xc;
  18. -    GPIOC_AFSEL = 0xff;
  19. +    GPIOB_AFSEL = 0xc;      /* B7, B6 = DBOP */
  20. +    GPIOC_AFSEL = 0xff;     /* C7..C0 = DBOP */
  21.  
  22.      DBOP_TIMPOL_23 = 0x6006e;
  23. -    DBOP_CTRL = 0x52008;
  24. -    DBOP_TIMPOL_01 = 0x6e167;
  25. +    DBOP_CTRL = 0x52008;        /* sdc/enw/osm=2words/ow=8bit/rs_t=8 */
  26. +    DBOP_TIMPOL_01 = 0x0006e167;
  27.      DBOP_TIMPOL_23 = 0xa167e06f;
  28.  
  29.      lcd_delay(20);
  30.  }
  31.  
  32. -/* we need to set the DBOP_DOUT pins high, for correct dbop reads */
  33. -bool lcd_button_support(void)
  34. +static unsigned short lcd_dbop_read(void)
  35.  {
  36. -    const fb_data data = 0xffff;
  37. +    unsigned int dbop_ctrl_old = DBOP_CTRL;
  38. +    unsigned int dbop_timpol23_old = DBOP_TIMPOL_23;
  39. +    unsigned int value;
  40. +   
  41. +    /* make sure that the DBOP FIFO is empty */
  42. +    while ((DBOP_STAT & (1<<10)) == 0);
  43.  
  44. -    if (lcd_busy)       /* we can't use dbop for reading if we are in the */
  45. -        return false;   /* middle of a write operation */
  46. +    /* write DBOP_DOUT to pre-charge DBOP data lines with a high level */
  47. +    DBOP_CTRL = (1 << 19) |         /* en_data=1 (tri-state enable) */
  48. +                (1 << 18) |         /* sdc=1 (short data count) */
  49. +                (1 << 16) |         /* enw=1 (enable write) */
  50. +                (0 << 13) |         /* osm=0 (single word out) */
  51. +                (1 << 12);          /* ow=1 (16-bit data width) */
  52. +    DBOP_TIMPOL_23 = 0xe167e167;    /* no strobe towards lcd */
  53. +    DBOP_DOUT32 = 0xFFFF;             /* all pins high */
  54. +    while ((DBOP_STAT & (1<<10)) == 0);
  55.  
  56. -    /* use out of screen coordinates */
  57. -    lcd_send_command(R_X_ADDR_AREA, 0);
  58. -    lcd_send_command(1, 0);
  59. -    lcd_send_command(R_Y_ADDR_AREA, 0);
  60. -    lcd_send_command(1, 0);
  61. +    /* perform a DBOP read */
  62. +    DBOP_CTRL = (1 << 19) |         /* en_data=1 (tri-state enable) */
  63. +                (1 << 18) |         /* sdc=1 (short data count) */
  64. +                (1 << 15) |         /* strd=1 (start read) */
  65. +                (1 << 12) |         /* ow=1 (16-bit data width) */
  66. +                (15 << 0);          /* read strobe time, at end of cycle */
  67. +    while ((DBOP_STAT & (1<<16)) == 0);
  68. +    value = DBOP_DIN;
  69. +   
  70. +    /* restore previous values */
  71. +    DBOP_CTRL = dbop_ctrl_old;
  72. +    DBOP_TIMPOL_23 = dbop_timpol23_old;
  73. +   
  74. +    return value;
  75. +}
  76.  
  77. -    lcd_write_data(&data, 1);
  78. +/* get the DBOP input value, either directly or cached if DBOP is busy */
  79. +unsigned short int lcd_dbop_input(void)
  80. +{
  81. +    if (!lcd_busy) {
  82. +        dbop_input = lcd_dbop_read();
  83. +    }
  84. +    return dbop_input;
  85. +}
  86.  
  87. -    return true;
  88. -}
  89.  #endif
  90.  
  91.  /* LCD init */
  92. @@ -431,6 +458,8 @@
  93.  #ifdef SANSA_C200V2
  94.      lcd_busy = true;
  95.  #endif
  96. +    /* perform a dbop read before doing a potentially lengthy lcd update */
  97. +    dbop_input = lcd_dbop_read();
  98.  
  99.      if (width <= 1) {
  100.          /* The X end address must be larger than the X start address, so we
  101. Index: firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c
  102. ===================================================================
  103. --- firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c     (revision 22622)
  104. +++ firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c     (working copy)
  105. @@ -26,10 +26,10 @@
  106.  #include "powermgmt.h"
  107.  
  108.  
  109. -unsigned short _dbop_din    = 0;
  110. +static unsigned short _dbop_din    = 0xFFFF;
  111.  
  112.  /* in the lcd driver */
  113. -extern bool lcd_button_support(void);
  114. +extern unsigned short int lcd_dbop_input(void);
  115.  
  116.  static bool hold_button     = false;
  117.  #ifndef BOOTLOADER
  118. @@ -49,29 +49,9 @@
  119.  
  120.  bool button_hold(void)
  121.  {
  122. -    return hold_button;
  123. +    return ((_dbop_din & (1<<12)) == 0);
  124.  }
  125.  
  126. -static void button_read_dbop(void)
  127. -{
  128. -    /* Set up dbop for input */
  129. -    DBOP_CTRL |= (1<<19);                /* Tri-state DBOP on read cycle */
  130. -    DBOP_CTRL &= ~(1<<16);               /* disable output (1:write enabled) */
  131. -    DBOP_TIMPOL_01 = 0xe167e167;         /* Set Timing & Polarity regs 0 & 1 */
  132. -    DBOP_TIMPOL_23 = 0xe167006e;         /* Set Timing & Polarity regs 2 & 3 */
  133. -
  134. -    DBOP_CTRL |= (1<<15);                /* start read */
  135. -    while (!(DBOP_STAT & (1<<16)));      /* wait for valid data */
  136. -
  137. -    _dbop_din = DBOP_DIN;                /* Read dbop data*/
  138. -
  139. -    /* Reset dbop for output */
  140. -    DBOP_TIMPOL_01 = 0x6e167;            /* Set Timing & Polarity regs 0 & 1 */
  141. -    DBOP_TIMPOL_23 = 0xa167e06f;         /* Set Timing & Polarity regs 2 & 3 */
  142. -    DBOP_CTRL |= (1<<16);                /* Enable output (0:write disable)  */
  143. -    DBOP_CTRL &= ~(1<<19);               /* Tri-state when no active write */
  144. -}
  145. -
  146.  /*
  147.   * Get button pressed from hardware
  148.   */
  149. @@ -79,13 +59,28 @@
  150.  {
  151.      int btn = BUTTON_NONE;
  152.  
  153. +    _dbop_din = lcd_dbop_input();
  154. +
  155. +    hold_button = button_hold();
  156. +
  157. +#ifndef BOOTLOADER
  158. +    /* light handling */
  159. +    if (hold_button != hold_button_old)
  160. +    {
  161. +        hold_button_old = hold_button;
  162. +        backlight_hold_changed(hold_button);
  163. +    }
  164. +#endif /* BOOTLOADER */
  165. +
  166. +    if (hold_button) {
  167. +        return 0;
  168. +    }
  169. +
  170.      /* direct GPIO connections */
  171.      if (GPIOA_PIN(3))
  172.          btn |= BUTTON_POWER;
  173.  
  174. -    if(lcd_button_support())
  175. -        button_read_dbop();
  176. -
  177. +    /* DBOP buttons */
  178.      if(!(_dbop_din & (1<<2)))
  179.          btn |= BUTTON_LEFT;
  180.      if(!(_dbop_din & (1<<3)))
  181. @@ -96,15 +91,12 @@
  182.          btn |= BUTTON_UP;
  183.      if(!(_dbop_din & (1<<6)))
  184.          btn |= BUTTON_RIGHT;
  185. +    if(!(_dbop_din & (1<<13)))
  186. +        btn |= BUTTON_VOL_UP;
  187. +    if(!(_dbop_din & (1<<14)))
  188. +        btn |= BUTTON_VOL_DOWN;
  189. +    if(!(_dbop_din & (1<<15)))
  190. +        btn |= BUTTON_REC;
  191.  
  192. -#ifndef BOOTLOADER
  193. -    /* light handling */
  194. -    if (hold_button != hold_button_old)
  195. -    {
  196. -        hold_button_old = hold_button;
  197. -        backlight_hold_changed(hold_button);
  198. -    }
  199. -#endif /* BOOTLOADER */
  200. -
  201.      return btn;
  202.  }

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus