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
FlashHelper.h File Reference

Eve's connected flash helper functions. More...

#include "FT_Gpu_Hal.h"
#include "Gpu_Hal.h"
#include "EVE_Platform.h"
#include "Gpu_CoCmd.h"

Go to the source code of this file.

Functions

Flash_Cmd_Status_t FlashHelper_Update (EVE_HalContext *phost, uint32_t dest_flash, uint32_t src_ram, uint32_t num)
 
Flash_Cmd_Status_t FlashHelper_Read (EVE_HalContext *phost, uint32_t dest_ram, uint32_t src_flash, uint32_t num, uint8_t *read_data)
 
ft_void_t FlashHelper_Erase (EVE_HalContext *phost)
 
uint8_t FlashHelper_GetState (EVE_HalContext *phost)
 
ft_void_t FlashHelper_ClearCache (EVE_HalContext *phost)
 
Flash_Cmd_Status_t FlashHelper_Write (EVE_HalContext *phost, uint32_t dest_flash, uint32_t num, const uint8_t *write_data)
 
uint32_t FlashHelper_SwitchState (EVE_HalContext *phost, uint8_t nextState)
 
uint32_t FlashHelper_SwitchFullMode (EVE_HalContext *phost)
 
ft_void_t FlashHelper_flashWriteExt (EVE_HalContext *phost, uint32_t dest, uint32_t num, const uint8_t *data)
 
ft_bool_t Esd_Calibrate (EVE_HalContext *phost)
 Do calibration.
 
ft_void_t Ft_QueueCmd (uint32_t cmd)
 
ft_void_t Ft_QueueString (const char *s)
 
ft_void_t Ft_FlushCmd (EVE_HalContext *phost)
 
ft_void_t Ft_Gpu_HorizontalScanoutFilter (EVE_HalContext *phost, uint32_t physical_W, uint32_t physical_H)
 Adjust for non-sqare pixel panel.
 
ft_void_t Ft_Gpu_CoCmd_FlashWriteExt (EVE_HalContext *phost, uint32_t dest, uint32_t num, const uint8_t *data)
 
void fadeout (EVE_HalContext *phost)
 Fadeout animation.
 
void fadein (EVE_HalContext *phost)
 Fadein animation perform display fadein effect by changing the display PWM from 0 till 100 and finally 128.
 
void Fifo_Init (Fifo_t *pFifo, uint32_t StartAddress, uint32_t Length, uint32_t HWReadRegAddress, uint32_t HWWriteRegAddress)
 Init mediafifo.
 
void Fifo_Update (EVE_HalContext *host, Fifo_t *pFifo)
 
uint32_t Fifo_Write (EVE_HalContext *host, Fifo_t *pFifo, const uint8_t *buffer, uint32_t NumbytetoWrite)
 
void Fifo_WriteWait (EVE_HalContext *host, Fifo_t *pFifo, const uint8_t *buffer, uint32_t Numbyte)
 
void Fifo_Write32 (EVE_HalContext *host, Fifo_t *pFifo, uint32_t WriteWord)
 
uint32_t Fifo_GetFreeSpace (EVE_HalContext *host, Fifo_t *pFifo)
 
void App_WrDl_Buffer (Gpu_Hal_Context_t *phost, uint32_t cmd)
 Write DL command to buffer.
 
void App_Flush_DL_Buffer (const Gpu_Hal_Context_t *phost)
 Flush DL buffer to Coprocessor.
 
void App_Set_DlBuffer_Index (uint32_t index)
 Set DL buffer index.
 
void GPU_DLSwap (Gpu_Hal_Context_t *phost, uint8_t DL_Swap_Type)
 API to check the status of previous DLSWAP and perform DLSWAP of new DL Check for the status of previous DLSWAP and if still not done wait for few ms and check again.
 
int32_t FlashHelper_GetSizeMB (Gpu_Hal_Context_t *host)
 

Detailed Description

Eve's connected flash helper functions.

