Tsev > Xov xwm > Ntsiab lus

FT8xx Emulator Library Introduction

Apr 26, 2019

2 FT8xx Emulator Library Introduction

2.1 FT8xx Emulator Library Interface

Lub interface ntawm FT8xx Emulator qiv sau hauv C ++ thiab nyob hauv lub npe "FT800EMU ::" lub npe

qhov chaw xwb. Nyob rau ntawm "FT800EMU ::" lub npe, muaj ob qhov "SPII2C" thiab

"Emulator" exposing interface. Ntawm no yog cov qauv:

image

Rooj ntawv 1 - FT8xx Emulator lub tsev qiv ntawv kev sib tham

2.1.1 FT800EMU :: SPII2C.begin ()

 Pov Tseg

tsis muaj dabtsis pib ();

 Nqe lus piav qhia

Initialize lub SPI / I2C module ntawm Emulator

 Tus nqi rov qab

Tsis muaj

 Parameter

Tsis muaj

2.1.2 FT800EMU :: SPII2C.end ()

 Pov Tseg

void xaus ();

 Nqe lus piav qhia

De-Initialize SPI / I2C module ntawm lub Emulator

 Tus nqi rov qab

Tsis muaj

 Parameter

Tsis muaj


2.1.3 FT800EMU :: SPII2C.csLow ()

 Pov Tseg

void csLow ();

 Nqe lus piav qhia

Hu rau API no los pib ib qho kev hloov SPI / I2C. Nws yog sib npaug kom rub tus ntiv tes xaiv tus pin

SPI / I2C tsheb npav nyob hauv FT8xx hardware. Rau kuv

2C npav, qhov no muaj peev xwm ua kom pib ib qho

lus nrog ib pib.

 Tus nqi rov qab

Tsis muaj

 Parameter

Tsis muaj


2.1.4 FT800EMU :: SPII2C.csHigh ()

 Pov Tseg

void csHigh ();

 Nqe lus piav qhia

Hu rau API no los xaus ib qho kev hloov SPI / I2C. Rau lub tsheb npav SPI, nws zoo ib yam li rub tawm nti xaiv

pin tus siab ntawm SPI / kuv

2C tsheb npav nyob hauv FT8xx hardware. Rau kuv

2C tsheb npav, qhov no zoo sib xws

xaus lus nrog ib qho NRES.

 Tus nqi rov qab

Tsis muaj

 Parameter

Tsis muaj


2.1.5 FT800EMU :: SPII2C.transfer ()

 Pov Tseg

uint8_t hloov (cov ntaub ntawv uint8_t);

 Nqe lus piav qhia

Hu rau API no yog xa ib daim ntawv los ntawm / los rau emulator.

Cov ntaub ntawv yuav tsum tau xa mus yog teev raws li ib qho parameter, thaum cov ntaub ntawv tau txais yog muab ua ib qho

rov qab muaj nqis.

 Tus nqi rov qab

Ib cov ntawv byte ntawm cov ntaub ntawv tau txais los ntawm FT8xx emulator yog tias nws nyeem ntawv hloov.

 Parameter

Ib tug byte ntawm cov ntaub ntawv xa mus rau FT8xx emulator. Nyob rau hauv cov ntaub ntawv ntawm kev hloov mus rau SPI, no byte yuav ua tau

txhua yam.


2.1.6 FT800EMU :: Emulator.run ()

 Pov Tseg

tsis muaj dabtsis khiav (const EmulatorParameters & params);

 Nqe lus piav qhia

Hu rau qhov kev ua haujlwm no yuav pib lub emulator tam sim ntawd thiab daim ntawv thov tswj yog

pauv mus rau lub emulator. Tus emulator tus cwj pwm yog teeb tsa los ntawm

tsis tau muab tso rau hauv. Daim ntawv thov lub npe yuav raug hu los ntawm ob

