Dom > Novice > Vsebine

Vir FTDI FT_Gpu_Hal.c

May 08, 2019

#include "FT_Platform.h"


/ * API za inicializacijo vmesnika SPI * /

ft_bool_t Ft_Gpu_Hal_Init (Ft_Gpu_HalInit_t * halinit)

{

#ifdef ARDUINO_PLATFORM_SPI

pinMode (FT_ARDUINO_PRO_SPI_CS, IZHOD);

pinMode (FT800_PD_N, IZHOD);

digitalWrite (FT_ARDUINO_PRO_SPI_CS, HIGH);

digitalWrite (FT800_PD_N, HIGH);

#endif


#ifdef MSVC_PLATFORM_SPI

/ * Inicializirajte libmpsse * /

Init_libMPSSE ();

SPI_GetNumChannels (& halinit-> TotalChannelNum);

/ * Privzeto sem predpostavljal, da je na računalnik priključen le en kabel mpsse in da je kanal 0 tega mpsse kabla uporabljen za spi transakcije * /

če (halinit-> TotalChannelNum> 0)

{

FT_DEVICE_LIST_INFO_NODE devList;

SPI_GetChannelInfo (0, & devList);

printf ("Informacije o številki kanala% d:", 0);

/ * natisni dev info * /

printf ("Zastavice = 0x% x", devList.Flags);

printf ("Type = 0x% x", devList.Type);

printf ("ID = 0x% x", devList.ID);

printf ("LocId = 0x% x", devList.LocId);

printf ("SerialNumber =% s", devList.SerialNumber);

printf ("Opis =% s", devList.Description);

printf ("ftHandle = 0x% x", devList.ftHandle); / * je 0, razen če je odprto * /

}

#endif

vrne TRUE;

}


ft_bool_t Ft_Gpu_Hal_Open (gostitelj Ft_Gpu_Hal_Context_t *)

{

#ifdef MSVC_FT800EMU

Ft_GpuEmu_SPII2C_begin ();

#endif

#ifdef ARDUINO_PLATFORM_SPI

SPI.bg ();

SPI.setClockDivider (SPI_CLOCK_DIV2);

SPI.setBitOrder (MSBFIRST);

SPI.setDataMode (SPI_MODE0);

#endif

#ifdef MSVC_PLATFORM_SPI

ChannelConfig channelConf; // konfiguracija kanala

Stanje FT_STATUS;

/ * konfiguriranje nastavitev spi * /

channelConf.ClockRate = gostitelj -> hal_config.spi_clockrate_khz * 1000;

channelConf.LatencyTimer = 2;

channelConf.configOptions = SPI_CONFIG_OPTION_MODE0 | SPI_CONFIG_OPTION_CS_DBUS3 | SPI_CONFIG_OPTION_CS_ACTIVELOW;

channelConf.Pin = 0x00000000; / * FinalVal-FinalDir-InitVal-InitDir (za dir 0 = in, 1 = out) * /


/ * Odprite prvi razpoložljivi kanal * /

SPI_OpenChannel (gostitelj -> hal_config.channel_no, (FT_HANDLE *) in gostitelj -> hal_handle);

status = SPI_InitChannel ((FT_HANDLE) gostitelj-> hal_handle, & channelConf);

printf ("ročaj = 0x% status = 0x% x", gostitelj-> hal_handle, status);

#endif

gostitelj -> ft_cmd_fifo_wp = gostitelj -> ft_dl_buff_wp = 0;

gostitelj -> status = FT_GPU_HAL_OPENED;

vrne TRUE;

}


ft_void_t Ft_Gpu_Hal_Close (gostitelj Ft_Gpu_Hal_Context_t *)

{

gostitelj -> status = FT_GPU_HAL_CLOSED;

#ifdef MSVC_PLATFORM_SPI

/ * Zapri kanal * /

SPI_CloseChannel (host-> hal_handle);

#endif

#ifdef ARDUINO_PLATFORM_SPI

SPI.end ();

#endif

#ifdef MSVC_FT800EMU

Ft_GpuEmu_SPII2C_end ();

#endif

}


ft_void_t Ft_Gpu_Hal_DeInit ()

{

#ifdef MSVC_PLATFORM_SPI

// Čiščenje MPSSE Lib

Cleanup_libMPSSE ();

#endif

}