Author
Tuan Nguyen tuan..nosp@m.nguy.nosp@m.en@br.nosp@m.tchi.nosp@m.p.com
Date
2019

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 FlashHelper.h.

Function Documentation

◆ App_Flush_DL_Buffer()

void App_Flush_DL_Buffer ( const Gpu_Hal_Context_t phost)

Flush DL buffer to Coprocessor.

Parameters
phostPointer to Hal context

Definition at line 471 of file FlashHelper.c.

472{
473#ifdef BUFFER_OPTIMIZATION
474 if (DlBuffer_Index > 0)
475 EVE_Hal_wrMem(phost, RAM_DL, DlBuffer, DlBuffer_Index); /* Not legal on big endian CPU */
476#endif
477 DlBuffer_Index = 0;
478}
#define RAM_DL
Definition EVE_GpuDefs.h:95
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
uint32_t DlBuffer_Index

◆ App_Set_DlBuffer_Index()

void App_Set_DlBuffer_Index ( uint32_t  index)

Set DL buffer index.

Parameters
index

Definition at line 485 of file FlashHelper.c.

486{
487 DlBuffer_Index = index;
488}

◆ App_WrDl_Buffer()

void App_WrDl_Buffer ( Gpu_Hal_Context_t phost,
uint32_t  cmd 
)

Write DL command to buffer.

Parameters
phostPointer to Hal context
cmdDL command

Definition at line 444 of file FlashHelper.c.

445{
446#ifdef BUFFER_OPTIMIZATION
447 /* Copy the command instruction into buffer */
448 uint32_t* pBuffcmd;
449 /* Prevent buffer overflow */
450 if (DlBuffer_Index < DL_SIZE)
451 {
452 pBuffcmd = (uint32_t*)&DlBuffer[DlBuffer_Index];
453 *pBuffcmd = cmd;
454 }
455 else
456 {
457 printf("DlBuffer overflow\n");
458 }
459#else
461#endif
462 /* Increment the command index */
464}
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
unsigned int uint32_t
static ft_void_t ft_uint32_t * cmd
Definition FT_Gpu_Hal.h:184
#define CMD_SIZE
Definition Gpu_Hal.h:77

◆ Esd_Calibrate()

ft_bool_t Esd_Calibrate ( EVE_HalContext phost)

Do calibration.

Returns
ft_bool_t True on successfull or otherwise

Definition at line 42 of file FlashHelper.c.

43{
44 ft_uint32_t result;
45 ft_uint32_t transMatrix[6];
46#if defined(EVE_SUPPORT_CAPACITIVE)
48#else
50#endif
51
52 eve_printf_debug("App_CoPro_Widget_Calibrate: Start\n");
53
54 EVE_CoCmd_dlStart(phost);
55 EVE_Cmd_wr32(phost, CLEAR_COLOR_RGB(64, 64, 64));
56 EVE_Cmd_wr32(phost, CLEAR(1, 1, 1));
57 EVE_Cmd_wr32(phost, COLOR_RGB(0xff, 0xff, 0xff));
58
59 EVE_CoCmd_text(phost, (uint16_t)(phost->Width / 2), (uint16_t)(phost->Height / 2), 27, OPT_CENTER, "Please Tap on the dot");
60
61 result = EVE_CoCmd_calibrate(phost);
62 EVE_Cmd_waitFlush(phost);
63
64 eve_printf_debug("App_CoPro_Widget_Calibrate: End\n");
65
66 // Print the configured values
67 EVE_Hal_rdMem(phost, (ft_uint8_t*)transMatrix, REG_TOUCH_TRANSFORM_A, 4 * 6); //read all the 6 coefficients
68 eve_printf_debug("Touch screen transform values are A 0x%x,B 0x%x,C 0x%x,D 0x%x,E 0x%x, F 0x%x\n",
69 transMatrix[0], transMatrix[1], transMatrix[2], transMatrix[3], transMatrix[4], transMatrix[5]);
70
71 return result != 0;
72}
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 uint32_t EVE_CoCmd_calibrate(EVE_HalContext *phost)
Send CMD_CALIBRATE.
Definition EVE_CoCmd.c:500
EVE_HAL_EXPORT void EVE_CoCmd_text(EVE_HalContext *phost, int16_t x, int16_t y, int16_t font, uint16_t options, const char *s,...)
Send CMD_TEXT.
static void EVE_CoCmd_dlStart(EVE_HalContext *phost)
Send CMD_DLSTART.
Definition EVE_CoCmd.h:159
#define CTOUCH_MODE_COMPATIBILITY
#define CLEAR(c, s, t)
#define ADC_DIFFERENTIAL
#define REG_TOUCH_ADC_MODE
#define COLOR_RGB(red, green, blue)
#define OPT_CENTER
#define REG_CTOUCH_EXTENDED
#define REG_TOUCH_TRANSFORM_A
#define CLEAR_COLOR_RGB(red, green, blue)
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.
Definition EVE_Hal.c:206
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
unsigned short uint16_t
#define eve_printf_debug(fmt,...)
#define ft_uint32_t
Definition FT_Gpu_Hal.h:54
#define ft_uint8_t
Definition FT_Gpu_Hal.h:50
void EVE_Cmd_waitFlush(EVE_HalContext *host)
Definition Gpu_Hal.cpp:775
uint32_t Height

