单片机/MCUwilliam hill官网
直播中

jf_67024233

1年用户 257经验值
擅长:电源/新能源 模拟技术 测量仪表 接口/总线/驱动
私信 关注
[文章]

【xG24 Matter开发套件试用体验】xG24 Matter开发套件范例代码测试

大家好,收到这块开发板已经好几天了,先给大家简单介绍一下开发板,后面做一下范例的测试。

这个EFR32xG24 Explorer 套件是一个基于 EFR32MG24 片上系统的小封装开发和评估平台。EFR32xG24 Explorer 套件专注于快速原型化和概念创建 2.4 GHz 无线协议的 IoT 应用程序,包括蓝牙 LE、蓝牙网状网络、Zigbee、Thread 和 Matter。

该板的关键功能包括一个 USB 接口、一个板载 SEGGER J-Link 调试器、数据包追踪接口和按钮,并可通过 mikroBus 插座和 Qwiic® 连接器对硬件附加板提供支持。硬件附加支持允许开发人员使用来自 mikroE、Sparkfun、AdaFruit 和 Seeed Studios 的现成板进行各种组合,来创建和原型化应用程序。

04.jpg

03.jpg

01.jpg

测试范例先安装SDKs,Install需要完整安装好后才能新建程序,从英国威廉希尔公司网站 开始选择硬件,
001.jpg

然后从范例程序创建
002.jpg

程序就创建成功了。
003.jpg

3、开始调试,选择build
通过后,因为是范例程序,一定可以pass,然后debugg,就flash到板子里
004.jpg
005.jpg006.jpg

程序就可以正常的在板子上亮灯了。

测试代码如下:

程序设计也比较规范,从main.c 标准入口,

#include "sl_component_catalog.h"
#include "sl_system_init.h"
#include "app.h"
#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)
#include "sl_power_manager.h"
#endif
#if defined(SL_CATALOG_KERNEL_PRESENT)
#include "sl_system_kernel.h"
#else // SL_CATALOG_KERNEL_PRESENT
#include "sl_system_process_action.h"
#endif // SL_CATALOG_KERNEL_PRESENT

int main(void)
{
  // Initialize Silicon Labs device, system, service(s) and protocol stack(s).
  // Note that if the kernel is present, processing task(s) will be created by
  // this call.
  sl_system_init();

  // Initialize the application. For example, create periodic timer(s) or
  // task(s) if the kernel is present.
  app_init();

#if defined(SL_CATALOG_KERNEL_PRESENT)
  // Start the kernel. Task(s) created in app_init() will start running.
  sl_system_kernel_start();
#else // SL_CATALOG_KERNEL_PRESENT
  while (1) {
    // Do not remove this call: Silicon Labs components process action routine
    // must be called from the super loop.
    sl_system_process_action();

    // Application process.
    app_process_action();

#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)
    // Let the CPU go to sleep if the system allows it.
    sl_power_manager_sleep();
#endif
  }
#endif // SL_CATALOG_KERNEL_PRESENT
}

然后引用app.c

#include "blink_pwm_app.h"

/***************************************************************************//**
 * Initialize application.
 ******************************************************************************/
void app_init(void)
{
  blink_pwm_init();
}

/***************************************************************************//**
 * App ticking function.
 ******************************************************************************/
void app_process_action(void)
{
  blink_pwm_process_action();
}

从app.c 调用最终的应用代码,其中为了设计呼吸的效果,还定了了数组lut[],显示逐步呼吸的明暗关系,很认真滴。不过也,用个循环好不好。

#include "sl_pwm.h"
#include "sl_pwm_instances.h"
#include "sl_sleeptimer.h"

uint8_t pwm_lut[] = {
  0, 1, 1, 1, 2, 2, 2, 2, 2, 2,
  2, 3, 3, 3, 3, 3, 4, 4, 4, 4,
  5, 5, 5, 5, 6, 6, 6, 7, 7, 7,
  8, 8, 8, 9, 9, 10, 10, 10, 11, 11,
  12, 12, 13, 13, 14, 15, 15, 16, 17, 17,
  18, 19, 19, 20, 21, 22, 23, 23, 24, 25,
  26, 27, 28, 29, 30, 31, 32, 34, 35, 36,
  37, 39, 40, 41, 43, 44, 46, 48, 49, 51,
  53, 54, 56, 58, 60, 62, 64, 66, 68, 71,
  73, 75, 78, 80, 83, 85, 88, 91, 94, 97,
  100,
};

void blink_pwm_init(void)
{
  // Enable PWM output
  sl_pwm_start(&sl_pwm_led0);
}

void blink_pwm_process_action(void)
{
  for (uint8_t i = 0; i < 100; i++) {
    sl_pwm_set_duty_cycle(&sl_pwm_led0, pwm_lut);
    sl_sleeptimer_delay_millisecond(6);
    if (i == 0) {
      sl_sleeptimer_delay_millisecond(190);
    }
  }
  for (uint8_t i = 100; i > 0; i--) {
    sl_pwm_set_duty_cycle(&sl_pwm_led0, pwm_lut);
    sl_sleeptimer_delay_millisecond(6);
    if (i == 100) {
      sl_sleeptimer_delay_millisecond(190);
    }
  }
}

更多回帖

发帖
×
20
完善资料,
赚取积分