/ * API-ji za branje / pisanje prenosa neprekinjeno samo z majhnim vmesnim sistemom * /

ft_void_t Ft_Gpu_Hal_StartTransfer (Ft_Gpu_Hal_Context_t * gostitelj, FT_GPU_TRANSFERDIR_T rw, ft_uint32_t addr)

{

če (FT_GPU_READ == rw) {

#ifdef MSVC_PLATFORM_SPI

ft_uint8_t Transfer_Array [4];

ft_uint32_t SizeTransffered;


/ * Sestavljanje paketa za branje * /

Transfer_Array [0] = addr >> 16;

Transfer_Array [1] = addr >> 8;

Transfer_Array [2] = addr;


Transfer_Array [3] = 0; / Dummy Read byte

SPI_Write ((FT_HANDLE) gostitelj-> hal_handle, Transfer_Array, sizeof (Transfer_Array), & SizeTransffered, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES | SPI_TRANSFER_OPTIONS_CHIPSELECT_ENABLE);

#endif

#ifdef ARDUINO_PLATFORM_SPI

digitalWrite (FT_ARDUINO_PRO_SPI_CS, LOW);

SPI.transfer (addr >> 16);

SPI.transfer (highByte (addr));

SPI.transfer (lowByte (addr));


SPI.transfer (0); // Dummy Read Byte

#endif

#ifdef MSVC_FT800EMU

Ft_GpuEmu_SPII2C_StartRead (addr);

#endif

gostitelj -> status = FT_GPU_HAL_READING;

} else {

#ifdef MSVC_PLATFORM_SPI

ft_uint8_t Transfer_Array [3];

ft_uint32_t SizeTransffered;


/ * Sestavljanje paketa za branje * /

Transfer_Array [0] = (0x80 | (addr >> 16));

Transfer_Array [1] = addr >> 8;

Transfer_Array [2] = addr;

SPI_Write ((FT_HANDLE) gostitelj-> hal_handle, Transfer_Array, 3, & SizeTransffered, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES | SPI_TRANSFER_OPTIONS_CHIPSELECT_ENABLE);

#endif

#ifdef ARDUINO_PLATFORM_SPI

digitalWrite (FT_ARDUINO_PRO_SPI_CS, LOW);

SPI.transfer (0x80 | (addr >> 16));

SPI.transfer (highByte (addr));

SPI.transfer (lowByte (addr));

#endif

#ifdef MSVC_FT800EMU

Ft_GpuEmu_SPII2C_StartWrite (addr);

#endif

gostitelj -> status = FT_GPU_HAL_WRITING;

}

}


/ * API-ji za neprekinjeno pisanje prenosov * /

ft_void_t Ft_Gpu_Hal_StartCmdTransfer (Ft_Gpu_Hal_Context_t * gostitelj, FT_GPU_TRANSFERDIR_T rw, št. ft_uint16_t)

{

Ft_Gpu_Hal_StartTransfer (gostitelj, rw, gostitelj -> ft_cmd_fifo_wp + RAM_CMD);

}

ft_uint8_t Ft_Gpu_Hal_TransferString (Ft_Gpu_Hal_Context_t * gostitelj, const ft_char8_t * niz)

{

ft_uint16_t dolžina = strlen (niz);

medtem (dolžina -) {

Ft_Gpu_Hal_Transfer8 (gostitelj, * niz);

niz ++;

}

// Dodajte eno null kot končnico

Ft_Gpu_Hal_Transfer8 (gostitelj, 0);

}


ft_uint8_t Ft_Gpu_Hal_Transfer8 (Ft_Gpu_Hal_Context_t * gostitelj, vrednost ft_uint8_t)

{

#ifdef ARDUINO_PLATFORM_SPI

vrne SPI.transfer (vrednost);

#endif

#ifdef MSVC_PLATFORM_SPI

ft_uint32_t SizeTransffered;

if (host-> status == FT_GPU_HAL_WRITING) {

SPI_Write (host-> hal_handle, & value, sizeof (value), & SizeTransposed, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES);

} else {

SPI_Read (host-> hal_handle, & value, sizeof (value), & SizeTransposed, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES);

}


if (SizeTransffered! = sizeof (value))

gostitelj -> status = FT_GPU_HAL_STATUS_ERROR;

vrnjena vrednost;

#endif

#ifdef MSVC_FT800EMU

vrne Ft_GpuEmu_SPII2C_transfer (vrednost);

#endif

}


