image/svg+xml
Brteve's API for EveApps
Version 0.0.1
The reference document for common folder of EveApps project.
 
Loading...
Searching...
No Matches
EVE_Util.h File Reference

EVE HAL framework utilities. More...

#include "EVE_HalDefs.h"

Go to the source code of this file.

Data Structures

struct  EVE_BootupParameters
 
struct  EVE_ConfigParameters
 

Typedefs

typedef struct EVE_BootupParameters EVE_BootupParameters
 
typedef struct EVE_ConfigParameters EVE_ConfigParameters
 
typedef enum EVE_DISPLAY_T EVE_DISPLAY_T
 

Enumerations

enum  EVE_DISPLAY_T {
  EVE_DISPLAY_DEFAULT = 0 , EVE_DISPLAY_QVGA_320x240_56Hz , EVE_DISPLAY_WQVGA_480x272_60Hz , EVE_DISPLAY_WVGA_800x480_74Hz ,
  EVE_DISPLAY_WSVGA_1024x600_59Hz , EVE_DISPLAY_HDTV_1280x720_58Hz , EVE_DISPLAY_WXGA_1280x800_57Hz , EVE_DISPLAY_HVGA_320x480_60Hz ,
  EVE_DISPLAY_WVGA_800x480_W860_60Hz , EVE_DISPLAY_RIVERDI_IPS35_62Hz , EVE_DISPLAY_RIVERDI_IPS43_58Hz , EVE_DISPLAY_RIVERDI_IPS50_63Hz ,
  EVE_DISPLAY_RIVERDI_IPS70_59Hz , EVE_DISPLAY_RIVERDI_IPS101_59Hz , EVE_DISPLAY_NB
}
 

Functions

INIT AND SHUTDOWN
EVE_HAL_EXPORT void EVE_Util_bootupDefaults (EVE_HalContext *phost, EVE_BootupParameters *bootup)
 
EVE_HAL_EXPORT bool EVE_Util_bootup (EVE_HalContext *phost, EVE_BootupParameters *bootup)
 
EVE_HAL_EXPORT void EVE_Util_configDefaults (EVE_HalContext *phost, EVE_ConfigParameters *config, EVE_DISPLAY_T display)
 
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 bool EVE_Util_config (EVE_HalContext *phost, EVE_ConfigParameters *config)
 
EVE_HAL_EXPORT void EVE_Util_shutdown (EVE_HalContext *phost)
 
EVE_HAL_EXPORT void EVE_Util_clearScreen (EVE_HalContext *phost)
 Clear the screen.
 
EVE_HAL_EXPORT bool EVE_Util_resetCoprocessor (EVE_HalContext *phost)
 Reset Coprocessor.
 
EVE_HAL_EXPORT bool EVE_Util_bootupConfig (EVE_HalContext *phost)
 Bootup Coprocessor.
 
INTERACTIVE SETUP
static void EVE_Util_selectDeviceInteractive (EVE_CHIPID_T *chipId, size_t *deviceIdx)
 
static void EVE_Util_selectDisplayInteractive (EVE_DISPLAY_T *display)
 
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_uploadFlashFileInteractive (EVE_HalContext *phost, const eve_tchar_t *flashPath, bool updateFlashFirmware)
 
EVE_HAL_EXPORT bool EVE_Util_openDeviceInteractive (EVE_HalContext *phost, const wchar_t *flashFile)
 
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 interactivity on FT9XX platform.
 
EVE_HAL_EXPORT void EVE_Util_forceFault (EVE_HalContext *phost, const char *err)
 

Detailed Description

EVE HAL framework utilities.

Author
Bridgetek
Date
2018

MIT License

Copyright (c) [2019] [Bridgetek Pte Ltd (BRTChip)]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Definition in file EVE_Util.h.

Typedef Documentation

◆ EVE_BootupParameters

◆ EVE_ConfigParameters

◆ EVE_DISPLAY_T

Display resolution presets.

Note
Also update s_DisplayResolutions and s_DisplayNames in EVE_Util.c around ln 50, as well as EVE_Util_configDefaults around ln 500, when adding display presets.

Enumeration Type Documentation

◆ EVE_DISPLAY_T

Display resolution presets.

Note
Also update s_DisplayResolutions and s_DisplayNames in EVE_Util.c around ln 50, as well as EVE_Util_configDefaults around ln 500, when adding display presets.
Enumerator
EVE_DISPLAY_DEFAULT 

0

EVE_DISPLAY_QVGA_320x240_56Hz 

Landscape

EVE_DISPLAY_WQVGA_480x272_60Hz 

Landscape

EVE_DISPLAY_WVGA_800x480_74Hz 

Landscape

EVE_DISPLAY_WSVGA_1024x600_59Hz 

Landscape

EVE_DISPLAY_HDTV_1280x720_58Hz 

Landscape

EVE_DISPLAY_WXGA_1280x800_57Hz 

Landscape

EVE_DISPLAY_HVGA_320x480_60Hz 

Portrait

EVE_DISPLAY_WVGA_800x480_W860_60Hz 

IDM2040

EVE_DISPLAY_RIVERDI_IPS35_62Hz 

Riverdi

EVE_DISPLAY_RIVERDI_IPS43_58Hz 

Riverdi

EVE_DISPLAY_RIVERDI_IPS50_63Hz 

Riverdi

EVE_DISPLAY_RIVERDI_IPS70_59Hz 

Riverdi

EVE_DISPLAY_RIVERDI_IPS101_59Hz 

Riverdi

EVE_DISPLAY_NB 

Definition at line 100 of file EVE_Util.h.

