Leaked source code of windows server 2003
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.3 KiB

  1. /*****************************************************************************
  2. *
  3. * Copyright (c) 1999 Microsoft Corporation
  4. *
  5. * @doc
  6. * @module girbil.c | IrSIR NDIS Miniport Driver
  7. * @comm
  8. *
  9. *-----------------------------------------------------------------------------
  10. *
  11. * Author: Stan Adermann (stana)
  12. *
  13. * Date: 6/9/1999 (created)
  14. *
  15. * Contents: GIrBIL 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 GIRBIL_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. GIRBIL_QueryCaps(
  31. OUT PDONGLE_CAPABILITIES pDongleCaps
  32. )
  33. {
  34. DEBUGMSG(DBG_FUNC, ("+GIRBIL_Init\n"));
  35. ASSERT(pDongleCaps != NULL);
  36. pDongleCaps->supportedSpeedsMask = GIRBIL_IRDA_SPEEDS;
  37. pDongleCaps->turnAroundTime_usec = 100;
  38. pDongleCaps->extraBOFsRequired = 0;
  39. DEBUGMSG(DBG_FUNC, ("-GIRBIL_Init\n"));
  40. return NDIS_STATUS_SUCCESS;
  41. }
  42. /*****************************************************************************
  43. *
  44. * Function: GIRBIL_Init
  45. *
  46. * Synopsis: Initialize the GIRBIL 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. GIRBIL_Init(
  63. IN PDEVICE_OBJECT pSerialDevObj
  64. )
  65. {
  66. UCHAR Data[] = { 0x07 };
  67. ULONG BytesWritten;
  68. DEBUGMSG(DBG_FUNC, ("+GIRBIL_Init\n"));
  69. (void)SerialSetRTS(pSerialDevObj);
  70. NdisMSleep(1000);
  71. (void)SerialClrRTS(pSerialDevObj);
  72. NdisMSleep(8000);
  73. (void)SerialSetRTS(pSerialDevObj);
  74. NdisMSleep(8000);
  75. (void)SerialSetDTR(pSerialDevObj);
  76. NdisMSleep(8000);
  77. (void)SerialClrDTR(pSerialDevObj);
  78. NdisMSleep(8000);
  79. (void)SerialSynchronousWrite(pSerialDevObj, Data, sizeof(Data), &BytesWritten);
  80. NdisMSleep(5000);
  81. (void)SerialSetDTR(pSerialDevObj);
  82. NdisMSleep(8000);
  83. DEBUGMSG(DBG_FUNC, ("-GIRBIL_Init\n"));
  84. return NDIS_STATUS_SUCCESS;
  85. }
  86. /*****************************************************************************
  87. *
  88. * Function: GIRBIL_Deinit
  89. *
  90. * Synopsis: The GIRBIL dongle doesn't require any special deinit, but for
  91. * purposes of being symmetrical with other dongles...
  92. *
  93. * Arguments:
  94. *
  95. * Returns:
  96. *
  97. * Algorithm:
  98. *
  99. * History: dd-mm-yyyy Author Comment
  100. * 10/2/1996 sholden author
  101. *
  102. * Notes:
  103. *
  104. *
  105. *****************************************************************************/
  106. VOID
  107. GIRBIL_Deinit(
  108. IN PDEVICE_OBJECT pSerialDevObj
  109. )
  110. {
  111. DEBUGMSG(DBG_FUNC, ("+GIRBIL_Deinit\n"));
  112. DEBUGMSG(DBG_FUNC, ("-GIRBIL_Deinit\n"));
  113. return;
  114. }
  115. /*****************************************************************************
  116. *
  117. * Function: GIRBIL_SetSpeed
  118. *
  119. * Synopsis: set the baud rate of the GIRBIL dongle
  120. *
  121. * Arguments:
  122. *
  123. * Returns: NDIS_STATUS_SUCCESS if bitsPerSec = 9600 || 19200 || 115200
  124. * NDIS_STATUS_FAILURE otherwise
  125. *
  126. * Algorithm:
  127. *
  128. * History: dd-mm-yyyy Author Comment
  129. * 10/2/1996 sholden author
  130. *
  131. * Notes:
  132. * The caller of this function should set the baud rate of the
  133. * serial driver (UART) to 9600 first to ensure that dongle
  134. * receives the commands.
  135. *
  136. *
  137. *****************************************************************************/
  138. NDIS_STATUS
  139. GIRBIL_SetSpeed(
  140. IN PDEVICE_OBJECT pSerialDevObj,
  141. IN UINT bitsPerSec,
  142. IN UINT currentSpeed
  143. )
  144. {
  145. ULONG Speed = 9600;
  146. ULONG BytesWritten;
  147. UCHAR Data[] = { 0x00, 0x51 };
  148. DEBUGMSG(DBG_FUNC, ("+GIRBIL_SetSpeed\n"));
  149. if (bitsPerSec==currentSpeed)
  150. {
  151. return NDIS_STATUS_SUCCESS;
  152. }
  153. switch (bitsPerSec){
  154. case 2400: Data[0] = 0x30; break;
  155. case 9600: Data[0] = 0x32; break;
  156. case 19200: Data[0] = 0x33; break;
  157. case 38400: Data[0] = 0x34; break;
  158. case 57600: Data[0] = 0x35; break;
  159. case 115200: Data[0] = 0x36; break;
  160. break;
  161. default:
  162. /*
  163. * Illegal speed
  164. */
  165. return NDIS_STATUS_FAILURE;
  166. }
  167. (void)SerialSetBaudRate(pSerialDevObj, &Speed);
  168. GIRBIL_Init(pSerialDevObj);
  169. (void)SerialClrDTR(pSerialDevObj);
  170. NdisMSleep(8000);
  171. (void)SerialSynchronousWrite(pSerialDevObj, Data, sizeof(Data), &BytesWritten);
  172. NdisMSleep(5000);
  173. (void)SerialSetDTR(pSerialDevObj);
  174. NdisMSleep(8000);
  175. DEBUGMSG(DBG_FUNC, ("-GIRBIL_SetSpeed\n"));
  176. return NDIS_STATUS_SUCCESS;
  177. }