TheLegace

sci0.h

Mar 28th, 2012
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.38 KB | None | 0 0
  1. // filename  ******************* sci0.h **************************
  2. // Jonathan W. Valvano 1/29/04
  3.  
  4. //  This example accompanies the books
  5. //   "Embedded Microcomputer Systems: Real Time Interfacing",
  6. //         Brooks-Cole, copyright (c) 2000,
  7. //   "Introduction to Embedded Microcomputer Systems:
  8. //    Motorola 6811 and 6812 Simulation", Brooks-Cole, copyright (c) 2002
  9.  
  10. // Copyright 2004 by Jonathan W. Valvano, [email protected]
  11. //    You may use, edit, run or distribute this file
  12. //    as long as the above copyright notice remains
  13. // Modified by EE345L students Charlie Gough && Matt Hawk
  14. // Modified by EE345M students Agustinus Darmawan + Mingjie Qiu
  15. //
  16. // adapted to the Dragon12 board using SCI0  --  fw-07-04
  17.  
  18. // define labels for baudrates
  19. // (necessary 'coz 115200 isn't a 16-bit number anymore  --  fw-08-04)
  20. #define BAUD_300      0
  21. #define BAUD_600      1
  22. #define BAUD_1200     2
  23. #define BAUD_2400     3
  24. #define BAUD_4800     4
  25. #define BAUD_9600     5
  26. #define BAUD_19200    6
  27. #define BAUD_38400    7
  28. #define BAUD_57600    8
  29. #define BAUD_115200   9
  30.  
  31.  
  32. // standard ASCII symbols
  33. #define CR   0x0D
  34. #define LF   0x0A
  35. #define BS   0x08
  36. #define ESC  0x1B
  37. #define SP   0x20      
  38. #define DEL  0x7F
  39.  
  40. //-------------------------SCI0_Init------------------------
  41. // Initialize Serial port SCI0
  42. // Input: baudRate is tha baud rate in bits/sec
  43. // Output: none
  44. extern void SCI0_Init(unsigned short baudRate);
  45.  
  46. //-------------------------SCI0_InStatus--------------------------
  47. // Checks if new input is ready, TRUE if new input is ready
  48. // Input: none
  49. // Output: TRUE if a call to InChar will return right away with data
  50. //         FALSE if a call to InChar will wait for input
  51. extern char SCI0_InStatus(void);  
  52.  
  53. //-------------------------SCI0_InChar------------------------
  54. // Wait for new serial port input, busy-waiting synchronization
  55. // Input: none
  56. // Output: ASCII code for key typed
  57. extern char SCI0_InChar(void);
  58.  
  59. extern void SCI0_InString(char *, unsigned short); // Reads in a String of max length
  60.  
  61. //----------------------SCI0_InUDec-------------------------------
  62. // InUDec accepts ASCII input in unsigned decimal format
  63. //     and converts to a 16 bit unsigned number
  64. //     valid range is 0 to 65535
  65. // Input: none
  66. // Output: 16-bit unsigned number
  67. // If you enter a number above 65535, it will truncate without an error
  68. // Backspace will remove last digit typed
  69. extern unsigned short SCI0_InUDec(void);  
  70.  
  71. //---------------------SCI0_InUHex----------------------------------------
  72. // Accepts ASCII input in unsigned hexadecimal (base 16) format
  73. // Input: none
  74. // Output: 16-bit unsigned number
  75. // No '$' or '0x' need be entered, just the 1 to 4 hex digits
  76. // It will convert lower case a-f to uppercase A-F
  77. //     and converts to a 16 bit unsigned number
  78. //     value range is 0 to FFFF
  79. // If you enter a number above FFFF, it will truncate without an error
  80. // Backspace will remove last digit typed
  81. extern unsigned short SCI0_InUHex(void);  
  82.  
  83. //-----------------------SCI0_OutStatus----------------------------
  84. // Checks if output data buffer is empty, TRUE if empty
  85. // Input: none
  86. // Output: TRUE if a call to OutChar will output and return right away
  87. //         FALSE if a call to OutChar will wait for output to be ready
  88. extern char SCI0_OutStatus(void);  
  89.  
  90. //-------------------------SCI0_OutChar------------------------
  91. // Wait for buffer to be empty, output 8-bit to serial port
  92. // busy-waiting synchronization
  93. // Input: 8-bit data to be transferred
  94. // Output: none
  95. extern void SCI0_OutChar(char);  
  96.  
  97. //-----------------------SCI0_OutUDec-----------------------
  98. // Output a 16-bit number in unsigned decimal format
  99. // Input: 16-bit number to be transferred
  100. // Output: none
  101. // Variable format 1-5 digits with no space before or after
  102. extern void SCI0_OutUDec(unsigned short);    
  103.  
  104. //-------------------------SCI0_OutString------------------------
  105. // Output String (NULL termination), busy-waiting synchronization
  106. // Input: pointer to a NULL-terminated string to be transferred
  107. // Output: none
  108. extern void SCI0_OutString(char *pt);
  109.  
  110. //--------------------------SCI0_OutUHex----------------------------
  111. // Output a 16 bit number in unsigned hexadecimal format
  112. // Input: 16-bit number to be transferred
  113. // Output: none
  114. // Variable format 1 to 4 digits with no space before or after
  115. extern void SCI0_OutUHex(unsigned short);
Advertisement
Add Comment
Please, Sign In to add comment