Bosh sahifa > Yangiliklar > Kontent

FT8xx misol ilovasida FT8xx emulyatorini qanday ishlatish kerakligi haqidagi misol

Apr 26, 2019

3 FT8xx Emulator kutubxonasidan foydalanish

Ushbu bo'lim FT8xx emulyatorini FT8xx misolida qanday ishlatish mumkinligi haqida ma'lumot beradi

dastur. Foydalanuvchilar FT8xx namunasi arizasi bilan tanishib chiqishlari tavsiya etiladi

(keyingi sahifada Sample App (+ EVE2) bo'limiga qarang).

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

FT8xx emulyator interfeysi quyidagi fayllarda aniqlanadi:

"Ft800emu_inttypes.h": turli platformalar uchun tamsayt turi uchun ta'rif.

"Ft800emu_spi_i2c.h": SPI / I

2C interfeysi deklaratsiyasi

"Ft800emu_emulator.h": emulyatorni ishga tushirish uchun interfeys

3.1 FT800 emulyatorini ishga tushiring

FT800 emulyatoridan foydalanish uchun foydalanuvchilar loyihasi APIni chaqirishlari kerak

"FT800EMU :: Emulator.run" maxsus parametr bilan. Emulyator kutubxonasi ishga tushiriladi

to'g'ri va SPI / I orqali kirishga tayyor

2C interfeysi.

Iltimos, 3-rasmga qarang - FT8xx emulyatorini ishga tushiring.

3.2 SPI / I2C interfeysi bilan ishlash.

SPI / I2C interfeysi FT800 ning boshqaruv interfeysidir. FT800 emulyator kutubxonasi API ni taqdim etadi

bir xil interfeysni simulyatsiya qilish. FT800 misol ilovasi C tilida yaratilganligi sababli

C ++, bitta oddiy C API sarlavhasi quyida keltirilgan konventsiyani osonlashtirish uchun kiritilgan.


#ifdef __cplusplus

tashqi "C" {

#endif

#ifdef MSVC_FT800EMU

# BUFFER_OPTIMIZATIONni belgilash

#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_tAdd);

uint8_t Ft_GpuEmu_SPII2C_transfer (uint8_t ma'lumotlar);

void Ft_GpuEmu_SPII2C_StartWrite (uint32_tAdd);

#ifdef __cplusplus

}

#endif

Shakl 4 - C interfeysi API

Quyidagilar amalga oshiriladi:

void Ft_GpuEmu_SPII2C_begin ()

{

FT800EMU :: SPII2C.begin ();

}

void Ft_GpuEmu_SPII2C_csLow ()

{

FT800EMU :: SPII2C.csLow ();

}

void Ft_GpuEmu_SPII2C_csHigh ()

{

FT800EMU :: SPII2C.csHigh ();

}

void Ft_GpuEmu_SPII2C_end ()

{

FT800EMU :: SPII2C.end ();

}

uint8_t Ft_GpuEmu_SPII2C_transfer (uint8_t ma'lumotlar)

{

qaytish FT800EMU :: SPII2C.transfer (ma'lumotlar);

}

void Ft_GpuEmu_SPII2C_StartRead (uint32_tAdd)

{

Ft_GpuEmu_SPII2C_csLow ();

Ft_GpuEmu_SPII2C_transfer ((addr >> 16) va 0xFF);

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

Ft_GpuEmu_SPII2C_transfer (addr & 0xFF);

Ft_GpuEmu_SPII2C_transfer (0); // Dummy Read Byte

}

void Ft_GpuEmu_SPII2C_StartWrite (uint32_tAdd)

{

Ft_GpuEmu_SPII2C_csLow ();

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

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

Ft_GpuEmu_SPII2C_transfer (addr & 0xFF);

}

5-rasm - C API dasturini amalga oshirish

3.3. Ilovani moslashtirish

FT800 misol dasturida dasturni amalga oshirish uchun apparatni ajratish qatlami (HAL) ishlatiladi

mantiq apparat platformasidan mustaqil emas. "FT_Gpu_Hal.c" da belgilanadi va foydalanuvchilar

oldinga harakat qilishdan oldin u bilan tanish bo'lgan.

FT800 emulyatoriga namuna dasturini moslashtirish uchun minimal o'zgarishlar talab etiladi: faqat

"FT_Gpu_Hal.c" da ta'riflangan API-larni quyidagi tarzda bajarish kerak:

Ft_GpuEmu_SPII2C_end ();

}

ft_void_t Ft_Gpu_Hal_DeInit ()

{

}

/ * 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_t addr)

{

agar (FT_GPU_READ == rw) {

Ft_GpuEmu_SPII2C_StartRead (addr);

host-> status = FT_GPU_HAL_READING;

} Boshqa {

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 qiymati)

{

qaytish Ft_GpuEmu_SPII2C_transfer (value);

}

ft_void_t Ft_Gpu_Hal_EndTransfer (Ft_Gpu_Hal_Context_t * host)

{

Ft_GpuEmu_SPII2C_csHigh ();

host-> status = FT_GPU_HAL_OPENED;

}

ft_void_t Ft_Gpu_HostCommand (Ft_Gpu_Hal_Context_t * host, ft_uint8_t cmd)

{

// FT800EMUda bajarilmaydi. Emulyatorda Quvvatni boshqarish xususiyati yo'q.

}

ft_void_t Ft_Gpu_Hal_WrMem (Ft_Gpu_Hal_Context_t * host, ft_uint32_tAdd, const

ft_uint8_t * bufer, ft_uint32_t uzunligi)

{

ft_uint32_t SizeTransfered = 0;

Ft_Gpu_Hal_StartTransfer (host, FT_GPU_WRITE, addr);

(uzunligi-) {

Ft_Gpu_Hal_Transfer8 (host, * buffer);

bufer ++;

}

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);

(uzunligi-) {

* bufer = Ft_Gpu_Hal_Transfer8 (xost, 0);

bufer ++;

}

Ft_Gpu_Hal_EndTransfer (host);

}

Shakl 6 - Emulator API-da apparatni ajratish qatlamini joriy qilish