cmd_display.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * (C) Copyright 2005
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <command.h>
  25. #if (CONFIG_COMMANDS & CFG_CMD_DISPLAY)
  26. #undef DEBUG_DISP
  27. #define DISP_SIZE 8
  28. #define CWORD_CLEAR 0x80
  29. #define CLEAR_DELAY (110 * 2)
  30. int do_display (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  31. {
  32. int i;
  33. int pos;
  34. /* Clear display */
  35. *((volatile char*)(CFG_DISP_CWORD)) = CWORD_CLEAR;
  36. udelay(1000 * CLEAR_DELAY);
  37. if (argc < 2)
  38. return (0);
  39. for (pos = 0, i = 1; i < argc && pos < DISP_SIZE; i++) {
  40. char *p = argv[i], c;
  41. if (i > 1) {
  42. *((volatile uchar *) (CFG_DISP_CHR_RAM + pos++)) = ' ';
  43. #ifdef DEBUG_DISP
  44. putc(' ');
  45. #endif
  46. }
  47. while ((c = *p++) != '\0' && pos < DISP_SIZE) {
  48. *((volatile uchar *) (CFG_DISP_CHR_RAM + pos++)) = c;
  49. #ifdef DEBUG_DISP
  50. putc(c);
  51. #endif
  52. }
  53. }
  54. #ifdef DEBUG_DISP
  55. putc('\n');
  56. #endif
  57. return (0);
  58. }
  59. /***************************************************/
  60. U_BOOT_CMD(
  61. display, CFG_MAXARGS, 1, do_display,
  62. "display- display string on dot matrix display\n",
  63. "[<string>]\n"
  64. " - with <string> argument: display <string> on dot matrix display\n"
  65. " - without arguments: clear dot matrix display\n"
  66. );
  67. #endif /* CFG_CMD_DISPLAY */