Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
- {RTT_BSP: "Edgi_Talk_M55_Blink_LED"}
- {RTT_BSP: "Edgi_Talk_CherryUSB/Edgi_Talk_M55_USB_D"}
- {RTT_BSP: "Edgi_Talk_CherryUSB/Edgi_Talk_M55_USB_H"}
- {RTT_BSP: "Edgi_Talk_CherryUSB/Edgi_Talk_Extend_Screen"}
- {RTT_BSP: "Edgi_Talk_M55_CoreMark"}
- {RTT_BSP: "Edgi_Talk_M33_CDC_Echo"}
- {RTT_BSP: "Edgi_Talk_M33_HyperRam"}
Expand Down
26 changes: 15 additions & 11 deletions libraries/Common/board/ports/display_panels/drv_touch.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ static struct rt_i2c_client ST7102_client;
static rt_err_t ST7102_write_reg(struct rt_i2c_client *dev, rt_uint8_t *data, rt_uint8_t len)
{
struct rt_i2c_msg msgs[2];
rt_uint8_t buf[2];

msgs[0].addr = dev->client_addr;
msgs[0].flags = RT_I2C_WR;
Expand All @@ -30,15 +29,14 @@ static rt_err_t ST7102_write_reg(struct rt_i2c_client *dev, rt_uint8_t *data, rt
}
}