callback zog hauv cov qauv parameter. API no yuav tsum tsis txhob rov qab, tshwj tsis yog tias emulator

raug tua los yog ua daim ntawv thov txheej txheem.

 Tus nqi rov qab

Tsis muaj

 Cov qhoos kas

Thov kos cov cai nram qab no kom paub meej txog qhov kev txhais ntawm parameter.


1) Kev txhais ntawm cov qauv parameter

typedef struct

{

// Microcontroller muaj nuj nqi hu ua ua ntej lub voj.

void (* teeb) ();

// Microcontroller nruam voj.

void (* looj) ();

// Saib EmulatorFlags.

tus chij;

// Emulator hom

FT8XXEMU_EmulatorMode hom;

// Hu tom qab hloov cov keyboard.

Cov khoom siv muaj peev xwm siv tau Keyboard.isKeyDown (FT8XXEMU_KEY_F3)

// los yog FT8XXEMU_isKeyDown (FT8XXEMU_KEY_F3) functions.

void (* Keyboard) ();

// Lub neej tsis zoo siab, vim 0 (ntau tshaj).

// Saib REG_TOUCH_RZTRESH, thiab lwm yam.

uint32_t MousePressure;

// Sab nraud zaus. Saib CLK, yam.

uint32_t ExternalFrequency;

// Txo cov graphics processor threads los ntawm cov zauv uas teev tseg, vim 0

// Tsim nyog thaum ua haujlwm hnyav heev hauv MCU los yog Tus Cwj Pwm

uint32_t ReduceGraphicsThreads;

// Pw tsaug zog muaj nuj nqi rau MCU xov xov throttle. Cov kev tawg rau qhov system

pw

void (* MCUSleep) (int ms);

// Replaces lub neej ntawd builtin ROM nrog ib tus ROM kev cai los ntawm cov ntaub ntawv.

// CEEB TOOM: Txoj hlua yog theej thiab tej zaum yuav raug deallocated tom qab hu mus khiav (...)

char * RomFilePath;

/ / Hloov cov neeg ua haujlwm nyob hauv OTP nrog ib qho kev cai OTP los ntawm cov ntaub ntawv.

// CEEB TOOM: Txoj hlua yog theej thiab tej zaum yuav raug deallocated tom qab hu mus khiav (...)

char * OtpFilePath;

/ / / Replaces tus builtin coprocessor ROM.

// CEEB TOOM: Txoj hlua yog theej thiab tej zaum yuav raug deallocated tom qab hu mus khiav (...)

char * CoprocessorRomFilePath;

Graphics hom tsis tau

// Kho qhov callback txhais tau hais tias tsis muaj qhov rais qhib, thiab tag nrho

// nws daim duab yuav raug xa mus rau qhov haujlwm no.

// Rau kev ua haujlwm ua haujlwm, ua haujlwm

// Memory.setTouchScreenXY thiab Memory.resetTouchScreenXY yuav tsum yog

// hu ua manually los ntawm lub party daim ntawv thov.

// Builtin keyboard functionality yog tsis txaus siab thiab yuav tsum yog

// dais manually thaum siv hom no.

/ / Cov zauv parameter yog cuav (0) thaum lub tso tawm.

Cov ntsiab lus ntawm cov tsis pointer no undefined tom qab qhov no

// kev ua haujlwm rov qab.

// Rov qab cuav (0) thaum daim ntawv thov yuav tsum tawm, tsis li rov qab tseeb (1).

int (* Graphics) (cov menyuam muaj zis, const argb8888 * tsis, uint32_t hsize, uint32_t

vsize, FT8XXEMU_FrameFlags chij);

// Interrupt handler

/ void (* Interrupt) ();

// Ntxwv callback

void (* zam) (const char * lus);

// Safe tawm tawm

tsis muaj dabtsis (* kaw) ();

} FT8XXEMU_EmulatorParameters;

Xam 1 - Kev txhais ntawm cov qauv "EmulatorParameters"