◆ fadein()

void fadein ( EVE_HalContext phost)

Fadein animation perform display fadein effect by changing the display PWM from 0 till 100 and finally 128.

Parameters
phostPointer to Hal context

Definition at line 542 of file FlashHelper.c.

543{
544 for (int8_t i = 0; i <= 100; i += 3)
545 {
546 EVE_Hal_wr8(phost, REG_PWM_DUTY, i);
547 EVE_sleep(2);//sleep for 2 ms
548 }
549 /* Finally make the PWM 100% */
550 uint8_t i = 128;
551 EVE_Hal_wr8(phost, REG_PWM_DUTY, i);
552}
#define REG_PWM_DUTY
EVE_HAL_EXPORT void EVE_sleep(uint32_t ms)
Sleep in milisecond.
unsigned char uint8_t
signed char int8_t

◆ fadeout()

void fadeout ( EVE_HalContext phost)

Fadeout animation.

Parameters
phostPointer to Hal context

Definition at line 527 of file FlashHelper.c.

528{
529 for (int8_t i = 100; i >= 0; i -= 3)
530 {
531 EVE_Hal_wr8(phost, REG_PWM_DUTY, i);
532 EVE_sleep(2);//sleep for 2 ms
533 }
534}

◆ Fifo_GetFreeSpace()

uint32_t Fifo_GetFreeSpace ( EVE_HalContext host,
Fifo_t pFifo 
)

Definition at line 1111 of file Gpu_Hal.cpp.

1112{
1113 uint32_t FreeSpace = 0;
1114
1115 Fifo_Update(host,pFifo);
1116
1117 if(pFifo->fifo_wp >= pFifo->fifo_rp)
1118 {
1119 FreeSpace = pFifo->fifo_len - pFifo->fifo_wp + pFifo->fifo_rp;
1120 }
1121 else
1122 {
1123 FreeSpace = pFifo->fifo_rp - pFifo->fifo_wp;
1124 }
1125
1126 if(FreeSpace >= 4)
1127 {
1128 FreeSpace -= 4;//make sure 1 word space is maintained between rd and wr pointers
1129 }
1130 return FreeSpace;
1131}
void Fifo_Update(EVE_HalContext *host, Fifo_t *pFifo)
Definition Gpu_Hal.cpp:1001
int32_t fifo_len
Definition Gpu_Hal.h:155
int32_t fifo_wp
Definition Gpu_Hal.h:156
int32_t fifo_rp
Definition Gpu_Hal.h:157

◆ Fifo_Init()

void Fifo_Init ( Fifo_t pFifo,
uint32_t  StartAddress,
uint32_t  Length,
uint32_t  HWReadRegAddress,
uint32_t  HWWriteRegAddress 
)

Init mediafifo.

