Dom > Vijesti > Sadržaj

FTDI Izvor FT_Gpu_Hal.c

May 08, 2019

#include "FT_Platform.h"


/ * API za inicijalizaciju SPI sučelja * /

ft_bool_t Ft_Gpu_Hal_Init (Ft_Gpu_HalInit_t * halinit)

{

#ifdef ARDUINO_PLATFORM_SPI

pinMode (FT_ARDUINO_PRO_SPI_CS, IZLAZ);

pinMode (FT800_PD_N, IZLAZ);

digitalWrite (FT_ARDUINO_PRO_SPI_CS, HIGH);

digitalni zapis (FT800_PD_N, HIGH);

#završi ako


#ifdef MSVC_PLATFORM_SPI

/ * Inicijaliziranje libmpsse * /

Init_libMPSSE ();

SPI_GetNumChannels (i halinit-> TotalChannelNum);

/ * Po defaultu ja sam uz pretpostavku da je samo jedan mpsse kabel spojen na PC i kanal 0 tog mpsse kabela se koristi za spi transakcije * /

ako (halinit-> TotalChannelNum> 0)

{

FT_DEVICE_LIST_INFO_NODE devList;

SPI_GetChannelInfo (0, devList);

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

/ * ispiši Dev Dev *

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

printf ("Vrsta = 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 ako nije otvoreno * /

}

#završi ako

return TRUE;

}


ft_bool_t Ft_Gpu_Hal_Open (Ft_Gpu_Hal_Context_t * host)

{

#ifdef MSVC_FT800EMU

Ft_GpuEmu_SPII2C_begin ();

#završi ako

#ifdef ARDUINO_PLATFORM_SPI

SPI.begin ();

SPI.setClockDivider (SPI_CLOCK_DIV2);

SPI.setBitOrder (MSBFIRST);

SPI.setDataMode (SPI_MODE0);

#završi ako

#ifdef MSVC_PLATFORM_SPI

ChannelConfig channelConf; // konfiguracija kanala

FT_STATUS status;

/ * konfiguriranje spi postavki * /

channelConf.ClockRate = host-> 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) * /


/ * Otvaranje prvog dostupnog kanala * /

SPI_OpenChannel (host-> hal_config.channel_no, (FT_HANDLE *) i host-> hal_handle);

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

printf ("handle = 0x% status = 0x% x", host-> hal_handle, status);

#završi ako

host-> ft_cmd_fifo_wp = host-> ft_dl_buff_wp = 0;

host-> status = FT_GPU_HAL_OPENED;

return TRUE;

}


ft_void_t Ft_Gpu_Hal_Close (Ft_Gpu_Hal_Context_t * host)

{

host-> status = FT_GPU_HAL_CLOSED;

#ifdef MSVC_PLATFORM_SPI

/ * Zatvaranje kanala * /

SPI_CloseChannel (spajanje domaćina> hal_handle);

#završi ako

#ifdef ARDUINO_PLATFORM_SPI

SPI.end ();

#završi ako

#ifdef MSVC_FT800EMU

Ft_GpuEmu_SPII2C_end ();

#završi ako

}


ft_void_t Ft_Gpu_Hal_DeInit ()

{

#ifdef MSVC_PLATFORM_SPI

// Čišćenje MPSSE Lib

Cleanup_libMPSSE ();

#završi ako

}


/ * API-ji za čitanje / pisanje prijenosa kontinuirano samo s malim tampon sustavom * /

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

{

ako (FT_GPU_READ == rw) {

#ifdef MSVC_PLATFORM_SPI

ft_uint8_t Transfer_Array [4];

ft_uint32_t Veličina prijenosa;


/ * Sastavljanje paketa za čitanje * /

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) host-> hal_handle, Transfer_Array, sizeof (Transfer_Array), & SizeTransffered, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES | SPI_TRANSFER_OPTIONS_CHIPSELECT_ENABLE);

#završi ako

#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

#završi ako

#ifdef MSVC_FT800EMU

Ft_GpuEmu_SPII2C_StartRead (addr);

#završi ako