ft_uint16_t Ft_Gpu_Hal_Transfer16 (Ft_Gpu_Hal_Context_t * gostitelj, vrednost ft_uint16_t)

{

ft_uint16_t retVal = 0;

if (host-> status == FT_GPU_HAL_WRITING) {

Ft_Gpu_Hal_Transfer8 (gostitelj, vrednost & 0xFF); // LSB

Ft_Gpu_Hal_Transfer8 (gostitelj, (vrednost >> 8) & 0xFF);

} else {

retVal = Ft_Gpu_Hal_Transfer8 (gostitelj, 0);

retVal | = (ft_uint16_t) Ft_Gpu_Hal_Transfer8 (gostitelj, 0) <>

}


return retVal;

}


ft_uint32_t Ft_Gpu_Hal_Transfer32 (Ft_Gpu_Hal_Context_t * gostitelj, vrednost ft_uint32_t)

{

ft_uint32_t retVal = 0;

if (host-> status == FT_GPU_HAL_WRITING) {

Ft_Gpu_Hal_Transfer16 (gostitelj, vrednost & 0xFFFF); // LSB

Ft_Gpu_Hal_Transfer16 (gostitelj, (vrednost >> 16) & 0xFFFF);

} else {

retVal = Ft_Gpu_Hal_Transfer16 (gostitelj, 0);

retVal | = (ft_uint32_t) Ft_Gpu_Hal_Transfer16 (gostitelj, 0) <>

}

return retVal;

}


ft_void_t Ft_Gpu_Hal_EndTransfer (gostitelj Ft_Gpu_Hal_Context_t *)

{

#ifdef MSVC_PLATFORM_SPI

/ / samo disbale CS - pošlji 0 bytes s CS onemogočiti

SPI_ToggleCS ((FT_HANDLE) gostitelj-> hal_handle, FALSE);

#endif

#ifdef ARDUINO_PLATFORM_SPI

digitalWrite (FT_ARDUINO_PRO_SPI_CS, HIGH);

#endif

#ifdef MSVC_FT800EMU

Ft_GpuEmu_SPII2C_csHigh ();

#endif

gostitelj -> status = FT_GPU_HAL_OPENED;

}


ft_uint8_t Ft_Gpu_Hal_Rd8 (Ft_Gpu_Hal_Context_t * gostitelj, ft_uint32_t addr)

{

vrednost ft_uint8_t;

Ft_Gpu_Hal_StartTransfer (gostitelj, FT_GPU_READ, addr);

vrednost = Ft_Gpu_Hal_Transfer8 (gostitelj, 0);

Ft_Gpu_Hal_EndTransfer (gostitelj);

vrnjena vrednost;

}

ft_uint16_t Ft_Gpu_Hal_Rd16 (Ft_Gpu_Hal_Context_t * gostitelj, ft_uint32_t addr)

{

vrednost ft_uint16_t;

Ft_Gpu_Hal_StartTransfer (gostitelj, FT_GPU_READ, addr);

vrednost = Ft_Gpu_Hal_Transfer16 (gostitelj, 0);

Ft_Gpu_Hal_EndTransfer (gostitelj);

vrnjena vrednost;

}

ft_uint32_t Ft_Gpu_Hal_Rd32 (Ft_Gpu_Hal_Context_t * gostitelj, ft_uint32_t addr)

{

vrednost ft_uint32_t;

Ft_Gpu_Hal_StartTransfer (gostitelj, FT_GPU_READ, addr);

vrednost = Ft_Gpu_Hal_Transfer32 (gostitelj, 0);

Ft_Gpu_Hal_EndTransfer (gostitelj);

vrnjena vrednost;

}

ft_void_t Ft_Gpu_Hal_Wr8 (Ft_Gpu_Hal_Context_t * gostitelj, ft_uint32_t naslovnik, ft_uint8_t v)

{

Ft_Gpu_Hal_StartTransfer (gostitelj, FT_GPU_WRITE, addr);

Ft_Gpu_Hal_Transfer8 (gostitelj, v);

Ft_Gpu_Hal_EndTransfer (gostitelj);

}

ft_void_t Ft_Gpu_Hal_Wr16 (Ft_Gpu_Hal_Context_t * gostitelj, ft_uint32_t addr, ft_uint16_t v)

