SiFli SDK Pragramming Guide SiFli SDK Pragramming Guide SiFli SDK Pragramming Guide
/
  • latest
  • SF32LB52x
  • SF32LB56x
  • SF32LB58x
  • SF32LB55x
  • English
  • 中文
  • Quick Start
    • Getting Started Guide
    • Installation Environment
      • Script Installation
        • Windows Installation Process
        • macOS or Linux Installation Process
      • Installing Environment Using ENV Tool
    • Build and Download
    • Software Architecture
  • Application Development
    • Creating an Application
    • Creating a Board
    • Chip Peripheral Drivers
    • Configuration and Compilation
    • Application Startup Flow
  • Hardware Abstraction Layer
    • ADC
    • AES
    • AON
    • ATIM
    • AUDCODEC
    • AUDPRC
    • BTIM
    • CACHE
    • CRC
    • DMA
    • EFUSE
    • EPIC
    • EXTDMA
    • EZIP
    • GPIO
    • GPT
    • Hash
    • I2C
    • I2S
    • LCDC
    • LPTIM
    • MAILBOX
    • MPI
    • PATCH
    • USBC
    • PDM
    • PINMUX
    • PMU
    • RCC
    • RNG
    • RTC
    • SPI
    • SYSCFG
    • TSEN
    • UART
    • WDT
  • RT-Thread Device Drivers
    • UART Device
    • PIN Device
    • ADC Device
    • HWTIMER Device
    • I2C Device
    • PWM Device
    • RTC Device
    • SPI Device
    • Audprc/Audcodec Audio Device
    • I2S Audio Device
    • USB Device
    • SDIO
    • Flash
    • LCD Device
    • Touch Screen
  • Application Note
    • ADC Usage Guide
    • Common Project Build Method
    • Crash Analysis Guide
    • Debugging and Logging
    • EZIP Image Conversion Tool Usage
    • Flash Usage Guide
    • JavaScript Support
    • JDI screen with LB551 debugging instructions
    • Low Power Usage Guide
    • Project Setup
    • SDK Quick Start (SF52X SF56X)
    • SCons and Kconfig Quick Start
    • Sensor Adding Guide
    • Watchdog Usage Guide
  • Middleware
    • Classic Bluetooth Service
      • HFP_HF
      • HFP_AG
      • GATT over BR/EDR
      • BT_PAN
      • PBAP (Phone Book Access Profile)
      • SPP (Serial Port Profile)
    • Bluetooth Low Energy Service
      • GAP
      • Sibles Service
        • Sibles GATT Service
        • Sibles Advertising
      • BLE Profiles
        • ANCS Client
        • Serial Transfer Service
    • Data Service
    • Power Management
    • Configuration Storage
    • Button Component
    • Graphical Application Framework
    • Watch Application Components
    • File System
    • Logger
    • Firmware Upgrade Service
      • Process Introduction
      • Upgrade Firmware Generation
    • Inter-Core Communication Queue
    • Gaussian Blur
    • 52x Platform Security Solution
    • Audio Server Usage Instructions
    • Partition Table
      • Partition Table Syntax Version 1.0
      • Partition Table Syntax Version 2.0
  • Supported Boards
    • EC-LB587
    • EC-LB587_A2
    • SF32LB52-CORE_52J_E8
    • SF32LB52-CORE_52J_N16
    • SF32LB52-LCD_52D
    • sf32lb52x与JDI屏硬件连接介绍
    • SF32LB56-LCD_A128R12N1
    • SF32LB56-LCD_N16R12N1
    • SF32LB58-LCD_A128R32N1_DSI
    • SF32LB58-LCD_N16R32N1_DPI
    • SF32LB58-LCD_N16R32N1_DSI
    • SF32LB58-LCD_N16R32N1_DPI
  • Secure Bootloader
  • Examples
    • Get started with SiFli-SDK
      • Blink
        • LED Blink (NO-OS)
        • LED Blink (RT-Thread)
      • Dual-Core Comprehensive Example
      • Hello World
        • Hello World Example (NO-OS)
        • Hello World Example (RT-Thread)
    • HAL interface example
      • ADC Example
        • ADC_battery Example
        • ADC Example
      • AES Example
      • CRC Example
      • HAL EPIC Example
      • EZIP Example
      • FACC Example
      • FFT Example
        • Simple FFT Example
      • GPIO Example
      • HASH Example
      • HWTIMER Example
      • I2C Example
        • I2C EEPROM Example
      • NNACC Example
      • PWM Example
      • RNG Example
      • RTC Example
      • SPI Example
      • TSEN Example
      • UART Example
      • Watchdog Example
        • IWDT Example
        • WDT1 Example
    • RT-Thread Device Driver
      • ADC Example
        • ADC_battery Example
        • ADC Example
      • Audprc Example
      • eMMC/SD Card Example
      • GPIO Example
      • GPU Example
        • GPU Render List Mode Example Program
        • EPIC Example Program
      • I2C Example
        • I2C EEPROM Example
      • I2S Example
      • nand_flash
      • NNACC Example
      • nor_flash
      • PDM Example
      • PM Example
      • pulse_encoder Example
      • PWM Example
        • PWM Example
        • PWM_DMA Example
      • RGBLED Example
      • RTC Example
      • Sensor Example
      • SPI Example
        • Using SPI to Read TF Card ID Through CMD Instructions
        • SPI Example
      • SD Card File System Performance Test Example
      • UART Example
      • USB Example
        • USB_MSTORAGE Example
        • USB_VCOM Example
      • WDT Example
    • Screen Module Debug Program
    • Multimedia
      • AGIF
        • AGIF+LVGL Animation Example
        • AGIF+LVGL(V9) Animation Example
      • audio
        • Local Music Example
        • MP3 Local Music Player
        • Record Example
      • lvgl
        • Electronic Compass Example
        • Games
          • LVGL Minesweeper Game
        • LVGL v8 Demos
        • LVGL v8 Official Example
        • LVGL v8 Lottie Example
        • Local Video File Playback Example
        • LVGL v9 Demo
        • LVGL v9 Official Example
        • Watch Interface
        • Watch Interface
        • Watch Interface Example
    • Storage Examples
      • FatFs Example
        • FatFs NAND Example
        • FatFs NOR Example
      • FlashDB Example
      • LittleFs Example
        • LittleFs NOR Example
    • System components
      • CPU Usage Profiler Example
      • FinSH
      • Log Usage Example
    • Powermanagement
      • BLE Broadcast and Connection Power Consumption Test
      • BLE/BT Power Consumption Test
      • Processor Power Consumption Test
    • Other Components
      • Button
      • ELM_RW Example
      • Generate Library Example
    • BT Example
      • BT 3SCO Example
      • BT/BLE UART HCI Transceiver Example
      • BT Hands-Free HF Role Example
      • BT Music Sink Example
      • BT Music Sink Relay Example
      • BT Music Source Example
      • BT PAN Example
      • BT SPP Profile Example
    • BLE Example
      • BLE AMS Example
      • BLE ANCS Example
      • BLE central and peripheral Example
      • BLE Central and Peripheral with Pingpong OTA Example
      • BLE File Transfer Example
      • BLE HID Example
      • BLE multi_connection Example
      • BLE Peripheral Example
      • BLE Periodic Advertisement Example
      • BLE Periodic Advertisement Sync Example
      • BLE peripheral Example
      • peripheral_with_ota Example Description and SDK DFU Integration
      • BLE Throughput Example
    • ZBT Example
      • BLE Audio Player
      • MP3 Local Music Player
      • BLE Audio Player
  • API Reference
    • HAL (Hardware Abstract Layer)
      • bf0_hal_adc.h
      • bf0_hal_aes.h
      • bf0_hal_aon.h
      • bf0_hal_tim_ex.h
      • bf0_hal_audcodec.h
      • bf0_hal_audprc.h
      • bf0_hal_cache.h
      • bf0_hal_crc.h
      • bf0_hal_dma.h
      • bf0_hal_efuse.h
      • bf0_hal_epic.h
      • bf0_hal_ext_dma.h
      • bf0_hal_ezip.h
      • bf0_hal_gpio.h
      • bf0_hal_tim.h
      • bf0_hal_i2c.h
      • bf0_hal_i2s.h
      • bf0_hal_lcdc.h
      • bf0_hal_lptim.h
      • bf0_hal_mailbox.h
      • bf0_hal_mpi.h
      • bf0_hal_patch.h
      • bf0_hal_pcd.h
      • bf0_hal_pdm.h
      • bf0_hal_pinmux.h
      • bf0_hal_pmu.h
      • bf0_hal_rcc.h
      • bf0_hal_rng.h
      • bf0_hal_rtc.h
      • bf0_hal_spi.h
      • bf0_hal.h
      • bf0_hal_tsen.h
      • bf0_hal_uart.h
      • bf0_hal_wdt.h
    • Middleware
      • acpu_ctrl.h
      • bf0_ble_gap.h
      • bf0_mbox_common.h
      • bf0_pm.h
      • gui_app_fwk.h
      • section_iter.h
      • section.h
      • button.h
      • context_backup.h
      • cpu_usage_profiler.h
      • data_service
      • ezipa_dec.h
      • file_logger.h
      • ipc_queue.h
      • ipc_queue_device.h
      • mem_pool_mng.h
      • metrics_collector.h
      • mod_installer.h
      • sf_type.h
      • share_prefs.h
      • bluetooth_service
    • SiFli CMSIS Device Interface
      • register.h
  • Contribution Guidelines
    • Coding Style (Non-HAL Modules)
    • Creating Example Projects

