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.

208 lines
5.2 KiB

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