{

Ft_Gpu_Hal_StartTransfer (gostitelj, FT_GPU_WRITE, addr);

Ft_Gpu_Hal_Transfer16 (gostitelj, v);

Ft_Gpu_Hal_EndTransfer (gostitelj);

}

ft_void_t Ft_Gpu_Hal_Wr32 (Ft_Gpu_Hal_Context_t * gostitelj, ft_uint32_t naslovnik, ft_uint32_t v)

{

Ft_Gpu_Hal_StartTransfer (gostitelj, FT_GPU_WRITE, addr);

Ft_Gpu_Hal_Transfer32 (gostitelj, v);

Ft_Gpu_Hal_EndTransfer (gostitelj);

}



ft_void_t Ft_Gpu_HostCommand (Ft_Gpu_Hal_Context_t * gostitelj, ft_uint8_t cmd)

{

#ifdef MSVC_PLATFORM_SPI

ft_uint8_t Transfer_Array [3];

ft_uint32_t SizeTransffered;


Transfer_Array [0] = cmd;

Transfer_Array [1] = 0;

Transfer_Array [2] = 0;


SPI_Write (gostitelj-> hal_handle, Transfer_Array, sizeof (Transfer_Array), & SizeTransffered, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES | SPI_TRANSFER_OPTIONS_CHIPSELECT_ENABLE | SPI_TRANSFER_OPTIONS_CHIPSELECT_DISABLE)

#endif

#ifdef ARDUINO_PLATFORM_SPI

digitalWrite (FT_ARDUINO_PRO_SPI_CS, LOW);

SPI.transfer (cmd);

SPI.transfer (0);

SPI.transfer (0);

digitalWrite (FT_ARDUINO_PRO_SPI_CS, HIGH);

#endif

#ifdef MSVC_FT800EMU

// Ne izvaja v FT800EMU

#endif

}


ft_void_t Ft_Gpu_ClockSelect (gostitelj Ft_Gpu_Hal_Context_t *, FT_GPU_PLL_SOURCE_T pllsource)

{

Ft_Gpu_HostCommand (gostitelj, pllsource);

}

ft_void_t Ft_Gpu_PLL_FreqSelect (Ft_Gpu_Hal_Context_t * gostitelj, FT_GPU_PLL_FREQ_T freq)

{

Ft_Gpu_HostCommand (gostitelj, freq);

}

ft_void_t Ft_Gpu_PowerModeSwitch (Ft_Gpu_Hal_Context_t * gostitelj, FT_GPU_POWER_MODE_T pwrmode)

{

Ft_Gpu_HostCommand (gostitelj, pwrmode);

}

ft_void_t Ft_Gpu_CoreReset (gostitelj Ft_Gpu_Hal_Context_t *)

{

Ft_Gpu_HostCommand (gostitelj, 0x68);

}


ft_void_t Ft_Gpu_Hal_Updatecmdfifo (Ft_Gpu_Hal_Context_t * gostitelj, število ft_uint16_t)

{

host-> ft_cmd_fifo_wp = (host-> ft_cmd_fifo_wp + count) & 4095;


// 4-bajtna poravnava

host-> ft_cmd_fifo_wp = (host-> ft_cmd_fifo_wp + 3) & 0xffc;

Ft_Gpu_Hal_Wr16 (gostitelj, REG_CMD_WRITE, gostitelj -> ft_cmd_fifo_wp);

}


ft_uint16_t Ft_Gpu_Cmdfifo_Freespace (gostitelj Ft_Gpu_Hal_Context_t *)

{

ft_uint16_t polnost, retval;


polnost = (gostitelj -> ft_cmd_fifo_wp - Ft_Gpu_Hal_Rd16 (gostitelj, REG_CMD_READ)) & 4095;

retval = (FT_CMD_FIFO_SIZE - 4) - polnost;

vrnitev (retval);

}

ft_void_t Ft_Gpu_Hal_WrCmdBuf (gostitelj Ft_Gpu_Hal_Context_t *, buffer ft_uint8_t *, število ft_uint16_t)

