1. Introduction
SiFli Component Registry Documentation
SiFli Component Registry Homepage
Documentation for Packaging and Uploading Components
SiFli Package Registry
The goal of this article is to introduce how to use SiFli components.
We will use thesensor-algorithmcomponent from the component registry to implement a motion sensor function.
Ultimately, we can observe the angle output data from the LSM6DSL sensor.
The development board used here is Huangshanpai (as it comes with an integrated LSM6DSL sensor).
2. Component Overview
You can find the required components on the SiFli Component Registry Homepage.
Click on a component to view its functionality and usage instructions.
The webpage includes package information. The entry under
Add to conanfile.py requires, specificallysensor-algorithm/[^0.1]@nuoning, is the component information we need.
3. Adding a Component
SiFli Component Registry Documentation
No user registration is required to use components.
Here, we demonstrate adding thesensor-algorithmcomponent to thehello_worldproject.
1. Initialize Dependencies
Navigate into the project’s
projectdirectory and run:sdk.py sf-pkg init
Upon success, aconanfile.pyfile will be generated with default content as shown below:
2. Search for Components
In addition to searching via the component registry website, you can also use the command:
sdk.py sf-pkg search <package_name>to find components.
Example:sdk.py sf-pkg search tf_hot_plug
3. Add Dependency
Add the component reference
sensor-algorithm/[^0.1]@nuoning(from earlier) to therequiresfield, as shown in the image:
4. Install Dependencies
Run
sdk.py sf-pkg installto install dependencies.
Upon successful installation, you will see the messagePackages installed successfully, and a new folder namedsf-pkgswill appear under theprojectdirectory.
Thesf-pkgsfolder contains the driver code provided by the component. At this point, component installation is complete.
5. Dependency Management
All installed dependencies are managed within the
sf-pkgsfolder.
Component pages on the web usually include usage instructions and API documentation. Installed component libraries also contain a
README.mdfile.
To use the component, simply include the relevant header file to access the APIs. There’s no need to specify absolute paths when including headers—Conan automatically handles path configuration.
Any additional Kconfig options defined by the component are automatically added to themenuconfigunderSiFli External Components.
4. Using the Component
1. menuconfig Configuration
Enter the
projectdirectory of thehello_worldproject and enable LSM6DSL-related settings inmenuconfig.
2. Component-specific menuconfig Settings
Some components include configurable options defined in their
Kconfigfile during creation.
When using such components, theirKconfigentries are automatically integrated intomenuconfig. You can configure them underSiFli External Componentsinmenuconfig.
Here, we set the sensor’s full scale range to ±2g (acceleration), ±125dps (angular rate), and the sampling rate to 200Hz.
3. Function Call in main.c
Add the header:
#include "sf_lsm6dsl.h"
Call the component functions within themainfunction. Refer to the component documentation for details.
#include "rtthread.h"
#include "bf0_hal.h"
#include "drv_io.h"
#include "stdio.h"
#include "string.h"
#include "sf_lsm6dsl.h"
int main(void)
{
/* Output a message on console using printf function */
rt_kprintf("Hello world!\n");
struct rt_sensor_config cfg;
rt_device_t lsm6d_dev, lsm6d_gyro_dev;
sf_lsm6dsl_runner_t runner;
sensors_init(&cfg, &lsm6d_dev, &lsm6d_gyro_dev);
sf_lsm6dsl_runner_init(&runner, lsm6d_dev, lsm6d_gyro_dev);
sf_lsm6dsl_runner_start(&runner, sf_lsm6dsl_sample_period_ticks());
/* Infinite loop */
while (1)
{
// Delay for 1000 ms to yield CPU time to other threads
rt_thread_mdelay(1000);
}
return 0;
}
4. Build and Flash
Build command:
scons --board=sf32lb52-lchspi-ulp -j8
Flash command:.\build_sf32lb52-lchspi-ulp_hcpu\uart_download.bat
View output:
5. Summary
This article briefly explains how to use dependencies from the SiFli Component Registry, using
sensor-algorithmas an example to walk through the entire process.
Additionally, users are encouraged to share and upload their own components. Future updates will cover how to package and upload your own components.
If you have any questions or issues, feel free to leave a comment below—let’s improve together.















