This commit is contained in:
刘可亮
2025-07-22 11:30:42 +08:00
parent 11c97ef399
commit 33c375efac
7 changed files with 39 additions and 3 deletions

View File

@@ -311,6 +311,7 @@ void drv_usart_irqhandler(int irq, void * data)
static rt_err_t drv_uart_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
{
int ret;
uint32_t index = 0;
usart_handle_t uart;
uint32_t bauds;
@@ -324,6 +325,7 @@ static rt_err_t drv_uart_configure(struct rt_serial_device *serial, struct seria
RT_ASSERT(uart != RT_NULL);
/* set baudrate parity...*/
index = serial->config.uart_index;
bauds = cfg->baud_rate;
mode = USART_MODE_ASYNCHRONOUS;
@@ -356,6 +358,10 @@ static rt_err_t drv_uart_configure(struct rt_serial_device *serial, struct seria
else
databits = USART_DATA_BITS_8;
hal_clk_disable(CLK_UART0 + index);
drv_usart_set_freq(bauds, index);
hal_clk_enable(CLK_UART0 + index);
aic_udelay(1000);
hal_usart_set_loopback(uart, 1);
hal_uart_reset_fifo(uart);

View File

@@ -134,9 +134,9 @@ static sfud_err spi_set_speed(const sfud_spi *spi, uint32_t bus_hz)
rtt_dev = sfud_dev->user_data;
#ifndef SFUD_USING_QSPI
struct rt_spi_configuration cfg = RT_SFUD_DEFAULT_SPI_CFG;
struct rt_spi_configuration spi_cfg = RT_SFUD_DEFAULT_SPI_CFG;
cfg.max_hz = bus_hz;
spi_cfg.max_hz = bus_hz;
return rt_spi_configure(rtt_dev->rt_spi_device, &spi_cfg);
#else
struct rt_qspi_configuration qspi_cfg = RT_SFUD_DEFAULT_QSPI_CFG;

View File

@@ -368,12 +368,14 @@ static bool cache_node_cache_create_cb(lv_freetype_cache_node_t * node, void * u
}
node->face = face;
lv_mutex_init(&node->face_lock);
return true;
}
static void cache_node_cache_free_cb(lv_freetype_cache_node_t * node, void * user_data)
{
FT_Done_Face(node->face);
lv_mutex_delete(&node->face_lock);
if(node->glyph_cache) {
lv_cache_destroy(node->glyph_cache, user_data);

View File

@@ -129,13 +129,19 @@ static bool freetype_glyph_create_cb(lv_freetype_glyph_cache_data_t * data, void
lv_font_glyph_dsc_t * dsc_out = &data->glyph_dsc;
lv_mutex_lock(&dsc->cache_node->face_lock);
FT_Face face = dsc->cache_node->face;
FT_UInt glyph_index = FT_Get_Char_Index(face, data->unicode);
FT_Set_Pixel_Sizes(face, 0, dsc->size);
error = FT_Load_Glyph(face, glyph_index, FT_LOAD_COMPUTE_METRICS | FT_LOAD_NO_BITMAP);
if(error) {
FT_ERROR_MSG("FT_Load_Glyph", error);
lv_mutex_unlock(&dsc->cache_node->face_lock);
return false;
}
@@ -172,6 +178,8 @@ static bool freetype_glyph_create_cb(lv_freetype_glyph_cache_data_t * data, void
dsc_out->is_placeholder = glyph_index == 0;
dsc_out->glyph_index = glyph_index;
lv_mutex_unlock(&dsc->cache_node->face_lock);
return true;
}
static void freetype_glyph_free_cb(lv_freetype_glyph_cache_data_t * data, void * user_data)

View File

@@ -123,15 +123,21 @@ static bool freetype_image_create_cb(lv_freetype_image_cache_data_t * data, void
FT_Error error;
lv_mutex_lock(&dsc->cache_node->face_lock);
FT_Face face = dsc->cache_node->face;
FT_Set_Pixel_Sizes(face, 0, dsc->size);
error = FT_Load_Glyph(face, data->glyph_index, FT_LOAD_RENDER | FT_LOAD_TARGET_NORMAL);
if(error) {
lv_mutex_unlock(&dsc->cache_node->face_lock);
FT_ERROR_MSG("FT_Load_Glyph", error);
return false;
}
error = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
if(error) {
lv_mutex_unlock(&dsc->cache_node->face_lock);
FT_ERROR_MSG("FT_Render_Glyph", error);
return false;
}
@@ -139,6 +145,7 @@ static bool freetype_image_create_cb(lv_freetype_image_cache_data_t * data, void
FT_Glyph glyph;
error = FT_Get_Glyph(face->glyph, &glyph);
if(error) {
lv_mutex_unlock(&dsc->cache_node->face_lock);
FT_ERROR_MSG("FT_Get_Glyph", error);
return false;
}
@@ -150,7 +157,12 @@ static bool freetype_image_create_cb(lv_freetype_image_cache_data_t * data, void
uint32_t stride = lv_draw_buf_width_to_stride(box_w, LV_COLOR_FORMAT_A8);
data->draw_buf = lv_draw_buf_create(box_w, box_h, LV_COLOR_FORMAT_A8, stride);
if (!data->draw_buf) {
FT_Done_Glyph(glyph);
lv_mutex_unlock(&dsc->cache_node->face_lock);
LV_LOG_ERROR("Can not create freetype draw buf");
return false;
}
for(int y = 0; y < box_h; ++y) {
lv_memcpy((uint8_t *)(data->draw_buf->data) + y * stride, glyph_bitmap->bitmap.buffer + y * box_w,
box_w);
@@ -158,6 +170,8 @@ static bool freetype_image_create_cb(lv_freetype_image_cache_data_t * data, void
FT_Done_Glyph(glyph);
lv_mutex_unlock(&dsc->cache_node->face_lock);
return true;
}
static void freetype_image_free_cb(lv_freetype_image_cache_data_t * data, void * user_data)

View File

@@ -119,12 +119,17 @@ bool lv_freetype_is_outline_font(const lv_font_t * font)
static bool freetype_glyph_outline_create_cb(lv_freetype_outline_node_t * node, lv_freetype_font_dsc_t * dsc)
{
lv_freetype_outline_t outline;
lv_mutex_lock(&dsc->cache_node->face_lock);
outline = outline_create(dsc->context,
dsc->cache_node->face,
node->glyph_index,
dsc->cache_node->ref_size,
dsc->style & LV_FREETYPE_FONT_STYLE_BOLD ? 1 : 0);
lv_mutex_unlock(&dsc->cache_node->face_lock);
if(!outline) {
return false;
}

View File

@@ -66,6 +66,7 @@ struct _lv_freetype_cache_node_t {
uint32_t ref_size; /**< Reference size for calculating outline glyph's real size.*/
FT_Face face;
lv_mutex_t face_lock;
/*glyph cache*/
lv_cache_t * glyph_cache;