62 { 860, 480, 60, 800 },
73#if defined(_WIN32) && defined(EVE_MULTI_GRAPHICS_TARGET)
82 "WSVGA 1024x600 59Hz",
88 "IDM2040-7A WVGA 60Hz",
90 "Riverdi IPS 3.5\" 62Hz",
91 "Riverdi IPS 4.3\" 58Hz",
92 "Riverdi IPS 5.0\" 63Hz",
93 "Riverdi IPS 7.0\" 59Hz",
94 "Riverdi IPS 10.1\" 59Hz",
103static const char *s_HostDisplayNames[
EVE_HOST_NB] = {
112#define EVE_SELECT_CHIP_NB 14
114#if defined(EVE_MULTI_GRAPHICS_TARGET)
117static const char *s_SelectChipName[EVE_SELECT_CHIP_NB] = {
134static EVE_CHIPID_T s_SelectChipId[EVE_SELECT_CHIP_NB] = {
156#if (!defined(BT8XXEMU_PLATFORM) || defined(EVE_MULTI_PLATFORM_TARGET)) \
157 && ((EVE_SUPPORT_CHIPID == EVE_FT811) || (EVE_SUPPORT_CHIPID == EVE_FT813) || defined(EVE_MULTI_GRAPHICS_TARGET))
158#define TOUCH_DATA_LEN 1172
160 26, 255, 255, 255, 32, 32, 48, 0, 4, 0, 0, 0, 2, 0, 0, 0, 34,
161 255, 255, 255, 0, 176, 48, 0, 120, 218, 237, 84, 255, 107, 92,
162 69, 16, 159, 125, 155, 107, 141, 201, 121, 247, 106, 130, 9,
163 225, 244, 238, 37, 246, 146, 52, 63, 53, 98, 172, 53, 48, 243,
164 8, 36, 166, 182, 63, 136, 216, 246, 7, 205, 219, 75, 122, 119,
165 185, 139, 196, 128, 34, 33, 136, 123, 65, 240, 7, 31, 44, 105,
166 41, 69, 72, 12, 210, 166, 6, 17, 12, 104, 64, 165, 73, 133, 134,
167 98, 80, 74, 43, 148, 22, 20, 133, 40, 20, 34, 233, 15, 82, 250,
168 131, 10, 113, 246, 229, 106, 197, 191, 161, 111, 217, 55, 179,
169 59, 59, 59, 243, 153, 47, 251, 135, 15, 58, 204, 11, 109, 114,
170 89, 149, 84, 169, 242, 172, 2, 109, 10, 73, 53, 167, 92, 158,
171 89, 21, 6, 89, 230, 236, 126, 86, 89, 206, 242, 169, 178, 61,
172 187, 115, 62, 85, 190, 199, 133, 129, 44, 132, 249, 90, 12, 243,
173 124, 67, 49, 169, 76, 81, 22, 195, 60, 211, 113, 40, 133, 249,
174 253, 104, 114, 113, 148, 197, 131, 105, 169, 158, 3, 19, 132,
175 65, 28, 187, 240, 25, 112, 3, 147, 99, 235, 163, 80, 98, 63, 10,
176 123, 181, 208, 73, 213, 29, 24, 246, 226, 121, 112, 199, 146,
177 74, 98, 56, 22, 195, 135, 245, 32, 14, 194, 17, 180, 182, 100,
178 46, 169, 220, 114, 244, 103, 171, 114, 252, 41, 222, 143, 97,
179 150, 53, 64, 167, 202, 110, 240, 86, 186, 45, 16, 90, 14, 191,
180 158, 110, 196, 163, 216, 130, 241, 232, 159, 42, 251, 88, 4,
181 169, 90, 80, 42, 163, 226, 248, 168, 206, 97, 132, 136, 169, 69,
182 113, 20, 27, 245, 203, 40, 131, 12, 54, 87, 37, 143, 253, 43,
183 105, 97, 137, 9, 172, 103, 181, 26, 172, 79, 163, 102, 184, 142,
184 57, 83, 0, 61, 139, 144, 159, 79, 135, 193, 62, 61, 0, 157, 250,
185 5, 20, 186, 67, 91, 255, 133, 238, 140, 104, 167, 30, 192, 197,
186 72, 2, 85, 137, 221, 89, 134, 101, 140, 177, 191, 238, 137, 75,
187 105, 137, 23, 97, 18, 226, 31, 175, 98, 31, 174, 165, 141, 90,
188 193, 21, 88, 194, 117, 60, 207, 243, 115, 248, 202, 254, 171,
189 171, 37, 248, 20, 87, 112, 17, 59, 180, 59, 246, 35, 199, 177,
190 83, 175, 35, 140, 93, 224, 187, 172, 45, 169, 172, 108, 29, 47,
191 192, 59, 186, 70, 159, 1, 208, 155, 136, 40, 71, 190, 195, 101,
192 222, 117, 131, 221, 90, 142, 110, 48, 221, 85, 165, 177, 42,
193 173, 169, 82, 89, 165, 78, 149, 138, 136, 110, 224, 13, 108,
194 200, 0, 132, 1, 50, 103, 114, 55, 176, 145, 254, 51, 132, 208,
195 183, 177, 137, 64, 111, 128, 192, 13, 104, 162, 86, 145, 165,
196 198, 255, 141, 86, 209, 68, 79, 146, 84, 87, 33, 163, 95, 132,
197 39, 120, 182, 242, 76, 115, 78, 123, 40, 142, 7, 200, 227, 21,
198 103, 50, 103, 171, 109, 123, 27, 242, 115, 193, 0, 197, 176, 70,
199 63, 141, 125, 212, 35, 14, 8, 95, 28, 20, 246, 116, 155, 30,
200 132, 152, 118, 3, 40, 29, 162, 62, 60, 158, 9, 131, 8, 197, 120,
201 49, 99, 115, 35, 39, 228, 200, 168, 48, 81, 197, 2, 175, 221,
202 224, 205, 140, 173, 148, 4, 87, 13, 148, 94, 19, 235, 216, 205,
203 62, 212, 179, 14, 199, 221, 234, 21, 223, 207, 112, 254, 163,
204 90, 169, 197, 247, 50, 110, 249, 16, 249, 156, 113, 137, 83, 98,
205 146, 163, 23, 215, 115, 16, 146, 173, 102, 142, 158, 74, 160,
206 205, 181, 28, 217, 67, 93, 156, 121, 40, 156, 202, 76, 130, 169,
207 184, 193, 12, 9, 125, 82, 132, 149, 121, 209, 65, 219, 198, 12,
208 47, 80, 7, 15, 182, 163, 97, 52, 171, 206, 211, 20, 186, 229,
209 195, 148, 42, 15, 137, 45, 116, 244, 29, 188, 138, 105, 177, 76,
210 139, 149, 18, 113, 141, 160, 192, 1, 218, 222, 14, 131, 101, 90,
211 224, 17, 195, 239, 51, 113, 156, 194, 111, 245, 21, 49, 137,
212 171, 100, 61, 238, 21, 166, 50, 67, 95, 83, 63, 154, 202, 71,
213 116, 141, 45, 205, 208, 37, 94, 133, 188, 186, 201, 177, 134,
214 82, 86, 117, 84, 109, 46, 137, 52, 237, 214, 102, 248, 22, 253,
215 82, 41, 137, 91, 148, 37, 29, 97, 147, 195, 86, 126, 89, 156,
216 165, 45, 214, 188, 43, 54, 43, 160, 63, 36, 139, 169, 142, 17,
217 73, 175, 31, 255, 230, 232, 164, 175, 244, 161, 197, 38, 71,
218 118, 121, 70, 109, 226, 43, 252, 14, 100, 249, 142, 135, 180,
219 156, 48, 185, 45, 172, 176, 247, 71, 244, 29, 104, 240, 25, 3,
220 37, 216, 78, 179, 159, 101, 171, 9, 63, 225, 95, 166, 6, 126,
221 71, 24, 29, 156, 165, 199, 253, 126, 108, 119, 88, 51, 146, 216,
222 19, 191, 137, 102, 191, 107, 186, 68, 109, 78, 247, 244, 95,
223 130, 99, 94, 134, 49, 183, 128, 158, 84, 207, 58, 245, 129, 9,
224 220, 145, 78, 16, 218, 85, 102, 226, 94, 102, 142, 121, 247, 51,
225 243, 146, 119, 63, 51, 3, 14, 71, 157, 94, 245, 86, 169, 151,
226 134, 156, 99, 212, 206, 189, 148, 208, 9, 109, 239, 43, 242,
227 125, 57, 135, 249, 19, 111, 120, 245, 182, 79, 121, 218, 62,
228 110, 231, 222, 203, 57, 220, 245, 52, 237, 217, 126, 246, 253,
229 183, 89, 95, 59, 59, 145, 238, 165, 15, 28, 91, 45, 86, 239,
230 140, 215, 231, 199, 56, 34, 59, 239, 154, 239, 159, 244, 38, 57,
231 63, 167, 156, 41, 126, 95, 14, 83, 82, 189, 203, 183, 244, 51,
232 186, 33, 39, 12, 234, 244, 105, 156, 79, 111, 161, 100, 186,
233 232, 37, 25, 187, 195, 253, 252, 137, 35, 245, 2, 243, 54, 207,
234 243, 8, 176, 143, 109, 175, 225, 57, 92, 131, 71, 248, 220, 151,
235 222, 113, 255, 28, 26, 114, 131, 139, 17, 130, 111, 24, 65, 63,
236 235, 157, 198, 90, 188, 238, 213, 251, 63, 120, 130, 59, 151,
237 187, 130, 95, 193, 207, 252, 26, 214, 221, 175, 215, 240, 186,
238 211, 85, 217, 197, 107, 67, 123, 113, 15, 217, 42, 252, 201,
239 155, 245, 133, 94, 131, 122, 255, 87, 207, 80, 143, 215, 238,
240 91, 47, 126, 247, 106, 248, 204, 159, 153, 187, 116, 219, 49,
241 116, 45, 115, 147, 182, 48, 242, 4, 190, 240, 127, 118, 224,
242 193, 247, 224, 3, 89, 247, 15, 148, 99, 211, 103, 26, 255, 255,
243 255, 20, 33, 48, 0, 4, 0, 0, 0, 15, 0, 0, 0, 26, 255, 255, 255,
244 32, 32, 48, 0, 4, 0, 0, 0, 0, 0, 0, 0
289#if !defined(EVE_USE_INTERNAL_OSC)
294#ifdef EVE_SYSTEM_CLOCK
299#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
306#if (EVE_SUPPORT_CHIPID >= EVE_FT810)
325#if (EVE_SUPPORT_CHIPID >= EVE_FT810)
326#if defined(EVE_MULTI_PLATFORM_TARGET)
337#elif defined(ENABLE_SPI_QUAD)
340#elif defined(ENABLE_SPI_DUAL)
350#ifndef EVE_HARDCODED_DISPLAY_TIMINGS
351#define EVE_HARDCODED_DISPLAY_TIMINGS 1
354#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
367 int32_t nearestFreq = 0x7FFFFFFFL;
370 for (
uint32_t div = 1; div < 15; ++div)
372 uint32_t mul = (freq * div) / 6000000;
378 int32_t resFreq = 6000000 * mul / div;
381 if (diffFreq >= 0 && diffFreq < (nearestFreq - (
int32_t)freq))
383 nearestFreq = resFreq;
388 if (mul && mul <= 18)
390 int32_t resFreq = 6000000 * (mul + 1) / div;
393 if (diffFreq >= 0 && diffFreq < (nearestFreq - (
int32_t)freq))
395 nearestFreq = resFreq;
397 nearestMul = mul + 1;
401 if (nearestFreq != 0x7FFFFFFFL)
406 uint32_t range = pllFreq >= 160 ? 3 : (pllFreq >= 80 ? 2 : (pllFreq >= 40 ? 1 : 0));
407 res = (nearestDiv & 0xF) | ((nearestMul & 0x3F) << 4) | (range << 10);
424 uint32_t mul = (pclkFreq >> 4) & 0x3F;
426 uint32_t res = mul * (12 * 1000 * 1000) / div / 2;
449 bool supportedResolution =
true;
465#ifdef EVE_SUPPORT_HSF
499#ifdef EVE_SUPPORT_HSF
500 if (hsfWidth >= width)
502 eve_printf_debug(
"Screen HSF width %i is too large, disabled\n", (
int)config->HsfWidth);
505 supportedResolution =
false;
512 supportedResolution =
false;
518 supportedResolution =
false;
528 supportedResolution =
false;
534 supportedResolution =
false;
538#ifdef EVE_SUPPORT_HSF
545 config->HsfWidth = (
int16_t)hsfWidth;
557 eve_printf_debug(
"Display config specifies HSF but not supported on this platform\n");
565 screenWidth = hsfWidth ? hsfWidth : width;
566 pixels = screenWidth * height;
569 minCycles = pixels + (pixels >> 2);
570#ifdef EVE_SUPPORT_HSF
571 maxRatePass = (freq - 1) / minCycles;
572 maxFreq = (freq << 1) < 96000000 ? (freq << 1) : 96000000;
574 maxRate = maxRatePass;
576 maxRate = maxFreq / minCycles;
578 maxRate = freq / minCycles;
582 if (refreshRate > maxRate)
584 minCycles = pixels + (pixels >> 3);
585#ifdef EVE_SUPPORT_HSF
586 maxRatePass = (freq - 1) / minCycles;
588 maxRate = maxRatePass;
590 maxRate = maxFreq / minCycles;
592 maxRate = freq / minCycles;
596#ifdef EVE_SUPPORT_HSF
604 int32_t wantFreq = minCycles * (refreshRate > maxRate ? maxRate : refreshRate);
605 config->PClkFreq = getPClkFreq(wantFreq);
606 pclkFreq = getFreqFromPClkFreq(config->PClkFreq);
608 maxRate = pclkFreq / minCycles;
612#ifdef EVE_SUPPORT_HSF
619 if (maxRate < refreshRate)
623 refreshRate = maxRate;
628#ifdef EVE_SUPPORT_HSF
629 pclk = maxRatePass / refreshRate;
631 pclk = maxRate / refreshRate;
642#ifdef EVE_SUPPORT_HSF
643 cycles = (pclkFreq ? pclkFreq : freq) / (refreshRate * pclk);
645 cycles = freq / (refreshRate * pclk);
647 vcycle = height * cycles / pixels;
648 vcycle = (vcycle + ((vcycle + height) >> 1) + height + height) >> 2;
649 hcycle = cycles / vcycle;
650 hoffset = (hcycle - screenWidth) >> 1;
651 voffset = (vcycle - height) >> 1;
652 hsync1 = hoffset >> 1;
653 vsync1 = voffset >> 1;
656#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
657 if (pclkFreq && pclkFreq >= freq)
676#ifdef EVE_SUPPORT_HSF
688#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
689#ifdef EVE_ADAPTIVE_FRAMERATE
696#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
697 config->AhHCycleMax = 0;
725 return supportedResolution;
743 bool res =
configDefaultsEx(phost, config, width, height, refreshRate, hsfWidth, freq);
745#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
746 if (config->PClkFreq)
748 uint32_t pclkFrequency = getFreqFromPClkFreq(config->PClkFreq);
749 eve_printf_debug(
"Display refresh rate set to %f Hz using pclk %X freq %f MHz\n", (
float)((
double)pclkFrequency / ((
double)config->
HCycle * (
double)config->
VCycle)), (
int)config->PClkFreq, (
float)((
double)pclkFrequency * 0.000001));
767 bool supportedResolution;
778#if defined(DISPLAY_RESOLUTION_QVGA)
780#elif defined(DISPLAY_RESOLUTION_WQVGA)
782#elif defined(DISPLAY_RESOLUTION_WVGA)
783#if defined(EVE_GRAPHICS_IDM2040)
788#elif defined(DISPLAY_RESOLUTION_WSVGA)
790#elif defined(DISPLAY_RESOLUTION_HDTV)
792#elif defined(DISPLAY_RESOLUTION_WXGA)
794#elif defined(DISPLAY_RESOLUTION_HVGA_PORTRAIT)
810#if EVE_DISPLAY_REFRESH
816 supportedResolution =
configDefaultsEx(phost, config, width, height, refreshRate, hsfWidth, freq);
819#if EVE_DISPLAY_REFRESH
833#if EVE_HARDCODED_DISPLAY_TIMINGS
834 if (supportedResolution)
847#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
848 config->PClkFreq = 0;
850#ifdef EVE_SUPPORT_HSF
851 config->HsfWidth = 0;
872#if EVE_HARDCODED_DISPLAY_TIMINGS
873 if (supportedResolution)
886#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
887 config->PClkFreq = 0;
889#ifdef EVE_SUPPORT_HSF
890 config->HsfWidth = 0;
895#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
899#if EVE_HARDCODED_DISPLAY_TIMINGS
900 if (supportedResolution)
913 config->PClkFreq = 0x885;
914 config->HsfWidth = 0;
928#if EVE_HARDCODED_DISPLAY_TIMINGS
929 if (supportedResolution)
942#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
943 config->PClkFreq = 0;
945#ifdef EVE_SUPPORT_HSF
946 config->HsfWidth = 0;
959#if EVE_HARDCODED_DISPLAY_TIMINGS
960 if (supportedResolution)
962 config->
Width = 1280;
973#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
974 config->PClkFreq = 0;
976#ifdef EVE_SUPPORT_HSF
977 config->HsfWidth = 0;
995#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
996#if EVE_HARDCODED_DISPLAY_TIMINGS
999 config->
Width = 1280;
1010 config->PClkFreq = 0x8B1;
1011#ifdef EVE_SUPPORT_HSF
1012 config->HsfWidth = 0;
1031#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
1032#if EVE_HARDCODED_DISPLAY_TIMINGS
1035 config->
Width = 1024;
1046 config->PClkFreq = 0xD12;
1047#ifdef EVE_SUPPORT_HSF
1048 config->HsfWidth = 0;
1061#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
1063 if (config->AhHCycleMax && config->
HCycle > config->AhHCycleMax)
1064 config->AhHCycleMax = 0;
1068#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
1069 if (config->PClkFreq)
1071 uint32_t pclkFrequency = getFreqFromPClkFreq(config->PClkFreq);
1072 eve_printf_debug(
"Display refresh rate set to %f Hz using pclk %X freq %f MHz\n", (
float)((
double)pclkFrequency / ((
double)config->
HCycle * (
double)config->
VCycle)), (
int)config->PClkFreq, (
float)((
double)pclkFrequency * 0.000001));
1098#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
1101#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
1105#ifdef EVE_SUPPORT_HSF
1111#define EXTRACT_CHIPID(romChipId) EVE_extendedChipId((((romChipId) >> 8) & 0xFF) | (((romChipId) & (0xFF)) << 8))
1167 eve_printf_debug(
"EVE ROM_CHIPID after wake up %lx\n", (
unsigned long)chipId);
1176#ifdef EVE_MULTI_TARGET
1195 eve_printf_debug(
"Mismatching EVE chip id %lx, expect model %lx\n", (
unsigned long)((chipId >> 8) & 0xFF) | ((chipId & 0xFF) << 8), (
unsigned long)expectedChipId);
1199#ifdef EVE_MULTI_GRAPHICS_TARGET
1202 phost->GpuDefs = &EVE_GpuDefs_BT81X;
1204 phost->GpuDefs = &EVE_GpuDefs_BT88X;
1206 phost->GpuDefs = &EVE_GpuDefs_FT81X;
1208 phost->GpuDefs = &EVE_GpuDefs_FT80X;
1214#ifdef EVE_MULTI_GRAPHICS_TARGET
1262 if (engineStatus & 0x01)
1266 if (engineStatus & 0x02)
1274 if (engineStatus & 0x04)
1291 eve_printf_debug(
"EVE clock frequency set to %d MHz\n", (
unsigned int)clockMHz);
1299#if (EVE_SUPPORT_CHIPID >= EVE_FT810)
1313 eve_printf_debug(
"%s channel SPI (%s unsupported)\n", spiChannels, requested);
1335#pragma warning(push)
1336#pragma warning(disable : 6285)
1343#if defined(PANL70) || defined(PANL70PLUS)
1350#if defined(PANL70) || defined(PANL70PLUS)
1358#pragma warning(push)
1359#pragma warning(disable : 6285)
1366#if defined(DISPLAY_RESOLUTION_WXGA)
1376#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
1377#ifdef EVE_TOUCH_GOODIX
1400 bool reconfigure = phost->
PCLK;
1456#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
1457 bool pclk2X =
false;
1461 uint16_t pclkFreq = config->PClkFreq;
1468 uint32_t range = pllFreq >= 160 ? 3 : (pllFreq >= 80 ? 2 : (pllFreq >= 40 ? 1 : 0));
1469 pclkFreq = 1 | ((refMul & 0x3F) << 4) | (range << 10);
1477 else if (config->
PCLK == 1)
1480 uint32_t pclkFrequency = getFreqFromPClkFreq(pclkFreq);
1481 pclk2X = pclkFrequency > freq;
1491#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
1498#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
1505#ifdef RESISTANCE_THRESHOLD
1520#if (EVE_SUPPORT_CHIPID >= EVE_FT810)
1545#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
1553#ifdef EVE_FLASH_AVAILABLE
1565#ifdef EVE_SUPPORT_HSF
1566 if (config->HsfWidth)
1581 phost->
Height = config->HsfWidth;
1583 phost->
Width = config->HsfWidth;
1595#ifdef EVE_SUPPORT_HSF
1596 if (config->HsfWidth)
1605#if (defined(ENABLE_ILI9488_HVGA_PORTRAIT) || defined(ENABLE_KD2401_HVGA_PORTRAIT))
1618#if defined(ENABLE_ILI9488_HVGA_PORTRAIT) || defined(ENABLE_KD2401_HVGA_PORTRAIT)
1619#if defined(RP2040_PLATFORM)
1620 EVE_ILI9488_RP2040_bootup(phost);
1624#if defined(FT9XX_PLATFORM)
1625 EVE_ILI9488_bootup();
1648#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
1651#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
1688#define EVE_SUBPATCH_PTR 0x7ffeU
1704#define EVE_VIDEOPATCH_ADDR 0x309162UL
1766 if (needsVideoPatch)
1805#if (EVE_SUPPORT_CHIPID >= EVE_FT810)
1851 if (needsVideoPatch)
1863#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
1871#ifdef EVE_FLASH_AVAILABLE
1936 int selectedDeviceIdx;
1942 size_t realDeviceCount = 0;
1943 for (i = 0; i < deviceCount; ++i)
1952 if (realDeviceCount > 1)
1955 printf(
"Select a device:\n");
1956 for (i = 0; i < deviceCount; ++i)
1962 fgets(buf,
sizeof(buf), stdin);
1963 if (sscanf_s(buf,
"%i", &selectedDeviceIdx) != 1)
1965 *deviceIdx = selectedDeviceIdx;
1971 else if (realDeviceCount > 0)
1983#ifdef EVE_MULTI_GRAPHICS_TARGET
1989 printf(
"Select a chip:\n");
1990 for (i = 0; i < EVE_SELECT_CHIP_NB; ++i)
1993 printf(
"- [%d] %s\n", (
unsigned int)i, s_SelectChipName[i]);
1995 fgets(buf,
sizeof(buf), stdin);
1996 if (sscanf_s(buf,
"%i", &selectedChipId) != 1)
1998 if (selectedChipId >= 0 && selectedChipId < EVE_SELECT_CHIP_NB)
1999 *chipId = s_SelectChipId[selectedChipId];
2001 *chipId = selectedChipId;
2015#ifdef EVE_MULTI_GRAPHICS_TARGET
2024 int selectedDisplay;
2030 printf(
"Select a display (or press ENTER to use the default):\n");
2033 printf(
"- [%d] %s\n", (
unsigned int)i, s_DisplayNames[i]);
2035 fgets(buf,
sizeof(buf), stdin);
2036 if (buf[0] ==
'\n' || buf[0] ==
'\r')
2042 if (sscanf_s(buf,
"%i", &selectedDisplay) != 1)
2045 *display = selectedDisplay;
2055#if defined(_WIN32) && defined(EVE_FLASH_AVAILABLE)
2073 *updateFlash =
false;
2074 *updateFlashFirmware =
false;
2077#if defined(EVE_MULTI_PLATFORM_TARGET) || !defined(BT8XXEMU_PLATFORM)
2079#if defined(EVE_MULTI_PLATFORM_TARGET)
2084 printf(
"Upload flash image (y/n, or press ENTER to skip):\n");
2089 *updateFlash = (
buffer[0] ==
'1' || (
buffer[0] & 0xD2) == 0x50);
2093 printf(
"Upload flash firmware (y/n, or press ENTER to skip):\n");
2096 *updateFlashFirmware = (
buffer[0] ==
'1' || (
buffer[0] & 0xD2) == 0x50);
2104#
if defined(EVE_MULTI_PLATFORM_TARGET) || defined(BT8XXEMU_PLATFORM)
2106#
if defined(EVE_MULTI_PLATFORM_TARGET)
2108#elif defined(BT8XXEMU_PLATFORM)
2112 && !wcscmp(flashFile, L
"__Flash.bin")
2114 && !strcmp(flashFile,
"__Flash.bin")
2121 printf(
"Select flash file %s(or press ENTER to use %s%ls%s):\n",
2122 *updateFlashFirmware ?
"with firmware " :
"",
2123 flashFile[0] ?
"\"" :
"",
2124 flashFile[0] ? flashFile : L
"no flash",
2125 flashFile[0] ?
"\"" :
"");
2127 fgetws(flashPath, MAX_PATH, stdin);
2128 if (flashPath[0] ==
'\r' || flashPath[0] ==
'\n')
2129 flashPath[0] =
'\0';
2130 flashPathSz = wcslen(flashPath);
2131 while (flashPathSz && (flashPath[flashPathSz - 1] ==
'\r' || flashPath[flashPathSz - 1] ==
'\n'))
2134 flashPath[flashPathSz - 1] =
'\0';
2138 if (flashFile[0] ==
'\0' && flashPath[0] ==
'\0')
2146 ferr = _wfopen_s(&
f, flashPath[0] ? flashPath : flashFile, L
"rb");
2149 printf(
"File \"%ls\" cannot be opened\n", flashPath[0] ? flashPath : flashFile);
2152 fseek(
f, 0, SEEK_END);
2158#
if defined(EVE_MULTI_PLATFORM_TARGET)
2160#elif defined(BT8XXEMU_PLATFORM)
2166 wcscpy_s(flashPath, flashPathSize, flashFile);
2172#if defined(BT8XXEMU_PLATFORM)
2173#if defined(ESD_SIMULATION) && defined(EVE_FLASH_AVAILABLE)
2174extern void Esd_SetFlashFirmware__ESD(
const eve_tchar_t *path);
2185#if defined(EVE_MULTI_PLATFORM_TARGET)
2193 pEmulatorParams->
Flags &= (~BT8XXEMU_EmulatorEnableDynamicDegrade & ~BT8XXEMU_EmulatorEnableRegPwmDutyEmulation);
2196 params->EmulatorParameters = pEmulatorParams;
2199#if defined(EVE_FLASH_AVAILABLE)
2208void EVE_Util_emulatorFlashDefaults(
EVE_HalParameters *params,
const void *emulatorParams,
void *flashParams,
const eve_tchar_t *flashPath)
2213#if defined(EVE_MULTI_PLATFORM_TARGET)
2219 if (!flashPath || !flashPath[0])
2225 pFlashParams->
StdOut = 1;
2228#if defined(EVE_FLASH_FIRMWARE)
2229 Esd_SetFlashFirmware__ESD(EVE_FLASH_FIRMWARE);
2232#ifdef EVE_FLASH_SIZE
2233 pFlashParams->
SizeBytes = EVE_FLASH_SIZE * 1024 * 1024;
2235 pFlashParams->
SizeBytes = 2 * 1024 * 1024;
2237#pragma warning(push)
2238#pragma warning(disable : 4996)
2239 FILE *
f = _wfopen(flashPath, L
"rb");
2242 FILE *
f = fopen(flashPath,
"rb");
2246 fseek(
f, 0, SEEK_END);
2249 while (pFlashParams->
SizeBytes < flashSize)
2255 params->EmulatorFlashParameters = pFlashParams;
2261#if defined(_WIN32) && defined(EVE_FLASH_AVAILABLE)
2262#pragma warning(push)
2263#pragma warning(disable : 6262)
2271EVE_HAL_EXPORT void EVE_Util_uploadFlashFileInteractive(EVE_HalContext *phost, const eve_tchar_t *flashPath, bool updateFlashFirmware)
2273 ptrdiff_t flashSize;
2282 printf(
"Preparing to upload flash...\n");
2286 err = _wfopen_s(&
f, flashPath, L
"rb");
2288 err = fopen_s(&
f, flashPath,
"rb");
2293 printf(
"Flash file cannot be opened\n");
2298 fseek(
f, 0, SEEK_END);
2299 flashSize = ftell(
f);
2300 fseek(
f, 0, SEEK_SET);
2312 configParams.
PCLK = 0;
2321 size_t remainingBytes;
2326 printf(
"This device doesn't support flash\n");
2336 printf(
"Coprocessor fault\n");
2344 printf(
"Flash could not be attached\n");
2348 if (updateFlashFirmware)
2350 printf(
"Upload flash firmware from image...\n");
2351 if (fread(
buffer, 4096, 1,
f) != 1)
2353 printf(
"Could not read file\n");
2365 printf(
"Coprocessor fault\n");
2371 if (fseek(
f, 4096, SEEK_CUR))
2373 printf(
"Could not seek file\n");
2380 printf(
"Enter fast flash mode\n");
2387 printf(
"Coprocessor fault\n");
2396 printf(
"Flash could not enter fast mode. Has the correct firmware been uploaded?\n");
2401 if (flashDeviceSize < flashSize)
2403 printf(
"Not enough space on flash, need %i bytes, have %i bytes\n", (
int)flashSize, (
int)flashDeviceSize);
2407 remainingBytes = flashSize - 4096;
2410 printf(
"Upload flash from image...\n");
2413 while (remainingBytes)
2418 if (remainingBytes < 4096)
2420 el = fread(
buffer, 1, remainingBytes,
f);
2426 el = fread(
buffer, 4096, min(remainingBytes,
sizeof(
buffer)) / 4096,
f);
2428 remainingBytes -= sz;
2432 printf(
"\nFailed to read file\n");
2448 printf(
"\nCoprocessor fault\n");
2455 for (
size_t i = 0; i < sz; ++i)
2466 printf(
"\nCoprocessor fault\n");
2470 for (
size_t i = 0; i < sz; ++i)
2472 if (
buffer[i] != rbuffer[i])
2474 printf(
"\nVerification failed\n");
2483 if (!remainingBytes)
2485 printf(
"\nFlash upload is ready\n");
2492 printf(
"Failed to bootup the device\n");
2500 printf(
"Failed to bootup the device\n");
2527#ifdef BT8XXEMU_PLATFORM
2529#if defined(EVE_FLASH_AVAILABLE)
2534#if defined(_WIN32) && defined(EVE_FLASH_AVAILABLE)
2535 bool updateFlash =
false;
2536 bool updateFlashFirmware =
false;
2537 wchar_t flashPath[MAX_PATH];
2538 flashPath[0] =
'\0';
2548#if defined(_WIN32) && defined(EVE_FLASH_AVAILABLE)
2549 if (chipId >=
EVE_BT815 || (chipId <= 0 && flashFile && flashFile[0]))
2553#if defined(BT8XXEMU_PLATFORM)
2554 EVE_Util_emulatorDefaults(¶ms, &emulatorParams, chipId);
2555#if defined(EVE_FLASH_AVAILABLE)
2556 EVE_Util_emulatorFlashDefaults(¶ms, &emulatorParams, &flashParams, flashPath);
2565#if defined(_WIN32) && defined(EVE_FLASH_AVAILABLE)
2566 if (updateFlash && flashPath[0])
2595 if (!selectedDisplay)
2596 selectedDisplay = display;
2638#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
2657#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
2666 for (
int i = (
int)errLen; i <
sizeof(phost->
DebugBackup); ++i)
EVE_HAL_EXPORT uint16_t EVE_Cmd_space(EVE_HalContext *phost)
Get free space of Coprocessor's command buffer.
EVE_HAL_EXPORT uint16_t EVE_Cmd_moveWp(EVE_HalContext *phost, uint16_t bytes)
Move the write pointer forward by the specified number of bytes. Returns the previous write pointer.
EVE_HAL_EXPORT uint32_t EVE_Cmd_waitSpace(EVE_HalContext *phost, uint32_t size)
EVE_HAL_EXPORT void EVE_Cmd_startFunc(EVE_HalContext *phost)
Begin writing a function, keeps the transfer open.
EVE_HAL_EXPORT uint16_t EVE_Cmd_rp(EVE_HalContext *phost)
Read from Coprocessor.
EVE_HAL_EXPORT void EVE_Cmd_endFunc(EVE_HalContext *phost)
End writing a function, closes the transfer.
EVE_HAL_EXPORT uint16_t EVE_Cmd_wp(EVE_HalContext *phost)
Write to Coprocessor.
EVE_HAL_EXPORT bool EVE_Cmd_wr32(EVE_HalContext *phost, uint32_t value)
Write 4 bytes to Coprocessor's command fifo.
EVE_HAL_EXPORT bool EVE_Cmd_wrProgMem(EVE_HalContext *phost, eve_progmem_const uint8_t *buffer, uint32_t size)
Write buffer in ProgMem to Coprocessor's comand fifo.
static void EVE_CoCmd_dlStart(EVE_HalContext *phost)
Send CMD_DLSTART.
#define EVE_DISPLAY_REFRESH
#define EVE_SUPPORT_CHIPID
#define eve_progmem_const
#define REG_ADAPTIVE_FRAMERATE
#define EVE_CMD_FIFO_SIZE
#define REG_TOUCH_RZTHRESH
#define FLASH_STATUS_BASIC
#define FLASH_STATUS_FULL
#define EVE_CMD_FAULT(rp)
#define REG_AH_HCYCLE_MAX
#define REG_PLAYBACK_LENGTH
#define REG_PLAYBACK_PLAY
#define FLASH_STATUS_DETACHED
EVE_HAL_EXPORT void EVE_Host_powerModeSwitch(EVE_HalContext *phost, EVE_POWER_MODE_T pwrmode)
Switch power mode for Coprocessor.
EVE_HAL_EXPORT uint32_t EVE_Hal_rd32(EVE_HalContext *phost, uint32_t addr)
Read 4 bytes from Coprocessor's memory.
EVE_HAL_EXPORT void EVE_Hal_rdMem(EVE_HalContext *phost, uint8_t *result, uint32_t addr, uint32_t size)
Read a block data from Coprocessor's memory.
EVE_HAL_EXPORT void EVE_Hal_wrProgMem(EVE_HalContext *phost, uint32_t addr, eve_progmem_const uint8_t *buffer, uint32_t size)
Write a buffer in ProgMem to Coprocessor's memory.
EVE_HAL_EXPORT void EVE_Hal_defaultsEx(EVE_HalParameters *parameters, size_t deviceIdx)
Setup default parameters for Eve_Hal framework.
EVE_HAL_EXPORT uint16_t EVE_Hal_rd16(EVE_HalContext *phost, uint32_t addr)
Read 2 bytes from Coprocessor's memory.
EVE_HAL_EXPORT void EVE_Host_selectSysClk(EVE_HalContext *phost, EVE_81X_PLL_FREQ_T freq)
Set system clock for Coprocessor.
EVE_HAL_EXPORT bool EVE_Hal_open(EVE_HalContext *phost, const EVE_HalParameters *parameters)
Open the Eve_Hal framework.
EVE_HAL_EXPORT void EVE_Hal_wr8(EVE_HalContext *phost, uint32_t addr, uint8_t v)
Write 8 bits to Coprocessor's memory.
EVE_HAL_EXPORT void EVE_Host_coreReset(EVE_HalContext *phost)
Send reset signal to Coprocessor.
EVE_HAL_EXPORT void EVE_Hal_wr16(EVE_HalContext *phost, uint32_t addr, uint16_t v)
Write 2 bytes to Coprocessor's memory.
EVE_HAL_EXPORT void EVE_Hal_wr32(EVE_HalContext *phost, uint32_t addr, uint32_t v)
Write 4 bytes to Coprocessor's memory.
EVE_HAL_EXPORT void EVE_Hal_wrMem(EVE_HalContext *phost, uint32_t addr, const uint8_t *buffer, uint32_t size)
Write a buffer to Coprocessor's memory.
EVE_HAL_EXPORT uint8_t EVE_Hal_rd8(EVE_HalContext *phost, uint32_t addr)
Read 8 bits from Coprocessor's memory.
EVE_HAL_EXPORT bool EVE_Hal_powerCycle(EVE_HalContext *phost, bool up)
Toggle PD_N pin of FT800 board for a power cycle.
EVE_HAL_EXPORT uint8_t EVE_Hal_transfer8(EVE_HalContext *phost, uint8_t value)
Write 8 bits to Coprocessor.
EVE_HAL_EXPORT void EVE_Hal_info(EVE_DeviceInfo *deviceInfo, size_t deviceIdx)
Get info of the specified device. Devices of type EVE_HOST_UNKNOWN should be ignored.
EVE_HAL_EXPORT void EVE_Hal_startTransfer(EVE_HalContext *phost, EVE_TRANSFER_T rw, uint32_t addr)
Start data transfer to Coprocessor.
static int EVE_gen(EVE_CHIPID_T chipId)
EVE_HAL_EXPORT void EVE_Hal_hostCommand(EVE_HalContext *phost, uint8_t cmd)
Send a host command to Coprocessor.
EVE_HAL_EXPORT void EVE_Hal_setSPI(EVE_HalContext *phost, EVE_SPI_CHANNELS_T numchnls, uint8_t numdummy)
Set number of SPI channel.
static int EVE_shortChipId(EVE_CHIPID_T chipId)
static bool EVE_Hal_supportHsf(EVE_HalContext *phost)
EVE_HAL_EXPORT size_t EVE_Hal_list()
List the available devices.
static bool EVE_Hal_supportFlash(EVE_HalContext *phost)
EVE_HAL_EXPORT void EVE_sleep(uint32_t ms)
Sleep in milisecond.
#define RAM_ERR_REPORT_MAX
static bool EVE_Hal_isScreenResistive(EVE_HalContext *phost)
EVE_HAL_EXPORT void EVE_Hal_restoreSPI(EVE_HalContext *phost)
EVE_HAL_EXPORT void EVE_Hal_endTransfer(EVE_HalContext *phost)
End data transfer.
EVE_HAL_EXPORT void EVE_Hal_flush(EVE_HalContext *phost)
Flush data to Coprocessor.
EVE_HAL_EXPORT uint32_t EVE_Hal_transfer32(EVE_HalContext *phost, uint32_t value)
Write 4 bytes to Coprocessor.
bool EVE_UtilImpl_bootupDisplayGpio(EVE_HalContext *phost)
Display GPIO pins.
bool EVE_Util_openDeviceInteractive(EVE_HalContext *phost, const wchar_t *flashFile)
EVE_HAL_EXPORT void EVE_Util_configDefaults(EVE_HalContext *phost, EVE_ConfigParameters *config, EVE_DISPLAY_T display)
EVE_HAL_EXPORT void EVE_Util_clearScreen(EVE_HalContext *phost)
Clear the screen.
#define EVE_VIDEOPATCH_ADDR
static bool EVE_Util_needsVideoPatch(EVE_HalContext *phost)
static const uint16_t s_DisplayResolutions[EVE_DISPLAY_NB][4]
EVE_HAL_EXPORT bool EVE_Util_configDefaultsEx(EVE_HalContext *phost, EVE_ConfigParameters *config, uint32_t width, uint32_t height, uint32_t refreshRate, uint32_t hsfWidth)
EVE_HAL_EXPORT void EVE_Util_bootupDefaults(EVE_HalContext *phost, EVE_BootupParameters *bootup)
static bool configDefaultsEx(EVE_HalContext *phost, EVE_ConfigParameters *config, uint32_t width, uint32_t height, uint32_t refreshRate, uint32_t hsfWidth, uint32_t freq)
EVE_HAL_EXPORT bool EVE_Util_bootupConfigInteractive(EVE_HalContext *phost, EVE_DISPLAY_T display)
Calls EVE_Util_bootup and EVE_Util_config using the default parameters. Falls back to no interactivit...
EVE_HAL_EXPORT bool EVE_Util_config(EVE_HalContext *phost, EVE_ConfigParameters *config)
EVE_HAL_EXPORT bool EVE_Util_resetCoprocessor(EVE_HalContext *phost)
Reset Coprocessor.
EVE_HAL_EXPORT bool EVE_Util_bootup(EVE_HalContext *phost, EVE_BootupParameters *bootup)
void debugBackupRamG(EVE_HalContext *phost)
Backup the last 128 bytes of RAM_G, which may be used for an error message.
static bool EVE_Util_needsSubPatch(EVE_HalContext *phost)
EVE_HAL_EXPORT bool EVE_Util_bootupConfig(EVE_HalContext *phost)
Bootup Coprocessor.
EVE_HAL_EXPORT void EVE_CoDlImpl_resetCoState(EVE_HalContext *phost)
static void uploadTouchFirmware(EVE_HalContext *phost)
void EVE_Util_forceFault(EVE_HalContext *phost, const char *err)
static eve_progmem_const uint8_t c_DlCodeBootup[12]
static void debugRestoreRamG(EVE_HalContext *phost)
#define EXTRACT_CHIPID(romChipId)
EVE_HAL_EXPORT void EVE_Util_shutdown(EVE_HalContext *phost)
EVE HAL framework utilities.
static void EVE_Util_uploadFlashFileInteractive(EVE_HalContext *phost, const eve_tchar_t *flashPath, bool updateFlashFirmware)
static void EVE_Util_selectDeviceInteractive(EVE_CHIPID_T *chipId, size_t *deviceIdx)
static void EVE_Util_selectFlashFileInteractive(eve_tchar_t *flashPath, size_t flashPathSize, bool *updateFlash, bool *updateFlashFirmware, const EVE_HalParameters *params, const eve_tchar_t *flashFile)
static void EVE_Util_selectDisplayInteractive(EVE_DISPLAY_T *display)
@ EVE_DISPLAY_QVGA_320x240_56Hz
@ EVE_DISPLAY_HDTV_1280x720_58Hz
@ EVE_DISPLAY_HVGA_320x480_60Hz
@ EVE_DISPLAY_WSVGA_1024x600_59Hz
@ EVE_DISPLAY_WQVGA_480x272_60Hz
@ EVE_DISPLAY_WVGA_800x480_74Hz
@ EVE_DISPLAY_WVGA_800x480_W860_60Hz
@ EVE_DISPLAY_WXGA_1280x800_57Hz
static ft_uint32_t ft_uint8_t * buffer
void EVE_Cmd_waitFlush(EVE_HalContext *host)
BT8XXEMU_API void BT8XXEMU_defaults(uint32_t versionApi, BT8XXEMU_EmulatorParameters *params, BT8XXEMU_EmulatorMode mode)
BT8XXEMU_API void BT8XXEMU_Flash_defaults(uint32_t versionApi, BT8XXEMU_FlashParameters *params)
#define BT8XXEMU_VERSION_API
BT8XXEMU_EmulatorMode Mode
eve_tchar_t DataFilePath[260]
EVE_SPI_CHANNELS_T SpiChannels
EVE_81X_PLL_FREQ_T SystemClock
uint32_t MediaFifoAddress
uint8_t DebugBackup[RAM_ERR_REPORT_MAX]
EVE_ResetCallback CbCoprocessorReset
EVE_SPI_CHANNELS_T SpiChannels