host-> status = FT_GPU_HAL_READING;

}drugo{

#ifdef MSVC_PLATFORM_SPI

ft_uint8_t Transfer_Array [3];

ft_uint32_t Veličina prijenosa;


/ * Sastavljanje paketa za čitanje * /

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

Transfer_Array [1] = addr >> 8;

Transfer_Array [2] = addr;

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

#završi ako

#ifdef ARDUINO_PLATFORM_SPI

digitalWrite (FT_ARDUINO_PRO_SPI_CS, LOW);

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

SPI.transfer (highByte (addr));

SPI.transfer (lowByte (addr));

#završi ako

#ifdef MSVC_FT800EMU

Ft_GpuEmu_SPII2C_StartWrite (addr);

#završi ako

host-> status = FT_GPU_HAL_WRITING;

}

}


/ * API-ji za kontinuirano pisanje prijenosa * /

ft_void_t Ft_Gpu_Hal_StartCmdTransfer (Ft_Gpu_Hal_Context_t * host, FT_GPU_TRANSFERDIR_T rw, ft_uint16_t count)

{

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

}

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

{

ft_uint16_t duljina = strlen (string);

dok (dužina -) {

Ft_Gpu_Hal_Transfer8 (domaćin, * niz);

string ++;

}

// Dodajte jedan null kao završnu zastavicu

Ft_Gpu_Hal_Transfer8 (domaćin, 0);

}


ft_uint8_t Ft_Gpu_Hal_Transfer8 (Ft_Gpu_Hal_Context_t * host, vrijednost ft_uint8_t)

{

#ifdef ARDUINO_PLATFORM_SPI

vrati SPI.transfer (vrijednost);

#završi ako

#ifdef MSVC_PLATFORM_SPI

ft_uint32_t Veličina prijenosa;

ako (host-> status == FT_GPU_HAL_WRITING) {

SPI_Write (spajanje domaćina> hal_handle, i vrijednost, sizeof (vrijednosti), SizeTransfered, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES);

}drugo{

SPI_Read (spajanje domaćina> hal_handle, i vrijednost, sizeof (vrijednosti), SizeTransfered, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES);

}


if (SizeTransffered! = sizeof (value))

host-> status = FT_GPU_HAL_STATUS_ERROR;

povratna vrijednost;

#završi ako

#ifdef MSVC_FT800EMU

vrati Ft_GpuEmu_SPII2C_transfer (vrijednost);

#završi ako

}


ft_uint16_t Ft_Gpu_Hal_Transfer16 (Ft_Gpu_Hal_Context_t * host, vrijednost ft_uint16_t)

{

ft_uint16_t retVal = 0;

ako (host-> status == FT_GPU_HAL_WRITING) {

Ft_Gpu_Hal_Transfer8 (host, vrijednost & 0xFF); // LSB prvi

Ft_Gpu_Hal_Transfer8 (host, (vrijednost >> 8) & 0xFF);

}drugo{

retVal = Ft_Gpu_Hal_Transfer8 (host, 0);

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

}


return retVal;

}


ft_uint32_t Ft_Gpu_Hal_Transfer32 (Ft_Gpu_Hal_Context_t * host, vrijednost ft_uint32_t)

{

ft_uint32_t retVal = 0;

ako (host-> status == FT_GPU_HAL_WRITING) {

Ft_Gpu_Hal_Transfer16 (host, vrijednost & 0xFFFF); // LSB prvi

Ft_Gpu_Hal_Transfer16 (host, (vrijednost >> 16) & 0xFFFF);

}drugo{

retVal = Ft_Gpu_Hal_Transfer16 (host, 0);

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

}

return retVal;

}


ft_void_t Ft_Gpu_Hal_EndTransfer (Ft_Gpu_Hal_Context_t * host)

{

#ifdef MSVC_PLATFORM_SPI

/ / samo disbale CS - poslati 0 bytes s CS onemogućiti

SPI_ToggleCS ((FT_HANDLE) spajanje domaćina> hal_handle, FALSE);

#završi ako

#ifdef ARDUINO_PLATFORM_SPI

digitalWrite (FT_ARDUINO_PRO_SPI_CS, HIGH);

#završi ako

#ifdef MSVC_FT800EMU

Ft_GpuEmu_SPII2C_csHigh ();

#završi ako

host-> status = FT_GPU_HAL_OPENED;

}