{

ft_uint32_t dolžina = 0, SizeTransffered = 0;

#define MAX_CMD_FIFO_TRANSFER Ft_Gpu_Cmdfifo_Freespace (gostitelj)

do {

dolžina = število;

if (dolžina> MAX_CMD_FIFO_TRANSFER) {

length = MAX_CMD_FIFO_TRANSFER;

}

Ft_Gpu_Hal_CheckCmdBuffer (gostitelj, dolžina);


Ft_Gpu_Hal_StartCmdTransfer (gostitelj, FT_GPU_WRITE, dolžina);

#if definirano (ARDUINO_PLATFORM_SPI) || definirano (MSVC_FT800EMU)

SizeTransffered = 0;

medtem (dolžina--) {

Ft_Gpu_Hal_Transfer8 (host, * buffer);

buffer ++;

SizeTransffered ++;

}

dolžina = velikost je prenesena;

#endif


#ifdef MSVC_PLATFORM_SPI

{

SPI_Write (host-> hal_handle, buffer, length, & SizeTransposed, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES);

dolžina = velikost je prenesena;

medpomnilnik + = velikost prenosa;

}

#endif

Ft_Gpu_Hal_EndTransfer (gostitelj);

Ft_Gpu_Hal_Updatecmdfifo (gostitelj, dolžina);


Ft_Gpu_Hal_WaitCmdfifo_empty (gostitelj);


count - = dolžina;

} medtem ko (count> 0);

}

#ifdef ARDUINO_PLATFORM_SPI

ft_void_t Ft_Gpu_Hal_WrCmdBufFromFlash (gostitelj Ft_Gpu_Hal_Context_t *, FT_PROGMEM ft_prog_uchar8_t *, število ft_uint16_t)

{

ft_uint32_t dolžina = 0, SizeTransffered = 0;

#define MAX_CMD_FIFO_TRANSFER Ft_Gpu_Cmdfifo_Freespace (gostitelj)

do {

dolžina = število;

if (dolžina> MAX_CMD_FIFO_TRANSFER) {

length = MAX_CMD_FIFO_TRANSFER;

}

Ft_Gpu_Hal_CheckCmdBuffer (gostitelj, dolžina);


Ft_Gpu_Hal_StartCmdTransfer (gostitelj, FT_GPU_WRITE, dolžina);



SizeTransffered = 0;

medtem (dolžina--) {

Ft_Gpu_Hal_Transfer8 (gostitelj, ft_pgm_read_byte_near (buffer));

buffer ++;

SizeTransffered ++;

}

dolžina = velikost je prenesena;


Ft_Gpu_Hal_EndTransfer (gostitelj);

Ft_Gpu_Hal_Updatecmdfifo (gostitelj, dolžina);


Ft_Gpu_Hal_WaitCmdfifo_empty (gostitelj);


count - = dolžina;

} medtem ko (count> 0);

}

#endif

ft_void_t Ft_Gpu_Hal_CheckCmdBuffer (Ft_Gpu_Hal_Context_t * gostitelj, število ft_uint16_t)

