ant_dll.cpp 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. This software is subject to the license described in the License.txt file
  3. included with this software distribution. You may not use this file except in compliance
  4. with this license.
  5. Copyright (c) Dynastream Innovations Inc. 2012
  6. All rights reserved.
  7. */
  8. #include "stdafx.h"
  9. #include "types.h"
  10. #include "antdefines.h"
  11. #include "antmessage.h"
  12. #include "ant_dll.h"
  13. //////////////////////////////////////////////////////////////////////////////////
  14. // Public Variables
  15. //////////////////////////////////////////////////////////////////////////////////
  16. // Function Pointers
  17. P_ANT_INIT ANT_Init;
  18. P_ANT_GETDEVICEUSBINFO ANT_GetDeviceUSBInfo;
  19. P_ANT_GETDEVICEUSBPID ANT_GetDeviceUSBPID;
  20. P_ANT_CLOSE ANT_Close;
  21. P_ANT_ARF ANT_AssignResponseFunction;
  22. P_ANT_AEF ANT_AssignChannelEventFunction;
  23. P_ANT_UNASSIGN ANT_UnAssignChannel;
  24. P_ANT_ASSIGN ANT_AssignChannel;
  25. P_ANT_SETID ANT_SetChannelId;
  26. P_ANT_SETPER ANT_SetChannelPeriod;
  27. P_ANT_SETTIME ANT_SetChannelSearchTimeout;
  28. P_ANT_SETFREQ ANT_SetChannelRFFreq;
  29. P_ANT_SETKEY ANT_SetNetworkKey;
  30. P_ANT_SETPWR ANT_SetTransmitPower;
  31. P_ANT_SETCHNLPWR ANT_SetChannelTxPower;
  32. P_ANT_RST ANT_ResetSystem;
  33. P_ANT_OPENCHNL ANT_OpenChannel;
  34. P_ANT_CLOSECHNL ANT_CloseChannel;
  35. P_ANT_REQMSG ANT_RequestMessage;
  36. P_ANT_WRITEMSG ANT_WriteMessage;
  37. P_ANT_TX ANT_SendBroadcastData;
  38. P_ANT_TXA ANT_SendAcknowledgedData;
  39. P_ANT_TXB ANT_SendBurstTransfer;
  40. P_ANT_LIBVER ANT_LibVersion;
  41. //////////////////////////////////////////////////////////////////////////////////
  42. // Private Variables
  43. //////////////////////////////////////////////////////////////////////////////////
  44. static HMODULE hANTdll;
  45. static BOOL bLoaded = FALSE;
  46. //////////////////////////////////////////////////////////////////////////////////
  47. // Public Functions
  48. //////////////////////////////////////////////////////////////////////////////////
  49. ///////////////////////////////////////////////////////////////////////
  50. BOOL ANT_Load(void)
  51. {
  52. if (bLoaded)
  53. return TRUE;
  54. hANTdll = LoadLibraryA("ANT_DLL.dll");
  55. if (hANTdll == NULL)
  56. return FALSE;
  57. ANT_Init = (P_ANT_INIT) GetProcAddress(hANTdll, "ANT_Init");
  58. ANT_GetDeviceUSBInfo = (P_ANT_GETDEVICEUSBINFO) GetProcAddress(hANTdll, "ANT_GetDeviceUSBInfo");
  59. ANT_GetDeviceUSBPID = (P_ANT_GETDEVICEUSBPID) GetProcAddress(hANTdll, "ANT_GetDeviceUSBPID");
  60. ANT_Close = (P_ANT_CLOSE) GetProcAddress(hANTdll, "ANT_Close");
  61. ANT_AssignResponseFunction = (P_ANT_ARF) GetProcAddress(hANTdll, "ANT_AssignResponseFunction");
  62. ANT_AssignChannelEventFunction = (P_ANT_AEF) GetProcAddress(hANTdll, "ANT_AssignChannelEventFunction");
  63. ANT_UnAssignChannel = (P_ANT_UNASSIGN) GetProcAddress(hANTdll, "ANT_UnAssignChannel_RTO");
  64. ANT_AssignChannel = (P_ANT_ASSIGN) GetProcAddress(hANTdll, "ANT_AssignChannel_RTO");
  65. ANT_WriteMessage = (P_ANT_WRITEMSG) GetProcAddress(hANTdll, "ANT_WriteMessage");
  66. ANT_SetChannelId =(P_ANT_SETID) GetProcAddress(hANTdll, "ANT_SetChannelId_RTO");
  67. ANT_SetChannelPeriod = (P_ANT_SETPER) GetProcAddress(hANTdll, "ANT_SetChannelPeriod_RTO");
  68. ANT_SetChannelSearchTimeout = (P_ANT_SETTIME) GetProcAddress(hANTdll, "ANT_SetChannelSearchTimeout_RTO");
  69. ANT_SetChannelRFFreq = (P_ANT_SETFREQ) GetProcAddress(hANTdll, "ANT_SetChannelRFFreq_RTO");
  70. ANT_SetNetworkKey = (P_ANT_SETKEY) GetProcAddress(hANTdll, "ANT_SetNetworkKey_RTO");
  71. ANT_SetTransmitPower = (P_ANT_SETPWR) GetProcAddress(hANTdll, "ANT_SetTransmitPower_RTO");
  72. ANT_SetChannelTxPower = (P_ANT_SETCHNLPWR) GetProcAddress(hANTdll, "ANT_SetChannelTxPower_RTO");
  73. ANT_ResetSystem = (P_ANT_RST) GetProcAddress(hANTdll, "ANT_ResetSystem");
  74. ANT_OpenChannel = (P_ANT_OPENCHNL) GetProcAddress(hANTdll, "ANT_OpenChannel");
  75. ANT_CloseChannel = (P_ANT_CLOSECHNL) GetProcAddress(hANTdll, "ANT_CloseChannel");
  76. ANT_RequestMessage = (P_ANT_REQMSG) GetProcAddress(hANTdll, "ANT_RequestMessage");
  77. ANT_SendBroadcastData = (P_ANT_TX) GetProcAddress(hANTdll, "ANT_SendBroadcastData");
  78. ANT_SendAcknowledgedData = (P_ANT_TXA) GetProcAddress(hANTdll, "ANT_SendAcknowledgedData");
  79. ANT_SendBurstTransfer = (P_ANT_TXB) GetProcAddress(hANTdll, "ANT_SendBurstTransfer");
  80. ANT_LibVersion = (P_ANT_LIBVER) GetProcAddress(hANTdll, "ANT_LibVersion");
  81. if (ANT_Init == NULL)
  82. return FALSE;
  83. if (ANT_GetDeviceUSBInfo == NULL)
  84. return FALSE;
  85. if (ANT_GetDeviceUSBPID == NULL)
  86. return FALSE;
  87. if (ANT_Close == NULL)
  88. return FALSE;
  89. if (ANT_AssignResponseFunction == NULL)
  90. return FALSE;
  91. if (ANT_AssignChannelEventFunction == NULL)
  92. return FALSE;
  93. if (ANT_UnAssignChannel == NULL)
  94. return FALSE;
  95. if (ANT_AssignChannel == NULL)
  96. return FALSE;
  97. if (ANT_WriteMessage == NULL)
  98. return FALSE;
  99. if (ANT_SetChannelId == NULL)
  100. return FALSE;
  101. if (ANT_SetChannelPeriod == NULL)
  102. return FALSE;
  103. if (ANT_SetChannelSearchTimeout == NULL)
  104. return FALSE;
  105. if (ANT_SetChannelRFFreq == NULL)
  106. return FALSE;
  107. if (ANT_SetNetworkKey == NULL)
  108. return FALSE;
  109. if (ANT_SetTransmitPower == NULL)
  110. return FALSE;
  111. if (ANT_SetChannelTxPower == NULL)
  112. return FALSE;
  113. if (ANT_ResetSystem == NULL)
  114. return FALSE;
  115. if (ANT_OpenChannel == NULL)
  116. return FALSE;
  117. if (ANT_CloseChannel == NULL)
  118. return FALSE;
  119. if (ANT_RequestMessage == NULL)
  120. return FALSE;
  121. if (ANT_SendBroadcastData == NULL)
  122. return FALSE;
  123. if (ANT_SendAcknowledgedData == NULL)
  124. return FALSE;
  125. if (ANT_SendBurstTransfer == NULL)
  126. return FALSE;
  127. bLoaded = TRUE;
  128. return TRUE;
  129. }
  130. ///////////////////////////////////////////////////////////////////////
  131. void ANT_UnLoad(void)
  132. {
  133. if (hANTdll != NULL)
  134. {
  135. FreeLibrary(hANTdll);
  136. }
  137. bLoaded = FALSE;
  138. }
  139. ///////////////////////////////////////////////////////////////////////
  140. BOOL ANT_LibVersionSupport(void)
  141. {
  142. BOOL bLibVer = FALSE;
  143. if(hANTdll != NULL)
  144. {
  145. if(ANT_LibVersion != NULL)
  146. bLibVer = TRUE;
  147. }
  148. return bLibVer;
  149. }