On this page

  • Overview
  • Supported Development Boards
  • Example Directory Structure
  • Example Usage
    • Hardware Requirements
    • Pin Configuration
    • Compilation and Flashing
  • Example Output Results
  • Troubleshooting
  • Example Extension
  1. SiFli SDK Pragramming Guide /
  2. Examples /
  3. Get started with SiFli-SDK /
  4. Blink /
  5. LED Blink (NO-OS)

LED Blink (NO-OS)

Overview

This example demonstrates LED blinking functionality using GPIO to better understand GPIO usage.

Supported Development Boards

This example can run on the following development boards:

  • eh-lb520

  • eh-lb523

  • eh-lb525

  • eh-lb561

  • eh-lb563

  • eh-ss6500

Note: Generally, examples run on the chip’s HCPU. If you want to run the example on LCPU, you can use “eh-lb563_lcpu”.

Example Directory Structure

The Blink project contains 1 .c file (main.c). The tree structure below shows other files in the project directory.

|--Readme.md
|--no-os
|--rtt
    |--src
    |    |--main.c
    |    |--Sconscript
    |--project  
         |--Kconfig
         |--Kconfig.proj
         |--proj.conf
         |--rtconfig.py
         |--SConscript
         |--SConstruct

Example Usage

Hardware Requirements