Parameters
pFifoFifo pointer
StartAddressAddress on RAM_G
LengthFifo length
HWReadRegAddressREG_MEDIAFIFO_READ
HWWriteRegAddressREG_MEDIAFIFO_WRITE

Definition at line 982 of file Gpu_Hal.cpp.

983{
984 /* update the context parameters */
985 pFifo->fifo_buff = StartAddress;
986 pFifo->fifo_len = Length;
987 pFifo->fifo_rp = pFifo->fifo_wp = 0;
988
989 /* update the hardware register addresses - specific to FT800 series chips */
990 pFifo->HW_Read_Reg = HWReadRegAddress;
991 pFifo->HW_Write_Reg = HWWriteRegAddress;
992}
uint32_t fifo_buff
Definition Gpu_Hal.h:154
uint32_t HW_Write_Reg
Definition Gpu_Hal.h:161
uint32_t HW_Read_Reg
Definition Gpu_Hal.h:160

◆ Fifo_Update()

void Fifo_Update ( EVE_HalContext host,
Fifo_t pFifo 
)

Definition at line 1001 of file Gpu_Hal.cpp.

1002{
1003 pFifo->fifo_rp = Gpu_Hal_Rd32(host,pFifo->HW_Read_Reg);
1004 //Gpu_Hal_Wr32(host,pFifo->HW_Write_Reg,pFifo->fifo_wp);
1005}
#define Gpu_Hal_Rd32
Definition Gpu_Hal.h:206

◆ Fifo_Write()

uint32_t Fifo_Write ( EVE_HalContext host,
Fifo_t pFifo,
const uint8_t buffer,
uint32_t  NumbytetoWrite 
)

◆ Fifo_Write32()

void Fifo_Write32 ( EVE_HalContext host,
Fifo_t pFifo,
uint32_t  WriteWord 
)

Definition at line 1069 of file Gpu_Hal.cpp.

1070{
1071 Fifo_WriteWait(host,pFifo,(uint8_t *)&WriteWord,4);
1072}
void Fifo_WriteWait(EVE_HalContext *host, Fifo_t *pFifo, uint8_t *buffer, uint32_t Numbyte)
Definition Gpu_Hal.cpp:1082

◆ Fifo_WriteWait()

void Fifo_WriteWait ( EVE_HalContext host,
Fifo_t pFifo,
const uint8_t buffer,
uint32_t  Numbyte 
)

◆ FlashHelper_ClearCache()

ft_void_t FlashHelper_ClearCache ( EVE_HalContext phost)

◆ FlashHelper_Erase()

ft_void_t FlashHelper_Erase ( EVE_HalContext phost)

◆ FlashHelper_flashWriteExt()

ft_void_t FlashHelper_flashWriteExt ( EVE_HalContext phost,
uint32_t  dest,
uint32_t  num,
const uint8_t data 
)

◆ FlashHelper_GetSizeMB()

int32_t FlashHelper_GetSizeMB ( Gpu_Hal_Context_t host)

Definition at line 723 of file FlashHelper.c.

724{
725 uint8_t status = Gpu_Hal_Rd8(phost, REG_FLASH_STATUS);
726
727 if (status == FLASH_STATUS_DETACHED)
728 {
730 App_Flush_Co_Buffer(phost);
732 status = Gpu_Hal_Rd8(phost, REG_FLASH_STATUS);
733
734 if (FLASH_STATUS_BASIC != status)
735 {
736 printf("Error, Flash is not able to attach\n");
737 return -1;
738 }
739 }
740 int32_t size = Gpu_Hal_Rd32(phost, REG_FLASH_SIZE);
741
742 return size;
743}
#define FLASH_STATUS_BASIC
#define REG_FLASH_SIZE
#define FLASH_STATUS_DETACHED
#define REG_FLASH_STATUS
int int32_t
#define Gpu_CoCmd_FlashAttach
Definition Gpu_CoCmd.h:71
#define Gpu_Hal_WaitCmdfifo_empty
Definition Gpu_Hal.h:240
#define App_Flush_Co_Buffer(phost)
Definition Gpu_Hal.h:439
#define Gpu_Hal_Rd8
Definition Gpu_Hal.h:204