101{
103
111
114
117
124
126
EVE_DISPLAY_T
Definition EVE_Util.h:101
@ EVE_DISPLAY_QVGA_320x240_56Hz
Definition EVE_Util.h:105
@ EVE_DISPLAY_HDTV_1280x720_58Hz
Definition EVE_Util.h:109
@ EVE_DISPLAY_DEFAULT
Definition EVE_Util.h:102
@ EVE_DISPLAY_HVGA_320x480_60Hz
Definition EVE_Util.h:113
@ EVE_DISPLAY_RIVERDI_IPS35_62Hz
Definition EVE_Util.h:119
@ EVE_DISPLAY_RIVERDI_IPS101_59Hz
Definition EVE_Util.h:123
@ EVE_DISPLAY_WSVGA_1024x600_59Hz
Definition EVE_Util.h:108
@ EVE_DISPLAY_RIVERDI_IPS70_59Hz
Definition EVE_Util.h:122
@ EVE_DISPLAY_WQVGA_480x272_60Hz
Definition EVE_Util.h:106
@ EVE_DISPLAY_NB
Definition EVE_Util.h:125
@ EVE_DISPLAY_WVGA_800x480_74Hz
Definition EVE_Util.h:107
@ EVE_DISPLAY_WVGA_800x480_W860_60Hz
Definition EVE_Util.h:116
@ EVE_DISPLAY_RIVERDI_IPS50_63Hz
Definition EVE_Util.h:121
@ EVE_DISPLAY_WXGA_1280x800_57Hz
Definition EVE_Util.h:110
@ EVE_DISPLAY_RIVERDI_IPS43_58Hz
Definition EVE_Util.h:120

Function Documentation

◆ EVE_Util_bootup()

EVE_HAL_EXPORT bool EVE_Util_bootup ( EVE_HalContext phost,
EVE_BootupParameters bootup 
)

Boot up the device. Obtains the chip Id. Sets up clock and SPI speed.

Parameters
phostPointer to Hal context
bootup
Returns
true True if successful
false False if error

Definition at line 1121 of file EVE_Util.c.

1122{
1123 /* IMPORTANT: Do not use EVE_CoCmd functions here, as they can be overridden by hooks */
1124
1125 const uint32_t expectedChipId = EVE_CHIPID;
1126 uint8_t engineStatus;
1127 uint32_t chipId;
1128 uint8_t id;
1129
1130 do
1131 {
1132 int tries = 0;
1133
1134 /* EVE will be in SPI Single channel after POR */
1135 if (!EVE_Hal_powerCycle(phost, true))
1136 return false;
1137
1138 if (bootup->ExternalOsc)
1139 {
1140 /* Set the clk to external clock. Must disable it when no external clock source on the board */
1142 EVE_sleep(10);
1143 }
1144 else
1145 {
1146 /* Send CLKINT explicitly to play safe for all EVE series chip*/
1148 EVE_sleep(10);
1149 }
1150
1151 /* Update system clock as per user selected */
1152 if (bootup->SystemClock)
1153 {
1154 EVE_Host_selectSysClk(phost, bootup->SystemClock);
1155 }
1156
1157 /* Access address 0 to wake up the FT800 */
1159 EVE_sleep(300);
1160
1161 EVE_Host_coreReset(phost);
1162 /* Wait for valid chip ID */
1163 chipId = EVE_Hal_rd32(phost, ROM_CHIPID);
1164 while (EXTRACT_CHIPID(chipId) < EVE_FT800
1165 || EXTRACT_CHIPID(chipId) > EVE_BT818)
1166 {
1167 eve_printf_debug("EVE ROM_CHIPID after wake up %lx\n", (unsigned long)chipId);
1168
1169 ++tries;
1170 EVE_sleep(20);
1171 if (phost->CbCmdWait && !phost->CbCmdWait(phost))
1172 return false;
1173
1174 chipId = EVE_Hal_rd32(phost, ROM_CHIPID);
1175
1176#ifdef EVE_MULTI_TARGET
1177 /* Turn off external clock if chipId reads incorrectly for 4 times */
1178 /* When not targeting multiple boards, set the EVE_USE_INTERNAL_OSC preprocessor variable, or configure the ExternalOsc parameter at runtime */
1179 if (tries >= 4)
1180 {
1181 bootup->ExternalOsc = !bootup->ExternalOsc;
1182 eve_printf_debug("Reattempting bootup with ExternalOsc changed from %s to %s\n", bootup->ExternalOsc ? "OFF" : "ON", bootup->ExternalOsc ? "ON" : "OFF");
1183
1184 EVE_Host_powerModeSwitch(phost, EVE_SLEEP_M); /* Put EVE into Sleep mode, prepare for clock selection */
1185 chipId = 0; //In case chipId is not zero
1186 break;
1187 }
1188#endif
1189 }
1190 } while (!chipId);
1191
1192 /* Validate chip ID to ensure the correct HAL is used */
1193 /* ROM_CHIPID is valid across all EVE devices */
1194 if (expectedChipId && EXTRACT_CHIPID(chipId) != expectedChipId)
1195 eve_printf_debug("Mismatching EVE chip id %lx, expect model %lx\n", (unsigned long)((chipId >> 8) & 0xFF) | ((chipId & 0xFF) << 8), (unsigned long)expectedChipId);
1196 eve_printf_debug("EVE chip id %lx %lx.%lx (EVE gen %i)\n", (unsigned long)EVE_shortChipId(EXTRACT_CHIPID(chipId)), (unsigned long)((chipId >> 16) & 0xFF), (unsigned long)((chipId >> 24) & 0xFF), EVE_gen(EXTRACT_CHIPID(chipId)));
1197
1198 /* Switch to the proper chip ID if applicable */
1199#ifdef EVE_MULTI_GRAPHICS_TARGET
1200 phost->ChipId = EXTRACT_CHIPID(chipId);
1201 if (phost->ChipId >= EVE_BT815)
1202 phost->GpuDefs = &EVE_GpuDefs_BT81X;
1203 else if (phost->ChipId >= EVE_BT880)
1204 phost->GpuDefs = &EVE_GpuDefs_BT88X;
1205 else if (phost->ChipId >= EVE_FT810)
1206 phost->GpuDefs = &EVE_GpuDefs_FT81X;
1207 else if (phost->ChipId >= EVE_FT800)
1208 phost->GpuDefs = &EVE_GpuDefs_FT80X;
1209#endif
1210
1211 /* Turn off previous audio playback (in case powerdown is not connected) */
1213
1214#ifdef EVE_MULTI_GRAPHICS_TARGET
1215 /* The default clock configuration is only set when the graphics target is known at compile time */
1216 if (!bootup->SystemClock)
1217 {
1218 if (phost->ChipId >= EVE_BT815)
1219 {
1220 /* No clock was set, but we want 72MHz default for BT81X and up */
1221 eve_printf_debug("Set system clock PLL to 72MHz\n");
1222 bootup->SystemClock = EVE_SYSCLK_72M;
1223
1224 /* Sleep */
1226 EVE_sleep(300);
1227
1228 /* Update system clock */
1229 EVE_Host_selectSysClk(phost, bootup->SystemClock);
1230
1231 /* Access address 0 to wake up the FT800 */
1233 EVE_sleep(300);
1234 }
1235 else if (phost->ChipId >= EVE_FT810)
1236 {
1237 /* Assume the default */
1238 bootup->SystemClock = EVE_SYSCLK_60M;
1239 }
1240 }
1241#endif
1242
1243 /* Read Register ID to check if EVE is ready. */
1244 while ((id = EVE_Hal_rd8(phost, REG_ID)) != 0x7C)
1245 {
1246 eve_printf_debug("EVE register ID after wake up %x\n", (unsigned int)id);
1247
1248 EVE_sleep(20);
1249 if (phost->CbCmdWait && !phost->CbCmdWait(phost))
1250 return false;
1251 }
1252 eve_printf_debug("EVE register ID after wake up %x\n", (unsigned int)id);
1253 eve_assert(chipId == EVE_Hal_rd32(phost, ROM_CHIPID));
1254
1255 /* Read REG_CPURESET to check if engines are ready.
1256 Bit 0 for coprocessor engine,
1257 Bit 1 for touch engine,
1258 Bit 2 for audio engine.
1259 */
1260 while ((engineStatus = EVE_Hal_rd8(phost, REG_CPURESET)) != 0x00)
1261 {
1262 if (engineStatus & 0x01)
1263 {
1264 eve_printf_debug("Coprocessor engine is not ready\n");
1265 }
1266 if (engineStatus & 0x02)
1267 {
1268 eve_printf_debug("Touch engine is not ready\n");
1269 if (EVE_HOST == EVE_HOST_BT8XXEMU) // FIXME: Emulator REG_CPURESET bits behaviour on FT800 and FT801 doesn't match
1270 {
1271 EVE_Hal_wr8(phost, REG_CPURESET, 0);
1272 }
1273 }
1274 if (engineStatus & 0x04)
1275 {
1276 eve_printf_debug("Audio engine is not ready\n");
1277 }
1278
1279 EVE_sleep(20);
1280 if (phost->CbCmdWait && !phost->CbCmdWait(phost))
1281 return false;
1282 }
1283 eve_printf_debug("All engines are ready\n");
1284
1285 /* Update REG_FREQUENCY as per user selected */
1286 if (bootup->SystemClock != EVE_SYSCLK_DEFAULT)
1287 {
1288 uint32_t clockMHz = bootup->SystemClock * 12;
1289 EVE_Hal_wr32(phost, REG_FREQUENCY, clockMHz * 1000 * 1000);
1290 EVE_Hal_flush(phost);
1291 eve_printf_debug("EVE clock frequency set to %d MHz\n", (unsigned int)clockMHz);
1292 }
1293 else
1294 {
1295 eve_printf_debug("EVE default clock is %d MHz\n", (unsigned int)(EVE_Hal_rd32(phost, REG_FREQUENCY) / 1000000));
1296 }
1297
1298 /* Switch to configured default SPI channel mode */
1299#if (EVE_SUPPORT_CHIPID >= EVE_FT810)
1300 if (EVE_CHIPID >= EVE_FT810)
1301 {
1302 EVE_Hal_setSPI(phost, bootup->SpiChannels, bootup->SpiDummyBytes);
1303#ifdef _DEBUG
1304 const char *spiChannels = (phost->SpiChannels == EVE_SPI_QUAD_CHANNEL)
1305 ? "Quad"
1306 : ((phost->SpiChannels == EVE_SPI_DUAL_CHANNEL) ? "Dual" : "Single");
1307 const char *requested = (bootup->SpiChannels == EVE_SPI_QUAD_CHANNEL)
1308 ? "Quad"
1309 : ((bootup->SpiChannels == EVE_SPI_DUAL_CHANNEL) ? "Dual" : "Single");
1310 if (bootup->SpiChannels == phost->SpiChannels)
1311 eve_printf_debug("%s channel SPI\n", spiChannels);
1312 else
1313 eve_printf_debug("%s channel SPI (%s unsupported)\n", spiChannels, requested);
1314#endif
1315 }
1316#endif
1317
1318 /* In some cases, for example, QSPI on MM817EV board with MM930LITE,
1319 the drive strength is required to adjust for better signal integrity.
1320 Setting to max current 20mA here is to play safe. Users may adjust the
1321 corresponding bits of REG_GPIOX according to their own situation. */
1322 if (EVE_CHIPID >= EVE_FT810)
1323 {
1324 EVE_Hal_wr16(phost, REG_GPIOX_DIR, 0xffff);
1325 EVE_Hal_wr16(phost, REG_GPIOX, 0xffff);
1326 }
1327 else
1328 {
1329 EVE_Hal_wr8(phost, REG_GPIO_DIR, 0xff);
1330 EVE_Hal_wr8(phost, REG_GPIO, 0xff);
1331 }
1332
1333 /* Update touch firmware */
1334#ifdef _MSC_VER
1335#pragma warning(push)
1336#pragma warning(disable : 6285)
1337#endif
1338 if ((EVE_CHIPID == EVE_FT811 || EVE_CHIPID == EVE_FT813) && (EVE_HOST != EVE_HOST_BT8XXEMU))
1339#ifdef _MSC_VER
1340#pragma warning(pop)
1341#endif
1342 {
1343#if defined(PANL70) || defined(PANL70PLUS)
1344 EVE_Hal_wr8(phost, REG_CPURESET, 2);
1345 EVE_Hal_wr16(phost, REG_TOUCH_CONFIG, 0x05d0);
1346#endif
1347 /* Download new firmware to fix pen up issue */
1348 /* It may cause resistive touch not working any more*/
1349 uploadTouchFirmware(phost);
1350#if defined(PANL70) || defined(PANL70PLUS)
1352#endif
1353 EVE_Hal_flush(phost);
1354 EVE_sleep(100);
1355 }
1356
1357#ifdef _MSC_VER
1358#pragma warning(push)
1359#pragma warning(disable : 6285)
1360#endif
1361 if ((EVE_CHIPID == EVE_BT815 || EVE_CHIPID == EVE_BT817) && (EVE_HOST != EVE_HOST_BT8XXEMU))
1362#ifdef _MSC_VER
1363#pragma warning(pop)
1364#endif
1365 {
1366#if defined(DISPLAY_RESOLUTION_WXGA)
1367 //Assume WXGA is using Goodix touch IC
1368 //To be fixed: use macro for touch configuration
1369 eve_printf_debug("Setup touch for Goodix\n");
1370 EVE_Hal_wr8(phost, REG_CPURESET, 2);
1371 EVE_Hal_wr16(phost, REG_TOUCH_CONFIG, 0x05d0);
1372 EVE_Hal_wr8(phost, REG_CPURESET, 0);
1373#endif
1374 }
1375
1376#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
1377#ifdef EVE_TOUCH_GOODIX
1378 eve_printf_debug("Goodix configuration\n");
1379 EVE_Hal_wr8(phost, REG_CPURESET, 2);
1380 EVE_Hal_wr16(phost, REG_TOUCH_CONFIG, 0x05d0);
1381 EVE_Hal_wr8(phost, REG_CPURESET, 0);
1382#endif
1383#endif
1384
1385 return true;
1386}
#define EVE_BT818
Definition EVE_Config.h:69
#define EVE_FT811
Definition EVE_Config.h:59
#define EVE_BT817
Definition EVE_Config.h:68
#define EVE_FT800
Definition EVE_Config.h:56
#define EVE_FT813
Definition EVE_Config.h:61
#define EVE_BT815
Definition EVE_Config.h:66
#define EVE_BT880
Definition EVE_Config.h:62
#define EVE_CHIPID
#define EVE_FT810
Definition EVE_Config.h:58
#define REG_TOUCH_CONFIG
#define REG_GPIO_DIR
#define REG_GPIOX
#define REG_FREQUENCY
#define REG_CPURESET
#define REG_ID
#define REG_GPIOX_DIR
#define REG_GPIO
#define REG_PLAYBACK_LENGTH
#define ROM_CHIPID
Definition EVE_GpuDefs.h:78
@ EVE_SPI_QUAD_CHANNEL
@ EVE_SPI_DUAL_CHANNEL
@ EVE_SLEEP_M
@ EVE_ACTIVE_M
@ EVE_INTERNAL_OSC
@ EVE_EXTERNAL_OSC
@ EVE_SYSCLK_60M
@ EVE_SYSCLK_DEFAULT
@ EVE_SYSCLK_72M
EVE_HAL_EXPORT void EVE_Host_powerModeSwitch(EVE_HalContext *phost, EVE_POWER_MODE_T pwrmode)
Switch power mode for Coprocessor.
Definition EVE_Hal.c:369
EVE_HAL_EXPORT uint32_t EVE_Hal_rd32(EVE_HalContext *phost, uint32_t addr)
Read 4 bytes from Coprocessor's memory.
Definition EVE_Hal.c:189
EVE_HAL_EXPORT void EVE_Host_selectSysClk(EVE_HalContext *phost, EVE_81X_PLL_FREQ_T freq)
Set system clock for Coprocessor.
Definition EVE_Hal.c:390
EVE_HAL_EXPORT void EVE_Hal_wr8(EVE_HalContext *phost, uint32_t addr, uint8_t v)
Write 8 bits to Coprocessor's memory.
Definition EVE_Hal.c:220
EVE_HAL_EXPORT void EVE_Host_coreReset(EVE_HalContext *phost)
Send reset signal to Coprocessor.
Definition EVE_Hal.c:379
EVE_HAL_EXPORT void EVE_Hal_wr16(EVE_HalContext *phost, uint32_t addr, uint16_t v)
Write 2 bytes to Coprocessor's memory.
Definition EVE_Hal.c:234
EVE_HAL_EXPORT void EVE_Hal_wr32(EVE_HalContext *phost, uint32_t addr, uint32_t v)
Write 4 bytes to Coprocessor's memory.
Definition EVE_Hal.c:248
EVE_HAL_EXPORT uint8_t EVE_Hal_rd8(EVE_HalContext *phost, uint32_t addr)
Read 8 bits from Coprocessor's memory.
Definition EVE_Hal.c:157
EVE_HAL_EXPORT bool EVE_Hal_powerCycle(EVE_HalContext *phost, bool up)
Toggle PD_N pin of FT800 board for a power cycle.
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.
@ EVE_HOST_BT8XXEMU
static int EVE_shortChipId(EVE_CHIPID_T chipId)
EVE_HAL_EXPORT void EVE_sleep(uint32_t ms)
Sleep in milisecond.
EVE_HAL_EXPORT void EVE_Hal_flush(EVE_HalContext *phost)
Flush data to Coprocessor.
bool EVE_UtilImpl_bootupDisplayGpio(EVE_HalContext *phost)
Display GPIO pins.
unsigned int uint32_t
unsigned char uint8_t
#define eve_assert(cond)
#define eve_printf_debug(fmt,...)
static void uploadTouchFirmware(EVE_HalContext *phost)
Definition EVE_Util.c:259
#define EXTRACT_CHIPID(romChipId)
Definition EVE_Util.c:1111
EVE_SPI_CHANNELS_T SpiChannels
Definition EVE_Util.h:50
uint8_t SpiDummyBytes
Definition EVE_Util.h:51
EVE_81X_PLL_FREQ_T SystemClock
Definition EVE_Util.h:43
EVE_Callback CbCmdWait
EVE_SPI_CHANNELS_T SpiChannels

◆ EVE_Util_bootupConfig()

EVE_HAL_EXPORT bool EVE_Util_bootupConfig ( EVE_HalContext phost)

Bootup Coprocessor.

Calls EVE_Util_bootup and EVE_Util_config using the default parameters

Parameters
phostPointer to Hal context
Returns
true True if successful
false False if error

Definition at line 1898 of file EVE_Util.c.

1899{
1900 EVE_BootupParameters bootup;
1901 EVE_ConfigParameters config;
1902
1903 EVE_Util_bootupDefaults(phost, &bootup);
1904 if (!EVE_Util_bootup(phost, &bootup))
1905 {
1906 return false;
1907 }
1908
1910 if (!EVE_Util_config(phost, &config))
1911 {
1912 EVE_Util_shutdown(phost);
1913 return false;
1914 }
1915
1916 return true;
1917}
EVE_HAL_EXPORT void EVE_Util_configDefaults(EVE_HalContext *phost, EVE_ConfigParameters *config, EVE_DISPLAY_T display)
Definition EVE_Util.c:765
EVE_HAL_EXPORT void EVE_Util_bootupDefaults(EVE_HalContext *phost, EVE_BootupParameters *bootup)
Definition EVE_Util.c:282
EVE_HAL_EXPORT bool EVE_Util_config(EVE_HalContext *phost, EVE_ConfigParameters *config)
Definition EVE_Util.c:1396
EVE_HAL_EXPORT bool EVE_Util_bootup(EVE_HalContext *phost, EVE_BootupParameters *bootup)
Definition EVE_Util.c:1121
EVE_HAL_EXPORT void EVE_Util_shutdown(EVE_HalContext *phost)
Definition EVE_Util.c:1667

◆ EVE_Util_bootupConfigInteractive()

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 interactivity on FT9XX platform.

Calls EVE_Util_bootup and EVE_Util_config using the default parameters. Falls back to no interactivity on FT9XX platform

Parameters
phostPointer to Hal context
display
Returns
true True if successful
false False if error

Definition at line 2582 of file EVE_Util.c.

2583{
2584 EVE_DISPLAY_T selectedDisplay;
2585 EVE_BootupParameters bootup;
2586 EVE_ConfigParameters config;
2587
2588 EVE_Util_bootupDefaults(phost, &bootup);
2589 if (!EVE_Util_bootup(phost, &bootup))
2590 {
2591 return false;
2592 }
2593
2594 EVE_Util_selectDisplayInteractive(&selectedDisplay);
2595 if (!selectedDisplay)
2596 selectedDisplay = display;
2597
2598 EVE_Util_configDefaults(phost, &config, selectedDisplay);
2599 if (!EVE_Util_config(phost, &config))
2600 {
2601 EVE_Util_shutdown(phost);
2602 return false;
2603 }
2604
2605 return true;
2606}
static void EVE_Util_selectDisplayInteractive(EVE_DISPLAY_T *display)
Definition EVE_Util.h:189

◆ EVE_Util_bootupDefaults()

EVE_HAL_EXPORT void EVE_Util_bootupDefaults ( EVE_HalContext phost,
EVE_BootupParameters bootup 
)

Get the default bootup parameters.

Parameters
phostPointer to Hal context
bootup

Definition at line 282 of file EVE_Util.c.

283{
284 int32_t chipId = EVE_CHIPID;
285 (void)chipId;
286
287 memset(bootup, 0, sizeof(EVE_BootupParameters));
288
289#if !defined(EVE_USE_INTERNAL_OSC)
290 /* Board without external oscillator will not work when ExternalOsc is enabled */
291 bootup->ExternalOsc = true;
292#endif
293
294#ifdef EVE_SYSTEM_CLOCK
295 bootup->SystemClock = EVE_SYSTEM_CLOCK;
296#else
297 if (chipId >= EVE_FT800 && chipId <= EVE_BT818)
298 {
299#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
300 if (chipId >= EVE_BT815)
301 {
302 bootup->SystemClock = EVE_SYSCLK_72M; /* 72Mhz is default for BT8xx */
303 }
304 else
305#endif
306#if (EVE_SUPPORT_CHIPID >= EVE_FT810)
307 if (chipId >= EVE_FT810)
308 {
309 bootup->SystemClock = EVE_SYSCLK_60M; /* 60Mhz is default for FT81x */
310 }
311 else
312#endif
313 {
314 bootup->SystemClock = EVE_SYSCLK_48M; /* 48Mhz is default for FT80x */
315 }
316 }
317 else
318 {
319 /* If the chipid is not known yet, this will reconfigure the system clock during `EVE_Util_bootup`.
320 Additional default clock overrides need to be implemented there as well. */
322 }
323#endif
324
325#if (EVE_SUPPORT_CHIPID >= EVE_FT810)
326#if defined(EVE_MULTI_PLATFORM_TARGET)
327 if (EVE_HOST == EVE_HOST_FT4222)
328 {
330 bootup->SpiDummyBytes = 2;
331 }
332 else
333 {
335 bootup->SpiDummyBytes = 1;
336 }
337#elif defined(ENABLE_SPI_QUAD)
339 bootup->SpiDummyBytes = 2;
340#elif defined(ENABLE_SPI_DUAL)
342 bootup->SpiDummyBytes = 2;
343#else
345 bootup->SpiDummyBytes = 1;
346#endif
347#endif
348}
@ EVE_SPI_SINGLE_CHANNEL
@ EVE_SYSCLK_48M
@ EVE_HOST_FT4222
int int32_t

◆ EVE_Util_clearScreen()

EVE_HAL_EXPORT void EVE_Util_clearScreen ( EVE_HalContext phost)

Clear the screen.

Sets the display list to a blank cleared screen.

Parameters
phostPointer to Hal context

Definition at line 270 of file EVE_Util.c.

271{
274}
#define REG_DLSWAP
#define RAM_DL
Definition EVE_GpuDefs.h:95
#define DLSWAP_FRAME
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.
Definition EVE_Hal.c:278
static eve_progmem_const uint8_t c_DlCodeBootup[12]
Definition EVE_Util.c:38

◆ EVE_Util_config()

EVE_HAL_EXPORT bool EVE_Util_config ( EVE_HalContext phost,
EVE_ConfigParameters config 
)

Boot up the device. Configures the display, resets or initializes coprocessor state.

Parameters
phostPointer to Hal context
config
Returns
true True if successful
false False if error

Definition at line 1396 of file EVE_Util.c.

1397{
1398 /* IMPORTANT: Do not use EVE_CoCmd functions here, as they can be overridden by hooks */
1399
1400 bool reconfigure = phost->PCLK;
1401 if (reconfigure)
1402 {
1403 /* If PCLK is already set, we're reconfiguring. Quiet flush first */
1404 eve_printf_debug("Reconfiguring\n");
1405 EVE_Cmd_waitFlush(phost);
1406 }
1407
1408 const bool swapXY = EVE_CHIPID >= EVE_FT810 ? EVE_Hal_rd8(phost, REG_ROTATE) & 0x2 : false;
1409 uint16_t wp;
1410 uint16_t rp;
1411
1412 if (EVE_CHIPID < EVE_FT810)
1413 {
1414 eve_assert(config->Width < 512);
1415 eve_assert(config->Height < 512);
1416 }
1417 else
1418 {
1419 eve_assert(config->Width < 2048);
1420 eve_assert(config->Height < 2048);
1421 }
1422
1423 /* Turn off display output clock */
1424 EVE_Hal_wr8(phost, REG_PCLK, 0);
1425 phost->PCLK = 0;
1426
1427 EVE_Hal_wr16(phost, REG_HCYCLE, config->HCycle);
1428 EVE_Hal_wr16(phost, REG_HOFFSET, config->HOffset);
1429 EVE_Hal_wr16(phost, REG_HSYNC0, config->HSync0);
1430 EVE_Hal_wr16(phost, REG_HSYNC1, config->HSync1);
1431 EVE_Hal_wr16(phost, REG_VCYCLE, config->VCycle);
1432 EVE_Hal_wr16(phost, REG_VOFFSET, config->VOffset);
1433 EVE_Hal_wr16(phost, REG_VSYNC0, config->VSync0);
1434 EVE_Hal_wr16(phost, REG_VSYNC1, config->VSync1);
1435 EVE_Hal_wr8(phost, REG_SWIZZLE, config->Swizzle);
1436 EVE_Hal_wr8(phost, REG_PCLK_POL, config->PCLKPol);
1437 EVE_Hal_wr16(phost, REG_HSIZE, config->Width);
1438 EVE_Hal_wr16(phost, REG_VSIZE, config->Height);
1439 EVE_Hal_wr16(phost, REG_CSPREAD, config->CSpread);
1440 EVE_Hal_wr16(phost, REG_DITHER, config->Dither);
1442 (uint16_t)(((config->OutBitsR & 0x7) << 6)
1443 | ((config->OutBitsG & 0x7) << 3)
1444 | (config->OutBitsB & 0x7)));
1445 if (swapXY)
1446 {
1447 phost->Width = config->Height;
1448 phost->Height = config->Width;
1449 }
1450 else
1451 {
1452 phost->Width = config->Width;
1453 phost->Height = config->Height;
1454 }
1455
1456#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
1457 bool pclk2X = false;
1458 if (EVE_CHIPID >= EVE_BT817)
1459 {
1460 uint32_t freq = EVE_Hal_rd32(phost, REG_FREQUENCY);
1461 uint16_t pclkFreq = config->PClkFreq;
1462 if (!pclkFreq)
1463 {
1464 /* If not configured, match system frequency, in case a legacy configuration with PClk 1 is specified */
1465 /* PClk Freq is 60MHz by default, but we raise the system frequency to 72MHz during bootup */
1466 uint32_t refMul = freq / 6000000;
1467 uint32_t pllFreq = 12 * refMul;
1468 uint32_t range = pllFreq >= 160 ? 3 : (pllFreq >= 80 ? 2 : (pllFreq >= 40 ? 1 : 0));
1469 pclkFreq = 1 | ((refMul & 0x3F) << 4) | (range << 10);
1470 }
1471 EVE_Hal_wr32(phost, REG_PCLK_FREQ, pclkFreq);
1472 if (config->PClk2X)
1473 {
1474 /* User forces 2X */
1475 EVE_Hal_wr8(phost, REG_PCLK_2X, 1);
1476 }
1477 else if (config->PCLK == 1)
1478 {
1479 /* Send two pixels per system clock to the EXTSYNC block if PCLK_frequency > SystemClock */
1480 uint32_t pclkFrequency = getFreqFromPClkFreq(pclkFreq);
1481 pclk2X = pclkFrequency > freq;
1482 EVE_Hal_wr8(phost, REG_PCLK_2X, pclk2X);
1483 }
1484 else
1485 {
1486 EVE_Hal_wr8(phost, REG_PCLK_2X, 0);
1487 }
1488 }
1489#endif
1490
1491#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
1492 if (EVE_CHIPID >= EVE_BT815)
1493 {
1495 }
1496#endif
1497
1498#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
1499 if (EVE_CHIPID >= EVE_BT817)
1500 {
1501 EVE_Hal_wr16(phost, REG_AH_HCYCLE_MAX, config->AhHCycleMax);
1502 }
1503#endif
1504
1505#ifdef RESISTANCE_THRESHOLD /* TODO: From config */
1506 if (EVE_Hal_isScreenResistive(phost))
1507 {
1508 /* Touch configuration - configure the resistance value to 1200 - this value is specific to customer requirement and derived by experiment */
1509 /* TODO: From config */
1511 }
1512#endif
1513
1514 EVE_Util_clearScreen(phost);
1515
1516 /* Refresh fifo */
1517 wp = EVE_Cmd_wp(phost);
1518 rp = EVE_Cmd_rp(phost);
1519 EVE_Cmd_space(phost);
1520#if (EVE_SUPPORT_CHIPID >= EVE_FT810)
1521 if (EVE_CHIPID >= EVE_FT810)
1522 {
1523 phost->MediaFifoAddress = 0;
1524 phost->MediaFifoSize = 0;
1525 }
1526#endif
1527
1528 /* Coprocessor needs a reset */
1529 if (reconfigure ? EVE_CMD_FAULT(rp) : (wp || rp))
1530 {
1531 /* If this occurs after powerdown and bootup, powerdown is not working */
1532 eve_printf_debug("Coprocessor fifo not empty\n");
1533 if (!EVE_Util_resetCoprocessor(phost))
1534 return false;
1535 }
1536 else
1537 {
1538 /* Setup coprocessor defaults */
1539 eve_printf_debug("Configure coprocessor defaults\n");
1540 EVE_Cmd_wr32(phost, CMD_DLSTART);
1542
1543 /* Set the latest API level.
1544 CMD_APILEVEL applicable since BT817. */
1545#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
1546 if (EVE_CHIPID >= EVE_BT817)
1547 {
1548 EVE_Cmd_wr32(phost, CMD_APILEVEL);
1549 EVE_Cmd_wr32(phost, 2);
1550 }
1551#endif
1552
1553#ifdef EVE_FLASH_AVAILABLE
1554 if (EVE_CHIPID >= EVE_BT815)
1555 {
1556 /* Reattach flash to avoid inconsistent state */
1559 }
1560#endif
1561
1563 }
1564
1565#ifdef EVE_SUPPORT_HSF
1566 if (config->HsfWidth)
1567 {
1568 if (EVE_Hal_supportHsf(phost) && !pclk2X)
1569 {
1570 EVE_Cmd_startFunc(phost);
1571 EVE_Cmd_wr32(phost, CMD_HSF);
1572 EVE_Cmd_wr32(phost, config->HsfWidth);
1573 EVE_Cmd_endFunc(phost);
1574 }
1575 else
1576 {
1577 /* Set width to screen width if HSF is not supported here */
1578 eve_printf_debug("HSF specified but not supported on this device\n");
1579 EVE_Hal_wr16(phost, REG_HSIZE, config->HsfWidth);
1580 if (swapXY)
1581 phost->Height = config->HsfWidth;
1582 else
1583 phost->Width = config->HsfWidth;
1584 }
1585 }
1586#endif
1587
1588 EVE_Hal_flush(phost);
1589 if (!EVE_Cmd_waitFlush(phost))
1590 return false;
1591
1592 EVE_Hal_wr8(phost, REG_PCLK, config->PCLK); /* After this display is visible on the LCD */
1593 phost->PCLK = config->PCLK;
1594
1595#ifdef EVE_SUPPORT_HSF
1596 if (config->HsfWidth)
1597 {
1598 if (EVE_Hal_supportHsf(phost))
1599 {
1600 eve_printf_debug("HSize: %i, HSF HSize: %i\n", EVE_Hal_rd32(phost, REG_HSIZE), EVE_Hal_rd32(phost, REG_HSF_HSIZE));
1601 }
1602 }
1603#endif
1604
1605#if (defined(ENABLE_ILI9488_HVGA_PORTRAIT) || defined(ENABLE_KD2401_HVGA_PORTRAIT))
1606 /* to cross check reset pin */
1607 EVE_Hal_wr8(phost, REG_GPIO, 0xff);
1608 EVE_Hal_flush(phost);
1609 EVE_sleep(120);
1610 EVE_Hal_wr8(phost, REG_GPIO, 0x7f);
1611 EVE_Hal_flush(phost);
1612 EVE_sleep(120);
1613 EVE_Hal_wr8(phost, REG_GPIO, 0xff);
1614 EVE_Hal_flush(phost);
1615 EVE_sleep(120);
1616#endif
1617
1618#if defined(ENABLE_ILI9488_HVGA_PORTRAIT) || defined(ENABLE_KD2401_HVGA_PORTRAIT)
1619#if defined(RP2040_PLATFORM)
1620 EVE_ILI9488_RP2040_bootup(phost);
1621 eve_printf_debug("after ILI9488 RP2040 bootup\n");
1622 EVE_Hal_restoreSPI(phost);
1623#endif
1624#if defined(FT9XX_PLATFORM)
1625 EVE_ILI9488_bootup();
1626 eve_printf_debug("after ILI9488 bootup\n");
1627 EVE_Hal_restoreSPI(phost);
1628#endif
1629#endif
1630
1631#if 0
1632 eve_printf_debug("REG_HSIZE: %i\n", (int)EVE_Hal_rd16(phost, REG_HSIZE));
1633 eve_printf_debug("REG_VSIZE: %i\n", (int)EVE_Hal_rd16(phost, REG_VSIZE));
1634 eve_printf_debug("REG_HCYCLE: %i\n", (int)EVE_Hal_rd16(phost, REG_HCYCLE));
1635 eve_printf_debug("REG_HOFFSET: %i\n", (int)EVE_Hal_rd16(phost, REG_HOFFSET));
1636 eve_printf_debug("REG_HSYNC0: %i\n", (int)EVE_Hal_rd16(phost, REG_HSYNC0));
1637 eve_printf_debug("REG_HSYNC1: %i\n", (int)EVE_Hal_rd16(phost, REG_HSYNC1));
1638 eve_printf_debug("REG_VCYCLE: %i\n", (int)EVE_Hal_rd16(phost, REG_VCYCLE));
1639 eve_printf_debug("REG_VOFFSET: %i\n", (int)EVE_Hal_rd16(phost, REG_VOFFSET));
1640 eve_printf_debug("REG_VSYNC0: %i\n", (int)EVE_Hal_rd16(phost, REG_VSYNC0));
1641 eve_printf_debug("REG_VSYNC1: %i\n", (int)EVE_Hal_rd16(phost, REG_VSYNC1));
1642 eve_printf_debug("REG_PCLK: %i\n", (int)EVE_Hal_rd16(phost, REG_PCLK));
1643 eve_printf_debug("REG_SWIZZLE: %i\n", (int)EVE_Hal_rd16(phost, REG_SWIZZLE));
1644 eve_printf_debug("REG_PCLK_POL: %i\n", (int)EVE_Hal_rd16(phost, REG_PCLK_POL));
1645 eve_printf_debug("REG_CSPREAD: %i\n", (int)EVE_Hal_rd16(phost, REG_CSPREAD));
1646 eve_printf_debug("REG_OUTBITS: %i\n", (int)EVE_Hal_rd16(phost, REG_OUTBITS));
1647 eve_printf_debug("REG_DITHER: %i\n", (int)EVE_Hal_rd16(phost, REG_DITHER));
1648#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
1649 eve_printf_debug("REG_ADAPTIVE_FRAMERATE: %i\n", (int)EVE_Hal_rd16(phost, REG_ADAPTIVE_FRAMERATE));
1650#endif
1651#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
1652 eve_printf_debug("REG_PCLK_FREQ: %X\n", (int)EVE_Hal_rd16(phost, REG_PCLK_FREQ));
1653 eve_printf_debug("REG_AH_HCYCLE_MAX: %i\n", (int)EVE_Hal_rd16(phost, REG_AH_HCYCLE_MAX));
1654 eve_printf_debug("REG_HSF_HSIZE: %i\n", (int)EVE_Hal_rd16(phost, REG_HSF_HSIZE));
1655#endif
1656#endif
1657
1658 eve_printf_debug("EVE configuration ready\n");
1659 return true;
1660}
EVE_HAL_EXPORT uint16_t EVE_Cmd_space(EVE_HalContext *phost)
Get free space of Coprocessor's command buffer.
Definition EVE_Cmd.c:105
EVE_HAL_EXPORT void EVE_Cmd_startFunc(EVE_HalContext *phost)
Begin writing a function, keeps the transfer open.
Definition EVE_Cmd.c:262
EVE_HAL_EXPORT uint16_t EVE_Cmd_rp(EVE_HalContext *phost)
Read from Coprocessor.
Definition EVE_Cmd.c:64
EVE_HAL_EXPORT void EVE_Cmd_endFunc(EVE_HalContext *phost)
End writing a function, closes the transfer.
Definition EVE_Cmd.c:274
EVE_HAL_EXPORT uint16_t EVE_Cmd_wp(EVE_HalContext *phost)
Write to Coprocessor.
Definition EVE_Cmd.c:80
EVE_HAL_EXPORT bool EVE_Cmd_wr32(EVE_HalContext *phost, uint32_t value)
Write 4 bytes to Coprocessor's command fifo.
Definition EVE_Cmd.c:394
#define REG_PCLK_POL
#define REG_VSYNC0
#define REG_HSIZE
#define REG_ROTATE
#define CMD_FLASHDETACH
#define REG_HSYNC1
#define REG_VSIZE
#define CMD_HSF
#define REG_DITHER
#define REG_ADAPTIVE_FRAMERATE
#define REG_TOUCH_RZTHRESH
#define CMD_DLSTART
#define REG_CSPREAD
#define CMD_FLASHATTACH
#define REG_PCLK_2X
#define EVE_CMD_FAULT(rp)
Definition EVE_GpuDefs.h:63
#define REG_HCYCLE
#define REG_VSYNC1
#define REG_VCYCLE
#define REG_AH_HCYCLE_MAX
#define REG_HOFFSET
#define REG_PCLK_FREQ
#define REG_OUTBITS
#define CMD_APILEVEL
#define CMD_COLDSTART
#define REG_HSF_HSIZE
#define REG_VOFFSET
#define REG_PCLK
#define REG_HSYNC0
#define REG_SWIZZLE
EVE_HAL_EXPORT uint16_t EVE_Hal_rd16(EVE_HalContext *phost, uint32_t addr)
Read 2 bytes from Coprocessor's memory.
Definition EVE_Hal.c:173
static bool EVE_Hal_supportHsf(EVE_HalContext *phost)
static bool EVE_Hal_isScreenResistive(EVE_HalContext *phost)
EVE_HAL_EXPORT void EVE_Hal_restoreSPI(EVE_HalContext *phost)
unsigned short uint16_t
EVE_HAL_EXPORT void EVE_Util_clearScreen(EVE_HalContext *phost)
Clear the screen.
Definition EVE_Util.c:270
EVE_HAL_EXPORT bool EVE_Util_resetCoprocessor(EVE_HalContext *phost)
Reset Coprocessor.
Definition EVE_Util.c:1752
EVE_HAL_EXPORT void EVE_CoDlImpl_resetCoState(EVE_HalContext *phost)
Definition EVE_CoDl.c:83
void EVE_Cmd_waitFlush(EVE_HalContext *host)
Definition Gpu_Hal.cpp:775
#define RESISTANCE_THRESHOLD
Definition Platform.h:59
uint32_t Height
uint32_t MediaFifoAddress
uint32_t MediaFifoSize