ft_uint8_t Ft_Gpu_Hal_Rd8 (Ft_Gpu_Hal_Context_t * host, ft_uint32_t addr)

{

vrijednost ft_uint8_t;

Ft_Gpu_Hal_StartTransfer (domaćin FT_GPU_READ, addr);

vrijednost = Ft_Gpu_Hal_Transfer8 (host, 0);

Ft_Gpu_Hal_EndTransfer (domaćina);

povratna vrijednost;

}

ft_uint16_t Ft_Gpu_Hal_Rd16 (Ft_Gpu_Hal_Context_t * host, ft_uint32_t addr)

{

vrijednost ft_uint16_t;

Ft_Gpu_Hal_StartTransfer (domaćin FT_GPU_READ, addr);

vrijednost = Ft_Gpu_Hal_Transfer16 (host, 0);

Ft_Gpu_Hal_EndTransfer (domaćina);

povratna vrijednost;

}

ft_uint32_t Ft_Gpu_Hal_Rd32 (Ft_Gpu_Hal_Context_t * host, ft_uint32_t addr)

{

vrijednost ft_uint32_t;

Ft_Gpu_Hal_StartTransfer (domaćin FT_GPU_READ, addr);

vrijednost = Ft_Gpu_Hal_Transfer32 (host, 0);

Ft_Gpu_Hal_EndTransfer (domaćina);

povratna vrijednost;

}

ft_void_t Ft_Gpu_Hal_Wr8 (Ft_Gpu_Hal_Context_t * host, ft_uint32_t adr, ft_uint8_t v)

{

Ft_Gpu_Hal_StartTransfer (domaćin FT_GPU_WRITE, addr);

Ft_Gpu_Hal_Transfer8 (domaćin, v);

Ft_Gpu_Hal_EndTransfer (domaćina);

}

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

{

Ft_Gpu_Hal_StartTransfer (domaćin FT_GPU_WRITE, addr);

Ft_Gpu_Hal_Transfer16 (domaćin, v);

Ft_Gpu_Hal_EndTransfer (domaćina);

}

ft_void_t Ft_Gpu_Hal_Wr32 (Ft_Gpu_Hal_Context_t * host, ft_uint32_t adr, ft_uint32_t v)

{

Ft_Gpu_Hal_StartTransfer (domaćin FT_GPU_WRITE, addr);

Ft_Gpu_Hal_Transfer32 (domaćin, v);

Ft_Gpu_Hal_EndTransfer (domaćina);

}



ft_void_t Ft_Gpu_HostCommand (Ft_Gpu_Hal_Context_t * host, ft_uint8_t cmd)

{

#ifdef MSVC_PLATFORM_SPI

ft_uint8_t Transfer_Array [3];

ft_uint32_t Veličina prijenosa;


Transfer_Array [0] = cmd;

Transfer_Array [1] = 0;

Transfer_Array [2] = 0;


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

#završi ako

#ifdef ARDUINO_PLATFORM_SPI

digitalWrite (FT_ARDUINO_PRO_SPI_CS, LOW);

SPI.transfer (Ctrl);

SPI.transfer (0);

SPI.transfer (0);

digitalWrite (FT_ARDUINO_PRO_SPI_CS, HIGH);

#završi ako

#ifdef MSVC_FT800EMU

// Nije implementirano u FT800EMU

#završi ako

}


ft_void_t Ft_Gpu_ClockSelect (Ft_Gpu_Hal_Context_t * host, FT_GPU_PLL_SOURCE_T pllsource)

{

Ft_Gpu_HostCommand (domaćin, pllsource);

}

ft_void_t Ft_Gpu_PLL_FreqSelect (Ft_Gpu_Hal_Context_t * host, FT_GPU_PLL_FREQ_T freq)

{

Ft_Gpu_HostCommand (domaćin, freq);

}

ft_void_t Ft_Gpu_PowerModeSwitch (Ft_Gpu_Hal_Context_t * host, FT_GPU_POWER_MODE_T pwrmode)

{

Ft_Gpu_HostCommand (domaćin, pwrmode);

}

