Dom > Novosti > Sadržaj

FT_Gpu_Hal.cpp

May 06, 2019

#include "FT_Platform.h"



/ * API za inicijalizaciju SPI sučelja * /

ft_bool_t Ft_Gpu_Hal_Init (Ft_Gpu_HalInit_t * halinit)

{\ T

#ifdef ARDUINO_PLATFORM_SPI

pinMode (FT_ARDUINO_PRO_SPI_CS, OUTPUT);

pinMode (FT800_PD_N, OUTPUT);

digitalWrite (FT_ARDUINO_PRO_SPI_CS, HIGH);

digitalWrite (FT800_PD_N, HIGH);

#endif

#ifdef MSVC_PLATFORM_SPI

/ * Inicijalizuj libmpsse * /

Init_libMPSSE ();

SPI_GetNumChannels (& halinit-> TotalChannelNum);

/ * Podrazumevano podrazumevam da je samo jedan mpsse kabl povezan sa PC-om, a kanal 0 tog mpsse kabla se koristi za spi transakcije * /

if (halinit-> TotalChannelNum> 0)

{\ T

FT_DEVICE_LIST_INFO_NODE devList;

SPI_GetChannelInfo (0, & devList);

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

/ * odštampaj dev info * /

printf ("Zastave = 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 osim ako je otvoreno * /

}

#endif

return TRUE;

}

ft_bool_t Ft_Gpu_Hal_Open (Ft_Gpu_Hal_Context_t * host)

{\ T

#ifdef ARDUINO_PLATFORM_SPI

SPI.begin ();

SPI.setClockDivider (SPI_CLOCK_DIV2);

SPI.setBitOrder (MSBFIRST);

SPI.setDataMode (SPI_MODE0);

#endif

#ifdef MSVC_PLATFORM_SPI

ChannelConfig channelConf; // konfiguracija kanala

FT_STATUS status;

/ * konfigurirati spi postavke * /

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% x status = 0x% x", host-> hal_handle, status);

#endif

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)

{\ T

host-> status = FT_GPU_HAL_CLOSED;

#ifdef MSVC_PLATFORM_SPI

/ * Zatvaranje kanala * /

SPI_CloseChannel (host-> hal_handle);

#endif

#ifdef ARDUINO_PLATFORM_SPI

SPI.end ();

#endif

}

ft_void_t Ft_Gpu_Hal_DeInit ()

{\ T

#ifdef MSVC_PLATFORM_SPI

// Čišćenje MPSSE Lib

Cleanup_libMPSSE ();

#endif

}


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

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

{\ T

ako (FT_GPU_READ == rw) {


#ifdef MSVC_PLATFORM_SPI

ft_uint8_t Transfer_Array [4];

ft_uint32_t SizeTransffered;


/ * Sastavite paket 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);

#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

host-> status = FT_GPU_HAL_READING;

} else {

#ifdef MSVC_PLATFORM_SPI

ft_uint8_t Transfer_Array [3];

ft_uint32_t SizeTransffered;


/ * Sastavite paket 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);

#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

host-> status = FT_GPU_HAL_WRITING;

}

}

/ * API-ji za neprekidno pisanje prenosa * /

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

{\ T

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 * string)

{\ T

ft_uint16_t dužina = strlen (string);

while (dužina -) {

Ft_Gpu_Hal_Transfer8 (host, * string);

string ++;

}

// Dodati jedan null kao završnu zastavicu

Ft_Gpu_Hal_Transfer8 (host, 0);

}

ft_uint8_t Ft_Gpu_Hal_Transfer8 (Ft_Gpu_Hal_Context_t * host, ft_uint8_t vrijednost)

{\ T

#ifdef ARDUINO_PLATFORM_SPI

vrati SPI.transfer (vrijednost);

#endif

#ifdef MSVC_PLATFORM_SPI

ft_uint32_t SizeTransffered;

if (host-> status == FT_GPU_HAL_WRITING) {

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

} else {

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

}


if (SizeTransffered! = sizeof (value))

host-> status = FT_GPU_HAL_STATUS_ERROR;

povratna vrijednost;

#endif

}


ft_uint16_t Ft_Gpu_Hal_Transfer16 (Ft_Gpu_Hal_Context_t * host, vrijednost ft_uint16_t)