◆ EVE_Util_configDefaults()

EVE_HAL_EXPORT void EVE_Util_configDefaults ( EVE_HalContext phost,
EVE_ConfigParameters config,
EVE_DISPLAY_T  display 
)

Get the default configuration parameters for the specified display.

Parameters
phostPointer to Hal context
config
display

Definition at line 765 of file EVE_Util.c.

766{
767 bool supportedResolution;
768 uint32_t freq = EVE_Hal_rd32(phost, REG_FREQUENCY);
769 uint32_t width;
770 uint32_t height;
771 uint32_t refreshRate;
772 uint32_t hsfWidth;
773
774 /* NOTE: Update `EVE_DISPLAY_T` in `EVE_Util.h` when adding display presets. */
775 if (!display)
776 {
777 /* Default displays if none was explicitly chosen */
778#if defined(DISPLAY_RESOLUTION_QVGA)
780#elif defined(DISPLAY_RESOLUTION_WQVGA)
782#elif defined(DISPLAY_RESOLUTION_WVGA)
783#if defined(EVE_GRAPHICS_IDM2040)
785#else
787#endif
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)
796#else
797 if (EVE_CHIPID >= EVE_BT817)
799 else if (EVE_CHIPID >= EVE_BT815)
801 else if (EVE_CHIPID >= EVE_FT810)
803 else if (EVE_CHIPID >= EVE_FT800)
805#endif
806 }
807
808 width = s_DisplayResolutions[display][0];
809 height = s_DisplayResolutions[display][1];
810#if EVE_DISPLAY_REFRESH
811 refreshRate = EVE_DISPLAY_REFRESH;
812#else
813 refreshRate = s_DisplayResolutions[display][2];
814#endif
815 hsfWidth = s_DisplayResolutions[display][3];
816 supportedResolution = configDefaultsEx(phost, config, width, height, refreshRate, hsfWidth, freq);
817
818 /* Known values for specific display models */
819#if EVE_DISPLAY_REFRESH
820 if (EVE_DISPLAY_REFRESH != s_DisplayResolutions[display][2])
821 {
822 /* Don't use known preset values if the requested refresh rate differs from the default */
823 }
824 else
825#endif
826 if (display == EVE_DISPLAY_QVGA_320x240_56Hz && freq == 48000000)
827 {
828 /*
829 FT800 known values:
830 Resolution: 320x240
831 Refresh rate: 55.916Hz
832 */
833#if EVE_HARDCODED_DISPLAY_TIMINGS
834 if (supportedResolution)
835 {
836 config->Width = 320;
837 config->Height = 240;
838 config->HCycle = 408;
839 config->HOffset = 70;
840 config->HSync0 = 0;
841 config->HSync1 = 10;
842 config->VCycle = 263;
843 config->VOffset = 13;
844 config->VSync0 = 0;
845 config->VSync1 = 2;
846 config->PCLK = 8;
847#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
848 config->PClkFreq = 0;
849#endif
850#ifdef EVE_SUPPORT_HSF
851 config->HsfWidth = 0;
852#endif
853 }
854#endif
855 config->Swizzle = 2;
856 config->PCLKPol = 0;
857 config->CSpread = 1;
858 config->Dither = 1;
859 }
860 else if (display == EVE_DISPLAY_WQVGA_480x272_60Hz && freq == 48000000)
861 {
862 /*
863 FT800 known values:
864 Display: LBL-T050BPH-01
865 REG_FREQUENCY: 48MHz
866 REG_PCLK: 5
867 REG_HCYCLE: 548
868 REG_VCYCLE: 292
869 Resolution: 480x272
870 Refresh rate: 59.994Hz
871 */
872#if EVE_HARDCODED_DISPLAY_TIMINGS
873 if (supportedResolution)
874 {
875 config->Width = 480;
876 config->Height = 272;
877 config->HCycle = 548;
878 config->HOffset = 43;
879 config->HSync0 = 0;
880 config->HSync1 = 41;
881 config->VCycle = 292;
882 config->VOffset = 12;
883 config->VSync0 = 0;
884 config->VSync1 = 10;
885 config->PCLK = 5;
886#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
887 config->PClkFreq = 0;
888#endif
889#ifdef EVE_SUPPORT_HSF
890 config->HsfWidth = 0;
891#endif
892 }
893#endif
894 }
895#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
896 else if (display == EVE_DISPLAY_WQVGA_480x272_60Hz && EVE_CHIPID >= EVE_BT817)
897 {
898 /* Same as above, but using PClkFreq */
899#if EVE_HARDCODED_DISPLAY_TIMINGS
900 if (supportedResolution)
901 {
902 config->Width = 480;
903 config->Height = 272;
904 config->HCycle = 548;
905 config->HOffset = 43;
906 config->HSync0 = 0;
907 config->HSync1 = 41;
908 config->VCycle = 292;
909 config->VOffset = 12;
910 config->VSync0 = 0;
911 config->VSync1 = 10;
912 config->PCLK = 1;
913 config->PClkFreq = 0x885; // 9.6MHz
914 config->HsfWidth = 0;
915 }
916#endif
917 }
918#endif
919 else if (display == EVE_DISPLAY_WVGA_800x480_74Hz && freq == 72000000)
920 {
921 /*
922 BT81X known values:
923 Display: MTF070TN83-V1
924 REG_FREQUENCY: 72MHz
925 Resolution: 800x480
926 Refresh rate: 73.892Hz
927 */
928#if EVE_HARDCODED_DISPLAY_TIMINGS
929 if (supportedResolution)
930 {
931 config->Width = 800;
932 config->Height = 480;
933 config->HCycle = 928;
934 config->HOffset = 88;
935 config->HSync0 = 0;
936 config->HSync1 = 48;
937 config->VCycle = 525;
938 config->VOffset = 32;
939 config->VSync0 = 0;
940 config->VSync1 = 3;
941 config->PCLK = 2;
942#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
943 config->PClkFreq = 0;
944#endif
945#ifdef EVE_SUPPORT_HSF
946 config->HsfWidth = 0;
947#endif
948 }
949#endif
950 }
951 else if (display == EVE_DISPLAY_HDTV_1280x720_58Hz && freq == 72000000)
952 {
953 /*
954 BT815 known values:
955 REG_FREQUENCY: 72MHz
956 Resolution: 1280x720
957 Refresh rate: 58.182Hz
958 */
959#if EVE_HARDCODED_DISPLAY_TIMINGS
960 if (supportedResolution)
961 {
962 config->Width = 1280;
963 config->Height = 720;
964 config->HCycle = 1650;
965 config->HOffset = 40 + 220;
966 config->HSync0 = 0;
967 config->HSync1 = 40;
968 config->VCycle = 750;
969 config->VOffset = 5 + 20;
970 config->VSync0 = 0;
971 config->VSync1 = 5;
972 config->PCLK = 1;
973#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
974 config->PClkFreq = 0;
975#endif
976#ifdef EVE_SUPPORT_HSF
977 config->HsfWidth = 0;
978#endif
979 }
980#endif
981 config->CSpread = 0;
982 config->Dither = 0;
983 config->PCLKPol = 0;
984 config->OutBitsR = 0;
985 config->OutBitsG = 0;
986 config->OutBitsB = 0;
987 }
988 else if (display == EVE_DISPLAY_WXGA_1280x800_57Hz)
989 {
990 /*
991 BT817 known values:
992 Resolution: 1280x800
993 Refresh rate: 57.393Hz
994 */
995#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
996#if EVE_HARDCODED_DISPLAY_TIMINGS
997 if (EVE_CHIPID >= EVE_BT817 && supportedResolution)
998 {
999 config->Width = 1280;
1000 config->Height = 800;
1001 config->HCycle = 1411;
1002 config->HOffset = 120;
1003 config->HSync0 = 0;
1004 config->HSync1 = 100;
1005 config->VCycle = 815;
1006 config->VOffset = 14;
1007 config->VSync0 = 0;
1008 config->VSync1 = 10;
1009 config->PCLK = 1;
1010 config->PClkFreq = 0x8B1; // 66MHz
1011#ifdef EVE_SUPPORT_HSF
1012 config->HsfWidth = 0;
1013#endif
1014 }
1015#endif
1016#endif
1017 config->CSpread = 0;
1018 config->Dither = 0;
1019 config->PCLKPol = 0;
1020 config->OutBitsR = 0;
1021 config->OutBitsG = 0;
1022 config->OutBitsB = 0;
1023 }
1024 else if (display == EVE_DISPLAY_WSVGA_1024x600_59Hz)
1025 {
1026 /*
1027 BT817 known values:
1028 Resolution: 1024x600
1029 Refresh rate: 59.758Hz
1030 */
1031#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
1032#if EVE_HARDCODED_DISPLAY_TIMINGS
1033 if (EVE_CHIPID >= EVE_BT817 && supportedResolution)
1034 {
1035 config->Width = 1024;
1036 config->Height = 600;
1037 config->HCycle = 1344;
1038 config->HOffset = 160;
1039 config->HSync0 = 0;
1040 config->HSync1 = 100;
1041 config->VCycle = 635;
1042 config->VOffset = 23;
1043 config->VSync0 = 0;
1044 config->VSync1 = 10;
1045 config->PCLK = 1;
1046 config->PClkFreq = 0xD12; // 51Mhz
1047#ifdef EVE_SUPPORT_HSF
1048 config->HsfWidth = 0;
1049#endif
1050 }
1051#endif
1052#endif
1053 config->CSpread = 0;
1054 config->Dither = 1;
1055 config->PCLKPol = 1;
1056 config->OutBitsR = 0;
1057 config->OutBitsG = 0;
1058 config->OutBitsB = 0;
1059 }
1060
1061#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
1062 /* Disable max cycle if incompatible hardcoded timings are used */
1063 if (config->AhHCycleMax && config->HCycle > config->AhHCycleMax)
1064 config->AhHCycleMax = 0;
1065#endif
1066
1067#ifdef _DEBUG
1068#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
1069 if (config->PClkFreq)
1070 {
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));
1073 }
1074 else
1075#endif
1076 eve_printf_debug("Display refresh rate set to %f Hz\n", (float)((double)freq / ((double)config->HCycle * (double)config->VCycle * (double)config->PCLK)));
1077#endif
1078
1079#if 0
1080 eve_printf_debug("Width: %i\n", (int)config->Width);
1081 eve_printf_debug("Height: %i\n", (int)config->Height);
1082 eve_printf_debug("HCycle: %i\n", (int)config->HCycle);
1083 eve_printf_debug("HOffset: %i\n", (int)config->HOffset);
1084 eve_printf_debug("HSync0: %i\n", (int)config->HSync0);
1085 eve_printf_debug("HSync1: %i\n", (int)config->HSync1);
1086 eve_printf_debug("VCycle: %i\n", (int)config->VCycle);
1087 eve_printf_debug("VOffset: %i\n", (int)config->VOffset);
1088 eve_printf_debug("VSync0: %i\n", (int)config->VSync0);
1089 eve_printf_debug("VSync1: %i\n", (int)config->VSync1);
1090 eve_printf_debug("PCLK: %i\n", (int)config->PCLK);
1091 eve_printf_debug("Swizzle: %i\n", (int)config->Swizzle);
1092 eve_printf_debug("PCLKPol: %i\n", (int)config->PCLKPol);
1093 eve_printf_debug("CSpread: %i\n", (int)config->CSpread);
1094 eve_printf_debug("OutBitsR: %i\n", (int)config->OutBitsR);
1095 eve_printf_debug("OutBitsG: %i\n", (int)config->OutBitsG);
1096 eve_printf_debug("OutBitsB: %i\n", (int)config->OutBitsB);
1097 eve_printf_debug("Dither: %i\n", (int)config->Dither);
1098#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
1099 eve_printf_debug("AdaptiveFramerate: %i\n", (int)config->AdaptiveFramerate);
1100#endif
1101#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
1102 eve_printf_debug("PClkFreq: %X\n", (int)config->PClkFreq);
1103 eve_printf_debug("AhHCycleMax: %i\n", (int)config->AhHCycleMax);
1104#endif
1105#ifdef EVE_SUPPORT_HSF
1106 eve_printf_debug("HsfWidth: %i\n", (int)config->HsfWidth);
1107#endif
1108#endif
1109}
#define EVE_DISPLAY_REFRESH
static const uint16_t s_DisplayResolutions[EVE_DISPLAY_NB][4]
Definition EVE_Util.c:45
static bool configDefaultsEx(EVE_HalContext *phost, EVE_ConfigParameters *config, uint32_t width, uint32_t height, uint32_t refreshRate, uint32_t hsfWidth, uint32_t freq)
Definition EVE_Util.c:445

