| SLAB_USB_SPI 1.0 Silicon Labs CP2130 USB-to-SPI Interface Library

- Main Page
- Data Structures
- Files

- File List
- Globals

SLAB_USB_SPI.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // SLAB_USB_SPI.h
3 //-----------------------------------------------------------------------------
4 // Copyright 2012-2013 Silicon Laboratories, Inc.
5 // http://www.silabs.com
6 //-----------------------------------------------------------------------------
7
10
11 #ifndef SLAB_USB_SPI_H
12 #define SLAB_USB_SPI_H
13
14 #ifdef SLAB_USB_SPI_EXPORTS
15 #define SLAB_USB_SPI_API __declspec(dllexport)
16 #else
17 #define SLAB_USB_SPI_API __declspec(dllimport)
18 #endif // USB_SPI_EXPORTS
19
21 // Type Definitions - Windows Types
25
26 typedef int BOOL;
27 typedef unsigned char BYTE;
28 typedef unsigned short WORD;
29 typedef unsigned long DWORD;
30 typedef char* LPSTR;
31 typedef const char* LPCSTR;
33
35 // Definitions - Windows Definitions
39
40 #define MAX_PATH 260
41 #define CALLBACK __stdcall
42 #define WINAPI __stdcall
43
46 // Variable types
50 typedef void* CP213x_DEVICE;
51 typedef int USB_SPI_STATUS;
53
55 // Definitions specific to USB SPI code
59
60 #define BULK_PACKETSIZE 64
61 #define EP_BUFSIZE BULK_PACKETSIZE
62 #define CMD_SIZE 8
63 #define CMD_TIMEOUT_MS 1000 // Timeout for completion of SPI command (i.e. first packet)
64 #define STRING_DESCRIPTOR_SIZE 256
65 #define SIZE_PIN_CONFIG 20
66
67
68 // Maximum block size for WriteRead
69 #define WRITEREAD_MAX_BLOCKSIZE 256 // Matches size of firmware Read buffer
70
71 // Number of GPIO/CS pins
72 #define CP213x_NUM_GPIO 11
73
74 // Chip Select Mode: 0: Idle, 1: Active, 2: Active; all other channels idle
75 #define CSMODE_IDLE 0
76 #define CSMODE_ACTIVE 1
77 #define CSMODE_ACTIVE_OTHERS_IDLE 2
78
79 // Mode definitions for GPIO/CS/SpecialFunction pins
80 #define GPIO_MODE_INPUT 0
81 #define GPIO_MODE_OUTPUT_OD 1
82 #define GPIO_MODE_OUTPUT_PP 2
83 #define GPIO_MODE_CHIPSELECT 3 // Chip select mode
84
85 #define GPIO_MODE__RTR_ACTLOW 4
86 #define GPIO_MODE__RTR_ACTHIGH 5
87
88 #define GPIO_MODE__EVTCNTR_RISING 4
89 #define GPIO_MODE__EVTCNTR_FALLING 5
90 #define GPIO_MODE__EVTCNTR_NEGPULSE 6
91 #define GPIO_MODE__EVTCNTR_POSPULSE 7
92
93 #define GPIO_MODE__CLK_OUT 4
94 #define GPIO_MODE__SPI_ACTIVITY 4
95 #define GPIO_MODE__SUSPEND 4
96 #define GPIO_MODE__SUSPENDBAR 4
97
98 // End of GPIO Mode definitions
99
100
101 // String Buffer Definitions
102 #define SHORT_STRING_LEN 60
103 #define LONG_STRING_LEN_1 61
104 #define LONG_STRING_LEN_2 63
105
108 // SPI Command and Subcommand definitions
110
113 #define CMD_TRANSFER_DATA 0x0000
114 // Subcommand definitions for TRANSFER_DATA command
115 #define SUBCMD_READ 0
116 #define SUBCMD_WRITE 1
117 #define SUBCMD_WRITEREAD 2
118 #define SUBCMD_RTREAD 4
119 #define SUBCMD_MSB_RELEASE_BUS 0x80
120
124 // Bits 7-6: Not assigned
125
126 // Bit 5: Clock phase (CPHA)
127 #define SPICTL_CPHA_SHIFT 5
128 #define SPICTL_CPHA_MASK 0x20
129 #define SPICTL_CPHA_LEADING_EDGE 0
130 #define SPICTL_CPHA_TRAILING_EDGE 1
131
132 // Bit 4: Clock polarity (CPOL)
133 #define SPICTL_CPOL_SHIFT 4
134 #define SPICTL_CPOL_MASK 0x10
135 #define SPICTL_CPOL_ACTIVE_HIGH 0
136 #define SPICTL_CPOL_ACTIVE_LOW 1
137
138 // Bit 3: Chip Select Mode
139 #define SPICTL_CSMODE_SHIFT 3
140 #define SPICTL_CSMODE_MASK 0x08
141 #define SPICTL_CSMODE_OPENDRAIN 0
142 #define SPICTL_CSMODE_PUSHPULL 1
143
144 // Bit 2-0: Clock rate
145 #define SPICTL_CLKRATE_SHIFT 0
146 #define SPICTL_CLKRATE_MASK 0x07
147 #define SPICTL_CLKRATE_12M 0 // 12 MHz
148 #define SPICTL_CLKRATE_6M 1 // 6 MHz
149 #define SPICTL_CLKRATE_3M 2 // 3 MHz
150 #define SPICTL_CLKRATE_1M5 3 // 1.5 MHz
151 #define SPICTL_CLKRATE_750K 4 // 750 kHz
152 #define SPICTL_CLKRATE_375K 5 // 375 kHz
153 #define SPICTL_CLKRATE_187K5 6 // 187.5 kHz
154 #define SPICTL_CLKRATE_93K75 7 // 93.75 kHz
155
158 // Error Definitions
160
163 #define bRESULT_PASS TRUE
164 #define bRESULT_FAIL FALSE
165
167 #define USB_SPI_ERRCODE_SYSTEM_ERROR 0xFFFFFFFE
168
171
172 #define USB_SPI_ERRCODE_SUCCESS 0x00
173 #define USB_SPI_ERRCODE_ALLOC_FAILURE 0x01
174 #define USB_SPI_ERRCODE_INVALID_ENUM_VALUE 0x02
175 #define USB_SPI_ERRCODE_NULL_POINTER 0x03
176 #define USB_SPI_ERRCODE_INVALID_CHANNEL_INDEX 0x04
177 #define USB_SPI_ERRCODE_INVALID_GPIO_MODE 0x05
178
179 #define USB_SPI_ERRCODE_UNKNOWN_ERROR 0xFFFFFFFF
180
182 //
183 // API Errors
184 //
187 #define USB_SPI_ERRCODE_INVALID_PARAMETER 0x10
188
189 #define USB_SPI_ERRCODE_INVALID_DEVICE_OBJECT 0x11
190
192 //
193 // Device Errors
194 //
197 // The specified USB device could not be found.
198 #define USB_SPI_ERRCODE_DEVICE_NOT_FOUND 0x20
199
200 // The current USB device is not opened.
201 #define USB_SPI_ERRCODE_USB_DEVICE_NOT_OPENED 0x21
202
203 // The handle is invalid.
204 #define USB_SPI_ERRCODE_INVALID_HANDLE 0x22
205
207 //
208 // Device Hardware Interface Errors
209 //
212 // An error occurred while communicating with the device or while retrieving device information.
213 #define USB_SPI_ERRCODE_HWIF_DEVICE_ERROR 0x30
214
215 // A control transfer operation timed out.
216 #define USB_SPI_ERRCODE_HWIF_TRANSFER_TIMEOUT 0x31
217
221
222 #define USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR 0x50
223 #define USB_SPI_ERRCODE_INVALID_TRANSFER_SIZE 0x51
224
225 #define USB_SPI_ERRCODE_PIPE_INIT_FAIL 0x60
226 #define USB_SPI_ERRCODE_PIPE_QUERY_FAIL 0x61
227 #define USB_SPI_ERRCODE_PIPE_WRITE_FAIL 0x62
228 #define USB_SPI_ERRCODE_PIPE_READ_FAIL 0x63
229 #define USB_SPI_ERRCODE_PIPE_ABORT_FAIL 0x64
230 #define USB_SPI_ERRCODE_PIPE_FLUSH_FAIL 0x65
231 #define USB_SPI_ERRCODE_PIPE_INVALID_ID 0x66
232
233 #define USB_SPI_ERRCODE_READ_THREAD_CREATE_FAILURE 0x70
234 #define USB_SPI_ERRCODE_READ_THREAD_NOT_RUNNING 0x71
235 #define USB_SPI_ERRCODE_READ_THREAD_START_FAILURE 0x72
236
237 #define USB_SPI_ERRCODE_DEVICE_RETURNED_TOO_MUCH_DATA 0x80
238
242 // User-Customizable Field Lock Bitmasks
243 #define CP213x_LOCK_PRODUCT_STR_1 0x0001
244 #define CP213x_LOCK_PRODUCT_STR_2 0x0002
245 #define CP213x_LOCK_SERIAL_STR 0x0004
246 #define CP213x_LOCK_PIN_CONFIG 0x0008
247
248 #define CP213x_LOCK_VID 0x0100
249 #define CP213x_LOCK_PID 0x0200
250 #define CP213x_LOCK_POWER 0x0400
251 #define CP213x_LOCK_POWER_MODE 0x0800
252 #define CP213x_LOCK_RELEASE_VERSION 0x1000
253 #define CP213x_LOCK_MFG_STR_1 0x2000
254 #define CP213x_LOCK_MFG_STR_2 0x4000
255 #define CP213x_LOCK_TRANSFER_PRIORITY 0x8000
256
257 // USB Config Bitmasks
258 #define CP213x_SET_VID 0x01
259 #define CP213x_SET_PID 0x02
260 #define CP213x_SET_POWER 0x04
261 #define CP213x_SET_POWER_MODE 0x08
262 #define CP213x_SET_RELEASE_VERSION 0x10
263 #define CP213x_SET_TRANSFER_PRIORITY 0x80
264
265 // String Lengths
266 #define MFG_STRLEN 62
267 #define PRODUCT_STRLEN 62
268 #define SERIAL_STRLEN 30
269 // MFG_STR
270 typedef char MFG_STR[MFG_STRLEN];
271 // PRODUCT_STR
272 typedef char PRODUCT_STR[PRODUCT_STRLEN];
273 // SERIAL_STR
274 typedef char SERIAL_STR[SERIAL_STRLEN];
275
277 // Enumerations
279
280 enum SET_STATUS {SET_SUCCESS, SET_FAIL, SET_VERIFY_FAIL};
281
283 // Pin Definitions
285
286 // Pin Config Mode Array Indices
287 #define CP213x_INDEX_GPIO_0 0
288 #define CP213x_INDEX_GPIO_1 1
289 #define CP213x_INDEX_GPIO_2 2
290 #define CP213x_INDEX_GPIO_3 3
291 #define CP213x_INDEX_GPIO_4 4
292 #define CP213x_INDEX_GPIO_5 5
293 #define CP213x_INDEX_GPIO_6 6
294 #define CP213x_INDEX_GPIO_7 7
295 #define CP213x_INDEX_GPIO_8 8
296 #define CP213x_INDEX_GPIO_9 9
297 #define CP213x_INDEX_GPIO_10 10
298
299 // Pin Bitmasks
300 #define CP213x_MASK_SCK 0x0001
301 #define CP213x_MASK_MISO 0x0002
302 #define CP213x_MASK_MOSI 0x0004
303 #define CP213x_MASK_GPIO_0 0x0008
304 #define CP213x_MASK_GPIO_1 0x0010
305 #define CP213x_MASK_GPIO_2 0x0020
306 #define CP213x_MASK_GPIO_3 0x0040
307 #define CP213x_MASK_GPIO_4 0x0080
308 #define CP213x_MASK_GPIO_5 0x0100
309 #define CP213x_MASK_GPIO_6 0x0400
310 #define CP213x_MASK_GPIO_7 0x0800
311 #define CP213x_MASK_GPIO_8 0x1000
312 #define CP213x_MASK_GPIO_9 0x2000
313 #define CP213x_MASK_GPIO_10 0x4000
314
316
318 // Structures
320
323
326 typedef struct DEVICE_DESCRIPTOR
327 {
328 BYTE bLength;
329 BYTE bDescriptorType;
330 WORD bcdUSB;
331 BYTE bDeviceClass;
332 BYTE bDeviceSubClass;
333 BYTE bDeviceProtocol;
334 BYTE bMaxPacketSize0;
335 WORD idVendor;
336 WORD idProduct;
337 WORD bcdDevice;
338 BYTE iManufacturer;
339 BYTE iProduct;
340 BYTE iSerialNumber;
341 BYTE bNumConfigurations;
342 } DEVICE_DESCRIPTOR, *PDEVICE_DESCRIPTOR;
343
345 typedef struct SPI_CMD
346 {
347 WORD Cmd;
348 WORD SubCmd;
349 DWORD Len;
350 DWORD blockSize;
351 DWORD timeoutMs;
352 DWORD res;
353 } SPI_CMD, *PSPI_CMD;
354
355
356 // Bitfield masks for delay_mode structure element
357 #define SPI_INTERBYTE_DELAY_MASK 0x01
358 #define SPI_CS_POSTASSERT_DELAY_MASK 0x02
359 #define SPI_CS_PREDEASSERT_DELAY_MASK 0x04
360 #define SPI_CS_TOGGLE_MASK 0x08
361
363
365 // Exported API Functions
367
370
371 #ifdef __cplusplus
372 extern "C" {
373 #endif // __cplusplus
374
375 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
376 CP213x_GetLibraryVersion ( BYTE* major, BYTE* minor, BOOL* release );
377
378 //
379 // CP2130 Device Management
380 //
383
384 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
385 CP213x_GetGuid ( LPGUID guid );
386
387 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
388 CP213x_SetGuid ( LPGUID guid );
389
390 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
391 CP213x_GetNumDevices ( DWORD* numDevices );
392
393 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
394 CP213x_GetDevicePath ( DWORD deviceIndex, LPSTR path );
395
396 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
397 CP213x_OpenByIndex ( DWORD deviceIndex,
398 CP213x_DEVICE* phDevice );
399
400 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
401 CP213x_OpenByDevicePath ( LPCSTR devicePath,
402 CP213x_DEVICE* phDevice );
403
404 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
405 CP213x_GetVidPid(DWORD deviceIndex, WORD* vid, WORD* pid );
406
407 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
408 CP213x_GetOpenedDevicePath ( CP213x_DEVICE device, LPSTR path );
409
410 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
411 CP213x_GetOpenedVidPid ( CP213x_DEVICE device, WORD* vid, WORD* pid );
412
413 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
414 CP213x_Close ( CP213x_DEVICE hDevice );
415
416 SLAB_USB_SPI_API BOOL WINAPI
417 CP213x_IsOpened ( CP213x_DEVICE hDevice);
418
419 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
420 CP213x_Reset ( CP213x_DEVICE hDevice );
421
422 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
423 CP213x_GetDeviceVersion ( CP213x_DEVICE hDevice, BYTE* majorVersion, BYTE* minorVersion );
424
425 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
426 CP213x_GetDeviceDescriptor ( CP213x_DEVICE hDevice,
427 PDEVICE_DESCRIPTOR pDescriptor );
428
429 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
430 CP213x_GetStringDescriptor ( CP213x_DEVICE hDevice,
431 BYTE index,
432 BYTE stringDescriptor[STRING_DESCRIPTOR_SIZE] );
433
434 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
435 CP213x_GetUsbConfig ( CP213x_DEVICE hDevice,
436 WORD* vid,
437 WORD* pid,
438 BYTE* power,
439 BYTE* powerMode,
440 WORD* releaseVersion,
441 BYTE* transferPriority );
442
443 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
444 CP213x_SetUsbConfig ( CP213x_DEVICE hDevice,
445 WORD vid,
446 WORD pid,
447 BYTE power,
448 BYTE powerMode,
449 WORD releaseVersion,
450 BYTE transferPriority,
451 BYTE mask );
452
453 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
454 CP213x_GetManufacturingString ( CP213x_DEVICE hDevice, LPSTR manufacturingString, BYTE* strlen );
455
456 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
457 CP213x_SetManufacturingString ( CP213x_DEVICE hDevice, LPCSTR manufacturingString, BYTE strlen );
458
459 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
460 CP213x_GetProductString ( CP213x_DEVICE hDevice, LPSTR productString, BYTE* strlen );
461
462 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
463 CP213x_SetProductString ( CP213x_DEVICE hDevice, LPCSTR productString, BYTE strlen );
464
465 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
466 CP213x_GetSerialString ( CP213x_DEVICE hDevice, LPSTR serialString, BYTE* strlen );
467
468 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
469 CP213x_SetSerialString ( CP213x_DEVICE hDevice, LPCSTR serialString, BYTE strlen );
470
471 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
472 CP213x_GetPinConfig ( CP213x_DEVICE hDevice, BYTE pinConfig[SIZE_PIN_CONFIG] );
473
474 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
475 CP213x_SetPinConfig ( CP213x_DEVICE hDevice, BYTE pinConfig[SIZE_PIN_CONFIG] );
476
477 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
478 CP213x_GetLock ( CP213x_DEVICE hDevice, WORD* lockValue );
479
480 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
481 CP213x_SetLock ( CP213x_DEVICE hDevice, WORD lockValue );
482
483 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
484 CP213x_ReadProm ( CP213x_DEVICE hDevice, BYTE pReadBuf[] );
485
486 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
487 CP213x_WriteProm ( CP213x_DEVICE hDevice, BYTE pWriteBuf[] );
489
490 //
491 // CP2130 SPI Configuration and Transfer Operations
492 //
495
496 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
497 CP213x_GetSpiControlBytes ( CP213x_DEVICE hDevice, BYTE controlBytes[CP213x_NUM_GPIO] );
498
499 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
500 CP213x_SetSpiControlByte ( CP213x_DEVICE hDevice, BYTE channel, BYTE controlByte );
501
502 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
503 CP213x_GetSpiDelay ( CP213x_DEVICE hDevice,
504 BYTE channel,
505 BYTE* delayMode,
506 WORD* interByteDelay,
507 WORD* postAssertDelay,
508 WORD* preDeassertDelay );
509
510 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
511 CP213x_SetSpiDelay ( CP213x_DEVICE hDevice,
512 BYTE channel,
513 BYTE delayMode,
514 WORD interByteDelay,
515 WORD postAssertDelay,
516 WORD preDeassertDelay );
517
518 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
519 CP213x_GetChipSelect ( CP213x_DEVICE hDevice,
520 WORD* channelCsEnable,
521 WORD* pinCsEnable );
522
523 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
524 CP213x_SetChipSelect ( CP213x_DEVICE hDevice, BYTE channel, BYTE mode );
525
526 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
527 CP213x_TransferWrite ( CP213x_DEVICE hDevice,
528 BYTE pWriteBuf[],
529 DWORD length,
530 BOOL releaseBusAfterTransfer,
531 DWORD timeoutMs,
532 DWORD* pBytesActuallyWritten );
533
534 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
535 CP213x_TransferWriteRead ( CP213x_DEVICE hDevice,
536 BYTE pWriteBuf[],
537 BYTE pReadBuf[],
538 DWORD length,
539 BOOL releaseBusAfterTransfer,
540 DWORD timeoutMs,
541 DWORD* pBytesActuallyTransferred );
542
543 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
544 CP213x_TransferReadAsync ( CP213x_DEVICE hDevice,
545 DWORD totalSize,
546 DWORD blockSize,
547 BOOL releaseBusAfterTransfer );
548
549 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
550 CP213x_TransferReadSync ( CP213x_DEVICE hDevice,
551 BYTE pReadBuf[],
552 DWORD length,
553 BOOL releaseBusAfterTransfer,
554 DWORD timeoutMs,
555 DWORD* pBytesActuallyRead );
556
557 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
558 CP213x_TransferReadRtrAsync ( CP213x_DEVICE hDevice,
559 DWORD totalSize,
560 DWORD blockSize,
561 BOOL releaseBusAfterTransfer );
562
563 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
564 CP213x_TransferReadRtrSync ( CP213x_DEVICE hDevice,
565 BYTE pReadBuf[],
566 DWORD totalSize,
567 DWORD blockSize,
568 BOOL releaseBusAfterTransfer,
569 DWORD timeoutMs,
570 DWORD* pBytesActuallyRead );
571
572 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
573 CP213x_GetRtrState ( CP213x_DEVICE hDevice, BYTE* isStopped );
574
575 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
576 CP213x_SetRtrStop ( CP213x_DEVICE hDevice, BYTE stopRtr );
577
578 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
579 CP213x_ReadPoll ( CP213x_DEVICE hDevice,
580 BYTE pReadBuf[],
581 DWORD maxLength,
582 DWORD* pBytesActuallyRead );
583
584 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
585 CP213x_ReadAbort ( CP213x_DEVICE hDevice );
586
587 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
588 CP213x_AbortInputPipe ( CP213x_DEVICE hDevice );
589
590 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
591 CP213x_FlushInputPipe ( CP213x_DEVICE hDevice );
592
593 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
594 CP213x_AbortOutputPipe ( CP213x_DEVICE hDevice );
595
596 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
597 CP213x_FlushOutputPipe ( CP213x_DEVICE hDevice );
598
599 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
600 CP213x_GetFifoFullThreshold ( CP213x_DEVICE hDevice, BYTE* pFifoFullThreshold );
601
602 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
603 CP213x_SetFifoFullThreshold ( CP213x_DEVICE hDevice, BYTE fifoFullThreshold );
604
606
607 //
608 // CP2130 GPIO and Auxiliary-Function Pins
609 //
612
613 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
614 CP213x_GetGpioModeAndLevel ( CP213x_DEVICE hDevice, BYTE channel, BYTE* mode, BYTE* level );
615
616 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
617 CP213x_SetGpioModeAndLevel ( CP213x_DEVICE hDevice, BYTE channel, BYTE mode, BYTE level );
618
619 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
620 CP213x_GetGpioValues ( CP213x_DEVICE hDevice, WORD* gpioValues );
621
622 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
623 CP213x_SetGpioValues ( CP213x_DEVICE hDevice, WORD mask, WORD gpioValues );
624
625 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
626 CP213x_GetEventCounter ( CP213x_DEVICE hDevice, BYTE* mode, WORD* eventCount );
627
628 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
629 CP213x_SetEventCounter ( CP213x_DEVICE hDevice, BYTE mode, WORD eventCount );
630
631 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
632 CP213x_GetClockDivider ( CP213x_DEVICE hDevice, BYTE* clockDivider );
633
634 SLAB_USB_SPI_API USB_SPI_STATUS WINAPI
635 CP213x_SetClockDivider ( CP213x_DEVICE hDevice, BYTE clockDivider );
636
638
639 #ifdef __cplusplus
640 }
641 #endif // __cplusplus
642
643 #endif // SLAB_USB_SPI_H
644
646 // End of file
CP213x_GetLibraryVersion
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetLibraryVersion(BYTE *pMajor, BYTE *pMinor, BOOL *pIsRelease)
Get the Interface Library version numbers.
Definition: SLAB_USB_SPI.cpp:139
CP213x_GetLock
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetLock(CP213x_DEVICE hDevice, WORD *lockValue)
Get the Lock values.
Definition: SLAB_USB_SPI.cpp:2628
SPI_CMD
struct SPI_CMD SPI_CMD
SPI Command Word.
CP213x_SetFifoFullThreshold
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetFifoFullThreshold(CP213x_DEVICE hDevice, BYTE fifoFullThreshold)
Set the FIFO full threshold.
Definition: SLAB_USB_SPI.cpp:1065
CP213x_ReadPoll
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_ReadPoll(CP213x_DEVICE hDevice, BYTE pReadBuf[], DWORD maxLength, DWORD *pBytesActuallyRead)
Read bytes received during an asynchronous Read or ReadRTR operation.
Definition: SLAB_USB_SPI.cpp:2487
CP213x_GetGpioModeAndLevel
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetGpioModeAndLevel(CP213x_DEVICE hDevice, BYTE channel, BYTE *mode, BYTE *level)
Get the GPIO mode control.
Definition: SLAB_USB_SPI.cpp:1245
CP213x_FlushInputPipe
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_FlushInputPipe(CP213x_DEVICE hDevice)
Flush USB input pipe.
Definition: SLAB_USB_SPI.cpp:690
CP213x_OpenByIndex
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_OpenByIndex(DWORD deviceIndex, CP213x_DEVICE *device)
Opens a USB device using a device index and returns a device object pointer which will be used for su...
Definition: SLAB_USB_SPI.cpp:405
CP213x_GetStringDescriptor
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetStringDescriptor(CP213x_DEVICE hDevice, BYTE index, BYTE stringDescriptor[STRING_DESCRIPTOR_SIZE])
Get specified string descriptor.
Definition: SLAB_USB_SPI.cpp:628
CP213x_SetLock
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetLock(CP213x_DEVICE hDevice, WORD lockValue)
Set the Lock values.
Definition: SLAB_USB_SPI.cpp:2594
CP213x_TransferReadSync
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_TransferReadSync(CP213x_DEVICE hDevice, BYTE pReadBuf[], DWORD length, BOOL releaseBusAfterTransfer, DWORD timeoutMs, DWORD *pBytesActuallyRead)
Perform SPI Read (synchronous)
Definition: SLAB_USB_SPI.cpp:1765
CP213x_SetSpiDelay
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetSpiDelay(CP213x_DEVICE hDevice, BYTE channel, BYTE delayMode, WORD interByteDelay, WORD postAssertDelay, WORD preDeassertDelay)
Set the SPI delay values.
Definition: SLAB_USB_SPI.cpp:968
CP213x_SetProductString
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetProductString(CP213x_DEVICE hDevice, LPCSTR productString, BYTE strlen)
Set the USB device Product string.
Definition: SLAB_USB_SPI.cpp:2821
CP213x_Close
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_Close(CP213x_DEVICE hDevice)
Close device handle.
Definition: SLAB_USB_SPI.cpp:521
CP213x_GetSpiControlBytes
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetSpiControlBytes(CP213x_DEVICE hDevice, BYTE controlBytes[CP213x_NUM_GPIO])
Get the SPI control word.
Definition: SLAB_USB_SPI.cpp:930
CP213x_SetUsbConfig
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetUsbConfig(CP213x_DEVICE hDevice, WORD vid, WORD pid, BYTE power, BYTE powerMode, WORD releaseVersion, BYTE transferPriority, BYTE mask)
Set the USB device Configuration info.
Definition: SLAB_USB_SPI.cpp:2668
CP213x_SetGuid
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetGuid(LPGUID pDevGuid)
Set the GUID used for device managment.
Definition: SLAB_USB_SPI.cpp:179
CP213x_OpenByDevicePath
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_OpenByDevicePath(LPCSTR devicePath, CP213x_DEVICE *phDevice)
Open device using specified Device Path.
Definition: SLAB_USB_SPI.cpp:465
CP213x_ReadAbort
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_ReadAbort(CP213x_DEVICE hDevice)
Abort an asynchronous Read or ReadRTR operation.
Definition: SLAB_USB_SPI.cpp:2558
CP213x_GetRtrState
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetRtrState(CP213x_DEVICE hDevice, BYTE *inRtrMode)
Read status of RTR operation.
Definition: SLAB_USB_SPI.cpp:826
CP213x_SetSerialString
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetSerialString(CP213x_DEVICE hDevice, LPCSTR serialString, BYTE strlen)
Set the USB device Serial Number string.
Definition: SLAB_USB_SPI.cpp:2897
CP213x_WriteProm
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_WriteProm(CP213x_DEVICE hDevice, BYTE pWbuffer[])
Write device EPROM configuration.
Definition: SLAB_USB_SPI.cpp:3054
CP213x_GetManufacturingString
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetManufacturingString(CP213x_DEVICE hDevice, LPSTR manufacturingString, BYTE *strlen)
Get the USB device Manufacturer string.
Definition: SLAB_USB_SPI.cpp:2754
CP213x_GetEventCounter
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetEventCounter(CP213x_DEVICE hDevice, BYTE *mode, WORD *count)
Get the Event Count value.
Definition: SLAB_USB_SPI.cpp:1415
CP213x_TransferReadRtrSync
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_TransferReadRtrSync(CP213x_DEVICE hDevice, BYTE pReadBuf[], DWORD totalSize, DWORD blockSize, BOOL releaseBusAfterTransfer, DWORD timeoutMs, DWORD *pBytesActuallyRead)
Perform SPI Read with RTR (synchronous)
Definition: SLAB_USB_SPI.cpp:2189
CP213x_GetChipSelect
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetChipSelect(CP213x_DEVICE hDevice, WORD *channelCsEnable, WORD *pinCsEnable)
Get SPI chip select control word.
Definition: SLAB_USB_SPI.cpp:1165
CP213x_GetSpiDelay
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetSpiDelay(CP213x_DEVICE hDevice, BYTE channel, BYTE *delayMode, WORD *interByteDelay, WORD *postAssertDelay, WORD *preDeassertDelay)
Get the SPI delay values.
Definition: SLAB_USB_SPI.cpp:1016
CP213x_TransferWrite
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_TransferWrite(CP213x_DEVICE hDevice, BYTE pWriteBuf[], DWORD length, BOOL releaseBusAfterTransfer, DWORD timeoutMs, DWORD *pBytesActuallyWritten)
Perform SPI Write.
Definition: SLAB_USB_SPI.cpp:1682
CP213x_SetChipSelect
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetChipSelect(CP213x_DEVICE hDevice, BYTE channel, BYTE mode)
Set SPI chip select control word.
Definition: SLAB_USB_SPI.cpp:1131
CP213x_GetNumDevices
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetNumDevices(DWORD *numDevices)
Definition: SLAB_USB_SPI.cpp:221
CP213x_SetEventCounter
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetEventCounter(CP213x_DEVICE hDevice, BYTE mode, WORD count)
Set the Event Count value.
Definition: SLAB_USB_SPI.cpp:1380
CP213x_SetRtrStop
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetRtrStop(CP213x_DEVICE hDevice, BYTE stopRtr)
Stop &#39;Read with RTR&#39; operation.
Definition: SLAB_USB_SPI.cpp:795
CP213x_SetManufacturingString
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetManufacturingString(CP213x_DEVICE hDevice, LPCSTR manufacturingString, BYTE strlen)
Set the USB device Manufacturer string.
Definition: SLAB_USB_SPI.cpp:2776
DEVICE_DESCRIPTOR
This struct has the same format as _USB_DEVICE_DESCRIPTOR, as defined in Windows usb100.h.
Definition: SLAB_USB_SPI.h:326
CP213x_GetDeviceVersion
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetDeviceVersion(CP213x_DEVICE hDevice, BYTE *majorVersion, BYTE *minorVersion)
Get the read-only device version.
Definition: SLAB_USB_SPI.cpp:861
CP213x_SetGpioValues
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetGpioValues(CP213x_DEVICE hDevice, WORD mask, WORD gpioValues)
Set the GPIO values.
Definition: SLAB_USB_SPI.cpp:1287
CP213x_GetGpioValues
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetGpioValues(CP213x_DEVICE hDevice, WORD *gpioValues)
Get the GPIO values.
Definition: SLAB_USB_SPI.cpp:1335
CP213x_GetSerialString
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetSerialString(CP213x_DEVICE hDevice, LPSTR serialString, BYTE *strlen)
Get the USB device Serial Number string.
Definition: SLAB_USB_SPI.cpp:2844
CP213x_GetUsbConfig
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetUsbConfig(CP213x_DEVICE hDevice, WORD *vid, WORD *pid, BYTE *power, BYTE *powerMode, WORD *releaseVersion, BYTE *transferPriority)
Get the USB Device Configuration info.
Definition: SLAB_USB_SPI.cpp:2714
CP213x_SetPinConfig
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetPinConfig(CP213x_DEVICE hDevice, BYTE pinConfig[SIZE_PIN_CONFIG])
Set the USB device Pin Configuration info.
Definition: SLAB_USB_SPI.cpp:2977
CP213x_AbortInputPipe
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_AbortInputPipe(CP213x_DEVICE hDevice)
Abort USB input pipe.
Definition: SLAB_USB_SPI.cpp:667
CP213x_TransferReadAsync
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_TransferReadAsync(CP213x_DEVICE hDevice, DWORD totalSize, DWORD blockSize, BOOL releaseBusAfterTransfer)
Perform SPI Read (asynchronous)
Definition: SLAB_USB_SPI.cpp:2406
CP213x_TransferWriteRead
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_TransferWriteRead(CP213x_DEVICE hDevice, BYTE pWriteBuf[], BYTE pReadBuf[], DWORD length, BOOL releaseBusAfterTransfer, DWORD timeoutMs, DWORD *pBytesActuallyTransferred)
Perform SPI Write/Read (synchronous)
Definition: SLAB_USB_SPI.cpp:1944
CP213x_GetFifoFullThreshold
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetFifoFullThreshold(CP213x_DEVICE hDevice, BYTE *pFifoFullThreshold)
Get the FIFO full threshold value.
Definition: SLAB_USB_SPI.cpp:1096
CP213x_TransferReadRtrAsync
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_TransferReadRtrAsync(CP213x_DEVICE hDevice, DWORD totalSize, DWORD blockSize, BOOL releaseBusAfterTransfer)
Perform SPI Read with RTR (asynchronous)
Definition: SLAB_USB_SPI.cpp:2304
CP213x_GetProductString
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetProductString(CP213x_DEVICE hDevice, LPSTR productString, BYTE *strlen)
Get the USB device Product string.
Definition: SLAB_USB_SPI.cpp:2799
CP213x_SetGpioModeAndLevel
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetGpioModeAndLevel(CP213x_DEVICE hDevice, BYTE index, BYTE mode, BYTE level)
Set the GPIO mode control.
Definition: SLAB_USB_SPI.cpp:1201
CP213x_AbortOutputPipe
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_AbortOutputPipe(CP213x_DEVICE hDevice)
Abort USB output pipe.
Definition: SLAB_USB_SPI.cpp:713
SPI_CMD
SPI Command Word.
Definition: SLAB_USB_SPI.h:345
CP213x_GetGuid
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetGuid(LPGUID pDevGuid)
Return the GUID used for device managment.
Definition: SLAB_USB_SPI.cpp:157
CP213x_GetDeviceDescriptor
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetDeviceDescriptor(CP213x_DEVICE hDevice, PDEVICE_DESCRIPTOR pDescriptor)
Get specified device descriptor.
Definition: SLAB_USB_SPI.cpp:585
CP213x_SetClockDivider
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetClockDivider(CP213x_DEVICE hDevice, BYTE clockDivider)
Set clock divider.
Definition: SLAB_USB_SPI.cpp:1449
DEVICE_DESCRIPTOR
struct DEVICE_DESCRIPTOR DEVICE_DESCRIPTOR
This struct has the same format as _USB_DEVICE_DESCRIPTOR, as defined in Windows usb100.h.
CP213x_ReadProm
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_ReadProm(CP213x_DEVICE hDevice, BYTE pRbuffer[])
Read device EPROM configuration.
Definition: SLAB_USB_SPI.cpp:3009
CP213x_FlushOutputPipe
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_FlushOutputPipe(CP213x_DEVICE hDevice)
Flush USB output pipe.
Definition: SLAB_USB_SPI.cpp:737
CP213x_SetSpiControlByte
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetSpiControlByte(CP213x_DEVICE hDevice, BYTE channel, BYTE controlByte)
Set the SPI control word.
Definition: SLAB_USB_SPI.cpp:897
CP213x_Reset
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_Reset(CP213x_DEVICE hDevice)
Reset device.
Definition: SLAB_USB_SPI.cpp:765
CP213x_GetPinConfig
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetPinConfig(CP213x_DEVICE hDevice, BYTE *pinConfig)
Get the USB device Pin Configuration info.
Definition: SLAB_USB_SPI.cpp:2940
CP213x_GetClockDivider
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetClockDivider(CP213x_DEVICE hDevice, BYTE *pClockDivider)
Get clock divider.
Definition: SLAB_USB_SPI.cpp:1480