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.

212 lines
5.1 KiB

  1. /*****************************************************************************
  2. *
  3. * Copyright (c) 1997-1999 Microsoft Corporation
  4. *
  5. * @doc
  6. * @module parallax.c | IrSIR NDIS Miniport Driver
  7. * @comm
  8. *
  9. *-----------------------------------------------------------------------------
  10. *
  11. * Author: Stan Adermann (stana)
  12. *
  13. * Date: 10/15/1997 (created)
  14. *
  15. * Contents: Parallax PRA9500A 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 PARALLAX_IRDA_SPEEDS ( \
  22. NDIS_IRDA_SPEED_2400 | \
  23. NDIS_IRDA_SPEED_9600 | \
  24. NDIS_IRDA_SPEED_19200 | \
  25. NDIS_IRDA_SPEED_38400 | \
  26. NDIS_IRDA_SPEED_57600 | \
  27. NDIS_IRDA_SPEED_115200 \
  28. )
  29. NDIS_STATUS
  30. PARALLAX_QueryCaps(
  31. OUT PDONGLE_CAPABILITIES pDongleCaps
  32. )
  33. {
  34. DEBUGMSG(DBG_FUNC, ("+PARALLAX_Init\n"));
  35. ASSERT(pDongleCaps != NULL);
  36. pDongleCaps->supportedSpeedsMask = PARALLAX_IRDA_SPEEDS;
  37. pDongleCaps->turnAroundTime_usec = 100;
  38. pDongleCaps->extraBOFsRequired = 0;
  39. DEBUGMSG(DBG_FUNC, ("-PARALLAX_Init\n"));
  40. return NDIS_STATUS_SUCCESS;
  41. }
  42. /*****************************************************************************
  43. *
  44. * Function: PARALLAX_Init
  45. *
  46. * Synopsis: Initialize the PARALLAX dongle.
  47. *
  48. * Arguments:
  49. *
  50. * Returns: NDIS_STATUS_SUCCESS
  51. * DONGLE_CAPABILITIES
  52. *
  53. * Algorithm:
  54. *
  55. * History: dd-mm-yyyy Author Comment
  56. * 10/2/1996 sholden author
  57. *
  58. * Notes:
  59. *
  60. *****************************************************************************/
  61. NDIS_STATUS
  62. PARALLAX_Init(
  63. IN PDEVICE_OBJECT pSerialDevObj
  64. )
  65. {
  66. DEBUGMSG(DBG_FUNC, ("+PARALLAX_Init\n"));
  67. (void)SerialSetDTR(pSerialDevObj);
  68. (void)SerialSetRTS(pSerialDevObj);
  69. DEBUGMSG(DBG_FUNC, ("-PARALLAX_Init\n"));
  70. return NDIS_STATUS_SUCCESS;
  71. }
  72. /*****************************************************************************
  73. *
  74. * Function: PARALLAX_Deinit
  75. *
  76. * Synopsis: The PARALLAX dongle doesn't require any special deinit, but for
  77. * purposes of being symmetrical with other dongles...
  78. *
  79. * Arguments:
  80. *
  81. * Returns:
  82. *
  83. * Algorithm:
  84. *
  85. * History: dd-mm-yyyy Author Comment
  86. * 10/2/1996 sholden author
  87. *
  88. * Notes:
  89. *
  90. *
  91. *****************************************************************************/
  92. VOID
  93. PARALLAX_Deinit(
  94. IN PDEVICE_OBJECT pSerialDevObj
  95. )
  96. {
  97. DEBUGMSG(DBG_FUNC, ("+PARALLAX_Deinit\n"));
  98. DEBUGMSG(DBG_FUNC, ("-PARALLAX_Deinit\n"));
  99. return;
  100. }
  101. /*****************************************************************************
  102. *
  103. * Function: PARALLAX_SetSpeed
  104. *
  105. * Synopsis: set the baud rate of the PARALLAX dongle
  106. *
  107. * Arguments:
  108. *
  109. * Returns: NDIS_STATUS_SUCCESS if bitsPerSec = 9600 || 19200 || 115200
  110. * NDIS_STATUS_FAILURE otherwise
  111. *
  112. * Algorithm:
  113. *
  114. * History: dd-mm-yyyy Author Comment
  115. * 10/2/1996 sholden author
  116. *
  117. * Notes:
  118. * The caller of this function should set the baud rate of the
  119. * serial driver (UART) to 9600 first to ensure that dongle
  120. * receives the commands.
  121. *
  122. *
  123. *****************************************************************************/
  124. NDIS_STATUS
  125. PARALLAX_SetSpeed(
  126. IN PDEVICE_OBJECT pSerialDevObj,
  127. IN UINT bitsPerSec,
  128. IN UINT currentSpeed
  129. )
  130. {
  131. ULONG NumToggles;
  132. #if DBG
  133. LARGE_INTEGER StartTime, EndTime;
  134. ULONG DbgNumToggles;
  135. #endif
  136. DEBUGMSG(DBG_FUNC, ("+PARALLAX_SetSpeed\n"));
  137. if (bitsPerSec==currentSpeed)
  138. {
  139. return NDIS_STATUS_SUCCESS;
  140. }
  141. //
  142. // We will need to 'count down' from 115.2 Kbaud.
  143. //
  144. switch (bitsPerSec){
  145. case 2400: NumToggles = 6; break;
  146. case 4800: NumToggles = 5; break;
  147. case 9600: NumToggles = 4; break;
  148. case 19200: NumToggles = 3; break;
  149. case 38400: NumToggles = 2; break;
  150. case 57600: NumToggles = 1; break;
  151. case 115200: NumToggles = 0; break;
  152. default:
  153. /*
  154. * Illegal speed
  155. */
  156. return NDIS_STATUS_FAILURE;
  157. }
  158. //
  159. // Set speed to 115200, enabling set-speed mode.
  160. //
  161. NdisMSleep(1000);
  162. (void)SerialClrRTS(pSerialDevObj);
  163. NdisMSleep(1000);
  164. (void)SerialSetRTS(pSerialDevObj);
  165. NdisMSleep(1000);
  166. while (NumToggles--)
  167. {
  168. (void)SerialClrDTR(pSerialDevObj);
  169. NdisMSleep(1000);
  170. (void)SerialSetDTR(pSerialDevObj);
  171. NdisMSleep(1000);
  172. }
  173. //
  174. // These NdisMSleep calls actually have a granularity of about 10ms under
  175. // NT, even though we're asking for 1ms. Fortunately, in this case, it
  176. // works.
  177. //
  178. DEBUGMSG(DBG_FUNC, ("-PARALLAX_SetSpeed\n"));
  179. return NDIS_STATUS_SUCCESS;
  180. }