static rt_err_t ST7102_read_regs(struct rt_i2c_client *dev, rt_uint8_t *reg, rt_uint8_t *data, rt_uint8_t len)
static rt_err_t ST7102_read_regs(struct rt_i2c_client *dev, const rt_uint8_t *reg, rt_uint8_t reg_len, rt_uint8_t *data, rt_uint8_t len)
{
struct rt_i2c_msg msgs[2];
rt_uint8_t buf[2];

msgs[0].addr = dev->client_addr;
msgs[0].flags = RT_I2C_WR;
msgs[0].buf = reg;
msgs[0].len = ST7102_REGITER_LEN;
msgs[0].buf = (rt_uint8_t *)reg;
msgs[0].len = reg_len;

msgs[1].addr = dev->client_addr;
msgs[1].flags = RT_I2C_RD;
Expand All @@ -59,16 +57,22 @@ static rt_err_t ST7102_get_info(struct rt_i2c_client *dev, struct rt_touch_info
{
rt_uint8_t Reg_High[2];
rt_uint8_t Reg_Low[2];
rt_uint8_t reg;

ST7102_read_regs(dev, ST7102_MAX_X_Coord_High, Reg_High, 1);
ST7102_read_regs(dev, ST7102_MAX_X_Coord_Low, Reg_Low, 1);
reg = ST7102_MAX_X_Coord_High;
ST7102_read_regs(dev, &reg, 1, Reg_High, 1);
reg = ST7102_MAX_X_Coord_Low;
ST7102_read_regs(dev, &reg, 1, Reg_Low, 1);
info->range_x = (Reg_High[0] & 0x3F) << 8 | Reg_Low[0];

ST7102_read_regs(dev, ST7102_MAX_Y_Coord_High, Reg_High, 1);
ST7102_read_regs(dev, ST7102_MAX_Y_Coord_Low, Reg_Low, 1);
reg = ST7102_MAX_Y_Coord_High;
ST7102_read_regs(dev, &reg, 1, Reg_High, 1);
reg = ST7102_MAX_Y_Coord_Low;
ST7102_read_regs(dev, &reg, 1, Reg_Low, 1);
info->range_y = (Reg_High[0] & 0x3F) << 8 | Reg_Low[0];

ST7102_read_regs(dev, ST7102_MAX_Touches, Reg_Low, 1);
reg = ST7102_MAX_Touches;
ST7102_read_regs(dev, &reg, 1, Reg_Low, 1);
info->point_num = Reg_Low[0];

return RT_EOK;
Expand Down Expand Up @@ -163,7 +167,7 @@ static rt_size_t ST7102_read_point(struct rt_touch_device *touch, void *buf, rt_
cmd[0] = (rt_uint8_t)((ST7102_Read_Start_Position >> 8) & 0xFF);
cmd[1] = (rt_uint8_t)(ST7102_Read_Start_Position & 0xFF);

if (ST7102_read_regs(&ST7102_client, cmd, read_buf, 8 * ST7102_MAX_TOUCH) != RT_EOK)
if (ST7102_read_regs(&ST7102_client, cmd, 2, read_buf, 8 * ST7102_MAX_TOUCH) != RT_EOK)
{
LOG_D("read point failed\n");
read_num = 0;
Expand Down
62 changes: 56 additions & 6 deletions libraries/HAL_Drivers/drv_lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@

#define LCD_WIDTH 512
#define LCD_HEIGHT 800
#define LCD_STRIDE 512
#define LCD_BITS_PER_PIXEL 16
#define LCD_BUF_SIZE (LCD_WIDTH * LCD_HEIGHT * LCD_BITS_PER_PIXEL / 8)
#define LCD_BUF_SIZE (LCD_STRIDE * LCD_HEIGHT * LCD_BITS_PER_PIXEL / 8)
#define LCD_PIXEL_FORMAT RTGRAPHIC_PIXEL_FORMAT_RGB565
#define LCD_DEVICE(dev) (struct drv_lcd_device*)(dev)
#define RESET_VAL 0U
#define GPU_TESSELLATION_BUFFER_SIZE ((LCD_WIDTH) * 128U)
#define APP_BUFFER_COUNT (2U)
#define DEFAULT_GPU_CMD_BUFFER_SIZE ((64U) * (512))
Expand Down Expand Up @@ -76,9 +76,7 @@ struct drv_lcd_device

static rt_err_t drv_lcd_init(struct rt_device *device)
{
struct drv_lcd_device *lcd = LCD_DEVICE(device);
/* nothing, right now */
lcd = lcd;
(void)device;
return RT_EOK;
}

Expand All @@ -90,6 +88,53 @@ static rt_err_t drv_lcd_control(struct rt_device *device, int cmd, void *args)
{
case RTGRAPHIC_CTRL_RECT_UPDATE:
{
struct rt_device_rect_info *info = (struct rt_device_rect_info *)args;
uint32_t start_line = 0U;
uint32_t end_line = lcd->lcd_info.height;
rt_bool_t try_partial = RT_FALSE;

if (info != RT_NULL)
{
if ((info->width == 0U) || (info->height == 0U))
{
return RT_EOK;
}
if ((info->x >= lcd->lcd_info.width) || (info->y >= lcd->lcd_info.height))
{
return RT_EOK;
}
if ((info->x + info->width) > lcd->lcd_info.width)
{
info->width = lcd->lcd_info.width - info->x;
}
if ((info->y + info->height) > lcd->lcd_info.height)
{
info->height = lcd->lcd_info.height - info->y;
}

start_line = info->y;
end_line = info->y + info->height;
if ((info->x == 0U) && (info->width == lcd->lcd_info.width))
{
try_partial = RT_TRUE;
}
}

if (try_partial &&
((lcd_gfx_context.dc_context.display_type == GFX_DISP_TYPE_DBI_A) ||
(lcd_gfx_context.dc_context.display_type == GFX_DISP_TYPE_DBI_B) ||
(lcd_gfx_context.dc_context.display_type == GFX_DISP_TYPE_DBI_C) ||
(lcd_gfx_context.dc_context.display_type == GFX_DISP_TYPE_DSI_DBI)))
{
status = Cy_GFXSS_TransferPartialFrame(gfxbase, start_line, end_line, &lcd_gfx_context);
if (CY_GFX_SUCCESS != status)
{
LOG_E("[%s: %d] Partial frame transfer failed. Error type: %u\r\n", __func__, __LINE__, status);
CY_ASSERT(0);
}
break;
}

/* update */
/* Set the frame buffer with the image pointer to be displayed on LCD */
status = Cy_GFXSS_Set_FrameBuffer(gfxbase, (uint32_t*)graphics_buffer, &lcd_gfx_context);
Expand All @@ -111,9 +156,11 @@ static rt_err_t drv_lcd_control(struct rt_device *device, int cmd, void *args)
RT_ASSERT(info != RT_NULL);
info->pixel_format = lcd->lcd_info.pixel_format;
info->bits_per_pixel = 16;
info->pitch = lcd->lcd_info.pitch;
info->width = lcd->lcd_info.width;
info->height = lcd->lcd_info.height;
info->framebuffer = lcd->lcd_info.framebuffer;
info->smem_len = lcd->lcd_info.smem_len;
}
break;
}
Expand Down Expand Up @@ -148,6 +195,7 @@ static void dc_irq_handler(void)
{
rt_interrupt_enter();
Cy_GFXSS_Clear_DC_Interrupt(gfxbase, &lcd_gfx_context);
rt_sem_release(&_lcd.lcd_lock);
rt_interrupt_leave();
}

Expand Down Expand Up @@ -251,6 +299,8 @@ int drv_lcd_hw_init(void)
_lcd.lcd_info.width = LCD_WIDTH;
_lcd.lcd_info.bits_per_pixel = LCD_BITS_PER_PIXEL;
_lcd.lcd_info.pixel_format = LCD_PIXEL_FORMAT;
_lcd.lcd_info.pitch = LCD_STRIDE * (LCD_BITS_PER_PIXEL / 8);
_lcd.lcd_info.smem_len = LCD_BUF_SIZE;

/* malloc memory for Triple Buffering */
// _lcd.front_buf=_lcd.lcd_info.framebuffer = rt_malloc_align(LCD_BUF_SIZE, 32);
Expand All @@ -264,7 +314,7 @@ int drv_lcd_hw_init(void)
goto __exit;
}
/* memset buff to 0xFF */
memset(_lcd.lcd_info.framebuffer, 0xFF, LCD_BUF_SIZE);
memset(_lcd.lcd_info.framebuffer, 0x00, LCD_BUF_SIZE);
device->type = RT_Device_Class_Graphic;
#ifdef RT_USING_DEVICE_OPS
device->ops = &lcd_ops;
Expand Down
2 changes: 2 additions & 0 deletions libraries/M55_Config/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ menu "On-chip Peripheral Drivers"
select RT_USING_LCD
select RT_USING_TOUCH
select RT_TOUCH_PIN_IRQ
select BSP_USING_I2C
select BSP_USING_SOFT_I2C1
default n
if BSP_USING_LCD
config COMPONENT_MTB_DISPLAY_tl043wvv02
Expand Down
9 changes: 9 additions & 0 deletions libraries/components/CherryUSB-1.6.0/Kconfig.rtt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ if RT_USING_CHERRYUSB
prompt "Enable usb dfu device"
default n

config RT_CHERRYUSB_DEVICE_DISPLAY
bool
prompt "Enable usb display device"
default n

config RT_CHERRYUSB_DEVICE_CDC_ACM_CHARDEV
bool
prompt "Enable chardev for cdc acm device"
Expand Down Expand Up @@ -243,6 +248,10 @@ if RT_USING_CHERRYUSB
bool
prompt "webusb_hid"
depends on RT_CHERRYUSB_DEVICE_HID
config RT_CHERRYUSB_DEVICE_TEMPLATE_DISPLAY
bool
prompt "display"
depends on RT_CHERRYUSB_DEVICE_DISPLAY
config RT_CHERRYUSB_DEVICE_TEMPLATE_ADB
bool
prompt "adb"
Expand Down
6 changes: 6 additions & 0 deletions libraries/components/CherryUSB-1.6.0/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ path += [cwd + '/class/dfu']
path += [cwd + '/class/serial']
path += [cwd + '/class/vendor/net']
path += [cwd + '/class/vendor/wifi']
path += [cwd + '/class/vendor/display']
src = []

LIBS = []
Expand Down Expand Up @@ -136,6 +137,11 @@ if GetDepend(['RT_CHERRYUSB_DEVICE']):
src += Glob('class/cdc/usbd_cdc_ncm.c')
if GetDepend(['RT_CHERRYUSB_DEVICE_DFU']):
src += Glob('class/dfu/usbd_dfu.c')
if GetDepend(['RT_CHERRYUSB_DEVICE_DISPLAY']):
path += [cwd + '/third_party/cherrymp']
src += Glob('class/vendor/display/usbd_display.c')
src += Glob('third_party/cherrymp/chry_mempool.c')
src += Glob('third_party/cherrymp/chry_mempool_osal_rtthread.c')
if GetDepend(['RT_CHERRYUSB_DEVICE_ADB']):
src += Glob('class/adb/usbd_adb.c')
src += Glob('platform/rtthread/usbd_adb_shell.c')
Expand Down
Loading