◆ FlashHelper_GetState()

uint8_t FlashHelper_GetState ( EVE_HalContext phost)

◆ FlashHelper_Read()

Flash_Cmd_Status_t FlashHelper_Read ( EVE_HalContext phost,
uint32_t  dest_ram,
uint32_t  src_flash,
uint32_t  num,
uint8_t read_data 
)

◆ FlashHelper_SwitchFullMode()

uint32_t FlashHelper_SwitchFullMode ( EVE_HalContext phost)

◆ FlashHelper_SwitchState()

uint32_t FlashHelper_SwitchState ( EVE_HalContext phost,
uint8_t  nextState 
)

◆ FlashHelper_Update()

Flash_Cmd_Status_t FlashHelper_Update ( EVE_HalContext phost,
uint32_t  dest_flash,
uint32_t  src_ram,
uint32_t  num 
)

◆ FlashHelper_Write()

Flash_Cmd_Status_t FlashHelper_Write ( EVE_HalContext phost,
uint32_t  dest_flash,
uint32_t  num,
const uint8_t write_data 
)

◆ Ft_FlushCmd()

ft_void_t Ft_FlushCmd ( EVE_HalContext phost)

◆ Ft_Gpu_CoCmd_FlashWriteExt()

ft_void_t Ft_Gpu_CoCmd_FlashWriteExt ( EVE_HalContext phost,
uint32_t  dest,
uint32_t  num,
const uint8_t data 
)

◆ Ft_Gpu_HorizontalScanoutFilter()

ft_void_t Ft_Gpu_HorizontalScanoutFilter ( EVE_HalContext phost,
uint32_t  physical_W,
uint32_t  physical_H 
)

Adjust for non-sqare pixel panel.

Parameters
phostPointer to Hal context
physical_WPanel width in inches
physical_HPanel height in inches
Returns
ft_void_t

Definition at line 385 of file FlashHelper.c.

385 {
386 uint32_t eve_W = phost->Width;
387 uint32_t eve_H = phost->Height;
388 uint32_t logical_W = eve_H * physical_W / physical_H;
389
390 // Configure panel
391 EVE_Hal_wr32(phost, REG_HSIZE, logical_W);
392 EVE_CoCmd_hsf(phost, eve_W);
393}
#define EVE_CoCmd_hsf(phost, hsf)
Definition EVE_CoCmd.h:351
#define REG_HSIZE

◆ Ft_QueueCmd()

ft_void_t Ft_QueueCmd ( uint32_t  cmd)

◆ Ft_QueueString()

ft_void_t Ft_QueueString ( const char *  s)

◆ GPU_DLSwap()

void GPU_DLSwap ( Gpu_Hal_Context_t phost,
uint8_t  DL_Swap_Type 
)

API to check the status of previous DLSWAP and perform DLSWAP of new DL Check for the status of previous DLSWAP and if still not done wait for few ms and check again.

Parameters
phostPointer to Hal context
DL_Swap_TypeDL list swap type

Definition at line 497 of file FlashHelper.c.

498{
499 uint8_t Swap_Type = DLSWAP_FRAME;
500 uint8_t Swap_Done = DLSWAP_FRAME;
501
502 if (DL_Swap_Type == DLSWAP_LINE)
503 {
504 Swap_Type = DLSWAP_LINE;
505 }
506
507 /* Perform a new DL swap */
508 EVE_Hal_wr8(phost, REG_DLSWAP, Swap_Type);
509
510 /* Wait till the swap is done */
511 while (Swap_Done)
512 {
513 Swap_Done = EVE_Hal_rd8(phost, REG_DLSWAP);
514
515 if (DLSWAP_DONE != Swap_Done)
516 {
517 EVE_sleep(10);//wait for 10ms
518 }
519 }
520}
#define DLSWAP_DONE
#define DLSWAP_LINE
#define REG_DLSWAP
#define DLSWAP_FRAME
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