Skip to content

Commit

Permalink
Various updates
Browse files Browse the repository at this point in the history
- Changes to support the EVE-Bitmap viewer [1]
- Support for the 4.3" 800x480 display
- Clang format support

[1] https://github.com/MatrixOrbital/EVE-Windows-Bitmap-Viewer
  • Loading branch information
matrixraym committed Sep 1, 2023
1 parent 00a07ea commit 12f329c
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 43 deletions.
7 changes: 7 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BinPackArguments: false
BinPackParameters: false
ColumnLimit: 99
BreakBeforeBraces: Allman
AllowShortBlocksOnASingleLine: Never
AllowShortFunctionsOnASingleLine: None

14 changes: 10 additions & 4 deletions Include/eve/Eve2_81x.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ extern "C"
#define ANIM_ONCE 0UL

// Definitions for EVE coprocessor command buffer
#define FT_DL_SIZE (8 * 1024) // 8KB Display List buffer size
#define FT_CMD_FIFO_SIZE (4096U) // 4KB coprocessor Fifo size
#define FT_CMD_SIZE (4) // 4 byte per coprocessor command of EVE
#define FT_DL_SIZE (8 * 1024) // 8KB Display List buffer size
#define FT_CMD_FIFO_SIZE (4096U) // 4KB coprocessor Fifo size
#define FT_CMD_SIZE (4) // 4 byte per coprocessor command of EVE

// Memory base addresses
#define RAM_G 0x0
Expand Down Expand Up @@ -407,8 +407,14 @@ extern "C"
extern uint16_t FifoWriteLocation;

// Function Prototypes

// FT81x_Init return values
// 0 Hardware reset failed
// 1 Hardware reset OK, but no EVE detected on the SPI bus
// else the chipID of the EVE IC that was detected.

int EVE_EXPORT FT81x_Init(int display, int board, int touch);
void EVE_EXPORT Eve_Reset(void);
int EVE_EXPORT Eve_Reset(void);
void EVE_EXPORT Cap_Touch_Upload(void);

void EVE_EXPORT HostCommand(uint8_t HostCommand);
Expand Down
5 changes: 3 additions & 2 deletions Include/eve/MatrixEve2Conf.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#define DISPLAY_70 1
#define DISPLAY_50 2
#define DISPLAY_50I 2
#define DISPLAY_43 3
#define DISPLAY_39 4
#define DISPLAY_38 5
Expand All @@ -9,8 +10,8 @@
#define DISPLAY_101 9
#define DISPLAY_70I 10
#define DISPLAY_24 11
#define DISPLAY_39I 12
#define DISPLAY_70I_WG 13
#define DISPLAY_70I_WG 12
#define DISPLAY_43_800480 13

#define BOARD_EVE2 1
#define BOARD_EVE3 2
Expand Down
2 changes: 1 addition & 1 deletion Include/eve/hw_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extern "C"
void HAL_Delay(uint32_t milliSeconds);

/* Gives an opertunity to reset the EVE hardware */
void HAL_Eve_Reset_HW(void);
int HAL_Eve_Reset_HW(void);

/* Cleans up and resources allocated */
void HAL_Close(void);
Expand Down
12 changes: 8 additions & 4 deletions src/demos/basic_eve_demo/basic_eve_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ void ClearScreen(void)