2) Chij los txhim kho rau tus emulator

Cov qauv code suav qhia hauv qab no txhais cov emulator feature yuav tsum khiav mus nrog. Yuav

pab kom muaj cov nta, koj tuaj yeem "LOSSIS" cov ntawv suav no thiab muab qhov txiaj ntsim tshwm rau

"Chij" teb nyob rau hauv cov qauv parameter "EmulatorParameters" saum toj no.

typedef enum

{

// enables cov keyboard yuav tsum siv li input (default: on)

FT8XXEMU_EmulatorEnableKeyboard = 0x01,

// enables suab (default: on)

FT8XXEMU_EmulatorEnableAudio = 0x02,

// enables coprocessor (default: on)

FT8XXEMU_EmulatorEnableCoprocessor = 0x04,

// enables mouse kov (default: on)

FT8XXEMU_EmulatorEnableMouse = 0x08,

// enable debug shortkeys (default: on)

FT8XXEMU_EmulatorEnableDebugShortkeys = 0x10,

/ / pab kom tau graphics processor multithreading (default: on)

FT8XXEMU_EmulatorEnableGraphicsMultithread = 0x20,

/ / pab kom tau qhov zoo ntawm cov duab kos zoo nkauj los ntawm kev sib tshuam thiab xa me me

(default: on)

FT8XXEMU_EmulatorEnableDynamicDegrade = 0x40,

// enable emulating REG_PWM_DUTY los ntawm fading tus tso saib kom dub

(default: tawm)

FT8XXEMU_EmulatorEnableRegPwmDutyExulation = 0x100,

// enable siv ntawm kov transformation matrix (default: on)

FT8XXEMU_EmulatorEnableTouchTransformation = 0x200,

} FT8XXEMU_EmulatorFlags;

Xam 2 - Chij teb txhais


3) Qhov chaw

Rau kev pom kev ua tau zoo, cov chaw hauv qab no raug pom zoo.

Qhov kev rov qab ua haujlwm "setup ()" thiab "loop ()" yuav raug txhais los ntawm tus neeg siv qhov project thiab lawv yuav yog

hu los ntawm tus emulator. Muaj nuj nqi "teeb ()" yog kwv yees khiav ib zaug los ntawm tus emulator rau initialization

lub hom phiaj. Kev ua haujlwm "loop ()" yuav raug hu los ntawm tus emulator. Cov hauj lwm ob no muaj tseeb

tus neeg siv qhov project yog nyob rau hauv lub ntsiab lus ntawm lub emulator. Qhov tsis ua ntawm kev tso "setup ()" thiab "loop ()"

rau cov emulator yuav ua rau tsis muaj tswv yim rau tus emulator.

Feem ntau, qhov kev ua haujlwm "setup ()" thiab "loop ()" nyob rau hauv cov neeg siv "qhov qhauj siv cov ntsiab logic thiab cov lus

cov npe yuav raug xa mus rau emulator los ntawm SPI / I2C interface.

#include "FT_Platform.h"

#ifdef MSVC_FT800EMU

#include

FT8XXEMU_EmulatorMode Ft_GpuEmu_Mode ();

extern "C" void setup ();

extern "C" void voj ();

ft_int32_t lub ntsiab (ft_int32_t argc, ft_char8_t * argv [])

{

FT8XXEMU_EmulatorParameters params;

FT8XXEMU_defaults (FT8XXEMU_VERSION_API, & params, Ft_GpuEmu_Mode ());

params.Flags & = (~ FT8XXEMU_EmulatorEnableDynamicDegrade &

~ FT8XXEMU_EmulatorEnableRegPwmDutyEmulation);

params.Setup = teeb;

params.Loop = loop;

/ params.Graphics = graphics;

FT8XXEMU_run (FT8XXEMU_VERSION_API, & params);

rov qab 0;

}

Daim duab 3 - Pib FT8xx emulator