◆ EVE_Util_configDefaultsEx()

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 
)

Get the default configuration parameters for the specified display parameters.

Parameters
phostPointer to Hal context
config
width
height
refreshRate
hsfWidth
Returns
true True if successful
false False if error

Definition at line 740 of file EVE_Util.c.

741{
742 uint32_t freq = EVE_Hal_rd32(phost, REG_FREQUENCY);
743 bool res = configDefaultsEx(phost, config, width, height, refreshRate, hsfWidth, freq);
744#ifdef _DEBUG
745#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
746 if (config->PClkFreq)
747 {
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));
750 }
751 else
752#endif
753 eve_printf_debug("Display refresh rate set to %f Hz\n", (float)((double)freq / ((double)config->HCycle * (double)config->VCycle * (double)config->PCLK)));
754#endif
755 return res;
756}

◆ EVE_Util_forceFault()

EVE_HAL_EXPORT void EVE_Util_forceFault ( EVE_HalContext phost,
const char *  err 
)

Forces a coprocessor fault, useful for triggering a delayed reset (TODO: Remove this)

Parameters
phostPointer to Hal context
err

Definition at line 2614 of file EVE_Util.c.

2615{
2616 /* Check if we're already in fault state */
2617 if (!EVE_Cmd_waitSpace(phost, 0))
2618 return;
2619#if 1
2620 /* Go into reset state and mimic a fault */
2621 EVE_Hal_wr8(phost, REG_CPURESET, 1);
2622 EVE_Hal_flush(phost);
2623 EVE_sleep(100);
2624 EVE_Hal_wr16(phost, REG_CMD_READ, 0xFFF);
2625 EVE_Hal_wr16(phost, REG_CMD_WRITE, 0xFFF);
2626#else
2627 /* TODO: Clean this up a bit */
2628 if (!EVE_Util_resetCoprocessor(phost))
2629 return;
2630 EVE_CoCmd_dlStart(phost);
2631 for (int i = 0; i < EVE_DL_COUNT; ++i)
2632 EVE_Cmd_wr32(phost, DISPLAY());
2633 EVE_Cmd_waitFlush(phost);
2634 EVE_Cmd_wr32(phost, DISPLAY());
2635 EVE_Hal_flush(phost);
2636 EVE_sleep(100);
2637#endif
2638#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
2639 if (EVE_CHIPID >= EVE_BT815 && (EVE_Cmd_rp(phost) & 0x3))
2640 {
2641 /* Write our own error to the error report area */
2642 uint32_t errLen = (uint32_t)strlen(err);
2643 EVE_Hal_wrMem(phost, RAM_ERR_REPORT, (const uint8_t *)err, errLen);
2644 if (errLen < RAM_ERR_REPORT_MAX)
2645 {
2647 for (int i = (int)errLen; i < RAM_ERR_REPORT_MAX; ++i)
2648 EVE_Hal_transfer8(phost, 0);
2649 EVE_Hal_endTransfer(phost);
2650 }
2651 }
2652#endif
2653 /* Fault state now */
2654 EVE_Cmd_waitFlush(phost);
2655#if 0
2656#if defined(_DEBUG)
2657#if (EVE_SUPPORT_CHIPID >= EVE_BT815)
2658 if (EVE_CHIPID >= EVE_BT815
2659 && phost->DebugMessageVisible)
2660 {
2661 uint32_t errLen = (uint32_t)strlen(err);
2662 EVE_Hal_wrMem(phost, RAM_G + RAM_G_SIZE - sizeof(phost->DebugBackup), (const uint8_t *)err, errLen);
2663 if (errLen < sizeof(phost->DebugBackup))
2664 {
2665 EVE_Hal_startTransfer(phost, EVE_TRANSFER_WRITE, RAM_G + RAM_G_SIZE - sizeof(phost->DebugBackup) + errLen);
2666 for (int i = (int)errLen; i < sizeof(phost->DebugBackup); ++i)
2667 EVE_Hal_transfer8(phost, 0);
2668 EVE_Hal_endTransfer(phost);
2669 }
2670 }
2671#endif
2672#endif
2673#endif
2674}
EVE_HAL_EXPORT uint32_t EVE_Cmd_waitSpace(EVE_HalContext *phost, uint32_t size)
Definition EVE_Cmd.c:580
static void EVE_CoCmd_dlStart(EVE_HalContext *phost)
Send CMD_DLSTART.
Definition EVE_CoCmd.h:159
#define RAM_ERR_REPORT
Definition EVE_GpuDefs.h:79
#define EVE_DL_COUNT
Definition EVE_GpuDefs.h:57
#define DISPLAY()
#define REG_CMD_WRITE
#define RAM_G_SIZE
Definition EVE_GpuDefs.h:98
#define REG_CMD_READ
#define RAM_G
Definition EVE_GpuDefs.h:77
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.
Definition EVE_Hal.c:263
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_startTransfer(EVE_HalContext *phost, EVE_TRANSFER_T rw, uint32_t addr)
Start data transfer to Coprocessor.
@ EVE_TRANSFER_WRITE
Definition EVE_HalDefs.h:68
#define RAM_ERR_REPORT_MAX
Definition EVE_HalDefs.h:89
EVE_HAL_EXPORT void EVE_Hal_endTransfer(EVE_HalContext *phost)
End data transfer.
bool DebugMessageVisible
uint8_t DebugBackup[RAM_ERR_REPORT_MAX]

