×
↑
Logo
  • Overview
  • Quick Start
  • EVB Guide
  • Tool Set
  • Platform
  • Subsystems
  • Protocols
  • Samples
    • Bluetooth
    • OTA
    • IO
      • IO General Introduction
      • PINMUX and PAD
      • GPIO
      • TIMER and PWM
      • UART
      • GDMA
      • I2C
      • SPI
      • IR
      • RTC
      • LPC
      • 3-Wire SPI
      • CapTouch
      • ADC
      • SLEEP LED
        • Sample List
          • SLEEP LED Breathe Mode
          • SLEEP LED Blink Mode
            • Requirements
            • Wiring
            • Configurations
            • Building and Downloading
            • Experimental Verification
            • Code Overview
              • Source Code Directory
              • Initialization
        • Functional Overview
        • Troubleshooting
      • QDEC
      • KeyScan
      • I2S
      • SDIO
      • CAN
    • USB
    • GUI
    • LCDC
    • Audio
    • LVGL
  • Applications
  • API Reference
  • Glossary
  • Disclaimer and Licenses
BT Audio SDK
  • Samples
  • IO
  • SLEEP LED
  • SLEEP LED Blink Mode

SLEEP LED Blink Mode

This sample code guide is designed to help users easily and comprehensively understand SLEEP LED sample. In this sample, SLEEP LED is configured in blink mode.

Requirements

For hardware requirements, please refer to the Requirements.

Wiring

Connect P0_1 to LED1 and connect P2_1 to LED2 and connect P2_2 to LED3 On the EVB.

The hardware connection of SLEEP LED sample code is shown in the figure below.

../../../_images/SLEEP_LED_Sample_Code_Hardware_Connection_Diagram.png

SLEEP LED Sample Code Hardware Connection Diagram

Configurations

  1. The following macros can be configured to modify pin definitions.

    • #define LED_OUT_0       ADC_1

    • #define LED_OUT_1       P2_1

    • #define LED_OUT_2       P2_2

  2. The entry function is as follows, call this function in main() to run this sample code. For more details, please refer to the Initialization.

    sleep_led_blink_demo();
    

Building and Downloading

For building and downloading, please refer to the Building and Downloading.

Experimental Verification

Press the Reset button on the EVB board, LEDs blink with 200ms on and 100ms off.

Code Overview

This section introduces the code and process description for initialization and corresponding function implementation in the sample.

Source Code Directory

  • For project directory, please refer to Source Code Directory.

  • Source code directory: sdk\src\sample\io_demo\led\sleep_led_demo.c.

Initialization

The initialization flow for peripherals can refer to Initialization Flow.

The initialization flow of SLEEP LED blink mode is shown in the following figure.

../../../_images/SLEEP_LED_Blink_Mode_Flow_Chart.png

SLEEP LED Blink Mode Initialization Flow Chart

  1. Call Pad_Config() and Pad_FunctionConfig() to initialize the pin.

    static void board_led_init(void)
    {
       Pad_Config(LED_OUT_0, PAD_SW_MODE, PAD_IS_PWRON, PAD_PULL_NONE, PAD_OUT_ENABLE, PAD_OUT_HIGH);
       Pad_Config(LED_OUT_1, PAD_SW_MODE, PAD_IS_PWRON, PAD_PULL_NONE, PAD_OUT_ENABLE, PAD_OUT_HIGH);
       Pad_Config(LED_OUT_2, PAD_SW_MODE, PAD_IS_PWRON, PAD_PULL_NONE, PAD_OUT_ENABLE, PAD_OUT_HIGH);
    
       Pad_FunctionConfig(LED_OUT_0, LED0);
       Pad_FunctionConfig(LED_OUT_1, LED1);
       Pad_FunctionConfig(LED_OUT_2, LED2);
    }
    
  2. Call SleepLed_Reset() to clear all SLEEP LED registers to their default reset values.

  3. Initialize the SLEEP LED peripheral:

    1. Define the SLEEP_LED_InitTypeDef type Led_Initsturcture, and call SleepLed_StructInit() to pre-fill Led_Initsturcture with default values.

    2. Modify the Led_Initsturcture parameters as needed. The SLEEP LED initialization parameter configuration is shown in the table below.

    3. Call SleepLed_Init() to initialize the SLEEP LED peripheral.

    SLEEP LED Initialization Parameters

    SLEEP LED Hardware Parameters

    Setting in the Led_Initsturcture Variables

    SLEEP LED

    Clock Division Factor

    SLEEP_LED_InitTypeDef::prescale

    32

    Mode

    SLEEP_LED_InitTypeDef::mode

    LED_BLINK_MODE

    Polarity

    SLEEP_LED_InitTypeDef::polarity

    LED_OUTPUT_NORMAL

    High Level Time

    SLEEP_LED_InitTypeDef::period_high

    Channel0 Period0: 200 (200ms)

    Channel0 Period1: 200 (200ms)

    Channel0 Period2 : 200 (200ms)

    Channel1 Period0: 200 (200ms)

    Channel1 Period1: 200 (200ms)

    Channel1 Period2 : 0 (0)

    Channel2 Period0: 200 (200ms)

    Channel2 Period1: 0 (0)

    Channel2 Period2 : 0 (0)

    Low Level Time

    SLEEP_LED_InitTypeDef::period_low

    Channel0 Period0: 100 (100ms)

    Channel0 Period1: 100 (100ms)

    Channel0 Period2 : 100 (100ms)

    Channel1 Period0: 100 (100ms)

    Channel1 Period1: 100 (100ms)

    Channel1 Period2 : 0 (0)

    Channel2 Period0: 100 (100ms)

    Channel2 Period1: 0 (0)

    Channel2 Period2 : 0 (0)

  4. Call SleepLed_Cmd() to enable SLEEP LED.

Previous Next

Copyrights ©瑞晟微电子有限公司 2025. All rights reserved. 苏ICP备10062199号-8