Tsev > Xov xwm > Ntsiab lus

Piv txwv li seb yuav siv Tus FT8xx Emulator Hauv Daim Ntawv Thov FT8xx

Apr 26, 2019

3 Siv lub library FT8xx Emulator

Tshooj lus no yuav muab ib qho piv txwv txog kev siv tus FT8xx emulator hauv tus qauv FT8xx

daim ntawv thov. Cov neeg siv raug txhawb kom paub lawv tus kheej nrog rau daim ntawv thov FT8xx

(saib Tshooj Ntawv App (+ EVE2) ntawm nplooj ntawv nram no) ua ntej pib tshooj lus no.

http://www.ftdichip.com/Support/SoftwareExamples/FT800_Projects.htm

Tus FT8xx emulator interface txhais hauv cov ntaub ntawv hauv qab no:

"Ft800emu_inttypes.h": txhais tias integer yam rau nyias platforms.

"Ft800emu_spi_i2c.h": tus SPI / kuv

2C interface tshaj tawm

"Ft800emu_emulator.h": lub interface pib lub emulator

3.1 Pib lub FT800 emulator

Txhawm rau siv cov FT800 emulator, cov neeg siv 'qhov dej num yuav tsum tau hu rau API

"FT800EMU :: Emulator.run" nrog lub ntsiab parameter. Lub tsev khaws ntawv emulator yuav pib

kom zoo thiab npaj txhij yuav raug nkag tau los ntawm SPI / kuv

2C interface.

Thov saib Xam 3 - Pib FT8xx emulator.

3.2 Ua haujlwm nrog rau SPI / I2C interface.

SPI / I2C interface yog tus tswj interface ntawm FT800. FT800 emulator tsev qiv ntawv muab cov APIs rau

simulate tib lub interface. Txij li FT800 qauv daim ntawv thov ua hauv C lus, tsis yog

C ++, ib qho yooj yim C API wrapper yog tswv yim raws li hauv qab no los yoojyim rau txoj kev caw hu ua.


#ifdef __cplusplus

extern "C" {

#endif

#ifdef MSVC_FT800EMU

#define BUFFER_OPTIMIZATION

#endif

void Ft_GpuEmu_SPII2C_begin ();

void Ft_GpuEmu_SPII2C_csLow ();

void Ft_GpuEmu_SPII2C_csHigh ();

void Ft_GpuEmu_SPII2C_end ();

void Ft_GpuEmu_SPII2C_StartRead (uint32_t addr);

uint8_t Ft_GpuEmu_SPII2C_transfer (uint8_t cov ntaub ntawv);

void Ft_GpuEmu_SPII2C_StartWrite (uint32_t addr);

#ifdef __cplusplus

}

#endif

Daim duab 4 - Tus API API interface

Qhov kev nqis tes ua yog raws li hauv qab no:

void Ft_GpuEmu_SPII2C_begin ()

{

FT800EMU :: SPII2C.begin ();

}

tsis muaj dab tsi Ft_GpuEmu_SPII2C_csLow ()

{

FT800EMU :: SPII2C.csLow ();

}

tsis muaj dab tsi Ft_GpuEmu_SPII2C_csHigh ()

{

FT800EMU :: SPII2C.csHigh ();

}

void Ft_GpuEmu_SPII2C_end ()

{

FT800EMU :: SPII2C.end ();

}

uint8_t Ft_GpuEmu_SPII2C_transfer (uint8_t cov ntaub ntawv)

{

rov qab FT800EMU :: SPII2C.transfer (cov ntaub ntawv);

}

void Ft_GpuEmu_SPII2C_StartRead (uint32_t addr)

{

Ft_GpuEmu_SPII2C_csLow ();

Ft_GpuEmu_SPII2C_transfer ((ntxiv rau >> 16) & 0xFF);

Ft_GpuEmu_SPII2C_transfer ((addr> 8) & 0xFF);

Ft_GpuEmu_SPII2C_transfer (addr & 0xFF);

Ft_GpuEmu_SPII2C_transfer (0); // Dummy Readte

}