ft_void_t Ft_Gpu_CoreReset (Ft_Gpu_Hal_Context_t * host)

{

Ft_Gpu_HostCommand (domaćin, 0x68);

}


ft_void_t Ft_Gpu_Hal_Updatecmdfifo (Ft_Gpu_Hal_Context_t * host, broj ft_uint16_t)

{

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


// 4-bajtno poravnanje

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

Ft_Gpu_Hal_Wr16 (domaćin REG_CMD_WRITE, spajanje domaćina> ft_cmd_fifo_wp);

}


ft_uint16_t Ft_Gpu_Cmdfifo_Freespace (Ft_Gpu_Hal_Context_t * host)

{

ft_uint16_t punina, retval;


punoća = (host-> ft_cmd_fifo_wp - Ft_Gpu_Hal_Rd16 (host, REG_CMD_READ)) & 4095;

retval = (FT_CMD_FIFO_SIZE - 4) - punoća;

povratak (retval);

}

ft_void_t Ft_Gpu_Hal_WrCmdBuf (Ft_Gpu_Hal_Context_t * host, ft_uint8_t * međuspremnik, ft_uint16_t count)

{

ft_uint32_t duljina = 0, SizeTransffered = 0;

#define MAX_CMD_FIFO_TRANSFER Ft_Gpu_Cmdfifo_Freespace (host)

čini {

duljina = broj;

if (duljina> MAX_CMD_FIFO_TRANSFER) {

length = MAX_CMD_FIFO_TRANSFER;

}

Ft_Gpu_Hal_CheckCmdBuffer (domaćin, duljina);


Ft_Gpu_Hal_StartCmdTransfer (domaćin FT_GPU_WRITE duljine);

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

SizeTransffered = 0;

dok (dužina--) {

Ft_Gpu_Hal_Transfer8 (domaćin, * pufer);

pufer ++;

SizeTransffered ++;

}

duljina = Veličina Prijenosa;

#završi ako


#ifdef MSVC_PLATFORM_SPI

{

SPI_Write (spajanje domaćina> hal_handle, pufer, duljina, i SizeTransfered, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES);

duljina = Veličina Prijenosa;

međuspremnik + = Veličina prijenosa;

}

#završi ako

Ft_Gpu_Hal_EndTransfer (domaćina);

Ft_Gpu_Hal_Updatecmdfifo (domaćin, duljina);


Ft_Gpu_Hal_WaitCmdfifo_empty (domaćina);


count - = duljina;

} vrijeme (broj> 0);

}

#ifdef ARDUINO_PLATFORM_SPI

ft_void_t Ft_Gpu_Hal_WrCmdBufFromFlash (Ft_Gpu_Hal_Context_t * host, FT_PROGMEM ft_prog_uchar8_t * međuspremnik, ft_uint16_t count)

{

ft_uint32_t duljina = 0, SizeTransffered = 0;

#define MAX_CMD_FIFO_TRANSFER Ft_Gpu_Cmdfifo_Freespace (host)

čini {

duljina = broj;

if (duljina> MAX_CMD_FIFO_TRANSFER) {

length = MAX_CMD_FIFO_TRANSFER;

}

Ft_Gpu_Hal_CheckCmdBuffer (domaćin, duljina);


Ft_Gpu_Hal_StartCmdTransfer (domaćin FT_GPU_WRITE duljine);



SizeTransffered = 0;

dok (dužina--) {

Ft_Gpu_Hal_Transfer8 (domaćin ft_pgm_read_byte_near (pufer));

pufer ++;

SizeTransffered ++;

}

duljina = Veličina Prijenosa;


Ft_Gpu_Hal_EndTransfer (domaćina);

Ft_Gpu_Hal_Updatecmdfifo (domaćin, duljina);


Ft_Gpu_Hal_WaitCmdfifo_empty (domaćina);


count - = duljina;

} vrijeme (broj> 0);

}

#završi ako

ft_void_t Ft_Gpu_Hal_CheckCmdBuffer (Ft_Gpu_Hal_Context_t * host, broj ft_uint16_t)