int main()
{
FT81x_Init(DEMO_DISPLAY,
DEMO_BOARD,
DEMO_TOUCH); // Initialize the EVE graphics controller. Make sure to define which
// display you are using in the MatrixEveConf.h
// Initialize the EVE graphics controller. Make sure to define which display
// you are using in the MatrixEveConf.h
if (FT81x_Init(DEMO_DISPLAY, DEMO_BOARD, DEMO_TOUCH) <= 1)
{
printf("ERROR: Eve not detected.\n");
return -1;
}

ClearScreen(); // Clear any remnants in the RAM

// If you are using a touch screen, make sure to define what
Expand Down
12 changes: 7 additions & 5 deletions src/demos/png_transparency_demo/png_transparency_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,11 +603,13 @@ void DrawLogoPNG()

int main()
{
FT81x_Init(
DEMO_DISPLAY,
DEMO_BOARD,
DEMO_TOUCH); // Initialize the EVE graphics controller. Make sure to define which display
// you are using in the MatrixEveConf.h
// Initialize the EVE graphics controller. Make sure to define which display
// you are using in the MatrixEveConf.h
if (FT81x_Init(DEMO_DISPLAY, DEMO_BOARD, DEMO_TOUCH) <= 1)
{
printf("ERROR: Eve not detected.\n");
return -1;
}
DrawLogoPNG(); // Draw the JPG embedded in this code file
HAL_Close(); // Close the comminucations with the unit.
}
57 changes: 45 additions & 12 deletions src/eve/Eve2_81x.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,27 @@ int FT81x_Init(int display, int board, int touch)
CSPREAD = 1;
DITHER = 1;
break;
case DISPLAY_43_800480:
DWIDTH = 800;
DHEIGHT = 480;
PIXVOFFSET = 0;
PIXHOFFSET = 0;
HCYCLE = 977;
HOFFSET = 176;
HSYNC0 = 40;
HSYNC1 = 88;
VCYCLE = 529;
VOFFSET = 48;
VSYNC0 = 13;
VSYNC1 = 16;
PCLK = 2;
SWIZZLE = 0;
PCLK_POL = 1;
HSIZE = 800;
VSIZE = 480;
CSPREAD = 0;
DITHER = 1;
break;
case DISPLAY_39:
DWIDTH = 480;
DHEIGHT = 128;
Expand Down Expand Up @@ -404,7 +425,8 @@ int FT81x_Init(int display, int board, int touch)
HOffset = PIXHOFFSET;
VOffset = PIXVOFFSET;
Touch = touch;
Eve_Reset(); // Hard reset of the EVE chip
if (!Eve_Reset()) // Hard reset of the EVE chip
return 0;

// Wakeup EVE
if (board >= BOARD_EVE3)
Expand All @@ -414,14 +436,25 @@ int FT81x_Init(int display, int board, int touch)
HostCommand(HCMD_ACTIVE);
HAL_Delay(300);

do
for (int loop = 0; loop < 50; loop++)
{
Ready = Cmd_READ_REG_ID();
} while (!Ready);
do
if (Ready)
break;
HAL_Delay(5);
}
if (!Ready)
return 1; // bridge detected but no eve found

for (int loop = 0; loop < 50; loop++)
{
Ready = rd16(REG_CPU_RESET);
} while (!Ready);
if (Ready)
break;
HAL_Delay(5);
}
if (!Ready)
return 1; // bridge detected but no eve found

// Log("EVE now ACTIVE\n"); //

Expand Down Expand Up @@ -500,7 +533,7 @@ int FT81x_Init(int display, int board, int touch)
{
Cap_Touch_Upload();
}
if (board == BOARD_EVE4 && DISPLAY_70I_WG)
if (board == BOARD_EVE4 && display == DISPLAY_70I_WG)
{
UploadTouchFirmware(Touch70I_WG, sizeof(Touch70I_WG));
}
Expand Down Expand Up @@ -530,13 +563,13 @@ int FT81x_Init(int display, int board, int touch)
wr32(RAM_DL + 8, DISPLAY());
wr8(REG_DLSWAP + RAM_REG, DLSWAP_FRAME); // Swap display lists
wr8(REG_PCLK + RAM_REG, PCLK); // After this display is visible on the TFT
return 1;
return Ready;
}

// Reset EVE chip via the hardware PDN line
void Eve_Reset(void)
int Eve_Reset(void)
{
HAL_Eve_Reset_HW();
return HAL_Eve_Reset_HW();
}

