GR5526 (1)-User Guide for watch reference scheme
[TOC]
1. GR5526 Wear (Watch) Ref.
Please get the download address of the GR5526 SDK from the [ 开发向导] page to download the SDK and build the development environment locally.
Download the GR5526 documentation from the [ 开发向导] page. Before entering the product development, it is necessary to spend some time to familiarize and read the development materials related to the chip.
Please obtain the software and tools required for the development process of GR5526 from the [ 开发向导] page to facilitate the subsequent development and debugging work.
1.1 Example Project
The GR5526 SDK provides a wealth of reference sample projects covering Bluetooth LE (Profile, Multi-Connect, DTM), peripheral usage, OS, DFU, low power, product reference designs, and more.
For wearable products, some important sample projects are listed; users can refer to the following sample projects to build all software modules of wearable products from scratch, from peripheral drivers to OS, application logic, Bluetooth LE Profile, DFU/OTA, sleep debugging, etc.
| 工程 | Path | 描述 |
|---|---|---|
| FreeRTOS模板工程 | ${SDK}\projects\ble\ble_peripheral\ble_app_template_freertos | 移植的FreeRTOS基础工程,支持休眠低功耗,可以基于此工程理解休眠设计和从零构建应用工程 |
| DTM测试工程 | ${SDK}\projects\ble\dtm\direct_test_mode | 基于此工程进行Bluetooth LE的DTM测试 |
| LVGL 810穿戴参考工程 | ${SDK}\projects\peripheral\graphics\graphics_lvgl_810_gpu_demo | 基于LVGL 810开发的穿戴参考,集成了常用的外设模块,构建了基础的UI/UX,可作为用户设计参考 |
| LVGL 831穿戴参考工程 | ${SDK}\projects\peripheral\graphics\graphics_lvgl_831_gpu_demo (454x454分辨率屏幕版本)${ SDK } \ projects \ peripheral \ graphics \ graphics _ lvgl _ 831 _ GPU _ demo _ 360p (360x360 resolution screen version) | 基于LVGL 831开发的穿戴参考,集成了常用的外设模块,集成了Bluetooth LE Profiles和DFU,构建了基础的UI/UX,可作为用户设计参 |
| 产品升级引导参考工程 | ${SDK}\projects\ble\dfu\app_bootloader | 提供的Bootloader引导固件可用于产品DFU升级引导程序 |
| DFU OTA 升级参考工程 | ${SDK}\projects\ble\ble_peripheral\ble_app_template_dfu | The OTA function is integrated and used with the app _ bootloader and OTA App (GRToolbox). During the product development process, the OTA part of this project needs to be transplanted to the product engineering. |
If you can obtain or purchase the GR5526 SK board, you can first run and experience the above project on the SK board. Intuitive testing experience for programs and effects helps engineers quickly build intuition for using products and SDKs.
If the user has rich experience in wearable product development, the above project can be used as a reference for debugging in product development.
If the user is relatively inexperienced in the development of wearable products, the LVGL 831 (or LVGL 810) project can be considered as a template project to delete unnecessary functions and develop the missing functions of the integrated product business.
In addition, we provide video demonstrations of some reference projects, and users can scan and send QR codes to view and experience them.
GR5526 LVGL 831 Demo Video
GR5526 Capability Demonstration Video
1.2 Drive reference
The GR5526 SDK provides driver references for commonly used chip peripherals and peripheral modules. In product development, it can be referenced or reused according to the actual situation.
| 外设模块 | 驱动文件或目录 | Instructions for use |
|---|---|---|
| GPU | ${SDK}\app\drivers\src\app_graphics_gpu.c | 主要管理GPU模块的初始化、休眠、同步等,GPU的 接口,仅适用于GPU版本芯片 |
| GPU驱动接口 | ${SDK}\app\components\graphics\gfx | GPU的驱动接口头文件放置 |
| Display Controller(显示控制模块) | ${SDK}\app\drivers\src\app_graphics_dc.c | The DC module can be used to generate the screen control timing of SPI, 3-SPI, 4-SPI and QSPI, and to process the GPU-specific compression format, which is only applicable to the GPU version chip. |
| OSPI PSRAM | ${SDK}\app\drivers\src\app_graphics_ospi.c | OSPI is the interface type Octal-SPI, and PSRAM is the read-write RAM space expanded through the OSPI DDR interface, which is slower than the internal SRAM, but much faster than the external QSPI PSRAM; Try to use DMA and GPU Master to access PSRAM with large data blocks, and try to avoid using CPU pointer to access PSRAM with large space, otherwise the access performance will be reduced; PSRAM address space is continuous with an alias address space of SRAM |
| PSRAM堆管理 | ${SDK}\app\components\libraries\app_graphics_mem\app_graphics_mem.c | The PSRAM space is managed as a large heap space. Since the address space of SRAM/PSRAM is continuous, the starting address of Heap is in SRAM. After initialization, two FB spaces are applied first. |
| QSPI-Flash | ${SDK}\app\components\drivers_ext\qspi_device提供了驱动参考 | Note the distinction between QSPI-Flash and XQSPI-Flash. The latter is the Flash that the SiP uses for code execution inside the chip, but its remaining space can also be used to store other resources; the data defined by const in the software is placed in XQSPI Flash |
| QSPI-Flash MMAP访问 | Wearing example works | 参考示例工程下提供了使用MMAP模式访问Flash的代码 |
| QSPI-PSRAM | ${SDK}\app\components\drivers_ext\qspi_device提供了驱动参考 | This is the PSRAM extended through the external QSPI interface, which is much slower than the OSPI PSRAM. If it is a GPU version chip, this peripheral can be ignored. |
| QSPI-Display | ${SDK}\app\components\drivers_ext\qspi_device提供了驱动参考 | The SDK provides multiple interface driver design references for multiple screens, such as SPI/QSPI timing driver based on QSPI hardware interface, and SPI, 3/4-SPI, QSPI timing driver based on DC hardware interface |
| DC-Display | ${SDK}\components\drivers_ext\graphics_dc | SDK提供基于Display Controller外设模块的屏幕驱动程序,涵盖XSJ和FLS等屏厂驱动 |
| Touch | Example Project Example Project | 参考示例工程下提供了Touch的一般驱动参考 |
1.3 LVGL GUI Framework Instructions
In the latest version of the GR5526 SDK (v1.0.2), two LVGL versions of the migration optimization are provided, and a reference project is provided respectively.
In general, it is recommended that users prefer to use LVGL version 8.3.1. From the point of view of porting and website support, the new version will have fewer bugs and better features.
| 版本 | Main optimization points | 源码路径 | 适用 SoC |
|---|---|---|---|
| LVGL 8.10 | 1. Integration provides GPU driver library 2. Complete LVGL drawing layer migration optimization (line, rectangle, polygon, image, circle, arc..) 3. LVGL supports RGB565, RGBA8888 and GPU compression format resources at 32bit color depth 4. Indev input buffer design is added to improve tracking 5. Add WMS (Window Management Service) design, responsible for window sliding rendering and event management, introduce Surface Flinger design, add window transition 3D animation 6. New features of WMS2.0: 1). Introduce ID system for Window management 2). Introduce Scene management system to solve the problem of one Window in multiple scenes. 3). Introduce Window Stack design, record management window stack 4). Embed the side key management into WMS, and handle various side key events in each window as required; if not, the system will handle them uniformly. 5). Introduce Gesture Exit 7. Provide a variety of custom control design reference (such as nebula dial, slide list, etc.) 8. Provide Watch Demo reference engineering |
${GR5526_SDK}\external\lvgl_8.1.0 | GR5526 GPU版本 |
| LVGL 8.31 | 1. Integration provides GPU driver library 2. Complete LVGL drawing layer migration optimization (line, rectangle, polygon, image, circle, arc..) 3. LVGL supports RGB565, RGBA8888 and GPU compression format resources at 32bit color depth 4. Indev input buffer design is added to improve tracking 5. Add WMS (Window Management Service) design, responsible for window sliding rendering and event management, introduce Surface Flinger design, add window transition 3D animation 6. New features of WMS2.0: 1). Introduce ID system for Window management 2). Introduce Scene management system to solve the problem of one Window in multiple scenes. 3). Introduce Window Stack design, record management window stack 4). Embed the side key management into WMS, and handle various side key events in each window as required; if not, the system will handle them uniformly. 5). Introduce Gesture Exit 7. Provide a variety of custom control design reference (such as nebula dial, slide list, etc.) 8. Provide Watch Demo reference engineering |
${GR5526_SDK}\external\lvgl_8.3.1 | GR5526 GPU版本 |
When using the LVGL GUI framework in a project, you also need to reference the following libraries or configuration files:
| LVGL | LVGL porting library | GPU库 | sct文件(ARMCC) |
|---|---|---|---|
| 8.1.0 | ${SDK}\platform\soc\linker\keil\graphics_lvgl_v810_lib.lib | ${SDK}\platform\soc\linker\keil\graphics_sdk.lib | ${SDK}\platform\soc\linker\keil\flash_scatter_graphics.sct |
| 8.3.1 | ${SDK}\platform\soc\linker\keil\graphics_lvgl_v831_lib.lib | ${SDK}\platform\soc\linker\keil\graphics_sdk.lib | ${SDK}\platform\soc\linker\keil\flash_scatter_graphics.sct |
2. Instructions for use of the migration
This chapter is based on the description of the project graphics_lvgl_831_gpu_demo_360p, and the same is true of the project graphics_lvgl_831_gpu_demo.
2.1 typical peripheral adaptation
The sample project abstracts an Adapter layer from the screen control, touch processing and data Flash access involved in wearable products, and carries out a reference implementation. On the basis of the adaptation layer, users can re-adapt these types of peripherals according to the product conditions.
By default, the function pointers of these types of peripherals are registered when the peripherals are initialized. For the sake of transplantation compatibility, the upper function interface is called as much as possible in the application layer.
void app_periph_init(void) { ..... drv_adapter_disp_register(); drv_adapter_norflash_register(); drv_adapter_touchpad_register(); ..... }
2.1.1 Adaptation of screen driver
The screen adaptation layer abstracts the following function interfaces, and the user needs to implement the adaptation as required
| 上层函数 | 适配层函数(用户实现) | Action |
|---|---|---|
| drv_adapter_disp_register | 如无必要,不用修改 | Registers an adaptation layer function |
| drv_adapter_disp_init | _disp_drv_init | Screen initialization interface |
| drv_adapter_disp_deinit | _disp_drv_deinit | Screen de-initialization interface |
| drv_adapter_disp_set_show_area | _disp_drv_set_show_area | Set the screen display area |
| drv_adapter_disp_wait_to_flush | _disp_drv_wait_to_flush | 等待刷屏, 必须等待上次刷屏完成 (一般使用信号量实现) |
| drv_adapter_disp_flush | _disp_drv_flush | Flushes the framebuffer data to the screen for display |
| drv_adapter_disp_wait_te | _disp_drv_wait_te | Wait for TE synchronization |
| drv_adapter_disp_on | _disp_drv_on | Screen display on/off |
| drv_adapter_disp_set_brightness | _disp_drv_set_brightness | Set the backlight brightness |
| drv_adapter_disp_sleep | _disp_drv_sleep | 屏幕休眠, 对屏幕进行掉电,屏幕电路配置为最低功耗 |
| drv_adapter_disp_wakeup | _disp_drv_wakeup | 屏幕唤醒, 配置屏幕电路及屏幕重新处于正常工作状态 |
Users can refer to the prototype definition of the adaptation layer function and the driver of the sample project to implement the above interface functions in the driver file of the screen and improve the adaptation layer function.
Note that the drv _ adapter _ disp _ set _ show _ area function sets the parameters for the display area as follows:
If the screen width and height are W and H, the input parameters are drv _ adapter _ disp _ set _ show _ area (0, 0, W-1, H-1);
In the initial stage of adaptation, the three more important functions are as follows, which can be adapted to light the screen first, and then implement other interfaces.
Drv _ adapter _ disp _ init-includes Reset, backlight pin control, command timing initialization, etc., to ensure that the screen is ready to light up
Drv _ adapter _ disp _ set _ show _ area-Set the desired display area through the control command
Drv _ adapter _ disp _ flush — Refreshes the frame data to the screen for display
2.1.2 Touch adaptation
The Touch adaptation layer abstracts the following function interfaces, and the user needs to implement the adaptation as required
| 上层函数 | 适配层函数(用户实现) | Action |
|---|---|---|
| drv_adapter_touchpad_register | 如无必要,不用修改 | Registers an adaptation layer function |
| drv_adapter_touchpad_init | _touchpad_drv_init | Touch initializes the interface |
| drv_adapter_touchpad_deinit | _touchpad_drv_deinit | Touch de-initialization interface |
| drv_adapter_touchpad_read_pointer | _touchpad_drv_read_pointer | Read Touch coordinate point function |
| drv_adapter_touchpad_sleep | _touchpad_drv_sleep | 设置Touch休眠, 根据产品设计, 进入休眠模式或直接掉电 |
| drv_adapter_touchpad_wakeup | _touchpad_drv_wakeup | Reset the Touch to wake-up mode |
Users can refer to the prototype definition of the adaptation layer function and the driver of the sample project to implement the above interface functions in the driver file of Touch and improve the adaptation layer function.
In general, the driver of Touch is mostly based on I2C interface, and the adaptation is relatively simple.
If Touch uses interrupt wake-up IO (note that it is placed in the AON IO domain), consider waking up the system in the callback function of I/O (such as implementing semaphores).
/* * Override this function, defined as __weak in file drv_adapter_port_touchpad.c */ void _touchpad_drv_irq_notify(void) { osal_sema_give(s_sleep_mgnt_sem); }
2.1.3 Data Nor Flash Adaptation
In general, the Nor Flash control commands of all manufacturers on the market are compatible, and there is no need to re-adapt the Nor Flash driver. However, the following situations need to be considered and the lower driver interface needs to be re-adapted:
The user may mount the Flash to a different QSPI module (it is mounted to QSPI0 by default), and needs to reconfigure the I/O of the Flash and modify the storage address of the picture material
There may be a few Flash models with differences in control commands from supported Flash vendors
The default driver does not support
The external Nor Flash adaptation layer abstracts the following function interfaces, and the user needs to implement the adaptation as required
| 上层函数 | 适配层函数(用户实现) | Action |
|---|---|---|
| drv_adapter_norflash_register | 如无必要,不用修改 | Registers an adaptation layer function |
| drv_adapter_norflash_init | _norflash_drv_init | The flash initialization interface |
| drv_adapter_norflash_deinit | _norflash_drv_deinit | Anti-initialization interface of flash |
| drv_adapter_norflash_write | _norflash_drv_write | The interface for writing data of any length requires that the write address has been erased in advance, and the interface will not perform data backup of reading first and then writing. |
| drv_adapter_norflash_read | _norflash_drv_read | Read-arbitrary-length data interface |
| drv_adapter_norflash_update | _norflash_drv_update | When updating the data interface of any length, the operations of reading, backup, erasing and writing will be performed before updating, but the page erasing implementation is used for erasing. If the Flash used does not support the page erasing command. Requires re-adaptation |
| drv_adapter_norflash_erase | _norflash_drv_erase | Erasing interface, supporting Page, Sector, Block, Chip and other erasing modes |
| drv_adapter_norflash_set_mmap_mode | _norflash_drv_set_mmap_mode | Set MMAP access mode for Flash (on/off) |
| drv_adapter_norflash_sleep | _norflash_drv_sleep | Set the Flash to sleep |
| drv_adapter_norflash_wakeup | _norflash_drv_wakeup | Wake up Flash back to working state |
If the external Flash on the circuit is not mounted on the QSPI0 module, modify qspi_norf_initthe input ID and PIN pin configuration
#define NORFLASH_DEV_QSPI_ID APP_QSPI_ID_0 /**< QSPI id to connect the norf */ #define NORFLASH_DEV_CLOCK_PREESCALER 2u /**< clock prescaler for qspi */ #define NORFLASH_DEV_PIN_CFG (g_qspi_pin_groups[QSPI0_PIN_GROUP_0]) /**< pin config for qspi */ #define NORFLASH_DEV_DEV_ID 0x0B /**< 0x0B - XTX; 0x85 - PUYA */
If Nor Flash is mounted to a non-QSPI0 module, the storage location of the resource image also needs to be adjusted. The default base address of the Lvgl image resource generated by the tool in accordance with the GPU version is placed in the MMAP space QSPI0_XIP_BASEof QSPI0. As follows (file lv _ IMG _ DSC _ list. C):
#if USE_EXTERNAL_RESOURCES #define BINARY_RESOURCES (const uint8_t *)QSPI0_XIP_BASE #else extern const uint8_t BINARY_RESOURCES[]; #endif // USE_EXTERNAL_RESOURCES const lv_img_dsc_t wd_img_black_clock_face = { .header.always_zero = 0, .header.cf = LV_IMG_CF_GDX_RGB565, .header.w = 360, .header.h = 360, .data_size = 259200, .data = BINARY_RESOURCES + OFFSET_BLACK_CLOCK_FACE, };
If you change to a QSPI1-mounted Flash, the base address is set to QSPI1_XIP_BASE, and so on
If the storage address of the image resource does not start from the 0 address of Flash, you need to add a specific offset.
2.3 User Task Description
The sample project newly defines three user-level tasks:
GUI Task-Rendering for Lvgl tasks. Lvgl tasks are not thread safe and cannot call the drawing class interface asynchronously.
Touch Task-used to collect Touch events and process the events for GUI tasks
Event Task-currently used to send Key events to Lvgl Task for execution through the Lvgl asynchronous interface