◆ EVE_Util_openDeviceInteractive()

EVE_HAL_EXPORT bool EVE_Util_openDeviceInteractive ( EVE_HalContext phost,
const wchar_t *  flashFile 
)

Command line device selection utility. Provides selection of flash file, and option to write the flash file to the device. Parameter flashFile is only relevant for Windows build. Falls back to no interactivity on FT9XX platform

Parameters
phostPointer to Hal context
flashFile
Returns
true True if successful
false False if error

Definition at line 2521 of file EVE_Util.c.

2522{
2523 EVE_CHIPID_T chipId;
2524 size_t deviceIdx;
2525 bool opened;
2526
2527#ifdef BT8XXEMU_PLATFORM
2528 BT8XXEMU_EmulatorParameters emulatorParams;
2529#if defined(EVE_FLASH_AVAILABLE)
2530 BT8XXEMU_FlashParameters flashParams;
2531#endif
2532#endif
2533 EVE_HalParameters params = { 0 };
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';
2539#endif
2540
2541 /* Interactive device selection */
2542 EVE_Util_selectDeviceInteractive(&chipId, &deviceIdx);
2543
2544 /* Fetch the default parameters for a device. Set the expected chip id.
2545 Pass the device index, or -1 to select the first device */
2546 EVE_Hal_defaultsEx(&params, deviceIdx);
2547
2548#if defined(_WIN32) && defined(EVE_FLASH_AVAILABLE)
2549 if (chipId >= EVE_BT815 || (chipId <= 0 && flashFile && flashFile[0]))
2550 EVE_Util_selectFlashFileInteractive(flashPath, sizeof(flashPath) / sizeof(flashPath[0]), &updateFlash, &updateFlashFirmware, &params, flashFile);
2551#endif
2552
2553#if defined(BT8XXEMU_PLATFORM)
2554 EVE_Util_emulatorDefaults(&params, &emulatorParams, chipId);
2555#if defined(EVE_FLASH_AVAILABLE)
2556 EVE_Util_emulatorFlashDefaults(&params, &emulatorParams, &flashParams, flashPath);
2557#endif
2558#endif
2559
2560 opened = EVE_Hal_open(phost, &params);
2561
2562 if (!opened)
2563 return false;
2564
2565#if defined(_WIN32) && defined(EVE_FLASH_AVAILABLE)
2566 if (updateFlash && flashPath[0])
2567 EVE_Util_uploadFlashFileInteractive(phost, flashPath, updateFlashFirmware);
2568#endif
2569
2570 return true;
2571}
EVE_HAL_EXPORT void EVE_Hal_defaultsEx(EVE_HalParameters *parameters, size_t deviceIdx)
Setup default parameters for Eve_Hal framework.
Definition EVE_Hal.c:89
EVE_HAL_EXPORT bool EVE_Hal_open(EVE_HalContext *phost, const EVE_HalParameters *parameters)
Open the Eve_Hal framework.
Definition EVE_Hal.c:103
EVE_CHIPID_T
Definition EVE_HalDefs.h:72
static void EVE_Util_uploadFlashFileInteractive(EVE_HalContext *phost, const eve_tchar_t *flashPath, bool updateFlashFirmware)
Definition EVE_Util.h:209
static void EVE_Util_selectDeviceInteractive(EVE_CHIPID_T *chipId, size_t *deviceIdx)
Definition EVE_Util.h:178
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)
Definition EVE_Util.h:198