{\ T

ft_uint16_t retVal = 0;


if (host-> status == FT_GPU_HAL_WRITING) {

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

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

} else {

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)

{\ T

ft_uint32_t retVal = 0;

if (host-> status == FT_GPU_HAL_WRITING) {

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

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

} else {

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)

{\ T

#ifdef MSVC_PLATFORM_SPI

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

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

#endif

#ifdef ARDUINO_PLATFORM_SPI

digitalWrite (FT_ARDUINO_PRO_SPI_CS, HIGH);

#endif

host-> status = FT_GPU_HAL_OPENED;

}

ft_uint8_t Ft_Gpu_Hal_Rd8 (Ft_Gpu_Hal_Context_t * host, ft_uint32_t addr)

{\ T

ft_uint8_t value;

Ft_Gpu_Hal_StartTransfer (host, FT_GPU_READ, addr);

vrijednost = Ft_Gpu_Hal_Transfer8 (host, 0);

Ft_Gpu_Hal_EndTransfer (host);

povratna vrijednost;

}

ft_uint16_t Ft_Gpu_Hal_Rd16 (Ft_Gpu_Hal_Context_t * host, ft_uint32_t addr)

{\ T

ft_uint16_t value;

Ft_Gpu_Hal_StartTransfer (host, FT_GPU_READ, addr);

vrijednost = Ft_Gpu_Hal_Transfer16 (host, 0);

Ft_Gpu_Hal_EndTransfer (host);

povratna vrijednost;

}

ft_uint32_t Ft_Gpu_Hal_Rd32 (Ft_Gpu_Hal_Context_t * host, ft_uint32_t addr)

{\ T

ft_uint32_t value;

Ft_Gpu_Hal_StartTransfer (host, FT_GPU_READ, addr);

vrijednost = Ft_Gpu_Hal_Transfer32 (host, 0);

Ft_Gpu_Hal_EndTransfer (host);

povratna vrijednost;

}

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

{\ T

Ft_Gpu_Hal_StartTransfer (host, FT_GPU_WRITE, addr);

Ft_Gpu_Hal_Transfer8 (host, v);

Ft_Gpu_Hal_EndTransfer (host);

}

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

{\ T

Ft_Gpu_Hal_StartTransfer (host, FT_GPU_WRITE, addr);

Ft_Gpu_Hal_Transfer16 (host, v);

Ft_Gpu_Hal_EndTransfer (host);

}

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

{\ T

Ft_Gpu_Hal_StartTransfer (host, FT_GPU_WRITE, addr);

Ft_Gpu_Hal_Transfer32 (host, v);

Ft_Gpu_Hal_EndTransfer (host);

}

ft_void_t Ft_Gpu_HostCommand (Ft_Gpu_Hal_Context_t * host, ft_uint8_t cmd)

{\ T

#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 (host-> 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

}

ft_void_t Ft_Gpu_ClockSelect (Ft_Gpu_Hal_Context_t * host, FT_GPU_PLL_SOURCE_T pllsource)

{\ T

Ft_Gpu_HostCommand (host, pllsource);

}

ft_void_t Ft_Gpu_PLL_FreqSelect (Ft_Gpu_Hal_Context_t * host, FT_GPU_PLL_FREQ_T freq)

{\ T

Ft_Gpu_HostCommand (host, freq);

}

ft_void_t Ft_Gpu_PowerModeSwitch (Ft_Gpu_Hal_Context_t * host, FT_GPU_POWER_MODE_T pwrmode)

{\ T

Ft_Gpu_HostCommand (host, pwrmode);

}

ft_void_t Ft_Gpu_CoreReset (Ft_Gpu_Hal_Context_t * host)

{\ T

Ft_Gpu_HostCommand (host, 0x68);

}

ft_void_t Ft_Gpu_Hal_Updatecmdfifo (Ft_Gpu_Hal_Context_t * host, ft_uint16_t count)

{\ T

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


// 4 bajtova poravnanja

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

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

}



ft_uint16_t Ft_Gpu_Cmdfifo_Freespace (Ft_Gpu_Hal_Context_t * host)

{\ T

ft_uint16_t punoća, 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 * bafer, ft_uint16_t count)

{\ T

ft_uint32_t dužina = 0, SizeTransffered = 0;


#define MAX_CMD_FIFO_TRANSFER Ft_Gpu_Cmdfifo_Freespace (host)

do {

dužina = broj;

if (dužina> MAX_CMD_FIFO_TRANSFER) {

length = MAX_CMD_FIFO_TRANSFER;

}

Ft_Gpu_Hal_CheckCmdBuffer (host, dužina);


Ft_Gpu_Hal_StartCmdTransfer (host, FT_GPU_WRITE, dužina);


#ifdef ARDUINO_PLATFORM_SPI

SizeTransffered = 0;

dok (dužina--) {

Ft_Gpu_Hal_Transfer8 (host, * buffer);

buffer ++;

SizeTransffered ++;

}

length = SizeTransffered;

#endif

#ifdef MSVC_PLATFORM_SPI

{\ T

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

length = SizeTransffered;

buffer + = SizeTransffered;

}

#endif


Ft_Gpu_Hal_EndTransfer (host);

Ft_Gpu_Hal_Updatecmdfifo (host, dužina);


Ft_Gpu_Hal_WaitCmdfifo_empty (host);


count - = dužina;

} dok (count> 0);

}

ft_void_t Ft_Gpu_Hal_WrCmdBuf_nowait (Ft_Gpu_Hal_Context_t * host, ft_uint8_t * buffer, ft_uint16_t count)

{\ T

ft_uint32_t dužina = 0, SizeTransffered = 0;


#define MAX_CMD_FIFO_TRANSFER Ft_Gpu_Cmdfifo_Freespace (host)


do {

dužina = broj;

if (dužina> MAX_CMD_FIFO_TRANSFER) {

length = MAX_CMD_FIFO_TRANSFER;

}

Ft_Gpu_Hal_CheckCmdBuffer (host, dužina);


Ft_Gpu_Hal_StartCmdTransfer (host, FT_GPU_WRITE, dužina);


#ifdef ARDUINO_PLATFORM_SPI

SizeTransffered = 0;

dok (dužina--) {

Ft_Gpu_Hal_Transfer8 (host, * buffer);

buffer ++;

SizeTransffered ++;

}

length = SizeTransffered;

#endif


#ifdef MSVC_PLATFORM_SPI

{\ T

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

length = SizeTransffered;

buffer + = SizeTransffered;

}

#endif


Ft_Gpu_Hal_EndTransfer (host);

Ft_Gpu_Hal_Updatecmdfifo (host, dužina);

count - = dužina;

} dok (count> 0);

}

#ifdef ARDUINO_PLATFORM_SPI

ft_void_t Ft_Gpu_Hal_WrCmdBufFromFlash (Ft_Gpu_Hal_Context_t * host, FT_PROGMEM ft_prog_uchar8_t * bafer, ft_uint16_t count)

{\ T

ft_uint32_t dužina = 0, SizeTransffered = 0;


#define MAX_CMD_FIFO_TRANSFER Ft_Gpu_Cmdfifo_Freespace (host)

do {

dužina = broj;

if (dužina> MAX_CMD_FIFO_TRANSFER) {

length = MAX_CMD_FIFO_TRANSFER;

}

Ft_Gpu_Hal_CheckCmdBuffer (host, dužina);


Ft_Gpu_Hal_StartCmdTransfer (host, FT_GPU_WRITE, dužina);



SizeTransffered = 0;

dok (dužina--) {

Ft_Gpu_Hal_Transfer8 (host, ft_pgm_read_byte_near (buffer));

buffer ++;

SizeTransffered ++;

}

length = SizeTransffered;


Ft_Gpu_Hal_EndTransfer (host);

Ft_Gpu_Hal_Updatecmdfifo (host, dužina);


Ft_Gpu_Hal_WaitCmdfifo_empty (host);


count - = dužina;

} dok (count> 0);

}

#endif

ft_void_t Ft_Gpu_Hal_CheckCmdBuffer (Ft_Gpu_Hal_Context_t * host, ft_uint16_t count)

{\ T

ft_uint16_t getfreespace;

do {

getfreespace = Ft_Gpu_Cmdfifo_Freespace (host);

} while (getfreespace <>

}

ft_void_t Ft_Gpu_Hal_WaitCmdfifo_empty (Ft_Gpu_Hal_Context_t * host)

{\ T

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_uint8_t Ft_Gpu_Hal_WaitCmdfifo_empty_status (Ft_Gpu_Hal_Context_t * host)

{\ T

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

{\ T

return 0;

}

drugo

{\ T

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

return 1;

}

}


ft_void_t Ft_Gpu_Hal_WaitLogo_Finish (Ft_Gpu_Hal_Context_t * host)

{\ T

ft_int16_t cmdrdptr, cmdwrptr;


do {

cmdrdptr = Ft_Gpu_Hal_Rd16 (host, REG_CMD_READ);

cmdwrptr = Ft_Gpu_Hal_Rd16 (host, REG_CMD_WRITE);

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

host-> ft_cmd_fifo_wp = 0;

}



ft_void_t Ft_Gpu_Hal_ResetCmdFifo (Ft_Gpu_Hal_Context_t * host)

{\ T

host-> ft_cmd_fifo_wp = 0;

}



ft_void_t Ft_Gpu_Hal_WrCmd32 (Ft_Gpu_Hal_Context_t * host, ft_uint32_t cmd)

{\ T

Ft_Gpu_Hal_CheckCmdBuffer (host, sizeof (cmd));

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

Ft_Gpu_Hal_Updatecmdfifo (host, sizeof (cmd));

}

ft_void_t Ft_Gpu_Hal_ResetDLBuffer (Ft_Gpu_Hal_Context_t * host)

{\ T

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)

{\ T

ako (gore)

{\ T

#ifdef MSVC_PLATFORM

FT_WriteGPIO (host-> hal_handle, 0xBB, 0x08); // PDN postavljen na 0, povezivanje BLUE žice 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);

#endif

#ifdef ARDUINO_PLATFORM

digitalWrite (FT800_PD_N, LOW);

Ft_Gpu_Hal_Sleep (20);


digitalWrite (FT800_PD_N, HIGH);

Ft_Gpu_Hal_Sleep (20);

#endif

} else

{\ T

#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, povezivanje BLUE žice MPSSE na PDN # od FT800 ploče

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 * host, ft_uint32_t addr, const ft_prog_uchar8_t * buffer, ft_uint32_t dužina)

{\ T

ft_uint32_t SizeTransffered = 0;


Ft_Gpu_Hal_StartTransfer (host, FT_GPU_WRITE, addr);


#ifdef ARDUINO_PLATFORM

dok (dužina--) {

Ft_Gpu_Hal_Transfer8 (host, ft_pgm_read_byte_near (buffer));

buffer ++;

}

#endif


#ifdef MSVC_PLATFORM_SPI

{\ T

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

}

#endif



Ft_Gpu_Hal_EndTransfer (host);

}


ft_void_t Ft_Gpu_Hal_WrMem (Ft_Gpu_Hal_Context_t * host, ft_uint32_t addr, const ft_uint8_t * buffer, ft_uint32_t dužina)

{\ T

ft_uint32_t SizeTransffered = 0;


Ft_Gpu_Hal_StartTransfer (host, FT_GPU_WRITE, addr);


#ifdef ARDUINO_PLATFORM

dok (dužina--) {

Ft_Gpu_Hal_Transfer8 (host, * buffer);

buffer ++;

}

#endif


#ifdef MSVC_PLATFORM_SPI

{\ T

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

}

#endif



Ft_Gpu_Hal_EndTransfer (host);

}



ft_void_t Ft_Gpu_Hal_RdMem (Ft_Gpu_Hal_Context_t * host, ft_uint32_t addr, ft_uint8_t * buffer, ft_uint32_t dužina)

{\ T

ft_uint32_t SizeTransffered = 0;


Ft_Gpu_Hal_StartTransfer (host, FT_GPU_READ, addr);


#ifdef ARDUINO_PLATFORM

dok (dužina--) {

* buffer = Ft_Gpu_Hal_Transfer8 (host, 0);

buffer ++;

}

#endif


#ifdef MSVC_PLATFORM_SPI

{\ T

SPI_Read ((FT_HANDLE) host-> hal_handle, buffer, length, & SizeTransffered, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES);

}

#endif


Ft_Gpu_Hal_EndTransfer (host);

}


ft_int32_t Ft_Gpu_Hal_Dec2Ascii (ft_char8_t * pSrc, vrijednost ft_int32_t)

{\ 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;


Length = strlen (pSrc);

pdst = pSrc + dužina;


if (0 == vrijednost)

{\ T

* pdst ++ = '0';

* pdst ++ = '';

return 0;

}


ako (CurrVal <>

{\ T

* pdst ++ = '-';

CurrVal = - CurlVal;

}

/ * unesite vrijednost * /

dok (CurrVal> 0) {

tmpval = CurrVal;

CurrVal / = 10;

tmpval = tmpval - CurrVal * 10;

charval = '0' + tmpval;

tmparray [idx ++] = charval;

}


za (i = 0; i

{\ T

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

}

* pdst ++ = '';


return 0;

}


ft_void_t Ft_Gpu_Hal_Sleep (ft_uint16_t ms)

{\ T

#ifdef MSVC_PLATFORM

Sleep (ms);

#endif

#ifdef ARDUINO_PLATFORM

kašnjenje (ms);

#endif

}