usbtc08.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. /*********************************************************************
  2. *
  3. * Filename: usbtc08.h
  4. * Author: SDI & MAS
  5. * Description:
  6. *
  7. * This header defines the interface to driver routines for the
  8. * USB TC-08 Thermocouple Data Loggers.
  9. *
  10. * History: 12May03 SDI Created
  11. *
  12. * Copyright � 2002 - 2022 Pico Technology Ltd. All rights reserved.
  13. *
  14. *********************************************************************/
  15. #ifndef __USBTC08_H__
  16. #define __USBTC08_H__
  17. #include <stdint.h>
  18. #ifdef __cplusplus
  19. #define PREF0 extern "C"
  20. #else
  21. #define PREF0
  22. #endif
  23. #ifdef WIN32
  24. #ifdef PREF1
  25. #undef PREF1
  26. #endif
  27. #ifdef PREF2
  28. #undef PREF2
  29. #endif
  30. #ifdef PREF3
  31. #undef PREF3
  32. #endif
  33. /* If you are dynamically linking usbtc08.dll into your project #define DYNLINK here
  34. */
  35. #ifdef DYNLINK
  36. #define PREF1 typedef
  37. #define PREF2
  38. #define PREF3(x) (__stdcall *x)
  39. #else
  40. #define PREF1
  41. #ifdef _USRDLL
  42. #define PREF2 __declspec (dllexport) __stdcall
  43. #else
  44. #define PREF2 __declspec (dllimport) __stdcall
  45. #endif
  46. #define PREF3(x) x
  47. #endif
  48. #else
  49. #ifdef DYNLINK
  50. #define PREF1 typedef
  51. #define PREF2
  52. #define PREF3(x) (*x)
  53. #else
  54. #ifdef _USRDLL
  55. #define PREF1 __attribute__((visibility("default")))
  56. #else
  57. #define PREF1
  58. #endif
  59. #define PREF2
  60. #define PREF3(x) x
  61. #endif
  62. #define __stdcall
  63. #endif
  64. /* General Defines **************************************************/
  65. #define USBTC08_MAX_FILTER_SIZE 255
  66. #define USBTC08_MAX_SAMPLE_BUFFER 600 /* Max readings that usb_tc08_get_temp will ever return */
  67. #define USBTC08_MAX_INFO_CHARS 256
  68. #define USBTC08_MAX_DATE_CHARS 9
  69. #define USBTC08_MAX_SERIAL_CHARS 11
  70. #define USBTC08_MAX_VERSION_CHARS 12
  71. #define USBTC08_MAX_VERSION_CHARS_V2 25
  72. /* Enumerations *****************************************************/
  73. /* There are 8 channels from 1 to 8
  74. * to enumerate them, use:
  75. *
  76. * for (i = 1; i <= USBTC08_MAX_CHANNELS; i++)
  77. *
  78. * the Cold Junction Compensation is channel 0
  79. */
  80. typedef enum enUSBTC08Channels
  81. {
  82. USBTC08_CHANNEL_CJC,
  83. USBTC08_CHANNEL_1,
  84. USBTC08_CHANNEL_2,
  85. USBTC08_CHANNEL_3,
  86. USBTC08_CHANNEL_4,
  87. USBTC08_CHANNEL_5,
  88. USBTC08_CHANNEL_6,
  89. USBTC08_CHANNEL_7,
  90. USBTC08_CHANNEL_8,
  91. USBTC08_MAX_CHANNELS = USBTC08_CHANNEL_8
  92. } USBTC08_CHANNELS;
  93. typedef enum enUSBTC08Progress
  94. {
  95. USBTC08_PROGRESS_FAIL = -1,
  96. USBTC08_PROGRESS_PENDING = 0,
  97. USBTC08_PROGRESS_COMPLETE = 1
  98. } USBTC08_PROGRESS;
  99. typedef enum enUSBTC08Error
  100. {
  101. /*========================
  102. User/Developer error codes
  103. =========================*/
  104. USBTC08_ERROR_OK,
  105. USBTC08_ERROR_OS_NOT_SUPPORTED, /* need to use win98 (or later) or win2k (or later) */
  106. USBTC08_ERROR_NO_CHANNELS_SET,
  107. USBTC08_ERROR_INVALID_PARAMETER, /* one or more of the function arguments was invalid */
  108. USBTC08_ERROR_VARIANT_NOT_SUPPORTED, /* the hardware version is not supported (download the latest driver) */
  109. USBTC08_ERROR_INCORRECT_MODE, /* an incompatible mix of legacy and non-legacy functions was called
  110. ... or usb_tc08_get_single was called while streaming was active */
  111. USBTC08_ERROR_ENUMERATION_INCOMPLETE, /* a second call to usb_tc08_open_unit_async() was made before
  112. asynchronous enumeration had completed */
  113. /*=======================
  114. Reserved Pico error codes
  115. ========================*/
  116. USBTC08_ERROR_NOT_RESPONDING, /* unit is not responding to the driver */
  117. USBTC08_ERROR_FW_FAIL, /* unabled to download firmware */
  118. USBTC08_ERROR_CONFIG_FAIL, /* missing or corrupted eeprom */
  119. USBTC08_ERROR_NOT_FOUND, /* cannot find enumerated device */
  120. USBTC08_ERROR_THREAD_FAIL, /* a threading function failed */
  121. USBTC08_ERROR_PIPE_INFO_FAIL, /* could not get pipes from the device */
  122. USBTC08_ERROR_NOT_CALIBRATED, /* no calibration date was found */
  123. USBTC08_EROOR_PICOPP_TOO_OLD,
  124. USBTC08_ERROR_PICOPP_TOO_OLD = USBTC08_EROOR_PICOPP_TOO_OLD,
  125. USBTC08_ERROR_PICO_DRIVER_FUNCTION,
  126. /*===========================
  127. New User/Developererror codes
  128. ============================*/
  129. USBTC08_ERROR_COMMUNICATION /*the PC has lost communication with unit*/
  130. } USBTC08_ERROR;
  131. typedef enum enUSBTC08Units
  132. {
  133. USBTC08_UNITS_CENTIGRADE,
  134. USBTC08_UNITS_FAHRENHEIT,
  135. USBTC08_UNITS_KELVIN,
  136. USBTC08_UNITS_RANKINE,
  137. USBTC08_MAX_UNITS = USBTC08_UNITS_RANKINE
  138. } USBTC08_UNITS;
  139. typedef enum enUSBTC08InfoLine
  140. {
  141. USBTC08LINE_DRIVER_VERSION,
  142. USBTC08LINE_KERNEL_DRIVER_VERSION,
  143. USBTC08LINE_HARDWARE_VERSION,
  144. USBTC08LINE_VARIANT_INFO,
  145. USBTC08LINE_BATCH_AND_SERIAL,
  146. USBTC08LINE_CAL_DATE,
  147. USBTC08LINE_DRIVER_PATH
  148. } USBTC08_INFO_LINE;
  149. /* Structures *****************************************************/
  150. typedef struct tUSBTC08Info
  151. {
  152. int16_t size;
  153. int8_t DriverVersion[USBTC08_MAX_VERSION_CHARS];
  154. int16_t PicoppVersion;
  155. int16_t HardwareVersion;
  156. int16_t Variant;
  157. int8_t szSerial[USBTC08_MAX_SERIAL_CHARS];
  158. int8_t szCalDate[USBTC08_MAX_DATE_CHARS];
  159. } USBTC08_INFO, *LPUSBTC08_INFO;
  160. typedef struct tUSBTC08InfoV2
  161. {
  162. int16_t size;
  163. int8_t DriverVersion[USBTC08_MAX_VERSION_CHARS_V2];
  164. int16_t UsbVersion;
  165. int16_t HardwareVersion;
  166. int16_t Variant;
  167. int8_t szSerial[USBTC08_MAX_SERIAL_CHARS];
  168. int8_t szCalDate[USBTC08_MAX_DATE_CHARS];
  169. } USBTC08_INFO_V2, *LPUSBTC08_INFO_V2;
  170. /*====================================================================
  171. New USB TC08 API Calls
  172. This set of functions should be used in preference to the
  173. Legacy API calls at the bottom of this header file
  174. (see also 'Shared API Calls' which are designed to be used
  175. with the new API calls, but can also be used with legacy calls)
  176. =====================================================================*/
  177. PREF0 PREF1 int16_t PREF2 PREF3(usb_tc08_set_channel)
  178. (
  179. int16_t handle,
  180. int16_t channel,
  181. int8_t tc_type
  182. );
  183. PREF0 PREF1 int32_t PREF2 PREF3(usb_tc08_run)
  184. (
  185. int16_t handle,
  186. int32_t interval_ms
  187. );
  188. /* must be called at least once per minute to ensure no data is lost */
  189. PREF0 PREF1 int32_t PREF2 PREF3(usb_tc08_get_temp)
  190. (
  191. int16_t handle,
  192. float *temp_buffer,
  193. int32_t *times_ms_buffer, /* wraps back to zero after 24 days */
  194. int32_t buffer_length,
  195. int16_t *overflow,
  196. int16_t channel,
  197. int16_t units,
  198. int16_t fill_missing
  199. );
  200. PREF0 PREF1 int32_t PREF2 PREF3(usb_tc08_get_temp_deskew)
  201. (
  202. int16_t handle,
  203. float *temp_buffer,
  204. int32_t *times_ms_buffer, /* wraps back to zero after 24 days */
  205. int32_t buffer_length,
  206. int16_t *overflow,
  207. int16_t channel,
  208. int16_t units,
  209. int16_t fill_missing
  210. );
  211. PREF0 PREF1 int16_t PREF2 PREF3(usb_tc08_get_single)
  212. (
  213. int16_t handle,
  214. float *temp,
  215. int16_t *overflow_flags,
  216. int16_t units
  217. );
  218. /*==========================================================================
  219. Shared API Calls
  220. These functions are designed for use with the USB TC08,
  221. however, they can (and should) still be used with the legacy API calls
  222. ===========================================================================*/
  223. PREF0 PREF1 int16_t PREF2 PREF3(usb_tc08_open_unit)
  224. (
  225. void
  226. );
  227. /* These two functions are used instead of usb_tc08_open_unit()
  228. * if the calling application needs to perform operations while
  229. * waiting for a unit to open
  230. */
  231. PREF0 PREF1 int16_t PREF2 PREF3(usb_tc08_open_unit_async)
  232. (
  233. void
  234. );
  235. PREF0 PREF1 int16_t PREF2 PREF3(usb_tc08_open_unit_progress)
  236. (
  237. int16_t *handle,
  238. int16_t *percent_progress
  239. );
  240. PREF0 PREF1 int16_t PREF2 PREF3(usb_tc08_close_unit)
  241. (
  242. int16_t handle
  243. );
  244. PREF0 PREF1 int16_t PREF2 PREF3(usb_tc08_stop)
  245. (
  246. int16_t handle
  247. );
  248. PREF0 PREF1 int16_t PREF2 PREF3(usb_tc08_set_mains)
  249. (
  250. int16_t handle,
  251. int16_t sixty_hertz
  252. );
  253. /* set-up all channels before calling this
  254. * in legacy mode, this will be the fixed sampling rate
  255. */
  256. PREF0 PREF1 int32_t PREF2 PREF3(usb_tc08_get_minimum_interval_ms)
  257. (
  258. int16_t handle
  259. );
  260. PREF0 PREF1 int16_t PREF2 PREF3(usb_tc08_get_unit_info)
  261. (
  262. int16_t handle, USBTC08_INFO * info
  263. );
  264. PREF0 PREF1 int16_t PREF2 PREF3(usb_tc08_get_unit_info_v2)
  265. (
  266. int16_t handle, USBTC08_INFO_V2* info
  267. );
  268. PREF0 PREF1 int16_t PREF2 PREF3(usb_tc08_get_unit_info2)
  269. (
  270. int16_t handle,
  271. int8_t *string,
  272. int16_t string_length,
  273. int16_t line
  274. );
  275. PREF0 PREF1 int16_t PREF2 PREF3(usb_tc08_get_formatted_info)
  276. (
  277. int16_t handle,
  278. int8_t *unit_info,
  279. int16_t string_length);
  280. /* pass 0 as the unit handle to get the last reason
  281. * that usb_tc08_open_unit() failed
  282. */
  283. PREF0 PREF1 int16_t PREF2 PREF3(usb_tc08_get_last_error)
  284. (
  285. int16_t handle
  286. );
  287. /*====================================================================
  288. Legacy API Calls
  289. Provided to aid backwards compatibility with code written
  290. for old TC08 Units (differences exist).
  291. These functions should not be used in new code and are
  292. deprecated for removal in a future version of the driver.
  293. =====================================================================*/
  294. /* Legacy defines
  295. */
  296. #define CHANNELS_PER_TC08 8
  297. #define MAX_TC08_UNITS 64
  298. PREF0 PREF1 int16_t PREF2 PREF3(usb_tc08_legacy_run)
  299. (
  300. int16_t handle
  301. );
  302. PREF0 PREF1 int16_t PREF2 PREF3(usb_tc08_legacy_set_channel)
  303. (
  304. int16_t handle,
  305. int16_t channel,
  306. int8_t tc_type,
  307. int16_t filter_factor,
  308. int16_t offset,
  309. int16_t slope
  310. );
  311. PREF0 PREF1 int16_t PREF2 PREF3(usb_tc08_legacy_get_temp)
  312. (
  313. int32_t *temp,
  314. int16_t handle,
  315. uint16_t channel,
  316. uint16_t filtered
  317. );
  318. PREF0 PREF1 int16_t PREF2 PREF3(usb_tc08_legacy_get_cold_junction)
  319. (
  320. int32_t * temp,
  321. int16_t handle
  322. );
  323. PREF0 PREF1 int16_t PREF2 PREF3(usb_tc08_legacy_get_driver_version)
  324. (
  325. void
  326. );
  327. PREF0 PREF1 int16_t PREF2 PREF3(usb_tc08_legacy_get_version)
  328. (
  329. int16_t *version,
  330. int16_t handle
  331. );
  332. PREF0 PREF1 int16_t PREF2 PREF3(usb_tc08_legacy_get_cycle)
  333. (
  334. int32_t *cycle,
  335. int16_t handle
  336. );
  337. #endif