◆ EVE_Util_resetCoprocessor()

EVE_HAL_EXPORT bool EVE_Util_resetCoprocessor ( EVE_HalContext phost)

Reset Coprocessor.

Resets the coprocessor. To be used after a coprocessor fault, or to exit CMD_LOGO. After a reset, flash will be in attached state (not in full speed). Coprocessor will be set to the latest API level.

Parameters
phostPointer to Hal context
Returns
true True if successful
false False if error

Definition at line 1752 of file EVE_Util.c.

1753{
1754 /* IMPORTANT: Do not use EVE_CoCmd functions here, as they can be overridden by hooks */
1755
1756 const bool needsVideoPatch = EVE_Util_needsVideoPatch(phost);
1757 uint16_t videoPatchVector;
1758 bool ready;
1759 uint16_t rd;
1760 uint16_t wr;
1761 (void)rd;
1762 (void)wr;
1763
1764 eve_printf_debug("Reset coprocessor\n");
1765
1766 if (needsVideoPatch)
1767 {
1768 /* BT81X video patch */
1769 videoPatchVector = EVE_Hal_rd16(phost, EVE_VIDEOPATCH_ADDR);
1770 }
1771
1772 /* Set REG_CPURESET to 1, to hold the coprocessor in the reset condition */
1773 EVE_Hal_wr8(phost, REG_CPURESET, 1);
1774 EVE_Hal_flush(phost);
1775 EVE_sleep(100);
1776
1777 /* Set REG_CMD_READ and REG_CMD_WRITE to zero */
1778 EVE_Hal_wr16(phost, REG_CMD_READ, 0);
1779 EVE_Hal_wr16(phost, REG_CMD_WRITE, 0);
1780 EVE_Hal_wr16(phost, REG_CMD_DL, 0);
1781 EVE_Hal_wr8(phost, REG_PCLK, phost->PCLK); /* j1 will set the pclk to 0 for that error case */
1782
1783 /* Stop playing audio in case video with audio was playing during reset */
1784 EVE_Hal_wr8(phost, REG_PLAYBACK_PLAY, 0);
1785
1786 if (EVE_Util_needsSubPatch(phost))
1787 {
1788 /* Enable patched rom in case the reset is requested while CMD_LOGO is running.
1789 This is necessary as CMD_LOGO may swap to the other rom page */
1790 EVE_Hal_wr8(phost, REG_ROMSUB_SEL, 3);
1791 }
1792
1793 /* Default */
1794 phost->CmdFault = false;
1795
1796 /* Set REG_CPURESET to 0, to restart the coprocessor */
1797 EVE_Hal_wr8(phost, REG_CPURESET, 0);
1798 EVE_Hal_flush(phost);
1799 EVE_sleep(100);
1800 eve_assert((wr = EVE_Hal_rd16(phost, REG_CMD_WRITE)) == 0);
1801 eve_assert((rd = EVE_Hal_rd16(phost, REG_CMD_READ)) == 0);
1802
1803 /* Refresh fifo */
1804 EVE_Cmd_waitFlush(phost);
1805#if (EVE_SUPPORT_CHIPID >= EVE_FT810)
1806 if (EVE_CHIPID >= EVE_FT810)
1807 {
1808 phost->MediaFifoAddress = 0;
1809 phost->MediaFifoSize = 0;
1810 }
1811#endif
1812
1813 if (EVE_Util_needsSubPatch(phost))
1814 {
1815 /* Clear cmd with CMD_STOP, exiting CMD_EXECUTE may loop over, depending on OTP */
1817 for (int i = 0; i < EVE_CMD_FIFO_SIZE; i += 4)
1819 EVE_Hal_endTransfer(phost);
1820
1821 /* Go back into the patched coprocessor main loop */
1822 EVE_Hal_wr8(phost, REG_ROMSUB_SEL, 3);
1823 EVE_Cmd_startFunc(phost);
1824 EVE_Cmd_wr32(phost, (4294967047UL));
1826 EVE_Cmd_wr32(phost, 0);
1827 EVE_Cmd_endFunc(phost);
1828 EVE_Hal_flush(phost);
1829 eve_assert((wr = EVE_Hal_rd16(phost, REG_CMD_WRITE)) == 12);
1830 eve_assert((rd = EVE_Hal_rd16(phost, REG_CMD_READ)) == 0);
1831
1832 /* Difficult to check when CMD_EXECUTE is processed when there's an OTP,
1833 since the read pointer keeps looping back to 0. */
1834 EVE_sleep(100);
1835 eve_assert((wr = EVE_Hal_rd16(phost, REG_CMD_WRITE)) == 12);
1836 eve_assert((rd = EVE_Hal_rd16(phost, REG_CMD_READ)) == 0);
1837
1838 /* Need to manually stop previous command from repeating infinitely,
1839 however, this may cause the coprocessor to overshoot the command fifo,
1840 hence it's been filled with harmless CMD_STOP commands. */
1841 EVE_Hal_wr16(phost, REG_CMD_WRITE, 0);
1842 EVE_Hal_flush(phost);
1843 EVE_sleep(100);
1844
1845 /* Refresh fifo */
1846 EVE_Cmd_waitFlush(phost);
1847 eve_assert((wr = EVE_Hal_rd16(phost, REG_CMD_WRITE)) == 0);
1848 eve_assert((rd = EVE_Hal_rd16(phost, REG_CMD_READ)) == 0);
1849 }
1850
1851 if (needsVideoPatch)
1852 {
1853 /* BT81X video patch */
1854 EVE_Hal_wr16(phost, EVE_VIDEOPATCH_ADDR, videoPatchVector);
1855 }
1856
1857 /* Cold start. Ensure that the coprocessor is ready. */
1858 EVE_Cmd_wr32(phost, CMD_DLSTART);
1860
1861 /* Set the latest API level.
1862 CMD_APILEVEL applicable since BT817. */
1863#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
1864 if (EVE_CHIPID >= EVE_BT817)
1865 {
1866 EVE_Cmd_wr32(phost, CMD_APILEVEL);
1867 EVE_Cmd_wr32(phost, 2);
1868 }
1869#endif
1870
1871#ifdef EVE_FLASH_AVAILABLE
1872 if (EVE_CHIPID >= EVE_BT815)
1873 {
1874 /* Reattach flash to avoid inconsistent state */
1876 }
1877#endif
1878
1879 /* Wait for coprocessor to be ready */
1880 ready = EVE_Cmd_waitFlush(phost);
1881 if (phost->CbCoprocessorReset) /* Notify */
1882 phost->CbCoprocessorReset(phost, !ready);
1883
1884#if defined(_DEBUG)
1885 debugRestoreRamG(phost);
1886#endif
1888 return ready;
1889}
#define REG_ROMSUB_SEL
#define RAM_CMD
#define CMD_STOP
#define EVE_CMD_FIFO_SIZE
Definition EVE_GpuDefs.h:58
#define REG_CMD_DL
#define REG_PLAYBACK_PLAY
EVE_HAL_EXPORT uint32_t EVE_Hal_transfer32(EVE_HalContext *phost, uint32_t value)
Write 4 bytes to Coprocessor.
#define EVE_VIDEOPATCH_ADDR
Definition EVE_Util.c:1704
static bool EVE_Util_needsVideoPatch(EVE_HalContext *phost)
Definition EVE_Util.c:1711
#define EVE_SUBPATCH_PTR
Definition EVE_Util.c:1688
static bool EVE_Util_needsSubPatch(EVE_HalContext *phost)
Definition EVE_Util.c:1695
static void debugRestoreRamG(EVE_HalContext *phost)
Definition EVE_Util.c:1735
EVE_ResetCallback CbCoprocessorReset

