Bosh sahifa > Yangiliklar > Kontent

FTDI manbasi FT_Gpu_Hal.c

May 08, 2019

#include "FT_Platform.h"


/ * SPI interfeysini ishga tushirish uchun API * /

ft_bool_t Ft_Gpu_Hal_Init (Ft_Gpu_HalInit_t * halinit)

{

#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, yuqori);

#endif


#ifdef MSVC_PLATFORM_SPI

/ * Libmpsse * / Initialize *

Init_libMPSSE ();

SPI_GetNumChannels (& halinit-> TotalChannelNum);

/ * Standart sifatida faqat bitta mpsse kabeli kompyuterga ulanganligini va mpsse simi 0-ni spi-harakatlar uchun ishlatilishini taxmin qilaman * /

agar (halinit-> TotalChannelNum> 0)

{

FT_DEVICE_LIST_INFO_NODE devList;

SPI_GetChannelInfo (0, & devList);

printf ("% d:%, kanal raqami haqida ma'lumot", 0);

/ * yirik ma'lumotni chop etish * /

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

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

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

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

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

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

printf ("ftHandle = 0x% x", devList.ftHandle); * /

}

#endif

ROST qaytish;

}


ft_bool_t Ft_Gpu_Hal_Open (Ft_Gpu_Hal_Context_t * host)

