image/svg+xml
Brteve's API for EveApps
Version 0.0.1
The reference document for common folder of EveApps project.
 
Loading...
Searching...
No Matches
EVE_HalImpl_FT4222.c
Go to the documentation of this file.
1
32#include "EVE_HalImpl.h"
33#include "EVE_Platform.h"
34#if defined(FT4222_PLATFORM)
35
36#if defined(EVE_MULTI_PLATFORM_TARGET)
37#define EVE_HalImpl_initialize EVE_HalImpl_FT4222_initialize
38#define EVE_HalImpl_release EVE_HalImpl_FT4222_release
39#define EVE_Hal_list EVE_Hal_FT4222_list
40#define EVE_Hal_info EVE_Hal_FT4222_info
41#define EVE_Hal_isDevice EVE_Hal_FT4222_isDevice
42#define EVE_HalImpl_defaults EVE_HalImpl_FT4222_defaults
43#define EVE_HalImpl_open EVE_HalImpl_FT4222_open
44#define EVE_HalImpl_close EVE_HalImpl_FT4222_close
45#define EVE_HalImpl_idle EVE_HalImpl_FT4222_idle
46#define EVE_Hal_flush EVE_Hal_FT4222_flush
47#define EVE_Hal_startTransfer EVE_Hal_FT4222_startTransfer
48#define EVE_Hal_endTransfer EVE_Hal_FT4222_endTransfer
49#define EVE_Hal_transfer8 EVE_Hal_FT4222_transfer8
50#define EVE_Hal_transfer16 EVE_Hal_FT4222_transfer16
51#define EVE_Hal_transfer32 EVE_Hal_FT4222_transfer32
52#define EVE_Hal_transferMem EVE_Hal_FT4222_transferMem
53#define EVE_Hal_transferProgMem EVE_Hal_FT4222_transferProgMem
54#define EVE_Hal_transferString EVE_Hal_FT4222_transferString
55#define EVE_Hal_hostCommand EVE_Hal_FT4222_hostCommand
56#define EVE_Hal_hostCommandExt3 EVE_Hal_FT4222_hostCommandExt3
57#define EVE_Hal_powerCycle EVE_Hal_FT4222_powerCycle
58#define EVE_UtilImpl_bootupDisplayGpio EVE_UtilImpl_FT4222_bootupDisplayGpio
59#define EVE_Hal_setSPI EVE_Hal_FT4222_setSPI
60#define EVE_Hal_restoreSPI EVE_Hal_FT4222_restoreSPI
61#endif
62
63#define FT4222_TRANSFER_SIZE_MAX (0xFFFF)
64#define FT4222_WRITE_HEADER_SIZE (3)
65#define FT4222_WRITE_SIZE_MAX (FT4222_TRANSFER_SIZE_MAX - FT4222_WRITE_HEADER_SIZE)
66
67#define FT4222_READ_TIMEOUT (5000)
68#define FT4222_WRITE_TIMEOUT (5000)
69
70#define FT4222_LATENCY_TIME (2)
71
72DWORD s_NumDevsD2XX;
73
76
81{
82#if 0
84 FT_STATUS status;
85 uint32_t numdevs;
86
87 status = FT_CreateDeviceInfoList(&numdevs);
88 if (FT_OK == status)
89 {
90 eve_printf_debug("Number of D2xx devices connected = %d\n", numdevs);
91 // TODO: g_HalPlatform.TotalDevices = numdevs;
92
93 FT_GetDeviceInfoDetail(0, &devList.Flags, &devList.Type, &devList.ID,
94 &devList.LocId,
95 devList.SerialNumber,
96 devList.Description,
97 &devList.ftHandle);
98 }
99 else
100 {
101 eve_printf_debug("FT_CreateDeviceInfoList failed");
102 return;
103 }
104
105 eve_printf_debug("Information on channel number %d:\n", 0);
106 /* print the dev info */
107 eve_printf_debug(" Flags=0x%x\n", devList.Flags);
108 eve_printf_debug(" Type=0x%x\n", devList.Host);
109 eve_printf_debug(" ID=0x%x\n", devList.ID);
110 eve_printf_debug(" LocId=0x%x\n", devList.LocId);
111 eve_printf_debug(" SerialNumber=%s\n", devList.SerialNumber);
112 eve_printf_debug(" Description=%s\n", devList.Description);
113 eve_printf_debug(" ftHandle=0x%p\n", devList.ftHandle); /*is 0 unless open*/
114#endif
115}
116
122{
123 /* no-op */
124}
125
130size_t EVE_Hal_list()
131{
132 s_NumDevsD2XX = 0;
133 FT_CreateDeviceInfoList(&s_NumDevsD2XX);
134 return s_NumDevsD2XX;
135}
136
143void EVE_Hal_info(EVE_DeviceInfo *deviceInfo, size_t deviceIdx)
144{
145 FT_DEVICE_LIST_INFO_NODE devInfo = { 0 };
146
147 memset(deviceInfo, 0, sizeof(EVE_DeviceInfo));
148 if (deviceIdx >= s_NumDevsD2XX)
149 return;
150
151 if (FT_GetDeviceInfoDetail((DWORD)deviceIdx,
152 &devInfo.Flags, &devInfo.Type, &devInfo.ID, &devInfo.LocId,
153 devInfo.SerialNumber, devInfo.Description, &devInfo.ftHandle)
154 != FT_OK)
155 return;
156
157 strcpy_s(deviceInfo->SerialNumber, sizeof(deviceInfo->SerialNumber), devInfo.SerialNumber);
158 strcpy_s(deviceInfo->DisplayName, sizeof(deviceInfo->DisplayName), devInfo.Description);
159 if (!strcmp(devInfo.Description, "FT4222 A"))
160 deviceInfo->Host = EVE_HOST_FT4222;
161 deviceInfo->Opened = devInfo.Flags & FT_FLAGS_OPENED;
162}
163
172bool EVE_Hal_isDevice(EVE_HalContext *phost, size_t deviceIdx)
173{
174 FT_DEVICE_LIST_INFO_NODE devInfo = { 0 };
175
176 if (!phost)
177 return false;
178 if (EVE_HOST != EVE_HOST_FT4222)
179 return false;
180 if (deviceIdx >= s_NumDevsD2XX)
181 return false;
182
183 if (!phost->SpiHandle)
184 return false;
185
186 if (FT_GetDeviceInfoDetail((DWORD)deviceIdx,
187 &devInfo.Flags, &devInfo.Type, &devInfo.ID, &devInfo.LocId,
188 devInfo.SerialNumber, devInfo.Description, &devInfo.ftHandle)
189 != FT_OK)
190 return false;
191
192 return phost->SpiHandle == devInfo.ftHandle;
193}
194
203bool EVE_HalImpl_defaults(EVE_HalParameters *parameters, size_t deviceIdx)
204{
205 bool res = deviceIdx >= 0 && deviceIdx < s_NumDevsD2XX;
206 if (!res)
207 {
208 uint32_t i;
209
210 if (!s_NumDevsD2XX)
211 EVE_Hal_list();
212
213 // Select first open device
214 deviceIdx = 0;
215 for (i = 0; i < s_NumDevsD2XX; ++i)
216 {
219 &devInfo.Flags, &devInfo.Type, &devInfo.ID, &devInfo.LocId,
220 devInfo.SerialNumber, devInfo.Description, &devInfo.ftHandle)
221 != FT_OK)
222 continue;
223 if ((!(devInfo.Flags & FT_FLAGS_OPENED)) && (!strcmp(devInfo.Description, "FT4222 A")))
224 {
225 deviceIdx = i;
226 res = true;
227 break;
228 }
229 }
230 }
231
232 parameters->DeviceIdx = (uint32_t)deviceIdx;
233 parameters->PowerDownPin = GPIO_PORT0;
234 parameters->SpiCsPin = 1;
235 parameters->SpiClockrateKHz = 12000;
236 return res;
237}
238
290bool computeCLK(EVE_HalContext *phost, FT4222_ClockRate *sysclk, FT4222_SPIClock *sysdivisor, const EVE_HalParameters *parameters)
291{
292 /* phost->Parameters.SpiClockrateKHz is the user requested SPI communication clock */
293
294 if (parameters->SpiClockrateKHz <= 5000)
295 {
296 /* set to 5000 KHz */
297 *sysclk = SYS_CLK_80;
298 *sysdivisor = CLK_DIV_16;
299 phost->SpiClockrateKHz = 5000;
300 }
301 else if (parameters->SpiClockrateKHz <= 10000)
302 {
303 /* set to 10000 KHz */
304 *sysclk = SYS_CLK_80;
305 *sysdivisor = CLK_DIV_8;
306 phost->SpiClockrateKHz = 10000;
307 }
308 else if (parameters->SpiClockrateKHz <= 15000)
309 {
310 /* This is the default */
311 /* set to 15000 KHz */
312 *sysclk = SYS_CLK_60;
313 *sysdivisor = CLK_DIV_4;
314 phost->SpiClockrateKHz = 15000;
315 }
316 else if (parameters->SpiClockrateKHz <= 20000)
317 {
318 /* set to 20000 KHz */
319 *sysclk = SYS_CLK_80;
320 *sysdivisor = CLK_DIV_4;
321 phost->SpiClockrateKHz = 20000;
322 }
323 else
324 {
325 /* 30MHz with Quad SPI seems to work reliably on BT816 */
326 /* set to 30000 KHz */
327 *sysclk = SYS_CLK_60;
328 *sysdivisor = CLK_DIV_2;
329 phost->SpiClockrateKHz = 30000;
330 }
331 eve_printf_debug("User Selected SPI clk : %d KHz\n", (int)parameters->SpiClockrateKHz);
332 eve_printf_debug("Configured clk : %d KHz, Ft4222 sys clk enum = %d , divisor enum = %d\n", (int)phost->SpiClockrateKHz, *sysclk, *sysdivisor);
333 return true;
334}
335
344bool EVE_HalImpl_open(EVE_HalContext *phost, const EVE_HalParameters *parameters)
345{
346 FT_STATUS status;
347 FT4222_Version pversion;
348 FT4222_ClockRate ftclk = 0;
349 FT4222_ClockRate selclk = 0;
350 FT4222_SPIClock seldiv = 0;
351 /* GPIO0 , GPIO1 , GPIO2 , GPIO3 } */
353
354 DWORD deviceIdxA = parameters->DeviceIdx;
356 DWORD deviceIdxB;
358
359 bool ret = true;
360
361 phost->SpiHandle = phost->GpioHandle = NULL;
362
363#ifdef EVE_MULTI_GRAPHICS_TARGET
364 phost->GpuDefs = &EVE_GpuDefs_FT80X;
365#endif
366
367 memset(&devInfoA, 0, sizeof(devInfoA));
368 status = FT_GetDeviceInfoDetail(deviceIdxA,
369 &devInfoA.Flags, &devInfoA.Type, &devInfoA.ID, &devInfoA.LocId,
370 devInfoA.SerialNumber, devInfoA.Description, &devInfoA.ftHandle);
371 if (status != FT_OK)
372 {
373 eve_printf_debug("FT_GetDeviceInfoDetail failed\n");
374 ret = false;
375 }
376 if (devInfoA.Flags & FT_FLAGS_OPENED)
377 {
378 eve_printf_debug("Device FT4222 A already opened\n");
379 ret = false;
380 }
381 eve_printf_debug("FT4222 open '%s'\n", devInfoA.Description);
382
383 if (ret)
384 {
385 for (deviceIdxB = deviceIdxA + 1; deviceIdxB < s_NumDevsD2XX; ++deviceIdxB)
386 {
387 memset(&devInfoB, 0, sizeof(devInfoB));
388 status = FT_GetDeviceInfoDetail(deviceIdxB,
389 &devInfoB.Flags, &devInfoB.Type, &devInfoB.ID, &devInfoB.LocId,
390 devInfoB.SerialNumber, devInfoB.Description, &devInfoB.ftHandle);
391 if (status != FT_OK)
392 continue;
393 if (!strcmp(devInfoB.Description, "FT4222 B"))
394 break;
395 }
396 if (deviceIdxB >= s_NumDevsD2XX)
397 {
398 eve_printf_debug("FT4222 B not found\n");
399 ret = false;
400 }
401 else if (devInfoB.Flags & FT_FLAGS_OPENED)
402 {
403 eve_printf_debug("Device FT4222 B already opened\n");
404 ret = false;
405 }
406 }
407
408 if (ret)
409 {
410 status = FT_Open(deviceIdxA, &phost->SpiHandle);
411 if (status != FT_OK)
412 {
413 eve_printf_debug("FT_Open FT4222 A failed %d\n", (int)status);
414 phost->SpiHandle = NULL;
415 ret = false;
416 }
417 }
418
419 if (ret)
420 {
421 status = FT_Open(deviceIdxB, &phost->GpioHandle);
422 if (status != FT_OK)
423 {
424 eve_printf_debug("FT_Open FT4222 B failed %d\n", (int)status);
425 FT_Close(phost->SpiHandle);
426 phost->GpioHandle = NULL;
427 phost->SpiHandle = NULL;
428 ret = false;
429 }
430 }
431
432 if (ret)
433 {
434 status = FT4222_GetVersion(phost->SpiHandle, &pversion);
435 if (status != FT4222_OK)
436 eve_printf_debug("FT4222_GetVersion failed\n");
437 else
438 eve_printf_debug("SPI:chipversion = 0x%x\t dllversion = 0x%x\n", (unsigned int)pversion.chipVersion, (unsigned int)pversion.dllVersion);
439 }
440
441 if (ret)
442 {
443 //Set default Read timeout 5s and Write timeout 5sec
444 status = FT_SetTimeouts(phost->SpiHandle, FT4222_READ_TIMEOUT, FT4222_WRITE_TIMEOUT);
445 if (status != FT_OK)
446 {
447 eve_printf_debug("FT_SetTimeouts failed!\n");
448 ret = false;
449 }
450 }
451
452 if (ret)
453 {
454 // no latency to usb
455 status = FT_SetLatencyTimer(phost->SpiHandle, FT4222_LATENCY_TIME);
456 if (status != FT_OK)
457 {
458 eve_printf_debug("FT_SetLatencyTimerfailed!\n");
459 ret = false;
460 }
461 }
462
463 if (ret)
464 {
465 if (!computeCLK(phost, &selclk, &seldiv, parameters))
466 {
467 eve_printf_debug("Requested clock %d KHz is not supported in FT4222\n", parameters->SpiClockrateKHz);
468 ret = false;
469 }
470 }
471
472 if (ret)
473 {
474 status = FT4222_SetClock(phost->SpiHandle, selclk);
475 if (status != FT4222_OK)
476 {
477 eve_printf_debug("FT4222_SetClock failed!\n");
478 ret = false;
479 }
480
481 status = FT4222_GetClock(phost->SpiHandle, &ftclk);
482
483 if (status != FT4222_OK)
484 eve_printf_debug("FT4222_SetClock failed\n");
485 else
486 eve_printf_debug("FT4222 clk = %d\n", ftclk);
487 }
488
489 if (ret)
490 {
491 /* Interface 1 is SPI master */
492 status = FT4222_SPIMaster_Init(
493 phost->SpiHandle,
495 seldiv,
496 CLK_IDLE_LOW, //,CLK_IDLE_HIGH
497 CLK_LEADING, // CLK_LEADING CLK_TRAILING
498 parameters->SpiCsPin); /* slave selection output pins */
499 if (status != FT4222_OK)
500 {
501 eve_printf_debug("Init FT4222 as SPI master device failed!\n");
502 ret = false;
503 }
504 phost->SpiCsPin = parameters->SpiCsPin;
505 phost->PowerDownPin = parameters->PowerDownPin;
506
507 status = FT4222_SPI_SetDrivingStrength(phost->SpiHandle, DS_4MA, DS_4MA, DS_4MA);
508 if (status != FT4222_OK)
509 {
510 eve_printf_debug("FT4222_SPI_SetDrivingStrength failed!\n");
511 }
512
513 EVE_sleep(20);
514
515 status = FT4222_SetSuspendOut(phost->GpioHandle, false);
516 if (status != FT4222_OK)
517 {
518 eve_printf_debug("Disable suspend out function on GPIO2 failed!\n");
519 ret = false;
520 }
521
522 status = FT4222_SetWakeUpInterrupt(phost->GpioHandle, false);
523 if (status != FT4222_OK)
524 {
525 eve_printf_debug("Disable wakeup/interrupt feature on GPIO3 failed!\n");
526 ret = false;
527 }
528 /* Interface 2 is GPIO */
529 status = FT4222_GPIO_Init(phost->GpioHandle, gpio_dir);
530 if (status != FT4222_OK)
531 {
532 eve_printf_debug("Init FT4222 as GPIO interface failed!\n");
533 ret = false;
534 }
535 }
536
537 if (ret)
538 {
540 phost->SpiDummyBytes = 1;
541 phost->Status = EVE_STATUS_OPENED;
543 }
544
545 return ret;
546}
547
554{
555 FT4222_STATUS status;
556 phost->Status = EVE_STATUS_CLOSED;
558
559 if ((status = FT4222_UnInitialize(phost->SpiHandle)) != FT4222_OK)
560 eve_printf_debug("FT4222_UnInitialize failed %d\n", status);
561
562 if ((status = FT4222_UnInitialize(phost->GpioHandle)) != FT4222_OK)
563 eve_printf_debug("FT4222_UnInitialize failed %d\n", status);
564
565 if ((status = FT_Close(phost->SpiHandle)) != FT_OK)
566 eve_printf_debug("CLOSE failed %d\n", status);
567
568 if ((status = FT_Close(phost->GpioHandle)) != FT_OK)
569 eve_printf_debug("CLOSE failed %d\n", status);
570}
571
578{
579 /* no-op */
580}
582
583/*************
584** TRANSFER **
585*************/
586
589
590static bool flush(EVE_HalContext *phost);
591
600static inline uint32_t incrementRamGAddr(EVE_HalContext *phost, uint32_t addr, uint32_t inc)
601{
602 if (!EVE_Hal_supportCmdB(phost) || (addr != REG_CMDB_WRITE))
603 {
604 bool wrapCmdAddr = (addr >= RAM_CMD) && (addr < (RAM_CMD + EVE_CMD_FIFO_SIZE));
605 addr += inc;
606 if (wrapCmdAddr)
608 }
609 return addr;
610}
611
621static inline bool rdBuffer(EVE_HalContext *phost, uint8_t *buffer, uint32_t size)
622{
623 FT4222_STATUS status;
624
625 uint8_t hrdpkt[8] = { 0 }; // 3 byte addr + 2 or 1 byte dummy
626
627 while (size)
628 {
629 uint32_t sizeTransferred;
630 uint32_t bytesPerRead;
631 uint32_t addr = phost->SpiRamGAddr;
632
633 /* Compose the HOST MEMORY READ packet */
634 hrdpkt[0] = (uint8_t)(addr >> 16) & 0xFF;
635 hrdpkt[1] = (uint8_t)(addr >> 8) & 0xFF;
636 hrdpkt[2] = (uint8_t)(addr & 0xFF);
637
638 if (size <= FT4222_TRANSFER_SIZE_MAX)
639 bytesPerRead = size;
640 else
641 bytesPerRead = FT4222_TRANSFER_SIZE_MAX;
642
644 {
645 uint16_t sizeWritten;
646 uint16_t sizeRead;
647
649 phost->SpiHandle,
650 hrdpkt,
651 3 + phost->SpiDummyBytes, /* 3 address and chosen dummy bytes */
652 &sizeWritten,
653 FALSE);
654
655 if ((status != FT4222_OK) || (sizeWritten != (3 + phost->SpiDummyBytes)))
656 {
657 eve_printf_debug("FT4222_SPIMaster_SingleWrite failed, sizeTransferred is %d with status %d\n", sizeWritten, status);
658 if (sizeWritten != (3 + phost->SpiDummyBytes))
659 phost->Status = EVE_STATUS_ERROR;
660 return false;
661 }
662
664 phost->SpiHandle,
665 buffer,
666 bytesPerRead,
667 &sizeRead,
668 TRUE);
669
670 if ((status != FT4222_OK) || (sizeRead != bytesPerRead))
671 {
672 eve_printf_debug("FT4222_SPIMaster_SingleRead failed,sizeTransferred is %d with status %d\n", sizeRead, status);
673 if (sizeRead != bytesPerRead)
674 phost->Status = EVE_STATUS_ERROR;
675 return false;
676 }
677
678 sizeTransferred = sizeRead;
679 }
680 else
681 {
683 phost->SpiHandle,
684 (uint8 *)buffer,
685 hrdpkt,
686 0,
687 3 + phost->SpiDummyBytes, /* 3 addr + dummy bytes */
688 bytesPerRead,
689 &sizeTransferred);
690
691 if ((status != FT4222_OK) || (sizeTransferred != bytesPerRead))
692 {
693 eve_printf_debug("FT4222_SPIMaster_MultiReadWrite failed, sizeTransferred is %d with status %d\n", sizeTransferred, status);
694 if (sizeTransferred != bytesPerRead)
695 phost->Status = EVE_STATUS_ERROR;
696 return false;
697 }
698 }
699
700 buffer += sizeTransferred;
701 if (size)
702 {
703 eve_assert_ex(sizeTransferred <= size, "Cannot have transferred more than size\n");
704 size -= sizeTransferred;
705 }
706
707 if (!EVE_Hal_supportCmdB(phost) || (addr != REG_CMDB_WRITE))
708 {
709 bool wrapCmdAddr = (addr >= RAM_CMD) && (addr < (RAM_CMD + EVE_CMD_FIFO_SIZE));
710 addr += sizeTransferred;
711 if (wrapCmdAddr)
713 phost->SpiRamGAddr = addr;
714 }
715 }
716
717 return true;
718}
719
729static inline bool wrBuffer(EVE_HalContext *phost, const uint8_t *buffer, uint32_t size)
730{
731 FT4222_STATUS status;
732
733 if (buffer && (size < (sizeof(phost->SpiWrBuf) - phost->SpiWrBufIndex - FT4222_WRITE_HEADER_SIZE)))
734 {
735 /* Write to buffer */
736 memcpy(&phost->SpiWrBuf[phost->SpiWrBufIndex + FT4222_WRITE_HEADER_SIZE], buffer, size);
737 phost->SpiWrBufIndex += size;
738 return true;
739 }
740 else
741 {
742 if (buffer && phost->SpiWrBufIndex)
743 {
744 /* Buffer is over size, flush now */
745 if (!flush(phost))
746 return false;
747
748 /* Write to buffer */
749 if (size < (sizeof(phost->SpiWrBuf) - FT4222_WRITE_HEADER_SIZE))
750 return wrBuffer(phost, buffer, size);
751 }
752
753 if (buffer || phost->SpiWrBufIndex)
754 {
755 /* Flush now, or write oversize buffer */
756 uint32_t addr = phost->SpiRamGAddr;
757
758 if (!buffer)
759 {
760 /* Flushing */
761 size = phost->SpiWrBufIndex;
762 phost->SpiWrBufIndex = 0;
763 }
764
765 while (size)
766 {
767 uint32_t sizeTransferred;
768 uint32_t bytesPerWrite;
769
770 if (size <= FT4222_WRITE_SIZE_MAX)
771 bytesPerWrite = size + FT4222_WRITE_HEADER_SIZE;
772 else
773 bytesPerWrite = FT4222_TRANSFER_SIZE_MAX;
774
775 if (buffer)
776 {
777 /* Writing large buffer */
778 memcpy(phost->SpiWrBuf + FT4222_WRITE_HEADER_SIZE, buffer, (bytesPerWrite - FT4222_WRITE_HEADER_SIZE));
779 }
780
781 /* Compose the HOST MEMORY WRITE packet */
782 phost->SpiWrBuf[0] = (addr >> 16) | 0x80; /* MSB bits 10 for WRITE */
783 phost->SpiWrBuf[1] = (addr >> 8) & 0xFF;
784 phost->SpiWrBuf[2] = addr & 0xFF;
785
787 {
788 uint16_t sizeWritten;
789
791 phost->SpiHandle,
792 phost->SpiWrBuf,
793 bytesPerWrite,
794 &sizeWritten,
795 TRUE);
796
797 if ((status != FT4222_OK) || (sizeWritten != bytesPerWrite))
798 {
799 eve_printf_debug("%d FT4222_SPIMaster_SingleWrite failed, sizeTransferred is %d with status %d\n", __LINE__, sizeWritten, status);
800 if (sizeWritten != bytesPerWrite)
801 phost->Status = EVE_STATUS_ERROR;
802 return false;
803 }
804
805 sizeTransferred = sizeWritten;
806 }
807 else
808 {
809 uint8_t dummyRead[8];
810
812 phost->SpiHandle,
813 dummyRead,
814 phost->SpiWrBuf,
815 0,
816 bytesPerWrite,
817 0,
818 &sizeTransferred);
819
820 if (status != FT4222_OK)
821 {
822 eve_printf_debug("FT4222_SPIMaster_MultiReadWrite failed, status %d\n", status);
823 return false;
824 }
825
826 sizeTransferred = bytesPerWrite;
827 }
828
829 if (buffer)
830 {
831 buffer += sizeTransferred - FT4222_WRITE_HEADER_SIZE;
832 }
833 if (size)
834 {
835 eve_assert_ex((sizeTransferred - FT4222_WRITE_HEADER_SIZE) <= (int32_t)size, "Cannot have transferred more than size\n");
836 size -= sizeTransferred - FT4222_WRITE_HEADER_SIZE;
837 // eve_assert_ex(!(buffer && size), "Cannot have space left after flushing buffer\n");
838 }
839
840 addr = incrementRamGAddr(phost, addr, (sizeTransferred - FT4222_WRITE_HEADER_SIZE));
841 phost->SpiRamGAddr = addr;
842 }
843 }
844
845 return true;
846 }
847}
848
857{
859
860 if (!EVE_Hal_supportCmdB(phost) && addr == REG_CMD_WRITE && rw == EVE_TRANSFER_WRITE)
861 {
862 /* Bypass fifo write pointer write */
863#if !defined(EVE_SUPPORT_CMDB) || defined(EVE_MULTI_GRAPHICS_TARGET)
864 phost->SpiWpWriting = true;
865#else
866 eve_assert(false);
867#endif
868 }
869 else if (addr != incrementRamGAddr(phost, phost->SpiRamGAddr, phost->SpiWrBufIndex) || rw == EVE_TRANSFER_READ)
870 {
871 /* Close any write transfer that was left open, if the address changed */
872 flush(phost);
873 phost->SpiRamGAddr = addr;
874 }
875
876 if (phost->Status != EVE_STATUS_ERROR)
877 {
878 if (rw == EVE_TRANSFER_READ)
879 phost->Status = EVE_STATUS_READING;
880 else
881 phost->Status = EVE_STATUS_WRITING;
882 }
883}
884
891{
893
895
896 /* Transfers to FIFO and DL are kept open */
897 addr = phost->SpiRamGAddr;
899 && !((addr >= RAM_CMD) && (addr < (RAM_CMD + EVE_CMD_FIFO_SIZE)))
900 && !((addr >= RAM_DL) && (addr < (RAM_CMD + EVE_DL_SIZE))))
901 {
902 flush(phost);
903 }
904
905#if !defined(EVE_SUPPORT_CMDB) || defined(EVE_MULTI_GRAPHICS_TARGET)
906 if (!EVE_Hal_supportCmdB(phost))
907 {
908 phost->SpiWpWriting = false;
909 }
910#endif
911
912 if (phost->Status != EVE_STATUS_ERROR)
913 phost->Status = EVE_STATUS_OPENED;
914}
915
923static bool flush(EVE_HalContext *phost)
924{
925 bool res = true;
926 if (phost->SpiWrBufIndex)
927 {
928 res = wrBuffer(phost, NULL, 0);
929 }
930 eve_assert(!phost->SpiWrBufIndex);
931#if !defined(EVE_SUPPORT_CMDB) || defined(EVE_MULTI_GRAPHICS_TARGET)
932 if (!EVE_Hal_supportCmdB(phost))
933 {
934 if (phost->SpiWpWritten)
935 {
936 phost->SpiWpWritten = false;
937 phost->SpiRamGAddr = REG_CMD_WRITE;
938 phost->SpiWrBufIndex = 2;
939 phost->SpiWrBuf[FT4222_WRITE_HEADER_SIZE + 0] = phost->SpiWpWrite & 0xFF;
940 phost->SpiWrBuf[FT4222_WRITE_HEADER_SIZE + 1] = phost->SpiWpWrite >> 8;
941 res = wrBuffer(phost, NULL, 0);
942 }
943 eve_assert(!phost->SpiWrBufIndex);
944 }
945#endif
946 return res;
947}
948
954void EVE_Hal_flush(EVE_HalContext *phost)
955{
957 flush(phost);
958}
959
968{
969#if defined(EVE_BUFFER_WRITES)
970#if !defined(EVE_SUPPORT_CMDB) || defined(EVE_MULTI_GRAPHICS_TARGET)
971 if (!EVE_Hal_supportCmdB(phost))
972 {
973 eve_assert(!phost->SpiWpWriting);
974 }
975#endif
976#endif
977 if (phost->Status == EVE_STATUS_READING)
978 {
979 rdBuffer(phost, &value, 1);
980 return value;
981 }
982 else
983 {
984 wrBuffer(phost, &value, 1);
985 return 0;
986 }
987}
988
997{
998 uint8_t buffer[2];
999#if defined(EVE_BUFFER_WRITES)
1000#if !defined(EVE_SUPPORT_CMDB) || defined(EVE_MULTI_GRAPHICS_TARGET)
1001 if (!EVE_Hal_supportCmdB(phost))
1002 {
1003 if (phost->SpiWpWriting)
1004 {
1005 phost->SpiWpWrite = value;
1006 phost->SpiWpWritten = true;
1007 return 0;
1008 }
1009 }
1010#endif
1011#endif
1012 if (phost->Status == EVE_STATUS_READING)
1013 {
1014 rdBuffer(phost, buffer, 2);
1015 return (uint16_t)buffer[0]
1016 | (uint16_t)buffer[1] << 8;
1017 }
1018 else
1019 {
1020 buffer[0] = value & 0xFF;
1021 buffer[1] = value >> 8;
1022 wrBuffer(phost, buffer, 2);
1023 return 0;
1024 }
1025}
1026
1035{
1036 uint8_t buffer[4];
1037#if defined(EVE_BUFFER_WRITES)
1038#if !defined(EVE_SUPPORT_CMDB) || defined(EVE_MULTI_GRAPHICS_TARGET)
1039 if (!EVE_Hal_supportCmdB(phost))
1040 {
1041 eve_assert(!phost->SpiWpWriting);
1042 }
1043#endif
1044#endif
1045 if (phost->Status == EVE_STATUS_READING)
1046 {
1047 rdBuffer(phost, buffer, 4);
1048 return (uint32_t)buffer[0]
1049 | (uint32_t)buffer[1] << 8
1050 | (uint32_t)buffer[2] << 16
1051 | (uint32_t)buffer[3] << 24;
1052 }
1053 else
1054 {
1055 buffer[0] = value & 0xFF;
1056 buffer[1] = (value >> 8) & 0xFF;
1057 buffer[2] = (value >> 16) & 0xFF;
1058 buffer[3] = value >> 24;
1059 wrBuffer(phost, buffer, 4);
1060 return 0;
1061 }
1062}
1063
1072void EVE_Hal_transferMem(EVE_HalContext *phost, uint8_t *result, const uint8_t *buffer, uint32_t size)
1073{
1074 if (!size)
1075 return;
1076
1077#if defined(EVE_BUFFER_WRITES)
1078#if !defined(EVE_SUPPORT_CMDB) || defined(EVE_MULTI_GRAPHICS_TARGET)
1079 if (!EVE_Hal_supportCmdB(phost))
1080 {
1081 eve_assert(!phost->SpiWpWriting);
1082 }
1083#endif
1084#endif
1085
1086 if (result && buffer)
1087 {
1088 /* not implemented */
1090 }
1091 else if (result)
1092 {
1093 rdBuffer(phost, result, size);
1094 }
1095 else if (buffer)
1096 {
1097 wrBuffer(phost, buffer, size);
1098 }
1099}
1100
1110{
1111 if (!size)
1112 return;
1113
1114#if defined(EVE_BUFFER_WRITES)
1115#if !defined(EVE_SUPPORT_CMDB) || defined(EVE_MULTI_GRAPHICS_TARGET)
1116 if (!EVE_Hal_supportCmdB(phost))
1117 {
1118 eve_assert(!phost->SpiWpWriting);
1119 }
1120#endif
1121#endif
1122
1123 if (result && buffer)
1124 {
1125 /* not implemented */
1127 }
1128 else if (result)
1129 {
1130 rdBuffer(phost, result, size);
1131 }
1132 else if (buffer)
1133 {
1134 wrBuffer(phost, buffer, size);
1135 }
1136}
1137
1148uint32_t EVE_Hal_transferString(EVE_HalContext *phost, const char *str, uint32_t index, uint32_t size, uint32_t padMask)
1149{
1150 uint32_t transferred;
1151
1152 if (!size)
1153 {
1154 /* TODO: Support different padding options */
1155 eve_assert(padMask == 0x3);
1156 EVE_Hal_transfer32(phost, 0);
1157 return 4;
1158 }
1159
1160#if defined(EVE_BUFFER_WRITES)
1161#if !defined(EVE_SUPPORT_CMDB) || defined(EVE_MULTI_GRAPHICS_TARGET)
1162 if (!EVE_Hal_supportCmdB(phost))
1163 {
1164 eve_assert(!phost->SpiWpWriting);
1165 }
1166#endif
1167#endif
1169 transferred = 0;
1170 if (phost->Status == EVE_STATUS_WRITING)
1171 {
1173
1174 for (;;)
1175 {
1176 char c = str[index + (transferred)];
1177 buffer[transferred++] = c;
1178 // putchar(c ? c : '_');
1179 if (!c)
1180 {
1181 break;
1182 }
1183 if (transferred >= size)
1184 {
1185 buffer[transferred++] = 0;
1186 // putchar('_');
1187 break;
1188 }
1189 }
1190 while (transferred & padMask)
1191 {
1192 buffer[transferred++] = 0;
1193 // putchar('_');
1194 }
1195
1196 eve_assert(transferred);
1197
1198 wrBuffer(phost, buffer, transferred);
1199 }
1200 else
1201 {
1202 /* not implemented */
1204 }
1205 return transferred;
1206}
1208
1209/************
1210** UTILITY **
1211************/
1212
1215
1223{
1224 FT4222_STATUS status;
1225 uint8_t dummyRead;
1226
1227 uint8_t transferArray[3];
1228
1229 uint16_t sizeTransferred;
1230 uint32_t sizeOfRead;
1231
1232 flush(phost);
1233
1234 transferArray[0] = cmd;
1235 transferArray[1] = 0;
1236 transferArray[2] = 0;
1237
1238 switch (phost->SpiChannels)
1239 {
1241 /* FYI : All HOST CMDs should only be executed in single channel mode*/
1243 phost->SpiHandle,
1244 transferArray,
1245 sizeof(transferArray),
1246 &sizeTransferred,
1247 true);
1248 if (FT4222_OK != status)
1249 {
1250 eve_printf_debug("SPI write failed = %d\n", status);
1251 phost->Status = EVE_STATUS_ERROR;
1252 }
1253 break;
1256 /* only reset command among phost commands can be executed in multi channel mode*/
1258 phost->SpiHandle,
1259 &dummyRead,
1260 transferArray,
1261 0,
1262 sizeof(transferArray),
1263 0,
1264 &sizeOfRead);
1265 if (FT4222_OK != status)
1266 {
1267 eve_printf_debug("SPI write failed = %d\n", status);
1268 phost->Status = EVE_STATUS_ERROR;
1269 }
1270 break;
1271 default:
1272 eve_printf_debug("No transfer\n");
1273 }
1274}
1275
1283{
1284 FT4222_STATUS status;
1285 uint8_t dummyRead;
1286 uint8_t transferArray[3];
1287
1288 uint16_t sizeTransferred;
1289 uint32_t sizeOfRead;
1290
1291 flush(phost);
1292
1293 transferArray[0] = cmd;
1294 transferArray[1] = (cmd >> 8) & 0xff;
1295 transferArray[2] = (cmd >> 16) & 0xff;
1296
1297 switch (phost->SpiChannels)
1298 {
1301 phost->SpiHandle,
1302 transferArray,
1303 sizeof(transferArray),
1304 &sizeTransferred,
1305 true);
1306 if (FT4222_OK != status)
1307 {
1308 eve_printf_debug("SPI write failed = %d\n", status);
1309 phost->Status = EVE_STATUS_ERROR;
1310 }
1311 break;
1314 /* FYI : Mostly all HOST CMDs can be executed in single channel mode
1315 * except system reset cmd */
1317 phost->SpiHandle,
1318 &dummyRead,
1319 transferArray,
1320 0,
1321 sizeof(transferArray),
1322 0,
1323 &sizeOfRead);
1324 if (FT4222_OK != status)
1325 {
1326 eve_printf_debug("SPI write failed = %d\n", status);
1327 phost->Status = EVE_STATUS_ERROR;
1328 }
1329 break;
1330 default:
1331 eve_printf_debug("No transfer\n");
1332 }
1333}
1334
1342void setSPI(EVE_HalContext *phost, EVE_SPI_CHANNELS_T numchnls, uint8_t numdummy)
1343{
1344 FT4222_STATUS ftstatus;
1345 FT4222_SPIMode spimode;
1346
1347 flush(phost);
1348
1349 /* switch FT4222 to relevant multi channel SPI communication mode */
1350 if (numchnls == EVE_SPI_DUAL_CHANNEL)
1351 spimode = SPI_IO_DUAL;
1352 else if (numchnls == EVE_SPI_QUAD_CHANNEL)
1353 spimode = SPI_IO_QUAD;
1354 else
1355 spimode = SPI_IO_SINGLE;
1356
1357 ftstatus = FT4222_SPIMaster_SetLines(phost->SpiHandle, spimode);
1358 if (FT4222_OK != ftstatus)
1359 eve_printf_debug("FT4222_SPIMaster_SetLines failed with status %d\n", ftstatus);
1360
1361 /* FT81x swicthed to dual/quad mode, now update global HAL context */
1362 phost->SpiChannels = numchnls;
1363 phost->SpiDummyBytes = numdummy;
1364}
1365
1374bool EVE_Hal_powerCycle(EVE_HalContext *phost, bool up)
1375{
1376 bool res = true;
1377 flush(phost);
1378
1379 if (up)
1380 {
1382
1383 if (FT4222_OK != (status = FT4222_GPIO_Write(phost->GpioHandle, phost->PowerDownPin, 0)))
1384 {
1385 eve_printf_debug("FT4222_GPIO_Write error = %d\n", status);
1386 res = false;
1387 }
1388 EVE_sleep(20);
1389
1390 if (FT4222_OK != (status = FT4222_GPIO_Write(phost->GpioHandle, phost->PowerDownPin, 1)))
1391 {
1392 eve_printf_debug("FT4222_GPIO_Write error = %d\n", status);
1393 res = false;
1394 }
1395 EVE_sleep(20);
1396 }
1397 else
1398 {
1400
1401 if (FT4222_OK != (status = FT4222_GPIO_Write(phost->GpioHandle, phost->PowerDownPin, 1)))
1402 {
1403 eve_printf_debug("FT4222_GPIO_Write error = %d\n", status);
1404 res = false;
1405 }
1406 EVE_sleep(20);
1407
1408 if (FT4222_OK != (status = FT4222_GPIO_Write(phost->GpioHandle, phost->PowerDownPin, 0)))
1409 {
1410 eve_printf_debug("FT4222_GPIO_Write error = %d\n", status);
1411 res = false;
1412 }
1413 EVE_sleep(20);
1414 }
1415
1416 /* Reset to single channel SPI mode */
1417 setSPI(phost, EVE_SPI_SINGLE_CHANNEL, 1);
1418
1419 return res;
1420}
1421
1429void EVE_Hal_setSPI(EVE_HalContext *phost, EVE_SPI_CHANNELS_T numchnls, uint8_t numdummy)
1430{
1431 uint8_t writebyte;
1432
1433 flush(phost);
1434 if (EVE_CHIPID < EVE_FT810)
1435 return;
1436
1437 writebyte = 0;
1438
1439 if ((numchnls > EVE_SPI_QUAD_CHANNEL) || (numdummy > 2) || (numdummy < 1))
1440 return; // error
1441
1442 /* Switch EVE to multi channel SPI mode */
1443 writebyte = numchnls;
1444 if (numdummy == 2)
1445 writebyte |= EVE_SPI_TWO_DUMMY_BYTES;
1446 EVE_Hal_wr8(phost, REG_SPI_WIDTH, writebyte);
1447
1448 /* Switch FT4222 to multi channel SPI mode */
1449 setSPI(phost, numchnls, numdummy);
1450}
1451
1453{
1454 flush(phost);
1455 if (EVE_CHIPID < EVE_FT810)
1456 return;
1457
1458 setSPI(phost, phost->SpiChannels, phost->SpiDummyBytes);
1459}
1461
1462/*********
1463** MISC **
1464*********/
1465
1468
1476{
1477 /* no-op */
1478 return true;
1479}
1481
1482#endif /* #if defined(FT4222_PLATFORM) */
1483
1484/* end of file */
static uint32_t c
Definition Common.c:38
static uint32_t wrBuffer(EVE_HalContext *phost, const void *buffer, uint32_t size, bool progmem, bool string)
Write buffer to Coprocessor's comand fifo.
Definition EVE_Cmd.c:191
#define EVE_CMD_STRING_MAX
Definition EVE_Cmd.h:44
#define strcpy_s(dst, sz, src)
#define EVE_CHIPID
#define eve_progmem_const
#define EVE_FT810
Definition EVE_Config.h:58
#define RAM_CMD
#define REG_CMDB_WRITE
#define EVE_CMD_FIFO_SIZE
Definition EVE_GpuDefs.h:58
#define REG_CMD_WRITE
#define RAM_DL
Definition EVE_GpuDefs.h:95
#define REG_SPI_WIDTH
#define EVE_DL_SIZE
Definition EVE_GpuDefs.h:56
#define EVE_CMD_FIFO_MASK
Definition EVE_GpuDefs.h:60
@ EVE_SPI_TWO_DUMMY_BYTES
EVE_SPI_CHANNELS_T
@ EVE_SPI_QUAD_CHANNEL
@ EVE_SPI_SINGLE_CHANNEL
@ EVE_SPI_DUAL_CHANNEL
EVE_HalPlatform g_HalPlatform
Definition EVE_Hal.c:43
EVE_HAL_EXPORT void EVE_Hal_wr8(EVE_HalContext *phost, uint32_t addr, uint8_t v)
Write 8 bits to Coprocessor's memory.
Definition EVE_Hal.c:220
EVE_HAL_EXPORT bool EVE_Hal_powerCycle(EVE_HalContext *phost, bool up)
Toggle PD_N pin of FT800 board for a power cycle.
@ EVE_STATUS_READING
Definition EVE_HalDefs.h:59
@ EVE_STATUS_CLOSED
Definition EVE_HalDefs.h:57
@ EVE_STATUS_OPENED
Definition EVE_HalDefs.h:58
@ EVE_STATUS_ERROR
Definition EVE_HalDefs.h:61
@ EVE_STATUS_WRITING
Definition EVE_HalDefs.h:60
EVE_HAL_EXPORT uint8_t EVE_Hal_transfer8(EVE_HalContext *phost, uint8_t value)
Write 8 bits to Coprocessor.
EVE_HAL_EXPORT uint16_t EVE_Hal_transfer16(EVE_HalContext *phost, uint16_t value)
Write 2 bytes to Coprocessor.
EVE_HAL_EXPORT bool EVE_Hal_isDevice(EVE_HalContext *phost, size_t deviceIdx)
Check whether the context is the specified device.
EVE_HAL_EXPORT void EVE_Hal_info(EVE_DeviceInfo *deviceInfo, size_t deviceIdx)
Get info of the specified device. Devices of type EVE_HOST_UNKNOWN should be ignored.
EVE_HAL_EXPORT void EVE_Hal_startTransfer(EVE_HalContext *phost, EVE_TRANSFER_T rw, uint32_t addr)
Start data transfer to Coprocessor.
EVE_HAL_EXPORT void EVE_Hal_hostCommand(EVE_HalContext *phost, uint8_t cmd)
Send a host command to Coprocessor.
EVE_TRANSFER_T
Definition EVE_HalDefs.h:65
@ EVE_TRANSFER_WRITE
Definition EVE_HalDefs.h:68
@ EVE_TRANSFER_READ
Definition EVE_HalDefs.h:67
EVE_HAL_EXPORT void EVE_Hal_setSPI(EVE_HalContext *phost, EVE_SPI_CHANNELS_T numchnls, uint8_t numdummy)
Set number of SPI channel.
EVE_HAL_EXPORT uint32_t EVE_Hal_transferString(EVE_HalContext *phost, const char *str, uint32_t index, uint32_t size, uint32_t padMask)
Transfer a string to EVE platform.
static bool EVE_Hal_supportCmdB(EVE_HalContext *phost)
@ EVE_HOST_FT4222
EVE_HAL_EXPORT size_t EVE_Hal_list()
List the available devices.
EVE_HAL_EXPORT void EVE_Hal_transferMem(EVE_HalContext *phost, uint8_t *result, const uint8_t *buffer, uint32_t size)
Transfer (read/write) a block data to Coprocessor.
EVE_HAL_EXPORT void EVE_sleep(uint32_t ms)
Sleep in milisecond.
EVE_HAL_EXPORT void EVE_Hal_transferProgMem(EVE_HalContext *phost, uint8_t *result, eve_progmem_const uint8_t *buffer, uint32_t size)
Transfer a block data from program memory.
EVE_HAL_EXPORT void EVE_Hal_restoreSPI(EVE_HalContext *phost)
EVE_HAL_EXPORT void EVE_Hal_endTransfer(EVE_HalContext *phost)
End data transfer.
EVE_HAL_EXPORT void EVE_Hal_flush(EVE_HalContext *phost)
Flush data to Coprocessor.
EVE_HAL_EXPORT void EVE_Hal_hostCommandExt3(EVE_HalContext *phost, uint32_t cmd)
This API sends a 3byte command to the phost.
EVE_HAL_EXPORT uint32_t EVE_Hal_transfer32(EVE_HalContext *phost, uint32_t value)
Write 4 bytes to Coprocessor.
Eve_Hal framework APIs.
bool EVE_HalImpl_open(EVE_HalContext *phost, const EVE_HalParameters *parameters)
Opens a new HAL context using the specified parameters.
bool EVE_HalImpl_defaults(EVE_HalParameters *parameters, size_t deviceIdx)
Get the default configuration parameters.
void EVE_HalImpl_close(EVE_HalContext *phost)
Close a HAL context.
void EVE_HalImpl_initialize()
Initialize HAL platform.
bool EVE_UtilImpl_bootupDisplayGpio(EVE_HalContext *phost)
Display GPIO pins.
void EVE_HalImpl_idle(EVE_HalContext *phost)
Idle. Call regularly to update frequently changing internal state.
void EVE_HalImpl_release()
Release HAL platform.
void setSPI(EVE_HalContext *phost, EVE_SPI_CHANNELS_T numchnls, uint8_t numdummy)
Set number of SPI channel.
static void rdBuffer(EVE_HalContext *phost, uint8_t *buffer, uint32_t size)
Read a block data from Coprocessor.
unsigned short uint16_t
int int32_t
unsigned int uint32_t
unsigned char uint8_t
Platform selector.
#define eve_assert(cond)
#define eve_printf_debug(fmt,...)
#define eve_assert_ex(cond, ex)
#define eve_debug_break()
static ft_uint32_t ft_uint8_t * buffer
Definition FT_Gpu_Hal.h:139
static ft_void_t ft_uint32_t * cmd
Definition FT_Gpu_Hal.h:184
static ft_uint32_t addr
Definition FT_Gpu_Hal.h:139
@ CLK_IDLE_LOW
Definition LibFT4222.h:215
LIBFT4222_API FT4222_STATUS FT4222_SPIMaster_MultiReadWrite(FT_HANDLE ftHandle, uint8 *readBuffer, uint8 *writeBuffer, uint8 singleWriteBytes, uint16 multiWriteBytes, uint16 multiReadBytes, uint32 *sizeOfRead)
FT4222_SPIClock
Definition LibFT4222.h:199
@ CLK_DIV_8
Definition LibFT4222.h:203
@ CLK_DIV_4
Definition LibFT4222.h:202
@ CLK_DIV_2
Definition LibFT4222.h:201
@ CLK_DIV_16
Definition LibFT4222.h:204
LIBFT4222_API FT4222_STATUS FT4222_SPIMaster_SetLines(FT_HANDLE ftHandle, FT4222_SPIMode spiMode)
FT4222_STATUS
Definition LibFT4222.h:124
@ FT4222_OTHER_ERROR
Definition LibFT4222.h:143
@ FT4222_OK
Definition LibFT4222.h:125
FT4222_SPIMode
Definition LibFT4222.h:190
@ SPI_IO_QUAD
Definition LibFT4222.h:194
@ SPI_IO_DUAL
Definition LibFT4222.h:193
@ SPI_IO_SINGLE
Definition LibFT4222.h:192
LIBFT4222_API FT4222_STATUS FT4222_UnInitialize(FT_HANDLE ftHandle)
uint8_t uint8
Definition LibFT4222.h:66
LIBFT4222_API FT4222_STATUS FT4222_SetWakeUpInterrupt(FT_HANDLE ftHandle, BOOL enable)
LIBFT4222_API FT4222_STATUS FT4222_SetSuspendOut(FT_HANDLE ftHandle, BOOL enable)
FT4222_ClockRate
Definition LibFT4222.h:172
@ SYS_CLK_80
Definition LibFT4222.h:176
@ SYS_CLK_60
Definition LibFT4222.h:173
LIBFT4222_API FT4222_STATUS FT4222_SPIMaster_Init(FT_HANDLE ftHandle, FT4222_SPIMode ioLine, FT4222_SPIClock clock, FT4222_SPICPOL cpol, FT4222_SPICPHA cpha, uint8 ssoMap)
LIBFT4222_API FT4222_STATUS FT4222_GetVersion(FT_HANDLE ftHandle, FT4222_Version *pVersion)
LIBFT4222_API FT4222_STATUS FT4222_SPIMaster_SingleRead(FT_HANDLE ftHandle, uint8 *buffer, uint16 bufferSize, uint16 *sizeOfRead, BOOL isEndTransaction)
@ DS_4MA
Definition LibFT4222.h:227
LIBFT4222_API FT4222_STATUS FT4222_SPIMaster_SingleWrite(FT_HANDLE ftHandle, uint8 *buffer, uint16 bufferSize, uint16 *sizeTransferred, BOOL isEndTransaction)
@ CLK_LEADING
Definition LibFT4222.h:221
LIBFT4222_API FT4222_STATUS FT4222_SetClock(FT_HANDLE ftHandle, FT4222_ClockRate clk)
GPIO_Dir
Definition LibFT4222.h:242
@ GPIO_INPUT
Definition LibFT4222.h:244
@ GPIO_OUTPUT
Definition LibFT4222.h:243
LIBFT4222_API FT4222_STATUS FT4222_SPI_SetDrivingStrength(FT_HANDLE ftHandle, SPI_DrivingStrength clkStrength, SPI_DrivingStrength ioStrength, SPI_DrivingStrength ssoStrength)
LIBFT4222_API FT4222_STATUS FT4222_GPIO_Write(FT_HANDLE ftHandle, GPIO_Port portNum, BOOL bValue)
LIBFT4222_API FT4222_STATUS FT4222_GetClock(FT_HANDLE ftHandle, FT4222_ClockRate *clk)
LIBFT4222_API FT4222_STATUS FT4222_GPIO_Init(FT_HANDLE ftHandle, GPIO_Dir gpioDir[4])
@ GPIO_PORT0
Definition LibFT4222.h:235
#define TRUE
Definition Platform.h:197
#define FALSE
Definition Platform.h:198
unsigned long DWORD
Definition ff.h:61
@ FT_OK
Definition ftd2xx.h:74
FTD2XX_API FT_STATUS WINAPI FT_SetLatencyTimer(FT_HANDLE ftHandle, UCHAR ucLatency)
FTD2XX_API FT_STATUS WINAPI FT_Open(int deviceNumber, FT_HANDLE *pHandle)
ULONG FT_STATUS
Definition ftd2xx.h:69
FTD2XX_API FT_STATUS WINAPI FT_Close(FT_HANDLE ftHandle)
FTD2XX_API FT_STATUS WINAPI FT_SetTimeouts(FT_HANDLE ftHandle, ULONG ReadTimeout, ULONG WriteTimeout)
FTD2XX_API FT_STATUS WINAPI FT_GetDeviceInfoDetail(DWORD dwIndex, LPDWORD lpdwFlags, LPDWORD lpdwType, LPDWORD lpdwID, LPDWORD lpdwLocId, LPVOID lpSerialNumber, LPVOID lpDescription, FT_HANDLE *pftHandle)
FTD2XX_API FT_STATUS WINAPI FT_CreateDeviceInfoList(LPDWORD lpdwNumDevs)
@ FT_FLAGS_OPENED
Definition ftd2xx.h:1285
char DisplayName[256]
char SerialNumber[16]
EVE_HOST_T Host
uint8_t PowerDownPin
EVE_SPI_CHANNELS_T SpiChannels
EVE_STATUS_T Status
uint8_t SpiDummyBytes
uint32_t OpenedDevices
DWORD chipVersion
Definition LibFT4222.h:281