libcomb.pas 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. unit libcomb;
  2. interface
  3. const
  4. // Status bits
  5. COMB_CTS = $100;
  6. COMB_DSR = $80;
  7. COMB_FE = $20;
  8. COMB_OE = $10;
  9. COMB_PERROR = $8;
  10. COMB_TXU = $4;
  11. COMB_RXRDY = $2;
  12. COMB_TXRDY = $1;
  13. // Control bits
  14. COMB_BIT_DTR = $1;
  15. COMB_BIT_RTS = $2;
  16. // Macros
  17. function CombSioStatus: longint; // Return serial controller status
  18. function CombControlStatus: longint; // Return control line status
  19. function CombGetMode: longint; // Return communication mode
  20. function CombGetBPS: longint; // Return transfer rate
  21. function CombGetPacketSize: longint; // Return current packet size
  22. function CombBytesToWrite: longint; // Return # bytes remaining in write buffer
  23. function CombBytesToRead: longint; // Return # bytes remaining to be read
  24. function CombBytesRemaining(a: longint): longint; // Return # bytes remaining to read or write
  25. function CombAsyncRequest(a: longint): longint; // Return async read/write request
  26. function CombSetControl(a: longint): longint; // Set the control line status
  27. function CombSetMode(a: longint): longint; // Sets communications mode
  28. function CombSetBPS(a: longint): longint; // Sets the transfer rate
  29. function CombSetPacketSize(a: longint): longint; // Sets the packet size
  30. function CombReset: longint; // Reset serial controller
  31. function CombResetError: longint; // Reset error bits
  32. function CombCancelWrite: longint; // Cancel async write request
  33. function CombCancelRead: longint; // Cancel async read request
  34. function CombSetRTS(a: longint): longint; // Set RTS to 'a'
  35. function CombCTS: longint; // Return status of CTS
  36. function CombWaitCallback(a: longint): longint; // Install wait callback function
  37. function CombResetVBLANK: longint; // Restart VBLANK signal
  38. procedure AddCOMB; stdcall external;
  39. procedure DelCOMB; stdcall external;
  40. procedure ChangeClearSIO(x: longint); stdcall external;
  41. function _comb_control(a, b, c: dword): longint; stdcall external;
  42. implementation
  43. function CombSioStatus: longint;
  44. begin
  45. CombSioStatus:= _comb_control(0,0,0);
  46. end;
  47. function CombControlStatus: longint;
  48. begin
  49. CombControlStatus:= _comb_control(0,1,0);
  50. end;
  51. function CombGetMode: longint;
  52. begin
  53. CombGetMode:= _comb_control(0,2,0);
  54. end;
  55. function CombGetBPS: longint;
  56. begin
  57. CombGetBPS:= _comb_control(0,3,0);
  58. end;
  59. function CombGetPacketSize: longint;
  60. begin
  61. CombGetPacketSize:= _comb_control(0,4,0);
  62. end;
  63. function CombBytesToWrite: longint;
  64. begin
  65. CombBytesToWrite:= _comb_control(0,5,0);
  66. end;
  67. function CombBytesToRead: longint;
  68. begin
  69. CombBytesToRead:= _comb_control(0,5,1);
  70. end;
  71. function CombBytesRemaining(a: longint): longint;
  72. begin
  73. CombBytesRemaining:= _comb_control(0,5,a);
  74. end;
  75. function CombAsyncRequest(a: longint): longint;
  76. begin
  77. CombAsyncRequest:= _comb_control(0,6,a);
  78. end;
  79. function CombSetControl(a: longint): longint;
  80. begin
  81. CombSetControl:= _comb_control(1,1,a);
  82. end;
  83. function CombSetMode(a: longint): longint;
  84. begin
  85. CombSetMode:= _comb_control(1,2,a);
  86. end;
  87. function CombSetBPS(a: longint): longint;
  88. begin
  89. CombSetBPS:= _comb_control(1,3,a);
  90. end;
  91. function CombSetPacketSize(a: longint): longint;
  92. begin
  93. CombSetPacketSize:= _comb_control(1,4,a);
  94. end;
  95. function CombReset: longint;
  96. begin
  97. CombReset:= _comb_control(2,0,0);
  98. end;
  99. function CombResetError: longint;
  100. begin
  101. CombResetError:= _comb_control(2,1,0);
  102. end;
  103. function CombCancelWrite: longint;
  104. begin
  105. CombCancelWrite:= _comb_control(2,2,0);
  106. end;
  107. function CombCancelRead: longint;
  108. begin
  109. CombCancelRead:= _comb_control(2,3,0);
  110. end;
  111. function CombSetRTS(a: longint): longint;
  112. begin
  113. CombSetRTS:= _comb_control(3,0,a);
  114. end;
  115. function CombCTS: longint;
  116. begin
  117. CombCTS:= _comb_control(3,1,0);
  118. end;
  119. function CombWaitCallback(a: longint): longint;
  120. begin
  121. CombWaitCallback:= _comb_control(4,0,a);
  122. end;
  123. function CombResetVBLANK: longint;
  124. begin
  125. CombResetVBLANK:= _comb_control(5,0,0);
  126. end;
  127. begin
  128. end.