altera_avalon_lcd_16207.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /******************************************************************************
  2. * *
  3. * License Agreement *
  4. * *
  5. * Copyright (c) 2006 Altera Corporation, San Jose, California, USA. *
  6. * All rights reserved. *
  7. * *
  8. * Permission is hereby granted, free of charge, to any person obtaining a *
  9. * copy of this software and associated documentation files (the "Software"), *
  10. * to deal in the Software without restriction, including without limitation *
  11. * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
  12. * and/or sell copies of the Software, and to permit persons to whom the *
  13. * Software is furnished to do so, subject to the following conditions: *
  14. * *
  15. * The above copyright notice and this permission notice shall be included in *
  16. * all copies or substantial portions of the Software. *
  17. * *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
  23. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
  24. * DEALINGS IN THE SOFTWARE. *
  25. * *
  26. * This agreement shall be governed in all respects by the laws of the State *
  27. * of California and by the laws of the United States of America. *
  28. * *
  29. ******************************************************************************/
  30. #ifndef __ALTERA_AVALON_LCD_16207_H__
  31. #define __ALTERA_AVALON_LCD_16207_H__
  32. #include <stddef.h>
  33. #include "sys/alt_alarm.h"
  34. #include "os/alt_sem.h"
  35. #ifdef __cplusplus
  36. extern "C"
  37. {
  38. #endif /* __cplusplus */
  39. /*
  40. * The altera_avalon_lcd_16207_dev structure is used to hold device specific
  41. * data. This includes the transmit and receive buffers.
  42. *
  43. * An instance of this structure is created in the auto-generated
  44. * alt_sys_init.c file for each UART listed in the systems PTF file. This is
  45. * done using the ALTERA_AVALON_LCD_16207_STATE_INSTANCE macro given below.
  46. */
  47. #define ALT_LCD_HEIGHT 2
  48. #define ALT_LCD_WIDTH 16
  49. #define ALT_LCD_VIRTUAL_WIDTH 80
  50. typedef struct altera_avalon_lcd_16207_state_s
  51. {
  52. int base;
  53. alt_alarm alarm;
  54. int period;
  55. char broken;
  56. unsigned char x;
  57. unsigned char y;
  58. char address;
  59. char esccount;
  60. unsigned char scrollpos;
  61. unsigned char scrollmax;
  62. char active; /* If non-zero then the foreground routines are
  63. * active so the timer call must not update the
  64. * display. */
  65. char escape[8];
  66. struct
  67. {
  68. char visible[ALT_LCD_WIDTH];
  69. char data[ALT_LCD_VIRTUAL_WIDTH+1];
  70. char width;
  71. unsigned char speed;
  72. } line[ALT_LCD_HEIGHT];
  73. ALT_SEM (write_lock)/* Semaphore used to control access to the
  74. * write buffer in multi-threaded mode */
  75. } altera_avalon_lcd_16207_state;
  76. /*
  77. * Called by alt_sys_init.c to initialize the driver.
  78. */
  79. extern void altera_avalon_lcd_16207_init(altera_avalon_lcd_16207_state* sp);
  80. /*
  81. * The LCD panel driver is not trivial, so leave it out in the small
  82. * drivers case. Also leave it out in simulation because there is no
  83. * simulated hardware for the LCD panel. These two can be overridden
  84. * by defining ALT_USE_LCE_16207 if you really want it.
  85. */
  86. #if (!defined(ALT_USE_SMALL_DRIVERS) && !defined(ALT_SIM_OPTIMIZE)) || defined ALT_USE_LCD_16207
  87. /*
  88. * Used by the auto-generated file
  89. * alt_sys_init.c to create an instance of this device driver.
  90. */
  91. #define ALTERA_AVALON_LCD_16207_STATE_INSTANCE(name, state) \
  92. altera_avalon_lcd_16207_state state = \
  93. { \
  94. name##_BASE \
  95. }
  96. /*
  97. * The macro ALTERA_AVALON_LCD_16207_INIT is used by the auto-generated file
  98. * alt_sys_init.c to initialize an instance of the device driver.
  99. */
  100. #define ALTERA_AVALON_LCD_16207_STATE_INIT(name, state) \
  101. altera_avalon_lcd_16207_init(&state)
  102. #else /* exclude driver */
  103. #define ALTERA_AVALON_LCD_16207_STATE_INSTANCE(name, state) extern int alt_no_storage
  104. #define ALTERA_AVALON_LCD_16207_STATE_INIT(name, state) while (0)
  105. #endif /* exclude driver */
  106. /*
  107. * Include in case non-direct version of driver required.
  108. */
  109. #include "altera_avalon_lcd_16207_fd.h"
  110. /*
  111. * Map alt_sys_init macros to direct or non-direct versions.
  112. */
  113. #ifdef ALT_USE_DIRECT_DRIVERS
  114. #define ALTERA_AVALON_LCD_16207_INSTANCE(name, state) \
  115. ALTERA_AVALON_LCD_16207_STATE_INSTANCE(name, state)
  116. #define ALTERA_AVALON_LCD_16207_INIT(name, state) \
  117. ALTERA_AVALON_LCD_16207_STATE_INIT(name, state)
  118. #else /* !ALT_USE_DIRECT_DRIVERS */
  119. #define ALTERA_AVALON_LCD_16207_INSTANCE(name, dev) \
  120. ALTERA_AVALON_LCD_16207_DEV_INSTANCE(name, dev)
  121. #define ALTERA_AVALON_LCD_16207_INIT(name, dev) \
  122. ALTERA_AVALON_LCD_16207_DEV_INIT(name, dev)
  123. #endif /* ALT_USE_DIRECT_DRIVERS */
  124. #ifdef __cplusplus
  125. }
  126. #endif /* __cplusplus */
  127. #endif /* __ALTERA_AVALON_LCD_16207_H__ */