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_CoCmd_IO.c
Go to the documentation of this file.
1
32#include "EVE_Platform.h"
33
35{
36 uint16_t resAddr;
37
38#if EVE_CMD_HOOKS
39 if (phost->CoCmdHook && phost->CoCmdHook(phost, CMD_MEMCRC, 0))
40 return false;
41#endif
42
43 EVE_Cmd_startFunc(phost);
45 EVE_Cmd_wr32(phost, ptr);
46 EVE_Cmd_wr32(phost, num);
47 resAddr = EVE_Cmd_moveWp(phost, 4);
48 EVE_Cmd_endFunc(phost);
49
50 /* Read result */
51 if (result)
52 {
53 if (!EVE_Cmd_waitFlush(phost))
54 return false;
55 *result = EVE_Hal_rd32(phost, RAM_CMD + resAddr);
56 }
57 return true;
58}
59
61{
62 uint16_t resAddr;
63
64#if EVE_CMD_HOOKS
65 if (phost->CoCmdHook && phost->CoCmdHook(phost, CMD_REGREAD, 0))
66 return false;
67#endif
68
69 EVE_Cmd_startFunc(phost);
71 EVE_Cmd_wr32(phost, ptr);
72 resAddr = EVE_Cmd_moveWp(phost, 4);
73 EVE_Cmd_endFunc(phost);
74
75 /* Read result */
76 if (result)
77 {
78 if (!EVE_Cmd_waitFlush(phost))
79 return false;
80 *result = EVE_Hal_rd32(phost, RAM_CMD + resAddr);
81 }
82 return true;
83}
84
86{
87 if (!EVE_Cmd_waitFlush(phost))
88 return false; // Coprocessor must be ready
89 EVE_Cmd_startFunc(phost);
91 EVE_Cmd_wr32(phost, dst);
92 EVE_Cmd_wrProgMem(phost, src, (size + 3) & ~0x3UL);
93 EVE_Cmd_endFunc(phost);
94 return EVE_Cmd_waitFlush(phost); // Resource failed to load
95}
96
105{
106 uint16_t resAddr;
107
108#if EVE_CMD_HOOKS
109 if (phost->CoCmdHook && phost->CoCmdHook(phost, CMD_GETPTR, 0))
110 return false;
111#endif
112
113 EVE_Cmd_startFunc(phost);
114 EVE_Cmd_wr32(phost, CMD_GETPTR);
115 resAddr = EVE_Cmd_moveWp(phost, 4); // move write pointer to result location
116 EVE_Cmd_endFunc(phost);
117
118 /* Read result */
119 if (result)
120 {
121 if (!EVE_Cmd_waitFlush(phost))
122 return false;
123 *result = EVE_Hal_rd32(phost, RAM_CMD + resAddr);
124 }
125 return true;
126}
127
129{
130#if EVE_CMD_HOOKS
131 if (phost->CoCmdHook && phost->CoCmdHook(phost, CMD_LOADIMAGE, dst))
132 return false;
133#endif
134
135 if (!EVE_Cmd_waitFlush(phost))
136 return false; // Coprocessor must be ready
137 EVE_Cmd_startFunc(phost);
139 EVE_Cmd_wr32(phost, dst);
140 EVE_Cmd_wr32(phost, OPT_NODL);
141 EVE_Cmd_wrProgMem(phost, src, (size + 3) & ~0x3UL);
142 EVE_Cmd_endFunc(phost);
143 if (!EVE_Cmd_waitFlush(phost))
144 return false; // Image failed to load
145 if (format)
146 *format = EVE_Hal_rd32(phost, 0x3097e8);
147 return true;
148}
149
151{
152 uint16_t resAddr;
153
154#if EVE_CMD_HOOKS
155 if (phost->CoCmdHook && phost->CoCmdHook(phost, CMD_GETPROPS, 0))
156 return false;
157#endif
158
159 EVE_Cmd_startFunc(phost);
161 resAddr = EVE_Cmd_moveWp(phost, 12);
162 EVE_Cmd_endFunc(phost);
163
164 /* Read result */
165 if (ptr || w || h)
166 {
167 if (!EVE_Cmd_waitFlush(phost))
168 return false;
169 if (ptr)
170 *ptr = EVE_Hal_rd32(phost, RAM_CMD + resAddr);
171 if (w)
172 *w = EVE_Hal_rd32(phost, RAM_CMD + resAddr + 4);
173 if (h)
174 *h = EVE_Hal_rd32(phost, RAM_CMD + resAddr + 8);
175 }
176 return true;
177}
178
179#if (EVE_SUPPORT_CHIPID >= EVE_BT815) && defined(EVE_FLASH_AVAILABLE)
180
182{
184
185 if (!EVE_Cmd_waitFlush(phost))
186 return false; // Coprocessor must be ready
187
189
190 return EVE_Cmd_waitFlush(phost);
191}
192
194{
196
197 if (!EVE_Cmd_waitFlush(phost))
198 return false; // Coprocessor must be ready
199
200 EVE_CoCmd_dddd(phost, CMD_FLASHREAD, dest, src, num);
201
202 return EVE_Cmd_waitFlush(phost);
203}
204
209{
210 uint32_t flashStatus;
212 if (!EVE_Cmd_waitFlush(phost))
213 return EVE_Hal_rd32(phost, REG_FLASH_STATUS); // Coprocessor must be ready
214 flashStatus = EVE_Hal_rd32(phost, REG_FLASH_STATUS);
215 if (flashStatus != FLASH_STATUS_DETACHED)
216 return flashStatus; // Only attach when detached
218 EVE_Cmd_waitFlush(phost); // Wait for command completion
219 return EVE_Hal_rd32(phost, REG_FLASH_STATUS); // Return current status
220}
221
229{
230 uint16_t resAddr;
231 uint32_t flashStatus;
232
234
235 if (!EVE_Cmd_waitFlush(phost))
236 {
237 if (result)
238 *result = 0xE000;
239 return EVE_Hal_rd32(phost, REG_FLASH_STATUS);
240 } // Coprocessor must be ready
241 flashStatus = EVE_Hal_rd32(phost, REG_FLASH_STATUS);
242 if (flashStatus < FLASH_STATUS_BASIC)
243 {
244 if (result)
245 *result = 0xE001;
246 return flashStatus;
247 }
248 if (flashStatus > FLASH_STATUS_BASIC)
249 {
250 if (result)
251 *result = 0;
252 return flashStatus;
253 } // Only enter fast mode when attached
254
255#if EVE_CMD_HOOKS
256 if (phost->CoCmdHook && phost->CoCmdHook(phost, CMD_FLASHFAST, 0))
257 return flashStatus;
258#endif
259
260 EVE_Cmd_startFunc(phost);
262 resAddr = EVE_Cmd_moveWp(phost, 4); // Get the address where the coprocessor will write the result
263 EVE_Cmd_endFunc(phost);
264 EVE_Cmd_waitFlush(phost); // Wait for command completion
265 if (result)
266 *result = EVE_Hal_rd32(phost, RAM_CMD + resAddr); // Fetch result
267 return EVE_Hal_rd32(phost, REG_FLASH_STATUS); // Return current status
268}
269
271{
272#if EVE_CMD_HOOKS
273 if (phost->CoCmdHook && phost->CoCmdHook(phost, CMD_FLASHSOURCE, src))
274 return false;
275 if (phost->CoCmdHook && phost->CoCmdHook(phost, CMD_LOADIMAGE, dst))
276 return false;
277#endif
278
279 if (!EVE_Cmd_waitFlush(phost))
280 return false; // Coprocessor must be ready
281 EVE_Cmd_startFunc(phost);
283 EVE_Cmd_wr32(phost, src);
285 EVE_Cmd_wr32(phost, dst);
287 EVE_Cmd_endFunc(phost);
288 if (!EVE_Cmd_waitFlush(phost))
289 return false; // Image failed to load
290 if (format)
291 *format = EVE_Hal_rd32(phost, 0x3097e8);
292 return true;
293}
294
296{
297#if EVE_CMD_HOOKS
298 if (phost->CoCmdHook && phost->CoCmdHook(phost, CMD_FLASHSOURCE, src))
299 return false;
300 if (phost->CoCmdHook && phost->CoCmdHook(phost, CMD_INFLATE2, dst))
301 return false;
302#endif
303
304 if (!EVE_Cmd_waitFlush(phost))
305 return false; // Coprocessor must be ready
306 EVE_Cmd_startFunc(phost);
308 EVE_Cmd_wr32(phost, src);
310 EVE_Cmd_wr32(phost, dst);
311 EVE_Cmd_wr32(phost, OPT_FLASH);
312 EVE_Cmd_endFunc(phost);
313 return EVE_Cmd_waitFlush(phost); // Image failed to load
314}
315
316#endif
317
318#if (EVE_SUPPORT_CHIPID >= EVE_BT817)
319
321{
322 uint16_t resAddr;
323
325
326#if EVE_CMD_HOOKS
327 if (phost->CoCmdHook && phost->CoCmdHook(phost, CMD_GETIMAGE, 0))
328 return false;
329#endif
330
331 EVE_Cmd_startFunc(phost);
333 resAddr = EVE_Cmd_moveWp(phost, 4 * 5);
334 EVE_Cmd_endFunc(phost);
335
336 /* Read result */
337 if (source || fmt || w || h || palette)
338 {
339 if (!EVE_Cmd_waitFlush(phost))
340 return false;
341 if (source)
342 *source = EVE_Hal_rd32(phost, RAM_CMD + resAddr);
343 if (fmt)
344 *fmt = EVE_Hal_rd32(phost, RAM_CMD + resAddr + 4);
345 if (w)
346 *w = EVE_Hal_rd32(phost, RAM_CMD + resAddr + 8);
347 if (h)
348 *h = EVE_Hal_rd32(phost, RAM_CMD + resAddr + 12);
349 if (palette)
350 *palette = EVE_Hal_rd32(phost, RAM_CMD + resAddr + 16);
351 }
352 return true;
353}
354
356{
357 uint16_t resAddr;
358
360
361#if EVE_CMD_HOOKS
362 if (phost->CoCmdHook && phost->CoCmdHook(phost, CMD_FONTCACHEQUERY, 0))
363 return false;
364#endif
365
366 EVE_Cmd_startFunc(phost);
368 resAddr = EVE_Cmd_moveWp(phost, 8);
369 EVE_Cmd_endFunc(phost);
370
371 /* Read result */
372 if (total || used)
373 {
374 if (!EVE_Cmd_waitFlush(phost))
375 return false;
376 if (total)
377 *total = EVE_Hal_rd32(phost, RAM_CMD + resAddr);
378 if (used)
379 *used = EVE_Hal_rd32(phost, RAM_CMD + resAddr + 4);
380 }
381 return true;
382}
383
384#endif
385
386/* end of file */
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.
Definition EVE_Cmd.c:446
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 void EVE_Cmd_endFunc(EVE_HalContext *phost)
End writing a function, closes the transfer.
Definition EVE_Cmd.c:274
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
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.
Definition EVE_Cmd.c:307
EVE_HAL_EXPORT void EVE_CoCmd_d(EVE_HalContext *phost, uint32_t cmd)
Definition EVE_CoCmd.c:39
EVE_HAL_EXPORT void EVE_CoCmd_dddd(EVE_HalContext *phost, uint32_t cmd, uint32_t d0, uint32_t d1, uint32_t d2)
Definition EVE_CoCmd.c:76
#define EVE_CoCmd_getImage(phost, source, fmt, w, h, palette)
Definition EVE_CoCmd.h:916
#define EVE_MULTI_TARGET_CHECK_RETURN(cmd, condition, res)
Definition EVE_CoCmd.h:138
#define EVE_CoCmd_fontCacheQuery(phost, total, used)
Definition EVE_CoCmd.h:918
EVE_HAL_EXPORT bool EVE_CoCmd_flashRead_flush(EVE_HalContext *phost, uint32_t dest, uint32_t src, uint32_t num)
Read from Flash to RAM_G.
EVE_HAL_EXPORT bool EVE_CoCmd_inflate_progMem(EVE_HalContext *phost, uint32_t dst, eve_progmem_const uint8_t *src, uint32_t size)
Inflates data from program memory to RAM_G.
EVE_HAL_EXPORT uint32_t EVE_CoCmd_flashAttach(EVE_HalContext *phost)
Attach flash.
EVE_HAL_EXPORT bool EVE_CoCmd_loadImage_flash(EVE_HalContext *phost, uint32_t dst, uint32_t src, uint32_t *format)
Load image from Flash to RAM_G.
EVE_HAL_EXPORT bool EVE_CoCmd_getProps(EVE_HalContext *phost, uint32_t *ptr, uint32_t *w, uint32_t *h)
Get the image properties decompressed by CMD_LOADIMAGE.
EVE_HAL_EXPORT bool EVE_CoCmd_regRead(EVE_HalContext *phost, uint32_t ptr, uint32_t *result)
Send CMD_REGREAD.
EVE_HAL_EXPORT uint32_t EVE_CoCmd_flashFast(EVE_HalContext *phost, uint32_t *result)
Enter fast flash state.
EVE_HAL_EXPORT bool EVE_CoCmd_loadImage_progMem(EVE_HalContext *phost, uint32_t dst, eve_progmem_const uint8_t *src, uint32_t size, uint32_t *format)
Load image from program memory.
EVE_HAL_EXPORT bool EVE_CoCmd_getPtr(EVE_HalContext *phost, uint32_t *result)
Get the end memory address of data inflated by CMD_INFLATE and CMD_INFLATE2 At API level 2,...
EVE_HAL_EXPORT bool EVE_CoCmd_memCrc(EVE_HalContext *phost, uint32_t ptr, uint32_t num, uint32_t *result)
Send CMD_MEMCRC.
EVE_HAL_EXPORT bool EVE_CoCmd_flashErase_flush(EVE_HalContext *phost)
Send CMD_FLASHERASE. Wait for completion.
EVE_HAL_EXPORT bool EVE_CoCmd_inflate_flash(EVE_HalContext *phost, uint32_t dst, uint32_t src)
Inflates data from Flash to RAM_G.
#define EVE_BT817
Definition EVE_Config.h:68
#define EVE_HAL_EXPORT
#define EVE_BT815
Definition EVE_Config.h:66
#define EVE_CHIPID
#define eve_progmem_const
#define OPT_FLASH
#define CMD_INFLATE2
#define OPT_NODL
#define RAM_CMD
#define CMD_FLASHERASE
#define CMD_INFLATE
#define FLASH_STATUS_BASIC
#define CMD_FLASHFAST
#define CMD_FLASHATTACH
#define CMD_GETPROPS
#define CMD_FLASHREAD
#define CMD_FONTCACHEQUERY
#define CMD_FLASHSOURCE
#define CMD_GETPTR
#define CMD_GETIMAGE
#define CMD_LOADIMAGE
#define CMD_REGREAD
#define FLASH_STATUS_DETACHED
#define REG_FLASH_STATUS
#define CMD_MEMCRC
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
unsigned short uint16_t
int int32_t
unsigned int uint32_t
unsigned char uint8_t
Platform selector.
void EVE_Cmd_waitFlush(EVE_HalContext *host)
Definition Gpu_Hal.cpp:775