### Login and State Handling Example Source: https://github.com/opensifli/sifli-sdk/blob/main/example/multimedia/lvgl/lvgl_v8_examples/src/examples/others/msg/index.rst Illustrates handling login processes and their various states. No specific setup or constraints are mentioned. ```c #include "lv_examples.h" void lv_example_msg_2(void) { /*Example code for handling login and its states*/ } ``` -------------------------------- ### Main Application Structure for LVGL Demos Source: https://github.com/opensifli/sifli-sdk/blob/main/example/multimedia/lvgl/lvgl_v9_demos/src/lv_demos/README_EN.md Example `main.c` demonstrating LVGL initialization, HAL setup, demo creation using `lv_demos_create`, and the main event loop. Handles demo selection via command-line arguments and shows help if arguments are invalid. ```c #include "lvgl.h" #include "demos/lv_demos.h" ... static lv_display_t* hal_init(void) { lv_display_t* disp = NULL; ... /* TODO: init display and indev */ ... return disp; } int main(int argc, char ** argv) { lv_init(); lv_display_t* disp = hal_init(); if (disp == NULL) { LV_LOG_ERROR("lv_demos initialization failure!"); return 1; } if (!lv_demos_create(&argv[1], argc - 1)) { lv_demos_show_help(); goto demo_end; } while (1) { uint32_t delay = lv_timer_handler(); if (delay < 1) delay = 1; usleep(delay * 1000); } demo_end: lv_deinit(); return 0; } ``` -------------------------------- ### Basic Grid Navigation Example Source: https://github.com/opensifli/sifli-sdk/blob/main/example/multimedia/lvgl/lvgl_v8_examples/src/examples/others/gridnav/index.rst Demonstrates basic grid navigation functionality. No specific setup or imports are shown. ```c #include void lv_example_gridnav_1(void) { /* Example code for basic grid navigation */ } ``` -------------------------------- ### Build the Example Project Source: https://github.com/opensifli/sifli-sdk/blob/main/example/ble/multi_connection/README_EN.md Use the scons command to build the example project. Ensure you are in the example project/common directory. ```bash > scons --board=eh-lb525 -j8 ``` -------------------------------- ### Simple Horizontal Gradient Source: https://github.com/opensifli/sifli-sdk/blob/main/example/multimedia/lvgl/lvgl_v9_examples/src/examples/grad/index.rst Implement a simple horizontal gradient. This is a basic example for getting started. ```c lv_example:: get_started/lv_example_grad_1 ``` -------------------------------- ### SPI Polling Example Startup Logs Source: https://github.com/opensifli/sifli-sdk/blob/main/example/hal/spi/polling/README_EN.md These are the expected logs when the SPI polling loopback demo starts. They indicate the purpose of the demo and the required hardware setup for loopback verification. ```text Start spi polling loopback demo! tip: short SPI1 MOSI(DIO/DO) to MISO(DI) for loopback verification. ``` -------------------------------- ### Build and Flash Example Source: https://github.com/opensifli/sifli-sdk/blob/main/example/cherryusb/device/msc/sdcard_disk/README_EN.md Use this command to build the example for a specific board. Replace the board name with your target hardware. ```shell scons --board=sf32lb56-lcd_a128r12n1 -j10 ``` -------------------------------- ### Example Serial Port Output Source: https://github.com/opensifli/sifli-sdk/blob/main/example/multimedia/lvgl/ezip_v9/README_EN.md This output indicates successful initialization of the system, mounting of file systems, and the start of the dynamic ezip loading example. ```text (...system initialization information omitted...) Register root to mtd device with base addr 0x12820000 mount fs on flash to root success dynamic ezip loading example. mount fs on sd0 to /sdcard success ``` -------------------------------- ### Example Output Log Source: https://github.com/opensifli/sifli-sdk/blob/main/example/pm/gpio/README_EN.md This is a sample of the expected output log when the GPIO Power Consumption Test Example is running. It includes system initialization messages and the start of the PM_GPIO process. ```text SFBL Serial:c2,Chip:4,Package:6,Rev:f Reason:00000000 Serial PowerOnMOde:0 rtc_record:00000000 \ | / - SiFli Corporation / | \ build on Aug 22 2025, 2.4.0 build 5d975f14 2020 - 2022 Copyright by SiFli team mount /dev sucess [I/drv.rtc] PSCLR=0x80000100 DivAI=128 DivAF=0 B=256 [I/drv.rtc] RTC use LXT RTC_CR=00000001 [I/drv.rtc] Init RTC, wake = 0 rt_flash_config_read addr: 0x1200e000 find handle error [I/drv.audprc] init 00 ADC_PATH_CFG0 0x606 [I/drv.audprc] HAL_AUDPRC_Init res 0 [I/drv.audcodec] HAL_AUDCODEC_Init res 0 [32m[I/TOUCH] Regist touch screen driver, probe=1203b139 [0m call par CFG1(3313) fc 9, xtal 2000, pll 2219 call par CFG1(3313) fc 7, xtal 2000, pll 1781 Start PM_GPIO! Set the frequency to 48M 0 msh /> ``` -------------------------------- ### Initialize and Connect MQTT Client Source: https://github.com/opensifli/sifli-sdk/blob/main/rtos/rtthread/components/net/lwip/lwip-2.0.3/doc/mqtt_client.txt Demonstrates static and dynamic memory allocation for the MQTT client and initiating a connection to the server. Ensure the `example_do_connect` function is correctly implemented to handle connection logic. ```c mqtt_client_t static_client; example_do_connect(&static_client); ``` ```c mqtt_client_t *client = mqtt_client_new(); if(client != NULL) { example_do_connect(&client); } ``` -------------------------------- ### Compile and Program Example Source: https://github.com/opensifli/sifli-sdk/blob/main/example/rt_device/pulse_encoder/README_EN.md Commands to compile the example project for a specific board and download it. Ensure you are in the example project directory. ```bash scons --board=sf32lb58-lcd_n16r64n4 -j8 ``` ```bash build_sf32lb58-lcd_n16r64n4_hcpu\download.bat ``` -------------------------------- ### NNACC Example Log Output Source: https://github.com/opensifli/sifli-sdk/blob/main/example/hal/nnacc/README_EN.md Example log output from the NNACC test, indicating successful buffer initialization, random data filling, hardware start, and verification of results. ```text SFBL ```boot log``` ```example log: ``` Buffers initialized successfully. testcase start. fill_with_random_data. 2000fc60 20012808 20012894 200182bc, sp=2000e35f HAL_NNACC_Start. Test passed: NNACC result is correct. msh /> ``` -------------------------------- ### Complex LVGL Menu Configuration Source: https://github.com/opensifli/sifli-sdk/blob/main/example/multimedia/lvgl/lvgl_v8_examples/src/examples/widgets/menu/index.rst Provides an example of a complex LVGL menu setup. ```c #include "lv_examples.h" void lv_example_menu_5(void) { lv_obj_t *menu = lv_menu_create(lv_screen_active()); lv_obj_set_size(menu, 200, 200); lv_obj_center(menu); /* Add some items */ lv_menu_separator_create(menu); lv_menu_page_t *page1 = lv_menu_page_create(menu, "Page 1"); lv_menu_cont_create(page1); lv_menu_separator_create(page1); lv_menu_page_t *page2 = lv_menu_page_create(page1, "Page 2"); lv_menu_cont_create(page2); lv_menu_separator_create(page2); lv_menu_page_t *page3 = lv_menu_page_create(page2, "Page 3"); lv_menu_cont_create(page3); lv_menu_separator_create(page3); } ``` -------------------------------- ### Initialize LVGL and Create UI Source: https://github.com/opensifli/sifli-sdk/blob/main/external/lvgl_v9/README.md This snippet shows the complete process of initializing LVGL, setting up a display and input device, and creating a simple 'Hello world' label. It includes necessary callbacks for tick and flush operations, and the main loop for handling LVGL tasks. ```c #include "lvgl/lvgl.h" /*Define LV_LVGL_H_INCLUDE_SIMPLE to include as "lvgl.h"*/ #define TFT_HOR_RES 320 #define TFT_VER_RES 240 static uint32_t my_tick_cb(void) { return my_get_millisec(); } static void my_flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t * px_map) { /*Write px_map to the area->x1, area->x2, area->y1, area->y2 area of the *frame buffer or external display controller. */ } static void my_touch_read_cb(lv_indev_t * indev, lv_indev_data_t * data) { if(my_touch_is_pressed()) { data->point.x = touchpad_x; data->point.y = touchpad_y; data->state = LV_INDEV_STATE_PRESSED; } else { data->state = LV_INDEV_STATE_RELEASED; } } void main(void) { my_hardware_init(); /*Initialize LVGL*/ lv_init(); /*Set millisecond-based tick source for LVGL so that it can track time.*/ lv_tick_set_cb(my_tick_cb); /*Create a display where screens and widgets can be added*/ lv_display_t * display = lv_display_create(TFT_HOR_RES, TFT_VER_RES); /*Add rendering buffers to the screen. *Here adding a smaller partial buffer assuming 16-bit (RGB565 color format)*/ static uint8_t buf[TFT_HOR_RES * TFT_VER_RES / 10 * 2]; /* x2 because of 16-bit color depth */ lv_display_set_buffers(display, buf, NULL, sizeof(buf), LV_DISPLAY_RENDER_MODE_PARTIAL); /*Add a callback that can flush the content from `buf` when it has been rendered*/ lv_display_set_flush_cb(display, my_flush_cb); /*Create an input device for touch handling*/ lv_indev_t * indev = lv_indev_create(); lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER); lv_indev_set_read_cb(indev, my_touch_read_cb); /*The drivers are in place; now we can create the UI*/ lv_obj_t * label = lv_label_create(lv_screen_active()); lv_label_set_text(label, "Hello world"); lv_obj_center(label); /*Execute the LVGL-related tasks in a loop*/ while(1) { lv_timer_handler(); my_sleep_ms(5); /*Wait a little to let the system breathe*/ } } ``` -------------------------------- ### Compile the Example Project Source: https://github.com/opensifli/sifli-sdk/blob/main/example/rt_device/adc/channel/README_EN.md Navigate to the example project directory and use the 'scons' command to compile the code. Replace 'em-'bread nmae'' with your board's name. ```bash scons --board=em-'bread nmae' -j8 ``` -------------------------------- ### Simple Slider Example Source: https://github.com/opensifli/sifli-sdk/blob/main/example/multimedia/lvgl/lvgl_v8_examples/src/examples/widgets/slider/index.rst Basic implementation of a slider widget. No special setup required. ```c #include "lv_examples.h" void lv_example_slider_1(void) { lv_obj_t * slider = lv_slider_create(lv_scr_act()); lv_obj_set_width(slider, lv_pct(70)); lv_obj_center(slider); lv_slider_set_value(slider, 50, LV_ANIM_OFF); } ``` -------------------------------- ### NNACC Example Core Process Source: https://github.com/opensifli/sifli-sdk/blob/main/example/rt_device/nnacc/README_EN.md This outlines the main steps involved in the NNACC example, from defining parameters to verifying results. Ensure NN Accelerator hardware is initialized before starting inference. ```text \Example core process main() ├── Define convolution parameters (size, channels, stride, padding, etc.) ├── Allocate input buffers: input, wt, bias ├── Allocate output buffer: output ├── Initialize NN Accelerator hardware (drv_nnacc.c already completed) ├── Fill random data to simulate real input ├── Start hardware inference: nn_acc_start[synchronous start]nn_acc_start_IT[asynchronous start], modified by top macro definition selection ├── Wait for completion and verify results └── Output test results (pass or fail) ``` -------------------------------- ### Compile Example Project Source: https://github.com/opensifli/sifli-sdk/blob/main/example/hal/epic/README_EN.md Use this command to compile the example project for a specific board. Ensure you are in the example project directory. ```bash scons --board=sf32lb52-lchspi-ulp -j8 ``` -------------------------------- ### DMA Memory-to-FLASH Transfer Example Source: https://github.com/opensifli/sifli-sdk/blob/main/docs/source/en/hal/dma.md Configures and starts a DMA transfer from memory to a FLASH module. The peripheral address is not auto-incremented, and the transfer unit is a single byte. This example transfers 4096 bytes. ```c DMA_HandleTypeDef hdma; HAL_StatusTypeDef err; uint32_t SrcAddress = 0x20000000; uint32_t DstAddress = hflash->Instance->DR; uint32_t Counts = 4096; //Transfer unit is byte, so Counts= 4096 / 1 /* Init DMA configure*/ hdma.Instance = DMA1_Channel6; hdma.Init.Request = DMA_REQUEST_0; hdma.Init.Direction = DMA_MEMORY_TO_PERIPH; hdma.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; hdma.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; hdma.Init.PeriphInc = DMA_PINC_DISABLE; //Peripheral address NOT auto-increment hdma.Init.MemInc = DMA_MINC_ENABLE; hdma.Init.Mode = DMA_NORMAL; hdma.Init.Priority = DMA_PRIORITY_MEDIUM; hdma.XferHalfCpltCallback = DMA_Xfer_Half_Callback_Func; hdma.XferCpltCallback = DMA_Xfer_Complete_Callback_Func; hdma.XferErrorCallback = DMA_Xfer_Error_Callback_Func; err = HAL_DMA_Init(&hdma); if (err != HAL_OK) return err; err = HAL_DMA_Start_IT(hadc->DMA_Handle, SrcAddress, DstAddress, Counts); if (err != HAL_OK) return err; ``` -------------------------------- ### RT-Thread Audio Playback Example Source: https://github.com/opensifli/sifli-sdk/blob/main/docs/source/en/drivers/i2s.md Example code for playing audio using an RT-Thread speaker or headphone device. The device should be opened in read-write mode. Configure the sample rate before starting playback. ```c uint8_t g_pipe_data[512]; // Find and open device rt_device_t g_i2s = rt_device_find("i2s2"); rt_err_t err = rt_device_open(g_i2s, RT_DEVICE_FLAG_RDWR); // Configure speaker device, sample rate 16000 struct rt_audio_caps caps; caps.main_type = AUDIO_TYPE_INPUT; caps.sub_type = AUDIO_DSP_SAMPLERATE; caps.udata.value = 16000; rt_device_control(g_i2s, AUDIO_CTL_CONFIGURE, &caps); // Start playback int stream = 0; // record = 1, playback = 0 rt_device_set_tx_complete(g_i2s, audio_tx_done); rt_device_control(g_i2s, AUDIO_CTL_START, &stream); ... ``` -------------------------------- ### Compile Hello World Example Source: https://github.com/opensifli/sifli-sdk/blob/main/example/get-started/hello_world/rtt/README_EN.md Use this command to compile the Hello World example for a specific board. For simulator usage, use '--board=pc'. ```bash scons --board=sf32lb52-lcd_n16r8 -j32 ``` ```bash scons --board=pc -j32 ``` -------------------------------- ### Download Audio Mixer Example Source: https://github.com/opensifli/sifli-sdk/blob/main/example/multimedia/audio/mixer/README.md Execute the download script after successful compilation to flash the firmware to the board. ```bash build_sf32lb56-lcd_n16r12n1_hcpu\uart_download.bat ``` -------------------------------- ### Pinyin IME 9 Key Input Example Source: https://github.com/opensifli/sifli-sdk/blob/main/example/multimedia/lvgl/lvgl_v8_examples/src/examples/others/ime/index.rst This C code provides an example for a Pinyin Input Method Editor utilizing a 9-key layout. It requires the LVGL library and appropriate setup. ```c #include "../lv_example_ime_pinyin_2.h" void lv_example_ime_pinyin_2(void) { } ``` -------------------------------- ### RT-Thread Audio Capture Example Source: https://github.com/opensifli/sifli-sdk/blob/main/docs/source/en/drivers/i2s.md Example code for capturing audio using an RT-Thread microphone device. Ensure the device is found and opened in read-only mode. Configure the sample rate before starting the capture. ```c uint8_t g_pipe_data[512]; // Find and open device rt_device_t g_mic = rt_device_find("i2s1"); rt_err_t err = rt_device_open(g_mic, RT_DEVICE_FLAG_RDONLY); // Configure Microphone device, sample rate 16000 struct rt_audio_caps caps; caps.main_type = AUDIO_TYPE_INPUT; caps.sub_type = AUDIO_DSP_SAMPLERATE; caps.udata.value = 16000; rt_device_control(g_mic, AUDIO_CTL_CONFIGURE, &caps); // Start capture int stream = 1; // record = 1, playback = 0 rt_device_set_rx_indicate(g_mic, audio_rx_ind); rt_device_control(g_mic, AUDIO_CTL_START, &stream); ... ``` -------------------------------- ### Program Example Source: https://github.com/opensifli/sifli-sdk/blob/main/example/misc/elm_rw/README_EN.md Download the compiled firmware to the development board using the provided batch script. ```shell .\build_sf32lb52-lcd_n16r8\uart_download.bat ``` -------------------------------- ### Flash Example Project Source: https://github.com/opensifli/sifli-sdk/blob/main/example/hal/epic/README_EN.md Execute this command to flash the compiled example project to the development board. Follow the on-screen prompts to select the correct serial port. ```bash build_sf32lb52-lchspi-ulp_hcpu\uart_download.bat ``` -------------------------------- ### Line Chart Example in C Source: https://github.com/opensifli/sifli-sdk/blob/main/example/multimedia/lvgl/lvgl_v8_examples/src/examples/widgets/chart/index.rst Demonstrates a basic line chart. No specific setup or constraints mentioned. ```c void lv_example_chart_1(void) { lv_obj_t * chart; chart = lv_chart_create(lv_screen_active()); lv_obj_set_size(chart, 400, 250); lv_obj_center(chart); lv_chart_set_type(chart, LV_CHART_TYPE_LINE); /*Add a cursor*/ lv_chart_set_cursor_point(chart, 1); /*Add some data*/ static lv_chart_series_t * ser1; ser1 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_RED)); lv_chart_set_point_count(chart, 30); lv_chart_set_value(chart, ser1, 0, 10); lv_chart_set_value(chart, ser1, 1, 15); lv_chart_set_value(chart, ser1, 2, 8); lv_chart_set_value(chart, ser1, 3, 12); lv_chart_set_value(chart, ser1, 4, 10); lv_chart_set_value(chart, ser1, 5, 18); lv_chart_set_value(chart, ser1, 6, 15); lv_chart_set_value(chart, ser1, 7, 10); lv_chart_set_value(chart, ser1, 8, 12); lv_chart_set_value(chart, ser1, 9, 14); lv_chart_set_value(chart, ser1, 10, 10); lv_chart_set_value(chart, ser1, 11, 16); lv_chart_set_value(chart, ser1, 12, 14); lv_chart_set_value(chart, ser1, 13, 10); lv_chart_set_value(chart, ser1, 14, 12); lv_chart_set_value(chart, ser1, 15, 15); lv_chart_set_value(chart, ser1, 16, 10); lv_chart_set_value(chart, ser1, 17, 18); lv_chart_set_value(chart, ser1, 18, 16); lv_chart_set_value(chart, ser1, 19, 12); lv_chart_set_value(chart, ser1, 20, 14); lv_chart_set_value(chart, ser1, 21, 17); lv_chart_set_value(chart, ser1, 22, 13); lv_chart_set_value(chart, ser1, 23, 10); lv_chart_set_value(chart, ser1, 24, 12); lv_chart_set_value(chart, ser1, 25, 15); lv_chart_set_value(chart, ser1, 26, 11); lv_chart_set_value(chart, ser1, 27, 19); lv_chart_set_value(chart, ser1, 28, 17); lv_chart_set_value(chart, ser1, 29, 13); /*Custom division lines*/ lv_chart_set_div_line_count(chart, 3); lv_chart_set_y_tick_length(chart, 10); lv_chart_set_x_tick_length(chart, 10); } ``` -------------------------------- ### Slider to Label Messaging Example Source: https://github.com/opensifli/sifli-sdk/blob/main/example/multimedia/lvgl/lvgl_v8_examples/src/examples/others/msg/index.rst Demonstrates how to implement slider-to-label messaging. No specific setup or constraints are mentioned. ```c #include "lv_examples.h" void lv_example_msg_1(void) { /*Example code for slider to label messaging*/ } ``` -------------------------------- ### Download the Example Source: https://github.com/opensifli/sifli-sdk/blob/main/example/cherryusb/device/hid_mouse/README_EN.md Download the compiled example to the development board using the uart_download.bat script. ```bash ./uart_download.bat Uart Download please input the serial port num: ``` -------------------------------- ### Development Guide - Customization Source: https://github.com/opensifli/sifli-sdk/blob/main/example/cherryusb/host/cdc_acm_host/README_EN.md Guidance on how to customize the CDC ACM Host example for specific development needs. ```APIDOC ## Development Guide ### Custom Development If you need to perform custom development based on this example, you can modify the following: 1. **Data Reception Processing**: - Modify the `rx_cb()` function to implement custom data processing logic. - Add data parsing, protocol processing, or storage functionality. - Can forward data to other modules or peripherals. 2. **Data Transmission Functionality**: - Add `rt_device_write()` calls to implement data transmission. - Can implement bidirectional communication functionality. - Support command transmission and response reception. 3. **Multi-Device Support**: - Find device nodes like ttyACM1, ttyACM2, etc. - Support simultaneous connection of multiple CDC devices. - Register independent callback functions for each device. 4. **Configuration Parameter Adjustment**: - Modify receive buffer size (recv_buffer). - Adjust enumeration delay time to accommodate different devices. - Configure DTR/RTS control signals. 5. **Enhanced Error Handling**: - Add device disconnection detection and reconnection mechanism. - Implement data transfer timeout handling. - Add logging for exceptional situations. ``` -------------------------------- ### Build and Flash Example Source: https://github.com/opensifli/sifli-sdk/blob/main/example/hal/adc/adc_battery/README_EN.md Commands to build the example project using SCons and flash the firmware to the board via UART. Ensure the correct board and serial port are specified. ```shell scons --board=sf32lb52-lcd_n16r8 -j8 ``` ```shell build_sf32lb52-lcd_n16r8_hcpu\uart_download.bat ``` ```shell please input the serial port num:5 ``` -------------------------------- ### NAND Flash Operations Example Source: https://github.com/opensifli/sifli-sdk/blob/main/example/rt_device/nand_flash/README_EN.md This example demonstrates getting a NAND device handle, performing erase, write, and read operations. It includes error logging for invalid addresses, erase failures, and data inconsistencies. ```c Address 0x%x is not for NAND FLASH ``` ```c Erase fail at address 0x%x, res %d ``` ```c "Data not 0xffffffff after erase at pos 0x%x ``` ```c write page fail at pos 0x%x ``` ```c "Read page fail at pos 0x ``` ```c Read data not same to source at pos 0x ``` -------------------------------- ### Setup Build Environment (Linux/macOS) Source: https://github.com/opensifli/sifli-sdk/blob/main/AGENTS.md Source this script to set up the build environment on Linux or macOS. Execute this in the repository's root directory. ```bash source ./export.sh ``` -------------------------------- ### Compile and Download Example Source: https://github.com/opensifli/sifli-sdk/blob/main/example/hal/aes/README_EN.md Commands to compile the example using scons and download it to the board via UART. Ensure the correct board name is specified. ```bash scons --board=sf32lb52-lcd_n16r8 -j32 ``` ```bash ./uart_download.bat Uart Download please input the serial port num:5 ``` -------------------------------- ### Compile Example Source: https://github.com/opensifli/sifli-sdk/blob/main/example/jpeg_dec/README_EN.md Compiles the example using scons. Replace with your specific board. ```bash > scons --board= -j10 ``` -------------------------------- ### SPI Circular DMA Example Flows Source: https://github.com/opensifli/sifli-sdk/blob/main/example/rt_device/spi/circular_rx/README_EN.md Step-by-step guides for implementing SPI circular DMA in different modes. ```APIDOC ## Example Flow ### Master TRX Mode (Mode 0) 1. **Configure Pinmux**: Set up SPI1 pinmux (or SPI2 for 56-LCD). 2. **Attach/Open Device**: Open the `spi_circular` device. 3. **Configure SPI**: Set SPI parameters (Master, Mode0, 8-bit, 20MHz). 4. **Take Bus**: Call `rt_spi_take_bus()` and `rt_spi_release_bus()` to link DMA handles. 5. **Configure DMA**: Call `rt_device_control(..., RT_SPI_CTRL_CONFIG_DMA_CIRCULAR, TXRX)`. 6. **Start Transfer**: Call `rt_spi_transfer()` to begin circular DMA. 7. **Loopback**: Short MOSI and MISO pins for loopback verification. ### Slave RX Mode (Mode 1) 1. **Configure Pinmux**: Set up SPI1 pinmux (or SPI2 for 56-LCD). 2. **Configure SPI**: Set SPI to Slave mode. 3. **Configure DMA**: Call `rt_device_control(..., RT_SPI_CTRL_CONFIG_DMA_CIRCULAR, RX)`. 4. **Start Receive**: Call `rt_device_read()` to initiate circular receive. 5. **External Master**: Connect an external SPI Master to provide the clock signal. ### Slave TX Mode (Mode 2) 1. **Configure Pinmux**: Set up SPI1 pinmux (or SPI2 for 56-LCD). 2. **Configure SPI**: Set SPI to Slave mode. 3. **Configure DMA**: Call `rt_device_control(..., RT_SPI_CTRL_CONFIG_DMA_CIRCULAR, TX)`. 4. **Start Transmit**: Call `rt_device_write()` to initiate circular transmit. 5. **External Master**: Connect an external SPI Master to provide the clock signal. ``` -------------------------------- ### Initialize and Run Music Player Demo Source: https://github.com/opensifli/sifli-sdk/blob/main/example/mp3online/src/lv_demos/music/README.md After initializing LVGL and its drivers, call the `lv_demo_music()` function to start the music player demo. ```c lv_init(); // Initialize drivers ... lv_demo_music(); ``` -------------------------------- ### DMA ADC Module-to-Memory Transfer Example Source: https://github.com/opensifli/sifli-sdk/blob/main/docs/source/en/hal/dma.md Configures and starts a DMA transfer from an ADC peripheral to memory. Note that the peripheral address is not auto-incremented in this configuration. This example transfers 4096 bytes using 4-byte word alignment. ```c DMA_HandleTypeDef hdma; HAL_StatusTypeDef err; uint32_t SrcAddress = 0x10000000; uint32_t DstAddress = 0x20000000; uint32_t Counts = 1024; //Transfer unit is word, so Counts= 4096 / 4 /* Init DMA configure*/ hdma.Instance = DMA1_Channel6; hdma.Init.Request = DMA_REQUEST_12; hdma.Init.Direction = DMA_PERIPH_TO_MEMORY; hdma.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; hdma.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; hdma.Init.PeriphInc = DMA_PINC_DISABLE; //Peripheral address NOT auto-increment hdma.Init.MemInc = DMA_MINC_ENABLE; hdma.Init.Mode = DMA_NORMAL; hdma.Init.Priority = DMA_PRIORITY_MEDIUM; hdma.XferHalfCpltCallback = DMA_Xfer_Half_Callback_Func; hdma.XferCpltCallback = DMA_Xfer_Complete_Callback_Func; hdma.XferErrorCallback = DMA_Xfer_Error_Callback_Func; err = HAL_DMA_Init(&hdma); if (err != HAL_OK) return err; err = HAL_DMA_Start_IT(hadc->DMA_Handle, SrcAddress, DstAddress, Counts); if (err != HAL_OK) return err; ``` -------------------------------- ### HAL-Level Standby Wake-Up API Example Source: https://github.com/opensifli/sifli-sdk/blob/main/docs/source/en/app_note/low_power.md Example of configuring a standby wake-up using HAL-level APIs. Use HAL_LPAON_QueryWakeupPin() and HAL_HPAON_QueryWakeupPin() to get wake-up pin indices. Configure GPIO interrupts if event handling is needed. ```c #include void standby_wakeup_init(void) { uint8_t wakeup_pin_index; /* Get wake-up pin index for low power analog on */ wakeup_pin_index = HAL_LPAON_QueryWakeupPin(); /* Configure wake-up pin for standby */ HAL_PMU_StandbyWakeupPinConfig(wakeup_pin_index, HAL_PMU_WAKEUP_LEVEL_HIGH); /* Get wake-up pin index for high power analog on */ wakeup_pin_index = HAL_HPAON_QueryWakeupPin(); /* Configure wake-up pin for standby */ HAL_PMU_StandbyWakeupPinConfig(wakeup_pin_index, HAL_PMU_WAKEUP_LEVEL_HIGH); /* If IO wake-up needs event handling, also configure the GPIO interrupt */ /* HAL_GPIO_IntConfig(wakeup_pin_index, HAL_GPIO_INT_TRIG_HIGH, HAL_GPIO_INT_TYPE_EDGE); HAL_GPIO_IntEnable(wakeup_pin_index); HAL_NVIC_SetIRQHandler(IRQn_Type_GPIO, standby_wakeup_handler); */ } ``` -------------------------------- ### Demonstrate Flex Grow (Alternative) Source: https://github.com/opensifli/sifli-sdk/blob/main/example/multimedia/lvgl/lvgl_v9_examples/src/examples/layouts/flex/index.rst Another example showing flex grow, this time with different initial sizes. ```c #include "lv_examples.h" void lv_example_flex_4(void) { lv_obj_t * parent = lv_common_playground_create(); lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_ROW); lv_obj_set_flex_align(parent, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); lv_obj_set_gap(parent, 10); lv_obj_t * child_fixed = lv_obj_create(parent); lv_obj_set_size(child_fixed, 50, 50); lv_obj_set_style_bg_color(child_fixed, lv_palette_main(LV_PALETTE_RED), 0); lv_obj_t * child_grow = lv_obj_create(parent); lv_obj_set_size(child_grow, LV_SIZE_CONTENT, LV_SIZE_CONTENT); lv_obj_set_style_bg_color(child_grow, lv_palette_main(LV_PALETTE_GREEN), 0); lv_obj_set_style_flex_grow(child_grow, 1, 0); lv_obj_t * child_fixed_2 = lv_obj_create(parent); lv_obj_set_size(child_fixed_2, 50, 50); lv_obj_set_style_bg_color(child_fixed_2, lv_palette_main(LV_PALETTE_BLUE), 0); } ``` -------------------------------- ### SiFli SDK Example Initialization Log Source: https://github.com/opensifli/sifli-sdk/blob/main/example/rt_device/spi_tf/README_EN.md This log shows the typical output during the initialization of the SiFli SDK example, including hardware detection, driver loading, and file system mounting. It indicates successful setup or potential errors. ```text SFBL Serial:c2,Chip:4,Package:4,Rev:7 Reason:00000000 [I/drv.adc] Get ADC configure fail \ | / - SiFli Corporation / | \ build on Jul 18 2025, 2.4.0 build 00000000 2020 - 2022 Copyright by SiFli team mount /dev sucess [BUS]spi1 probe sdcard... [MSD] 1006 [err] wait ready timeout! [MSD] 1006 [info] SD card goto IDLE mode OK! [MSD] 1007 [info] CMD8 response : 0x01 0xF0 0x00 0x01 0xAA [MSD] 1008 [info] Ver2.00 or later or SDHC or SDXC memory card! [MSD] 1009 SD_V2: READ_OCR [MSD] 1009 response:1,0,ff,80 [MSD] 1010 [info] OCR is 0x00FF8000 [MSD] 1041 SD_V2 again: READ_OCR [MSD] 1041 [info] OCR 2nd read is 0xC0FF8000 [MSD] 1042 [info] It is SD2.0 SDHC Card!!! [MSD] 1044 [info] CSD Version 2.0 [MSD] 1044 [info] TRAN_SPEED: 0x32, 10Mbit/s. [MSD] 1045 [info] CSD : C_SIZE : 60719 [MSD] 1045 [info] card capacity : 29.64 Gbyte [MSD] 1046 [info] sector_count : 62177280 [SD]msd init ok find sd0 ok ! 2000d1ac [I/drv.rtc] PSCLR=0x80000100 DivAI=128 DivAF=0 B=256 [I/drv.rtc] RTC use LXT RTC_CR=00000001 [I/drv.rtc] Init RTC, wake = 0 [I/drv.audprc] init 00 ADC_PATH_CFG0 0x606 [I/drv.audprc] HAL_AUDPRC_Init res 0 [I/drv.audcodec] HAL_AUDCODEC_Init res 0 [I/TOUCH] Regist touch screen driver, probe=120260f5 call par CFG1(3313) fc 9, xtal 2000, pll 2095 call par CFG1(3313) fc 7, xtal 2000, pll 1676 fal_mtd_msd_device_create dev:sd0 part:root offset:0x0, size:0xfa000 fal_mtd_msd_device_create dev:sd0 part:misc offset:0xfa000, size:0xfa000 mount fs on flash to root success mount fs on flash to FS_MSIC success ========== SD Card File System Performance Test ========== SF32LB52x SD Card Test Program Tick Per Second: 1000 Optimal Buffer Size: 64 KB SD Operation Interval: 5 ms Use 'help' to see available commands Quick commands: fs_write /test.dat 16 - Test write speed (16MB) fs_read /test.dat 16 - Test read speed (16MB) sd_optimize - Check SD configuration buffer_optimize - Test different buffer sizes fs_speed_test 32 - Complete speed test (32MB) ========================================================= msh /> ``` -------------------------------- ### Download the Example Source: https://github.com/opensifli/sifli-sdk/blob/main/example/ble/cppc/README_EN.md Use the provided batch script to download the compiled firmware to the development board. You will be prompted to select the serial port number. ```bash build_sf32lb52-lcd_n16r8_hcpu\uart_download.bat Uart Download please input the serial port num:5 ``` -------------------------------- ### Run FLAC tests and install Source: https://github.com/opensifli/sifli-sdk/blob/main/external/flac-1.5.0/README.md Execute tests and install the built FLAC libraries and headers using make targets. Ensure you have the necessary permissions for installation. ```bash /path/to/flac-build$ make test ``` ```bash /path/to/flac-build$ make install ``` -------------------------------- ### Draw Line on Canvas Source: https://github.com/opensifli/sifli-sdk/blob/main/example/multimedia/lvgl/lvgl_v9_examples/src/examples/widgets/canvas/index.rst Example of drawing a line on an LVGL canvas. Requires specifying start and end points and drawing style. ```c void lv_example_canvas_7(void) { lv_obj_t *canvas; canvas = lv_canvas_create(lv_scr_act(), NULL); lv_obj_set_size(canvas, 200, 150); lv_obj_center(canvas); /* Draw a line */ lv_draw_line_dsc_t line_dsc; lv_draw_line_init_dsc(&line_dsc); line_dsc.color = LV_COLOR_TEAL; line_dsc.width = 3; lv_canvas_draw_line(canvas, 10, 10, 180, 130, &line_dsc); lv_canvas_finish(canvas, 0); } ``` -------------------------------- ### HAL FACC Convolution Example Source: https://github.com/opensifli/sifli-sdk/blob/main/docs/source/en/hal/facc.md Demonstrates how to configure and start a convolution operation using the HAL FACC module. This is a synchronous operation. ```c // Convolution example // facc_out = dsp_conv_conv_coef_b * dsp_conv_conv_input; uint32_t dsp_conv_conv_param = 0x200; // Parameter structure reference #FACC_ConfigTypeDef param = (FACC_ConfigTypeDef *)&dsp_conv_conv_param; param->last_sel = 1; // This is the last input block HAL_FACC_Config(&hfacc, param); // Set FACC HAL_FACC_SetCoeff(&hfacc, dsp_conv_conv_coef_b, (uint16_t)sizeof(dsp_conv_conv_coef_b), NULL, 0, 0); // Input dsp_conv_conv_coef_b HAL_FACC_Start(&hfacc, dsp_conv_conv_input, facc_out, sizeof(dsp_conv_conv_input)); // Start convolution calculation. Synchronous completion. ``` -------------------------------- ### Compile Example Project Source: https://github.com/opensifli/sifli-sdk/blob/main/example/ble/ams/README_EN.md Use the scons command to compile the example project. Specify the target board using the --board option. ```bash > scons --board=eh-lb525 -j32 ```