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 File Reference

EVE's co-processor IO commmands. More...

#include "EVE_Platform.h"

Go to the source code of this file.

Functions

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_regRead (EVE_HalContext *phost, uint32_t ptr, uint32_t *result)
 Send CMD_REGREAD.
 
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 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, the allocation pointer is also advanced by:
 
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_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_flashErase_flush (EVE_HalContext *phost)
 Send CMD_FLASHERASE. Wait for completion.
 
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 uint32_t EVE_CoCmd_flashAttach (EVE_HalContext *phost)
 Attach flash.
 
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_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_inflate_flash (EVE_HalContext *phost, uint32_t dst, uint32_t src)
 Inflates data from Flash to RAM_G.
 

Detailed Description

EVE's co-processor IO commmands.

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_CoCmd_IO.c.

Function Documentation

◆ EVE_CoCmd_flashAttach()

EVE_HAL_EXPORT uint32_t EVE_CoCmd_flashAttach ( EVE_HalContext phost)

Attach flash.

Parameters
phostPointer to Hal context
Returns
uint32_t Returns new FLASH_STATUS

Definition at line 208 of file EVE_CoCmd_IO.c.

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}
EVE_HAL_EXPORT void EVE_CoCmd_d(EVE_HalContext *phost, uint32_t cmd)
Definition EVE_CoCmd.c:39
#define EVE_MULTI_TARGET_CHECK_RETURN(cmd, condition, res)
Definition EVE_CoCmd.h:138
#define EVE_BT815
Definition EVE_Config.h:66
#define EVE_CHIPID
#define CMD_FLASHATTACH
#define FLASH_STATUS_DETACHED
#define REG_FLASH_STATUS
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 int uint32_t
void EVE_Cmd_waitFlush(EVE_HalContext *host)
Definition Gpu_Hal.cpp:775

◆ EVE_CoCmd_flashErase_flush()

EVE_HAL_EXPORT bool EVE_CoCmd_flashErase_flush ( EVE_HalContext phost)

Send CMD_FLASHERASE. Wait for completion.

Parameters
phostPointer to Hal context
Returns
bool false on coprocessor fault

Definition at line 181 of file EVE_CoCmd_IO.c.

182{
184
185 if (!EVE_Cmd_waitFlush(phost))
186 return false; // Coprocessor must be ready
187
189
190 return EVE_Cmd_waitFlush(phost);
191}
#define CMD_FLASHERASE

◆ EVE_CoCmd_flashFast()

EVE_HAL_EXPORT uint32_t EVE_CoCmd_flashFast ( EVE_HalContext phost,
uint32_t result 
)

Enter fast flash state.

Parameters
phostPointer to Hal context
result
Returns
new FLASH_STATUS

Definition at line 228 of file EVE_CoCmd_IO.c.

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}
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
#define RAM_CMD
#define FLASH_STATUS_BASIC
#define CMD_FLASHFAST
unsigned short uint16_t

◆ EVE_CoCmd_flashRead_flush()

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.

Parameters
phostPointer to Hal context
destdestination address in main memory. Must be 4-byte aligned
srcsource address in flash memory. Must be 64-byte aligned
numnumber of bytes to read, must be multiple of 4
Returns
bool false on coprocessor fault

Definition at line 193 of file EVE_CoCmd_IO.c.

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}
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 CMD_FLASHREAD

◆ EVE_CoCmd_getProps()

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.

Parameters
phostPointer to Hal context
ptrSource address of bitmap
wWidth of bitmap, in pixels
hHeight of bitmap, in pixels
Returns
bool Returns false on coprocessor fault

Definition at line 150 of file EVE_CoCmd_IO.c.

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}
#define CMD_GETPROPS

◆ EVE_CoCmd_getPtr()

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, the allocation pointer is also advanced by:

Get the end memory address of data inflated by CMD_INFLATE.

  • cmd_loadimage
  • cmd_playvideo
  • cmd_videoframe
  • cmd_endlist

Definition at line 104 of file EVE_CoCmd_IO.c.

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}
#define CMD_GETPTR

◆ EVE_CoCmd_inflate_flash()

EVE_HAL_EXPORT bool EVE_CoCmd_inflate_flash ( EVE_HalContext phost,
uint32_t  dst,
uint32_t  src 
)

Inflates data from Flash to RAM_G.

Parameters
phostPointer to Hal context
dstImage location on flash
srcDestination on RAM_G
Returns
bool Returns false on coprocessor fault

Definition at line 295 of file EVE_CoCmd_IO.c.

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}
#define OPT_FLASH
#define CMD_INFLATE2
#define CMD_FLASHSOURCE

◆ EVE_CoCmd_inflate_progMem()

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.

Parameters
phostPointer to Hal context
dstImage address
srcDesination on RAM_G
sizesize of src in bytes
Returns
Returns false on coprocessor fault

Definition at line 85 of file EVE_CoCmd_IO.c.

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}
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
#define CMD_INFLATE

◆ EVE_CoCmd_loadImage_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.

Parameters
phostPointer to Hal context
dstImage location on flash
srcDestination on RAM_G
formatOutput parameter format returns loaded bitmap format on success
Returns
bool Returns false on coprocessor fault

Definition at line 270 of file EVE_CoCmd_IO.c.

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}
#define OPT_NODL
#define CMD_LOADIMAGE

◆ EVE_CoCmd_loadImage_progMem()

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.

Parameters
phostPointer to Hal context
dstImage address
srcDesination on RAM_G
sizesize of src in bytes
formatOutput parameter format returns loaded bitmap format on success
Returns
bool Returns false on coprocessor fault

Definition at line 128 of file EVE_CoCmd_IO.c.

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}

◆ EVE_CoCmd_memCrc()

EVE_HAL_EXPORT bool EVE_CoCmd_memCrc ( EVE_HalContext phost,
uint32_t  ptr,
uint32_t  num,
uint32_t result 
)

Send CMD_MEMCRC.

Parameters
phostPointer to Hal context
ptrstarting address of the memory block
numnumber of bytes in the source memory block
resultoutput parameter; written with the CRC-32 after command execution
Returns
bool Returns false in case of error

Definition at line 34 of file EVE_CoCmd_IO.c.

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}
#define CMD_MEMCRC

◆ EVE_CoCmd_regRead()

EVE_HAL_EXPORT bool EVE_CoCmd_regRead ( EVE_HalContext phost,
uint32_t  ptr,
uint32_t result 
)

Send CMD_REGREAD.

Parameters
phostPointer to Hal context
ptraddress of register to read
resultoutput parameter; written with the register value
Returns
bool Returns false in case of error

Definition at line 60 of file EVE_CoCmd_IO.c.

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}
#define CMD_REGREAD