{

ft_uint16_t getfreespace;

do {

getfreespace = Ft_Gpu_Cmdfifo_Freespace (gostitelj);

} while (getfreespace <>

}

ft_void_t Ft_Gpu_Hal_WaitCmdfifo_empty (gostitelj Ft_Gpu_Hal_Context_t *)

{

while (Ft_Gpu_Hal_Rd16 (gostitelj, REG_CMD_READ)! = Ft_Gpu_Hal_Rd16 (gostitelj, REG_CMD_WRITE));

host-> ft_cmd_fifo_wp = Ft_Gpu_Hal_Rd16 (gostitelj, REG_CMD_WRITE);

}

ft_void_t Ft_Gpu_Hal_WrCmdBuf_nowait (Ft_Gpu_Hal_Context_t * gostitelj, buffer ft_uint8_t *, število ft_uint16_t)

{

ft_uint32_t dolžina = 0, SizeTransffered = 0;

#define MAX_CMD_FIFO_TRANSFER Ft_Gpu_Cmdfifo_Freespace (gostitelj)

do {

dolžina = število;

if (dolžina> MAX_CMD_FIFO_TRANSFER) {

length = MAX_CMD_FIFO_TRANSFER;

}

Ft_Gpu_Hal_CheckCmdBuffer (gostitelj, dolžina);


Ft_Gpu_Hal_StartCmdTransfer (gostitelj, FT_GPU_WRITE, dolžina);


// # ifdef ARDUINO_PLATFORM_SPI

#if definirano (ARDUINO_PLATFORM_SPI) || definirano (MSVC_FT800EMU)

SizeTransffered = 0;

medtem (dolžina--) {

Ft_Gpu_Hal_Transfer8 (host, * buffer);

buffer ++;

SizeTransffered ++;

}

dolžina = velikost je prenesena;

#endif

#ifdef MSVC_PLATFORM_SPI

{

SPI_Write (host-> hal_handle, buffer, length, & SizeTransposed, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES);

dolžina = velikost je prenesena;

medpomnilnik + = velikost prenosa;

}

#endif


Ft_Gpu_Hal_EndTransfer (gostitelj);

Ft_Gpu_Hal_Updatecmdfifo (gostitelj, dolžina);


// Ft_Gpu_Hal_WaitCmdfifo_empty (gostitelj);


count - = dolžina;

} medtem ko (count> 0);

}



ft_uint8_t Ft_Gpu_Hal_WaitCmdfifo_empty_status (gostitelj Ft_Gpu_Hal_Context_t *)

{

if (Ft_Gpu_Hal_Rd16 (gostitelj, REG_CMD_READ)! = Ft_Gpu_Hal_Rd16 (gostitelj, REG_CMD_WRITE))

{

return 0;

}

drugače

{

host-> ft_cmd_fifo_wp = Ft_Gpu_Hal_Rd16 (gostitelj, REG_CMD_WRITE);

return 1;

}

}


ft_void_t Ft_Gpu_Hal_WaitLogo_Finish (Ft_Gpu_Hal_Context_t * gostitelj)

{

ft_int16_t cmdrdptr, cmdwrptr;


do {

cmdrdptr = Ft_Gpu_Hal_Rd16 (gostitelj, REG_CMD_READ);

cmdwrptr = Ft_Gpu_Hal_Rd16 (gostitelj, REG_CMD_WRITE);

} while ((cmdwrptr! = cmdrdptr) || (cmdrdptr! = 0));

host-> ft_cmd_fifo_wp = 0;

}


ft_void_t Ft_Gpu_Hal_ResetCmdFifo (gostitelj Ft_Gpu_Hal_Context_t *)

{

host-> ft_cmd_fifo_wp = 0;

}


ft_void_t Ft_Gpu_Hal_WrCmd32 (Ft_Gpu_Hal_Context_t * gostitelj, ft_uint32_t cmd)

{

Ft_Gpu_Hal_CheckCmdBuffer (gostitelj, velikost (cmd));

Ft_Gpu_Hal_Wr32 (gostitelj, RAM_CMD + gostitelj-> ft_cmd_fifo_wp, cmd);

Ft_Gpu_Hal_Updatecmdfifo (gostitelj, velikost (cmd));

}


ft_void_t Ft_Gpu_Hal_ResetDLBuffer (gostitelj Ft_Gpu_Hal_Context_t *)

{

gostitelj -> ft_dl_buff_wp = 0;

}

/ * Toggle PD_N pin FT800 plošče za cikel moči * /

ft_void_t Ft_Gpu_Hal_Powercycle (Ft_Gpu_Hal_Context_t * gostitelj, ft_bool_t navzgor)

{

če (gor)

{

#ifdef MSVC_PLATFORM

FT_WriteGPIO (host-> hal_handle, 0xBB, 0x08); // PDN nastavljen na 0, povežite BLUE žico MPSSE s PDN # na FT800 plošči

Ft_Gpu_Hal_Sleep (20);


FT_WriteGPIO (gostitelj-> hal_handle, 0xBB, 0x88); // PDN nastavljen na 1

Ft_Gpu_Hal_Sleep (20);

#endif

#ifdef ARDUINO_PLATFORM

digitalWrite (FT800_PD_N, LOW);

Ft_Gpu_Hal_Sleep (50);


digitalWrite (FT800_PD_N, HIGH);

Ft_Gpu_Hal_Sleep (50);

#endif

} else

{

#ifdef MSVC_PLATFORM

FT_WriteGPIO (gostitelj-> hal_handle, 0xBB, 0x88); // PDN nastavljen na 1

Ft_Gpu_Hal_Sleep (20);

FT_WriteGPIO (host-> hal_handle, 0xBB, 0x08); // PDN nastavljen na 0, povežite BLUE žico MPSSE s PDN # na FT800 plošči

Ft_Gpu_Hal_Sleep (20);

#endif

#ifdef ARDUINO_PLATFORM

digitalWrite (FT800_PD_N, HIGH);

Ft_Gpu_Hal_Sleep (20);

digitalWrite (FT800_PD_N, LOW);

Ft_Gpu_Hal_Sleep (20);

#endif

}

}



ft_void_t Ft_Gpu_Hal_WrMemFromFlash (Ft_Gpu_Hal_Context_t * gostitelj, ft_uint32_t addr, const ft_prog_uchar8_t * buffer, ft_uint32_t dolžina)

{

ft_uint32_t SizeTransffered = 0;


Ft_Gpu_Hal_StartTransfer (gostitelj, FT_GPU_WRITE, addr);


#if definirano (ARDUINO_PLATFORM_SPI) || definirano (MSVC_FT800EMU)

medtem (dolžina--) {

Ft_Gpu_Hal_Transfer8 (gostitelj, ft_pgm_read_byte_near (buffer));

buffer ++;

}

#endif


#ifdef MSVC_PLATFORM_SPI

{

SPI_Write ((FT_HANDLE) gostitelj-> hal_handle, medpomnilnik, dolžina in velikost prenosa, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES);

}

#endif



Ft_Gpu_Hal_EndTransfer (gostitelj);

}


ft_void_t Ft_Gpu_Hal_WrMem (Ft_Gpu_Hal_Context_t * gostitelj, ft_uint32_t addr, const ft_uint8_t * buffer, ft_uint32_t dolžina)

{

ft_uint32_t SizeTransffered = 0;


Ft_Gpu_Hal_StartTransfer (gostitelj, FT_GPU_WRITE, addr);


#if definirano (ARDUINO_PLATFORM_SPI) || definirano (MSVC_FT800EMU)

medtem (dolžina--) {

Ft_Gpu_Hal_Transfer8 (host, * buffer);

buffer ++;

}

#endif


#ifdef MSVC_PLATFORM_SPI

{

SPI_Write ((FT_HANDLE) gostitelj-> hal_handle, medpomnilnik, dolžina in velikost prenosa, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES);

}

#endif



Ft_Gpu_Hal_EndTransfer (gostitelj);

}



ft_void_t Ft_Gpu_Hal_RdMem (Ft_Gpu_Hal_Context_t * gostitelj, ft_uint32_t addr, ft_uint8_t * buffer, ft_uint32_t dolžina)

{

ft_uint32_t SizeTransffered = 0;


Ft_Gpu_Hal_StartTransfer (gostitelj, FT_GPU_READ, addr);


#if definirano (ARDUINO_PLATFORM_SPI) || definirano (MSVC_FT800EMU)

medtem (dolžina--) {

* buffer = Ft_Gpu_Hal_Transfer8 (gostitelj, 0);

buffer ++;

}

#endif


#ifdef MSVC_PLATFORM_SPI

{

SPI_Read ((FT_HANDLE) gostitelj-> hal_handle, medpomnilnik, dolžina, & velikost prenosa, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES);

}

#endif


Ft_Gpu_Hal_EndTransfer (gostitelj);

}


ft_int32_t Ft_Gpu_Hal_Dec2Ascii (ft_char8_t * pSrc, vrednost ft_int32_t)

{

ft_int16_t Dolžina;

ft_char8_t * pdst, charval;

ft_int32_t CurrVal = vrednost, tmpval, i;

ft_char8_t tmparray [16], idx = 0;


Dolžina = strlen (pSrc);

pdst = pSrc + dolžina;


če (0 == vrednost)

{

* pdst ++ = '0';

* pdst ++ = '';

return 0;

}


če (CurrVal <>

{

* pdst ++ = '-';

CurrVal = - CurrVal;

}

/ * vstavite vrednost * /

medtem (CurrVal> 0) {

tmpval = CurrVal;

CurrVal / = 10;

tmpval = tmpval - CurrVal * 10;

charval = '0' + tmpval;

tmparray [idx ++] = charval;

}


za (i = 0; i

{

* pdst ++ = tmparray [idx - i - 1];

}

* pdst ++ = '';


return 0;

}


ft_void_t Ft_Gpu_Hal_Sleep (ft_uint16_t ms)

{

#if definirano (MSVC_PLATFORM) || definirano (MSVC_FT800EMU)

Spanje (ms);

#endif

#ifdef ARDUINO_PLATFORM

zakasnitev (ms);

#endif

}