{

ft_uint16_t getfreespace;

čini{

getfreespace = Ft_Gpu_Cmdfifo_Freespace (host);

} while (getfreespace <>

}

ft_void_t Ft_Gpu_Hal_WaitCmdfifo_empty (Ft_Gpu_Hal_Context_t * host)

{

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

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

}

ft_void_t Ft_Gpu_Hal_WrCmdBuf_nowait (Ft_Gpu_Hal_Context_t * host, ft_uint8_t * međuspremnik, ft_uint16_t count)

{

ft_uint32_t duljina = 0, SizeTransffered = 0;

#define MAX_CMD_FIFO_TRANSFER Ft_Gpu_Cmdfifo_Freespace (host)

čini {

duljina = broj;

if (duljina> MAX_CMD_FIFO_TRANSFER) {

length = MAX_CMD_FIFO_TRANSFER;

}

Ft_Gpu_Hal_CheckCmdBuffer (domaćin, duljina);


Ft_Gpu_Hal_StartCmdTransfer (domaćin FT_GPU_WRITE duljine);


// # ifdef ARDUINO_PLATFORM_SPI

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

SizeTransffered = 0;

dok (dužina--) {

Ft_Gpu_Hal_Transfer8 (domaćin, * pufer);

pufer ++;

SizeTransffered ++;

}

duljina = Veličina Prijenosa;

#završi ako

#ifdef MSVC_PLATFORM_SPI

{

SPI_Write (spajanje domaćina> hal_handle, pufer, duljina, i SizeTransfered, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES);

duljina = Veličina Prijenosa;

međuspremnik + = Veličina prijenosa;

}

#završi ako


Ft_Gpu_Hal_EndTransfer (domaćina);

Ft_Gpu_Hal_Updatecmdfifo (domaćin, duljina);


// Ft_Gpu_Hal_WaitCmdfifo_empty (domaćina);


count - = duljina;

} vrijeme (broj> 0);

}



ft_uint8_t Ft_Gpu_Hal_WaitCmdfifo_empty_status (Ft_Gpu_Hal_Context_t * host)

{

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

{

return 0;

}

drugo

{

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

povratak 1;

}

}


ft_void_t Ft_Gpu_Hal_WaitLogo_Finish (Ft_Gpu_Hal_Context_t * host)

{

ft_int16_t cmdrdptr, cmdwrptr;


čini{

cmdrdptr = Ft_Gpu_Hal_Rd16 (host, REG_CMD_READ);

cmdwrptr = Ft_Gpu_Hal_Rd16 (host, REG_CMD_WRITE);

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

host-> ft_cmd_fifo_wp = 0;

}


ft_void_t Ft_Gpu_Hal_ResetCmdFifo (Ft_Gpu_Hal_Context_t * host)

{

host-> ft_cmd_fifo_wp = 0;

}


ft_void_t Ft_Gpu_Hal_WrCmd32 (Ft_Gpu_Hal_Context_t * host, ft_uint32_t cmd)

{

Ft_Gpu_Hal_CheckCmdBuffer (domaćin, sizeof (Ctrl));

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

Ft_Gpu_Hal_Updatecmdfifo (domaćin, sizeof (Ctrl));

}


ft_void_t Ft_Gpu_Hal_ResetDLBuffer (Ft_Gpu_Hal_Context_t * host)

{

host-> ft_dl_buff_wp = 0;

}

/ * Prebaci PD_N pin FT800 ploče za ciklus napajanja * /

ft_void_t Ft_Gpu_Hal_Powercycle (Ft_Gpu_Hal_Context_t * host, ft_bool_t gore)

{

ako (gore)

{

#ifdef MSVC_PLATFORM

FT_WriteGPIO (host-> hal_handle, 0xBB, 0x08); // PDN postavljen na 0, spojite BLUE žicu MPSSE na PDN # od FT800 ploče

Ft_Gpu_Hal_Sleep (20);


FT_WriteGPIO (host-> hal_handle, 0xBB, 0x88); // PDN postavljen na 1

Ft_Gpu_Hal_Sleep (20);

#završi ako

#ifdef ARDUINO_PLATFORM

digitalWrite (FT800_PD_N, LOW);

Ft_Gpu_Hal_Sleep (50);


digitalni zapis (FT800_PD_N, HIGH);

Ft_Gpu_Hal_Sleep (50);

#završi ako

}drugo

{

#ifdef MSVC_PLATFORM

FT_WriteGPIO (host-> hal_handle, 0xBB, 0x88); // PDN postavljen na 1

Ft_Gpu_Hal_Sleep (20);

FT_WriteGPIO (host-> hal_handle, 0xBB, 0x08); // PDN postavljen na 0, spojite BLUE žicu MPSSE na PDN # od FT800 ploče

Ft_Gpu_Hal_Sleep (20);

#završi ako

#ifdef ARDUINO_PLATFORM

digitalni zapis (FT800_PD_N, HIGH);

Ft_Gpu_Hal_Sleep (20);

digitalWrite (FT800_PD_N, LOW);

Ft_Gpu_Hal_Sleep (20);

#završi ako

}

}



ft_void_t Ft_Gpu_Hal_WrMemFromFlash (Ft_Gpu_Hal_Context_t * host, ft_uint32_t addr, const ft_prog_uchar8_t * međuspremnik, ft_uint32_t duljina)

{

ft_uint32_t SizeTransffered = 0;


Ft_Gpu_Hal_StartTransfer (domaćin FT_GPU_WRITE, addr);


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

dok (dužina--) {

Ft_Gpu_Hal_Transfer8 (domaćin ft_pgm_read_byte_near (pufer));

pufer ++;

}

#završi ako


#ifdef MSVC_PLATFORM_SPI

{

SPI_Write ((FT_HANDLE) spajanje domaćina> hal_handle, pufer, duljina, i SizeTransfered, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES);

}

#završi ako



Ft_Gpu_Hal_EndTransfer (domaćina);

}


ft_void_t Ft_Gpu_Hal_WrMem (Ft_Gpu_Hal_Context_t * host, ft_uint32_t addr, const ft_uint8_t * međuspremnik, ft_uint32_t duljina)

{

ft_uint32_t SizeTransffered = 0;


Ft_Gpu_Hal_StartTransfer (domaćin FT_GPU_WRITE, addr);


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

dok (dužina--) {

Ft_Gpu_Hal_Transfer8 (domaćin, * pufer);

pufer ++;

}

#završi ako


#ifdef MSVC_PLATFORM_SPI

{

SPI_Write ((FT_HANDLE) spajanje domaćina> hal_handle, pufer, duljina, i SizeTransfered, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES);

}

#završi ako



Ft_Gpu_Hal_EndTransfer (domaćina);

}



ft_void_t Ft_Gpu_Hal_RdMem (Ft_Gpu_Hal_Context_t * host, ft_uint32_t addr, ft_uint8_t * međuspremnik, ft_uint32_t duljina)

{

ft_uint32_t SizeTransffered = 0;


Ft_Gpu_Hal_StartTransfer (domaćin FT_GPU_READ, addr);


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

dok (dužina--) {

* međuspremnik = Ft_Gpu_Hal_Transfer8 (host, 0);

pufer ++;

}

#završi ako


#ifdef MSVC_PLATFORM_SPI

{

SPI_Read ((FT_HANDLE) spajanje domaćina> hal_handle, pufer, duljina, i SizeTransfered, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES);

}

#završi ako


Ft_Gpu_Hal_EndTransfer (domaćina);

}


ft_int32_t Ft_Gpu_Hal_Dec2Ascii (ft_char8_t * pSrc, vrijednost ft_int32_t)

{

ft_int16_t Dužina;

ft_char8_t * pdst, charval;

ft_int32_t CurrVal = vrijednost, tmpval, i;

ft_char8_t tmparray [16], idx = 0;


Duljina = strlen (pSrc);

pdst = pSrc + duljina;


ako (0 == vrijednost)

{

* pdst ++ = '0';

* pdst ++ = '';

return 0;

}


ako (CurrVal <>

{

* pdst ++ = '-';

CurrVal = - CurlVal;

}

/ * umetnite vrijednost * /

dok (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)

Spavanja (ms);

#završi ako

#ifdef ARDUINO_PLATFORM

kašnjenja (ms);

#završi ako

}