◆ EVE_Util_selectDeviceInteractive()

static void EVE_Util_selectDeviceInteractive ( EVE_CHIPID_T chipId,
size_t *  deviceIdx 
)
inlinestatic

Command line device selection utility

Definition at line 178 of file EVE_Util.h.

179{
180 *chipId = EVE_SUPPORT_CHIPID;
181 *deviceIdx = -1;
182}
#define EVE_SUPPORT_CHIPID

◆ EVE_Util_selectDisplayInteractive()

static void EVE_Util_selectDisplayInteractive ( EVE_DISPLAY_T display)
inlinestatic

Command line display selection utility

Definition at line 189 of file EVE_Util.h.

190{
191 *display = EVE_DISPLAY_DEFAULT;
192}

◆ EVE_Util_selectFlashFileInteractive()

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

Definition at line 198 of file EVE_Util.h.

199{
200 flashPath[0] = '\0';
201 *updateFlash = false;
202 *updateFlashFirmware = false;
203}

◆ EVE_Util_shutdown()

EVE_HAL_EXPORT void EVE_Util_shutdown ( EVE_HalContext phost)

Complementary of bootup. Does not close the HAL context.

Parameters
phostPointer to Hal context

Definition at line 1667 of file EVE_Util.c.

1668{
1669 if (EVE_CHIPID >= EVE_FT810)
1670 {
1671 EVE_Hal_wr16(phost, REG_GPIOX_DIR, 0xffff);
1672 EVE_Hal_wr16(phost, REG_GPIOX, 0);
1673 }
1674 else
1675 {
1676 EVE_Hal_wr8(phost, REG_GPIO_DIR, 0xff);
1677 EVE_Hal_wr8(phost, REG_GPIO, 0);
1678 }
1679 EVE_Hal_wr8(phost, REG_PCLK, 0);
1680 EVE_Hal_flush(phost);
1681 EVE_Hal_powerCycle(phost, false);
1682}

◆ EVE_Util_uploadFlashFileInteractive()

static void EVE_Util_uploadFlashFileInteractive ( EVE_HalContext phost,
const eve_tchar_t flashPath,
bool  updateFlashFirmware 
)
inlinestatic

Definition at line 209 of file EVE_Util.h.

210{
211 /* no-op */
212}