Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

268 lines
6.0 KiB

  1. /*****************************************************************************
  2. *
  3. * Copyright (c) 1996-1999 Microsoft Corporation
  4. *
  5. * @doc
  6. * @module esi.c | IrSIR NDIS Miniport Driver
  7. * @comm
  8. *
  9. *-----------------------------------------------------------------------------
  10. *
  11. * Author: Scott Holden (sholden)
  12. *
  13. * Date: 9/30/1996 (created)
  14. *
  15. * Contents: ESI 9680 JetEye dongle specific code for initialization,
  16. * deinit, and setting the baud rate of the device.
  17. *
  18. *****************************************************************************/
  19. #include "irsir.h"
  20. #include "dongle.h"
  21. #define ESI_9680_IRDA_SPEEDS ( NDIS_IRDA_SPEED_9600 | \
  22. NDIS_IRDA_SPEED_19200 | \
  23. NDIS_IRDA_SPEED_115200 \
  24. )
  25. NDIS_STATUS
  26. ESI_QueryCaps(
  27. OUT PDONGLE_CAPABILITIES pDongleCaps
  28. )
  29. {
  30. DEBUGMSG(DBG_FUNC, ("+ESI_QueryCaps\n"));
  31. ASSERT(pDongleCaps != NULL);
  32. pDongleCaps->supportedSpeedsMask = ESI_9680_IRDA_SPEEDS;
  33. pDongleCaps->turnAroundTime_usec = 100;
  34. pDongleCaps->extraBOFsRequired = 0;
  35. DEBUGMSG(DBG_FUNC, ("-ESI_QueryCaps\n"));
  36. return NDIS_STATUS_SUCCESS;
  37. }
  38. /*****************************************************************************
  39. *
  40. * Function: ESI_Init
  41. *
  42. * Synopsis: Initialize the ESI dongle.
  43. *
  44. * Arguments:
  45. *
  46. * Returns: NDIS_STATUS_SUCCESS
  47. * DONGLE_CAPABILITIES
  48. *
  49. * Algorithm:
  50. *
  51. * History: dd-mm-yyyy Author Comment
  52. * 10/2/1996 sholden author
  53. *
  54. * Notes:
  55. *
  56. *****************************************************************************/
  57. NDIS_STATUS
  58. ESI_Init(
  59. IN PDEVICE_OBJECT pSerialDevObj
  60. )
  61. {
  62. DEBUGMSG(DBG_FUNC, ("+ESI_Init\n"));
  63. DEBUGMSG(DBG_FUNC, ("-ESI_Init\n"));
  64. return NDIS_STATUS_SUCCESS;
  65. }
  66. /*****************************************************************************
  67. *
  68. * Function: ESI_Deinit
  69. *
  70. * Synopsis: The ESI dongle doesn't require any special deinit, but for
  71. * purposes of being symmetrical with other dongles...
  72. *
  73. * Arguments:
  74. *
  75. * Returns:
  76. *
  77. * Algorithm:
  78. *
  79. * History: dd-mm-yyyy Author Comment
  80. * 10/2/1996 sholden author
  81. *
  82. * Notes:
  83. *
  84. *
  85. *****************************************************************************/
  86. VOID
  87. ESI_Deinit(
  88. IN PDEVICE_OBJECT pSerialDevObj
  89. )
  90. {
  91. DEBUGMSG(DBG_FUNC, ("+ESI_Deinit\n"));
  92. DEBUGMSG(DBG_FUNC, ("-ESI_Deinit\n"));
  93. return;
  94. }
  95. /*****************************************************************************
  96. *
  97. * Function: ESI_SetSpeed
  98. *
  99. * Synopsis: set the baud rate of the ESI JetEye dongle
  100. *
  101. * Arguments:
  102. *
  103. * Returns: NDIS_STATUS_SUCCESS if bitsPerSec = 9600 || 19200 || 115200
  104. * NDIS_STATUS_FAILURE otherwise
  105. *
  106. * Algorithm:
  107. *
  108. * History: dd-mm-yyyy Author Comment
  109. * 10/2/1996 sholden author
  110. *
  111. * Notes:
  112. * The caller of this function should set the baud rate of the
  113. * serial driver (UART) to 9600 first to ensure that dongle
  114. * receives the commands.
  115. *
  116. *
  117. *****************************************************************************/
  118. NDIS_STATUS
  119. ESI_SetSpeed(
  120. IN PDEVICE_OBJECT pSerialDevObj,
  121. IN UINT bitsPerSec,
  122. IN UINT currentSpeed
  123. )
  124. {
  125. ULONG BaudRate;
  126. NDIS_STATUS status;
  127. DEBUGMSG(DBG_FUNC, ("+ESI_SetSpeed\n"));
  128. status = NDIS_STATUS_SUCCESS;
  129. switch (bitsPerSec)
  130. {
  131. case 9600:
  132. case 19200:
  133. case 115200:
  134. //
  135. // Set the UART baud rate so we can communicate with the
  136. // dongle. The baud rate needs to be 9600 to communicate
  137. // with the dongle.
  138. //
  139. if (currentSpeed != 9600)
  140. {
  141. BaudRate = 9600;
  142. status = (NDIS_STATUS) SerialSetBaudRate(
  143. pSerialDevObj,
  144. &BaudRate
  145. );
  146. if (status != NDIS_STATUS_SUCCESS)
  147. {
  148. goto done;
  149. }
  150. }
  151. break;
  152. default:
  153. //
  154. // Illegal speed setting.
  155. //
  156. DEBUGMSG(DBG_ERR, (" Illegal speed = %d\n", bitsPerSec));
  157. status = NDIS_STATUS_FAILURE;
  158. goto done;
  159. }
  160. switch (bitsPerSec)
  161. {
  162. case 9600:
  163. //
  164. // set request-to-send
  165. // clear data-terminal-ready
  166. //
  167. status = (NDIS_STATUS) SerialSetRTS(pSerialDevObj);
  168. if (status != NDIS_STATUS_SUCCESS)
  169. {
  170. goto done;
  171. }
  172. status = (NDIS_STATUS) SerialClrDTR(pSerialDevObj);
  173. if (status != NDIS_STATUS_SUCCESS)
  174. {
  175. goto done;
  176. }
  177. break;
  178. case 19200:
  179. //
  180. // clear request-to-send
  181. // set data-terminal-ready
  182. //
  183. status = (NDIS_STATUS) SerialClrRTS(pSerialDevObj);
  184. if (status != NDIS_STATUS_SUCCESS)
  185. {
  186. goto done;
  187. }
  188. status = (NDIS_STATUS) SerialSetDTR(pSerialDevObj);
  189. if (status != NDIS_STATUS_SUCCESS)
  190. {
  191. goto done;
  192. }
  193. break;
  194. case 115200:
  195. //
  196. // set request-to-send
  197. // set data-terminal-ready
  198. //
  199. status = (NDIS_STATUS) SerialSetRTS(pSerialDevObj);
  200. if (status != NDIS_STATUS_SUCCESS)
  201. {
  202. goto done;
  203. }
  204. status = (NDIS_STATUS) SerialSetDTR(pSerialDevObj);
  205. if (status != NDIS_STATUS_SUCCESS)
  206. {
  207. goto done;
  208. }
  209. break;
  210. default:
  211. break;
  212. }
  213. done:
  214. DEBUGMSG(DBG_FUNC, ("-ESI_SetSpeed\n"));
  215. return(status);
  216. }