term.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. #ifndef _DEV_TERM_H_
  2. #define _DEV_TERM_H_
  3. /*
  4. * Copyright (C) 2003-2005 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
  23. * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. */
  34. #include <sys/device.h>
  35. /*!
  36. * \file dev/term.h
  37. * \brief Terminal device definitions.
  38. */
  39. /*!
  40. * \addtogroup xgTerminal
  41. */
  42. /*@{*/
  43. /*
  44. * I/O control commands.
  45. */
  46. #define LCD_CMDBYTE 0x0401
  47. #define LCD_CMDWORD16 0x0402
  48. #define LCD_CMDWORD32 0x0403
  49. #define LCD_DATABYTE 0x0405
  50. #define LCD_DATAWORD16 0x0406
  51. #define LCD_DATAWORD32 0x0407
  52. #define LCD_SETCOOKEDMODE 0x0413 /*!< \brief Set raw mode. */
  53. #define LCD_GETCOOKEDMODE 0x0414 /*!< \brief Query raw mode. */
  54. #ifndef TIOCGWINSZ
  55. #define TIOCGWINSZ 0x0501 /*!< Gets the window size */
  56. #endif
  57. #ifndef TIOCSWINSZ
  58. #define TIOCSWINSZ 0x0502 /*!< Sets the window size */
  59. #endif
  60. #define LCD_MF_CURSORON 0x00000001UL /*!< \brief Cursor on flag. */
  61. #define LCD_MF_COOKEDMODE 0x00020000UL /*!< \brief Control character interpretation on flag. */
  62. #define ESC_CHAR "\x1B"
  63. #define ESC_POS ESC_CHAR "Y"
  64. #define ESC_UP ESC_CHAR "A"
  65. #define ESC_DOWN ESC_CHAR "B"
  66. #define ESC_RIGHT ESC_CHAR "C"
  67. #define ESC_LEFT ESC_CHAR "D"
  68. #define ESC_CLRHOME ESC_CHAR "H"
  69. #define ESC_CLR ESC_CHAR "E"
  70. #define ESC_CLREND ESC_CHAR "J"
  71. #define ESC_CLREOL ESC_CHAR "K"
  72. #define ESC_CLRSTART ESC_CHAR "d"
  73. #define ESC_CLRSOL ESC_CHAR "o"
  74. #define ESC_INSCHAR ESC_CHAR "@"
  75. #define ESC_INSLINE ESC_CHAR "L"
  76. #define ESC_DELCHAR ESC_CHAR "P"
  77. #define ESC_DELLINE ESC_CHAR "M"
  78. #define ESC_RLF ESC_CHAR "I"
  79. #define ESC_CURSORON ESC_CHAR "e"
  80. #define ESC_CURSOROFF ESC_CHAR "f"
  81. #define ESC_SPECIALSET ESC_CHAR "F"
  82. #define ESC_DEFAULTSET ESC_CHAR "G"
  83. #define ESC_ACTIVE ESC_CHAR "R"
  84. #define ESC_SLEEP ESC_CHAR "S"
  85. /*
  86. * winsize structure
  87. */
  88. typedef struct _WINSIZE WINSIZE;
  89. struct _WINSIZE {
  90. u_short ws_row;
  91. u_short ws_col;
  92. u_short ws_xpixel;
  93. u_short ws_ypixel;
  94. };
  95. /*!
  96. * Terminal device control block type.
  97. */
  98. typedef struct _TERMDCB TERMDCB;
  99. /*!
  100. * \struct _TERMDCB term.h dev/term.h
  101. * \brief Terminal device control block structure.
  102. */
  103. struct _TERMDCB {
  104. /*! \brief Initialize display subsystem.
  105. */
  106. void (*dss_init)(NUTDEVICE*);
  107. /*! \brief Write display character.
  108. */
  109. void (*dss_write)(u_char);
  110. /*! \brief Write display command.
  111. */
  112. void (*dss_command)(u_char, u_char);
  113. /*! \brief Clear display.
  114. */
  115. void (*dss_clear)(void);
  116. /*! \brief Set display cursor.
  117. */
  118. void (*dss_set_cursor)(u_char);
  119. /*! \brief Set display cursor home.
  120. */
  121. void (*dss_cursor_home)(void);
  122. /*! \brief Move display cursor left.
  123. */
  124. void (*dss_cursor_left)(void);
  125. /*! \brief Move display cursor right.
  126. */
  127. void (*dss_cursor_right)(void);
  128. /*! \brief Switch cursor on/off.
  129. */
  130. void (*dss_cursor_mode)(u_char);
  131. /*! \brief Mode flags.
  132. */
  133. u_long dcb_modeflags;
  134. /*! \brief Control sequence.
  135. */
  136. u_char dcb_ctlseq;
  137. /*! \brief Number of rows.
  138. * Specifies the display height.
  139. */
  140. u_char dcb_nrows;
  141. /*! \brief Total number of columns per row.
  142. * Used to calculate display memory addresses.
  143. */
  144. u_char dcb_ncols;
  145. /*! \brief Number of visible columns.
  146. * Specifies the display width being updated.
  147. */
  148. u_char dcb_vcols;
  149. /*! \brief Cursor row.
  150. */
  151. u_char dcb_row;
  152. /*! \brief Cursor column.
  153. */
  154. u_char dcb_col;
  155. /*! \brief Display shadow memory.
  156. */
  157. u_char *dcb_smem;
  158. /*! \brief Display shadow memory.
  159. */
  160. u_char *dcb_sptr;
  161. };
  162. /*@}*/
  163. extern int TermInit(NUTDEVICE * dev);
  164. extern int TermIOCtl(NUTDEVICE * dev, int req, void *conf);
  165. extern int TermWrite(NUTFILE * fp, CONST void *buffer, int len);
  166. #ifdef __HARVARD_ARCH__
  167. extern int TermWrite_P(NUTFILE * fp, PGM_P buffer, int len);
  168. #endif
  169. extern NUTFILE *TermOpen(NUTDEVICE * dev, CONST char *name, int mode, int acc);
  170. extern int TermClose(NUTFILE * fp);
  171. #endif