{

#ifdef MSVC_FT800EMU

Ft_GpuEmu_SPII2C_begin ();

#endif

#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; // kanal konfiguratsiyasi

FT_STATUS holati;

/ * spi-ni sozlash * /

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 (dir 0 = uchun, 1 = tashqariga) * /


/ * Birinchi mavjud kanalni oching * /

SPI_OpenChannel (host-> hal_config.channel_no, (FT_HANDLE *) va 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;

ROST qaytish;

}


ft_void_t Ft_Gpu_Hal_Close (Ft_Gpu_Hal_Context_t * host)

{

host-> status = FT_GPU_HAL_CLOSED;

#ifdef MSVC_PLATFORM_SPI

/ * Kanalni yopish * /

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

// MPSSE Lib ni tozalash

Cleanup_libMPSSE ();

#endif

}


/ * O'qish / yozish uchun API-lar faqat kichik bufer tizim bilan uzluksiz * /

ft_void_t Ft_Gpu_Hal_StartTransfer (Ft_Gpu_Hal_Context_t * host, FT_GPU_TRANSFERDIR_T rw, ft_uint32_tAdd)

{

agar (FT_GPU_READ == rw) {

#ifdef MSVC_PLATFORM_SPI

ft_uint8_t Transfer_Array [4];

ft_uint32_t SizeTransfered;


/ * O'qish paketini tuzish * /

Transfer_Array [0] = addr >> 16;

Transfer_Array [1] = addr >> 8;

Transfer_Array [2] = addr;


Transfer_Array [3] = 0; // Dummy o'qish bayt

SPI_Write ((FT_HANDLE) host-> hal_handle, Transfer_Array, sizeof (Transfer_Array), & SizeTransfered, 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 (pastByte (addr));


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

#endif

#ifdef MSVC_FT800EMU

Ft_GpuEmu_SPII2C_StartRead (addr);

#endif

host-> status = FT_GPU_HAL_READING;

} Boshqa {

#ifdef MSVC_PLATFORM_SPI

ft_uint8_t Transfer_Array [3];

ft_uint32_t SizeTransfered;


/ * O'qish paketini tuzish * /

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 & SizeTransfered, 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 (pastByte (addr));

#endif

#ifdef MSVC_FT800EMU

Ft_GpuEmu_SPII2C_StartWrite (addr);

#endif

host-> status = FT_GPU_HAL_WRITING;

}

}


/ * Yozish uchun API faqat uzluksiz * /

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

{

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)

{

ft_uint16_t uzunligi = strlen (string);

(uzunligi -) {

Ft_Gpu_Hal_Transfer8 (host, * string);

string ++;

}

// tugatish bayrog'i sifatida bitta null qo'shing

Ft_Gpu_Hal_Transfer8 (host, 0);

}


ft_uint8_t Ft_Gpu_Hal_Transfer8 (Ft_Gpu_Hal_Context_t * host, ft_uint8_t qiymati)

{

#ifdef ARDUINO_PLATFORM_SPI

SPI.transfer (qiymat) qiymatini qaytarish;

#endif

#ifdef MSVC_PLATFORM_SPI

ft_uint32_t SizeTransfered;

agar (host-> status == FT_GPU_HAL_WRITING) {

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

} Boshqa {

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

}


agar (SizeTransfered! = sizeof (value))

host-> status = FT_GPU_HAL_STATUS_ERROR;

qaytish qiymati;

#endif

#ifdef MSVC_FT800EMU

qaytish Ft_GpuEmu_SPII2C_transfer (value);

#endif

}


ft_uint16_t Ft_Gpu_Hal_Transfer16 (Ft_Gpu_Hal_Context_t * host, ft_uint16_t qiymati)

{

ft_uint16_t retVal = 0;

agar (host-> status == FT_GPU_HAL_WRITING) {

Ft_Gpu_Hal_Transfer8 (host, value & 0xFF); // birinchi LSB

Ft_Gpu_Hal_Transfer8 (host, (qiymat >> 8) va 0xFF);

} Boshqa {

retVal = Ft_Gpu_Hal_Transfer8 (xost, 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, ft_uint32_t qiymati)

{

ft_uint32_t retVal = 0;

agar (host-> status == FT_GPU_HAL_WRITING) {

Ft_Gpu_Hal_Transfer16 (host, value & 0xFFFF); // birinchi LSB

Ft_Gpu_Hal_Transfer16 (host, (qiymat >> 16) va 0xFFFF);

} Boshqa {

retVal = Ft_Gpu_Hal_Transfer16 (xost, 0);

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

}

return retVal;

}


ft_void_t Ft_Gpu_Hal_EndTransfer (Ft_Gpu_Hal_Context_t * host)

{

#ifdef MSVC_PLATFORM_SPI

// CS-ni ajratib qo'yish - CS by 0 byte ni o'chirib qo'ying

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

#endif

#ifdef ARDUINO_PLATFORM_SPI

digitalWrite (FT_ARDUINO_PRO_SPI_CS, HIGH);

#endif

#ifdef MSVC_FT800EMU

Ft_GpuEmu_SPII2C_csHigh ();

#endif

host-> status = FT_GPU_HAL_OPENED;

}


ft_uint8_t Ft_Gpu_Hal_Rd8 (Ft_Gpu_Hal_Context_t * host, ft_uint32_tAdd)

{

ft_uint8_t qiymati;

Ft_Gpu_Hal_StartTransfer (host, FT_GPU_READ, addr);

qiymat = Ft_Gpu_Hal_Transfer8 (xost, 0);

Ft_Gpu_Hal_EndTransfer (host);

qaytish qiymati;

}

ft_uint16_t Ft_Gpu_Hal_Rd16 (Ft_Gpu_Hal_Context_t * host, ft_uint32_tAdd)

{

ft_uint16_t qiymati;

Ft_Gpu_Hal_StartTransfer (host, FT_GPU_READ, addr);

qiymat = Ft_Gpu_Hal_Transfer16 (xost, 0);

Ft_Gpu_Hal_EndTransfer (host);

qaytish qiymati;

}

ft_uint32_t Ft_Gpu_Hal_Rd32 (Ft_Gpu_Hal_Context_t * host, ft_uint32_tAdd)

{

ft_uint32_t qiymati;

Ft_Gpu_Hal_StartTransfer (host, FT_GPU_READ, addr);

qiymat = Ft_Gpu_Hal_Transfer32 (xost, 0);

Ft_Gpu_Hal_EndTransfer (host);

qaytish qiymati;

}

ft_void_t Ft_Gpu_Hal_Wr8 (Ft_Gpu_Hal_Context_t * host, ft_uint32_tAdd, ft_uint8_t v)

{

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_tAdd, ft_uint16_t v)

{

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_tAdd, ft_uint32_t v)

{

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)

{

#ifdef MSVC_PLATFORM_SPI

ft_uint8_t Transfer_Array [3];

ft_uint32_t SizeTransfered;


Transfer_Array [0] = cmd;

Transfer_Array [1] = 0;

Transfer_Array [2] = 0;


SPI_Write (host-> hal_handle, Transfer_Array, sizeof (Transfer_Array), & SizeTransfered, 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

// FT800EMUda bajarilmaydi

#endif

}


ft_void_t Ft_Gpu_ClockSelect (Ft_Gpu_Hal_Context_t * host, FT_GPU_PLL_SOURCE_T pllsource)

{

Ft_Gpu_HostCommand (host, pllsource);

}

ft_void_t Ft_Gpu_PLL_FreqSelect (Ft_Gpu_Hal_Context_t * host, FT_GPU_PLL_FREQ_T freq)

{

Ft_Gpu_HostCommand (host, freq);

}

ft_void_t Ft_Gpu_PowerModeSwitch (Ft_Gpu_Hal_Context_t * host, FT_GPU_POWER_MODE_T pwrmode)

{

Ft_Gpu_HostCommand (host, pwrmode);

}

ft_void_t Ft_Gpu_CoreReset (Ft_Gpu_Hal_Context_t * host)

{

Ft_Gpu_HostCommand (host, 0x68);

}


ft_void_t Ft_Gpu_Hal_Updatecmdfifo (Ft_Gpu_Hal_Context_t * host, ft_uint16_t hisoblash)

{

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


// 4 bayt hizalamasi

host-> ft_cmd_fifo_wp = (host-> ft_cmd_fifo_wp + 3) va 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)

{

ft_uint16_t to'liqligi, retval;


fullness = (host-> ft_cmd_fifo_wp - Ft_Gpu_Hal_Rd16 (host, REG_CMD_READ)) va 4095;

retval = (FT_CMD_FIFO_SIZE - 4) - to'liqlik;

orqaga qaytish (retval);

}

ft_void_t Ft_Gpu_Hal_WrCmdBuf (Ft_Gpu_Hal_Context_t * host, ft_uint8_t * bufer, ft_uint16_t hisoblash)

{

ft_uint32_t uzunligi = 0, SizeTransfered = 0;

#define MAX_CMD_FIFO_TRANSFER Ft_Gpu_Cmdfifo_Freespace (host)

do {

uzunlik = son;

agar (uzunlik> MAX_CMD_FIFO_TRANSFER) {

uzunlik = MAX_CMD_FIFO_TRANSFER;

}

Ft_Gpu_Hal_CheckCmdBuffer (mezbon, uzunlik);


Ft_Gpu_Hal_StartCmdTransfer (host, FT_GPU_WRITE, uzunlik);

#if belgilangan (ARDUINO_PLATFORM_SPI) || belgilangan (MSVC_FT800EMU)

SizeTransfered = 0;

(uzunligi-) {

Ft_Gpu_Hal_Transfer8 (host, * buffer);

bufer ++;

SizeTransfered ++;

}

uzunlik = hajmiTransfered;

#endif


#ifdef MSVC_PLATFORM_SPI

{

SPI_Write (host-> hal_handle, bufer, uzunlik va hajmiTransfer, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES);

uzunlik = hajmiTransfered;

bufer + = hajmiTransfered;

}

#endif

Ft_Gpu_Hal_EndTransfer (host);

Ft_Gpu_Hal_Updatecmdfifo (mezbon, uzunlik);


Ft_Gpu_Hal_WaitCmdfifo_empty (host);


hisoblash - = uzunligi;

} while (son,> 0);

}

#ifdef ARDUINO_PLATFORM_SPI

ft_void_t Ft_Gpu_Hal_WrCmdBufFromFlash (Ft_Gpu_Hal_Context_t * host, FT_PROGMEM ft_prog_uchar8_t * bufer, ft_uint16_t hisoblash)

{

ft_uint32_t uzunligi = 0, SizeTransfered = 0;

#define MAX_CMD_FIFO_TRANSFER Ft_Gpu_Cmdfifo_Freespace (host)

do {

uzunlik = son;

agar (uzunlik> MAX_CMD_FIFO_TRANSFER) {

uzunlik = MAX_CMD_FIFO_TRANSFER;

}

Ft_Gpu_Hal_CheckCmdBuffer (mezbon, uzunlik);


Ft_Gpu_Hal_StartCmdTransfer (host, FT_GPU_WRITE, uzunlik);



SizeTransfered = 0;

(uzunligi-) {

Ft_Gpu_Hal_Transfer8 (host, ft_pgm_read_byte_near (bufer));

bufer ++;

SizeTransfered ++;

}

uzunlik = hajmiTransfered;


Ft_Gpu_Hal_EndTransfer (host);

Ft_Gpu_Hal_Updatecmdfifo (mezbon, uzunlik);


Ft_Gpu_Hal_WaitCmdfifo_empty (host);


hisoblash - = uzunligi;

} while (son,> 0);

}

#endif

ft_void_t Ft_Gpu_Hal_CheckCmdBuffer (Ft_Gpu_Hal_Context_t * host, ft_uint16_t hisoblash)

{

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)

{

(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 * bufer, ft_uint16_t hisoblash)

{

ft_uint32_t uzunligi = 0, SizeTransfered = 0;

#define MAX_CMD_FIFO_TRANSFER Ft_Gpu_Cmdfifo_Freespace (host)

do {

uzunlik = son;

agar (uzunlik> MAX_CMD_FIFO_TRANSFER) {

uzunlik = MAX_CMD_FIFO_TRANSFER;

}

Ft_Gpu_Hal_CheckCmdBuffer (mezbon, uzunlik);


Ft_Gpu_Hal_StartCmdTransfer (host, FT_GPU_WRITE, uzunlik);


// # ifdef ARDUINO_PLATFORM_SPI

#if belgilangan (ARDUINO_PLATFORM_SPI) || belgilangan (MSVC_FT800EMU)

SizeTransfered = 0;

(uzunligi-) {

Ft_Gpu_Hal_Transfer8 (host, * buffer);

bufer ++;

SizeTransfered ++;

}

uzunlik = hajmiTransfered;

#endif

#ifdef MSVC_PLATFORM_SPI

{

SPI_Write (host-> hal_handle, bufer, uzunlik va hajmiTransfer, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES);

uzunlik = hajmiTransfered;

bufer + = hajmiTransfered;

}

#endif


Ft_Gpu_Hal_EndTransfer (host);

Ft_Gpu_Hal_Updatecmdfifo (mezbon, uzunlik);


// Ft_Gpu_Hal_WaitCmdfifo_empty (host);


hisoblash - = uzunligi;

} while (son,> 0);

}



ft_uint8_t Ft_Gpu_Hal_WaitCmdfifo_empty_status (Ft_Gpu_Hal_Context_t * host)

{

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

{

qaytish 0;

}

boshqa

{

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

1-qaytish;

}

}


ft_void_t Ft_Gpu_Hal_WaitLogo_Finish (Ft_Gpu_Hal_Context_t * host)

{

ft_int16_t cmdrdptr, cmdwrptr;


do {

cmdrdptr = Ft_Gpu_Hal_Rd16 (host, REG_CMD_READ);

cmdwrptr = Ft_Gpu_Hal_Rd16 (host, REG_CMD_WRITE);

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

{

host-> ft_dl_buff_wp = 0;

}

/ * Bir kuch aylanishi uchun FT800 kengashining PD_N pinini almashtiring * /

ft_void_t Ft_Gpu_Hal_Powercycle (Ft_Gpu_Hal_Context_t * host, ft_bool_t yuqoriga)

{

agar (yuqoriga)

{

#ifdef MSVC_PLATFORM

FT_WriteGPIO (host-> hal_handle, 0xBB, 0x08); // PDN 0 ga o'rnatilgan, MPSSE ning BLUE telini PDN # FT800 kartasiga ulang

Ft_Gpu_Hal_Sleep (20);


FT_WriteGPIO (host-> hal_handle, 0xBB, 0x88); // PDN 1 ga o'rnatildi

Ft_Gpu_Hal_Sleep (20);

#endif

#ifdef ARDUINO_PLATFORM

digitalWrite (FT800_PD_N, LOW);

Ft_Gpu_Hal_Sleep (50);


digitalWrite (FT800_PD_N, yuqori);

Ft_Gpu_Hal_Sleep (50);

#endif

} boshqa

{

#ifdef MSVC_PLATFORM

FT_WriteGPIO (host-> hal_handle, 0xBB, 0x88); // PDN 1 ga o'rnatildi

Ft_Gpu_Hal_Sleep (20);

FT_WriteGPIO (host-> hal_handle, 0xBB, 0x08); // PDN 0 ga o'rnatilgan, MPSSE ning BLUE telini PDN # FT800 kartasiga ulang

Ft_Gpu_Hal_Sleep (20);

#endif

#ifdef ARDUINO_PLATFORM

digitalWrite (FT800_PD_N, yuqori);

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_tAdr, const ft_prog_uchar8_t * bufer, ft_uint32_t uzunligi)

{

ft_uint32_t SizeTransfered = 0;


Ft_Gpu_Hal_StartTransfer (host, FT_GPU_WRITE, addr);


#if belgilangan (ARDUINO_PLATFORM_SPI) || belgilangan (MSVC_FT800EMU)

(uzunligi-) {

Ft_Gpu_Hal_Transfer8 (host, ft_pgm_read_byte_near (bufer));

bufer ++;

}

#endif


#ifdef MSVC_PLATFORM_SPI

{

SPI_Write ((FT_HANDLE) host-> hal_handle, bufer, uzunlik va hajmiTransfere, 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_tAdr, const ft_uint8_t * bufer, ft_uint32_t uzunligi)

{

ft_uint32_t SizeTransfered = 0;


Ft_Gpu_Hal_StartTransfer (host, FT_GPU_WRITE, addr);


#if belgilangan (ARDUINO_PLATFORM_SPI) || belgilangan (MSVC_FT800EMU)

(uzunligi-) {

Ft_Gpu_Hal_Transfer8 (host, * buffer);

bufer ++;

}

#endif


#ifdef MSVC_PLATFORM_SPI

{

SPI_Write ((FT_HANDLE) host-> hal_handle, bufer, uzunlik va hajmiTransfere, 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_tAdd, ft_uint8_t * bufer, ft_uint32_t uzunligi)

{

ft_uint32_t SizeTransfered = 0;


Ft_Gpu_Hal_StartTransfer (host, FT_GPU_READ, addr);


#if belgilangan (ARDUINO_PLATFORM_SPI) || belgilangan (MSVC_FT800EMU)

(uzunligi-) {

* bufer = Ft_Gpu_Hal_Transfer8 (xost, 0);

bufer ++;

}

#endif


#ifdef MSVC_PLATFORM_SPI

{

SPI_Read ((FT_HANDLE) host-> hal_handle, bufer, uzunlik, & SizeTransfer, SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES);

}

#endif


Ft_Gpu_Hal_EndTransfer (host);

}


ft_int32_t Ft_Gpu_Hal_Dec2Ascii (ft_char8_t * pSrc, ft_int32_t qiymati)

{

ft_int16_t uzunligi;

ft_char8_t * pdst, charval;

ft_int32_t CurrVal = qiymat, tmpval, i;

ft_char8_t tmparray [16], idx = 0;


Length = strlen (pSrc);

pdst = pSrc + uzunligi;


agar (0 == qiymat)

{

* pdst ++ = '0';

* pdst ++ = '';

qaytish 0;

}


agar (CurrVal <>

{

* pdst ++ = '-';

CurrVal = - CurrVal;

}

/ * qiymatini kiriting * /

(CurrVal> 0) {

tmpval = CurrVal;

CurrVal / = 10;

tmpval = tmpval - CurrVal * 10;

charval = '0' + tmpval;

tmparray [idx ++] = charval;

}


(i = 0; i

{

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

}

* pdst ++ = '';


qaytish 0;

}


ft_void_t Ft_Gpu_Hal_Sleep (ft_uint16_tm)

{

#if belgilangan (MSVC_PLATFORM) || belgilangan (MSVC_FT800EMU)

Kutish (milodiy);

#endif

#ifdef ARDUINO_PLATFORM

kechiktirish (milodiy);

#endif

}