To run this example, you need to have a development board that supports this example.

Pin Configuration

Note: The table below shows the pin configurations for LED control on each development board.

pin assign

eh-lb523

PA25

eh-lb520

PA25

eh-lb525

PA25

eh-lb561

PA41

eh-lb563

PA41

eh-ss6500

PA41

Compilation and Flashing

Follow these steps to complete compilation and flashing:

menuconfig --board=eh-lb523
scons --board=eh-lb523 -j8
 .\build_eh-lb523\uart_download.bat

Example Output Results

The following results show the log after the example runs on the development board. If you cannot see these logs, it means the example did not run successfully as expected and troubleshooting is needed.

Start example blink
Turning the LED OFF
Turning the LED ON

Troubleshooting

If the expected logs do not appear, troubleshooting can be performed from the following aspects:

  • Whether hardware connections are normal

  • Whether pin configuration is correct

Example Extension

To control more LEDs, the following example shows how to extend the example by adding a second LED on development board eh-lb523:

  1. Modify the kconfig file “\siflisdk\customer\boards\Kconfig.v2” to add LED2 option: BSP_USING_LED2;

menuconfig BSP_USING_LED2
   bool "Use LED2"
   default n
   if BSP_USING_LED2  
       config BSP_LED2_PIN
           int "LED2 pin number"
           default 99
       config BSP_LED2_ACTIVE_HIGH
           bool "Level is high if LED is on"
           default n
   endif 
  1. Modify the development board configuration file “\siflisdk\customer\boards\eh-lb523\hcpu\board.conf” to enable LED2 and configure the corresponding pin and active level;

CONFIG_BSP_USING_LED2=y
CONFIG_BSP_LED2_PIN=26
CONFIG_BSP_LED2_ACTIVE_HIGH=y

The above configuration is the default configuration for eh-lb523, i.e., LED2 is configured to pin 26 by default; if you want to modify it to another pin, you can run menuconfig –board eh-lb523 to modify it;

  1. Modify the code main.c to control BSP_LED2_PINs to implement LED blinking;

int main(void)
{
  /*recode led state*/

  /* Output a message on console using printf function */
  rt_kprintf("Start example blink\n");

  /*Init pin state */
  rt_pin_mode(BSP_LED1_PIN, PIN_MODE_OUTPUT);
    rt_pin_mode(BSP_LED2_PIN, PIN_MODE_OUTPUT);
  bool state = RT_FALSE;

  /* Infinite loop, len flash inter 1s */
  while (1)
  {
    rt_kprintf("Turning the LED %s", state == RT_TRUE ? "ON" : "OFF");
#ifndef BSP_LED1_ACTIVE_HIGH
    rt_pin_write(BSP_LED1_PIN, !state);
    rt_pin_write(BSP_LED2_PIN, !state);
#else
    rt_pin_write(BSP_LED1_PIN, state);
  	  rt_pin_write(BSP_LED2_PIN, !state);
#endif
    /*toggle the LED statu*/
    state = !state;

    rt_thread_mdelay(1000);
  }
  return 0;
}
Previous
Blink
Next
LED Blink (RT-Thread)

2019 - 2025 SiFli Technologies(Nanjing) Co., Ltd

Made with Sphinx and Shibuya theme.

提交反馈