// Upload Goodix Calibration file, ex GT911
Expand Down Expand Up @@ -1255,9 +1288,9 @@ void Wait4CoProFIFOEmpty(void)
// EVE is unhappy - needs a paddling.
uint32_t Patch_Add = rd32(REG_COPRO_PATCH_PTR + RAM_REG);
wr8(REG_CPU_RESET + RAM_REG, 1);
wr8(REG_CMD_READ + RAM_REG, 0);
wr8(REG_CMD_WRITE + RAM_REG, 0);
wr8(REG_CMD_DL + RAM_REG, 0);
wr16(REG_CMD_READ + RAM_REG, 0);
wr16(REG_CMD_WRITE + RAM_REG, 0);
wr16(REG_CMD_DL + RAM_REG, 0);
wr8(REG_CPU_RESET + RAM_REG, 0);
wr32(REG_COPRO_PATCH_PTR + RAM_REG, Patch_Add);
HAL_Delay(250); // We already saw one error message and we don't need to see then 1000 times
Expand Down
2 changes: 1 addition & 1 deletion src/usb_bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if(WIN32)
add_library(usb_bridge STATIC usb_bridge.c)
target_link_libraries(usb_bridge PUBLIC mpsse d2xx)
target_link_libraries(usb_bridge PUBLIC mpsse)
else()
add_library(usb_bridge STATIC usb_bridge_libftdi.c)
target_link_libraries(usb_bridge PUBLIC libftdi)
Expand Down
17 changes: 11 additions & 6 deletions src/usb_bridge/usb_bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ FT_HANDLE GetFTDIHandle()
void HAL_Close(void)
{
if (handle)
{
SPI_CloseChannel(handle);
handle = NULL;
}
}

void HAL_SPI_Enable(void)
Expand Down Expand Up @@ -74,15 +77,15 @@ void HAL_Delay(uint32_t milliSeconds)
usleep(milliSeconds * 1000);
#endif
}
FT_STATUS READ_CBUS(FT_HANDLE handle, unsigned char *result);
FT_STATUS SETUP_CBUS(FT_HANDLE handle);
void HAL_Eve_Reset_HW(void)

int HAL_Eve_Reset_HW(void)
{
uint32_t total_channels;
#ifndef _MSC_VER
FT_SetVIDPID(0x1b3d, 0x0200);
#endif
Init_libMPSSE();
HAL_Close();
FT_STATUS result = SPI_GetNumChannels(&total_channels);
printf("channels found : %d\n", total_channels);
const char *channel = getenv("SPICHANNEL");
Expand All @@ -92,7 +95,7 @@ void HAL_Eve_Reset_HW(void)
ichan = atoi(channel);
}

if ((int)total_channels > ichan)
if (total_channels > ichan)
{
FT_DEVICE_LIST_INFO_NODE devList;
SPI_GetChannelInfo(ichan, &devList);
Expand All @@ -116,18 +119,20 @@ void HAL_Eve_Reset_HW(void)
else
{
printf("Unable to open USB->SPI Bridge\n");
exit(1);
return 0;
}
}
else
{
printf("USB->SPI Bridge not found.");
exit(1);
return 0;
}

// reset the EVE by toggling PD pin (GPIO 7 of the FT232H) 0 to 1
FT_WriteGPIO(handle, (1 << FT800_PD_N) | 0x3B, (0 << FT800_PD_N) | 0x08); // PDN set to 0
HAL_Delay(20);

FT_WriteGPIO(handle, (1 << FT800_PD_N) | 0x3B, (1 << FT800_PD_N) | 0x08); // PDN set to 1
HAL_Delay(20);
return 1;
}
16 changes: 8 additions & 8 deletions src/usb_bridge/usb_bridge_libftdi.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ void HAL_Eve_Reset_HW(void)

unsigned int icmd = 0;
unsigned char buf[256] = {0};
buf[icmd++] = TCK_DIVISOR;
buf[icmd++] = 0x05;
buf[icmd++] = 0x00;
buf[icmd++] = DIS_ADAPTIVE;
buf[icmd++] = DIS_3_PHASE;
buf[icmd++] = SET_BITS_LOW;
buf[icmd++] = pinInitialState;
buf[icmd++] = pinDirection;
buf[icmd++] = TCK_DIVISOR; // opcode: set clk divisor
buf[icmd++] = 0x05; // argument: low bit. 6 MHz / (5+1) = 1 MHz
buf[icmd++] = 0x00; // argument: high bit.
buf[icmd++] = DIS_ADAPTIVE; // opcode: disable adaptive clocking
buf[icmd++] = DIS_3_PHASE; // opcode: disable 3-phase clocking
buf[icmd++] = SET_BITS_LOW; // opcode: set low bits (ADBUS[0-7])
buf[icmd++] = pinInitialState; // argument: inital pin states
buf[icmd++] = pinDirection; // argument: pin direction
if (ftdi_write_data(ftdi, buf, icmd) != icmd)
{
printf("Bridge setup failed\n");
Expand Down

0 comments on commit 12f329c

Please sign in to comment.