void Ft_GpuEmu_SPII2C_StartWrite (uint32_t addr)

{

Ft_GpuEmu_SPII2C_csLow ();

Ft_GpuEmu_SPII2C_transfer (((addr >> 16) & 0xFF) | 0x80);

Ft_GpuEmu_SPII2C_transfer ((addr> 8) & 0xFF);

Ft_GpuEmu_SPII2C_transfer (addr & 0xFF);

}

Daim duab 5 - Qhov kev siv ntawm API C API

3.3 Ua qauv siv hloov

FT800 daim ntawv thov ua haujlwm ntiav cov khoom siv rau Hardware Abstraction Layer (HAL) los ua daim ntawv thov

logic ywj siab los ntawm cov kev kho vajtse. Nws txhais hauv "FT_Gpu_Hal.c" thiab cov neeg siv yog

xav tias nws yuav tsum paub txog nws ua ntej tsiv ua ntej.

Yuav kom hloov tus qauv daim ntawv thov ntawm tus FT800 emulator, qhov hloov tsawg tshaj plaws yuav tsum tau muaj: xwb

siv lub API hais tseg hauv "FT_Gpu_Hal.c" hauv qab no:

Ft_GpuEmu_SPII2C_end ();

}

ft_void_t Ft_Gpu_Hal_DeInit ()

{

}

/ * Cov APIs rau kev nyeem ntawv / kev sau ntaub ntawv tsis tu ncua tsuas yog siv me me xwb * /

ft_void_t Ft_Gpu_Hal_StartTransfer (Ft_Gpu_Hal_Context_t * host, FT_GPU_TRANSFERDIR_T

rw, ft_uint32_t addr)

{

yog tias (FT_GPU_READ == rw) {

Ft_GpuEmu_SPII2C_StartRead (addr);

host-> status = FT_GPU_HAL_READING;

} lwm {

Ft_GpuEmu_SPII2C_StartWrite (addr);

host-> status = FT_GPU_HAL_WRITING;

}

}

ft_uint8_t Ft_Gpu_Hal_Transfer8 (Ft_Gpu_Hal_Context_t * host, ft_uint8_t tus nqi)

{

xa Ft_GpuEmu_SPII2C_transfer (tus nqi);

}

ft_void_t Ft_Gpu_Hal_EndTransfer (Ft_Gpu_Hal_Context_t * party)

{

Ft_GpuEmu_SPII2C_csHigh ();

host-> status = FT_GPU_HAL_OPENED;

}

ft_void_t Ft_Gpu_HostCommand (Ft_Gpu_Hal_Context_t * party, ft_uint8_t cmd)

{

// Tsis siv rau hauv FT800EMU. Tsis muaj Cov Kev Tswj Fais fab hauv Cov Emulator.

}

ft_void_t Ft_Gpu_Hal_WrMem (Ft_Gpu_Hal_Context_t * party, ft_uint32_t addr, const

ft_uint8_t * tsis, ft_uint32_t ntev)

{

ft_uint32_t SizeTransfered = 0;

Ft_Gpu_Hal_StartTransfer (host, FT_GPU_WRITE, addr);

thaum (ntev--) {

Ft_Gpu_Hal_Transfer8 (tus tswv tsev, * tsis tuaj);

tsis ++;

}

Ft_Gpu_Hal_EndTransfer (tus tswv tsev);

}

ft_void_t Ft_Gpu_Hal_RdMem (Ft_Gpu_Hal_Context_t * party, ft_uint32_t addr, ft_uint8_t

* tsis, ft_uint32_t ntev)

{

ft_uint32_t SizeTransfered = 0;

Ft_Gpu_Hal_StartTransfer (host, FT_GPU_READ, addr);

thaum (ntev--) {

* ntas = Ft_Gpu_Hal_Transfer8 (party, 0);

tsis ++;

}

Ft_Gpu_Hal_EndTransfer (tus tswv tsev);

}

Daim Duab 6 - Cov Khoom Siv Txheej Txheem Kho Kev Siv tus qauv siv hauv API emulator