汇顶Goodix GR5515的FREERTOS移植及低功耗测试

其实说移植,更确切说是完善DEMO Code,因为官方已经有一个ble_app_template_freertos的demo code了,为了方便测试功耗已经功能的运行.

1.打开工程

工程的目录结构还算简洁

2.为了简化测试,先将程序瘦身,其中 print_test_task只留了一个延时,vStartTasks只创建print_task任务

static void print_test_task(void *p_arg)
{
    while (1)
    {
  //      app_rtc_get_time(&g_calendar_time);
  //      APP_LOG_INFO("TickCount: %d, Time: %02d/%02d %02d:%02d:%02d.%03d\r\n",
  //                    xTaskGetTickCount(),
   //                   g_calendar_time.mon, g_calendar_time.date,
  //                    g_calendar_time.hour, g_calendar_time.min, g_calendar_time.sec, g_calendar_time.ms);
   //     app_log_flush();
        vTaskDelay(2000);
    }
}

/**
 *****************************************************************************************
 * @brief To create two task, the one is ble-schedule, another is watcher task
 *****************************************************************************************
 */
static void vStartTasks(void *arg)
{
 //   system_pmu_calibration_start();
 //   app_calendar_init();
    xTaskCreate(print_test_task, "print_task", APP_TASK_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL);
//    xTaskCreate(dfu_schedule_task, "dfu_schedule_task", DFU_TASK_STACK_SIZE, NULL, configMAX_PRIORITIES - 2, NULL);
#if APP_LOG_STORE_ENABLE
    xTaskCreate(log_store_dump_task,     "log_store_dump_task",       LOG_STORE_DUMP_TASK_STACK_SIZE,  NULL, configMAX_PRIORITIES - 3, NULL);
#endif
    vTaskDelete(NULL);
}

需要注意修改以下宏定义

// <o> Eanble APP log module
// <0=> DISABLE
// <1=> ENABLE
#ifndef APP_LOG_ENABLE
#define APP_LOG_ENABLE          0//1
#endif

// <o> Enable BLE DFU support
// <0=> DISABLE
// <1=> ENABLE
#ifndef DFU_ENABLE
#define DFU_ENABLE              0//1
#endif

3.调整代码

1)调整app_periph_init函数

/*
 * GLOBAL FUNCTION DEFINITIONS
 *****************************************************************************************
 */
void app_periph_init(void)
{
    SYS_SET_BD_ADDR(s_bd_addr);
 //   bsp_log_init();
#if APP_LOG_STORE_ENABLE
    log_store_init();
#endif
 //   dfu_port_init(NULL, NULL);
    pwr_mgmt_mode_set(PMR_MGMT_SLEEP_MODE);
}

2)添加gus透传profile,此处为了与原有的gus区分开,将文件名也更新为gus_test

 

3)在下列参数中修改广播周期为2000mS

#define DEVICE_NAME                        "RTOS_test"  /**< Device Name which will be set in GAP. */
#define APP_ADV_FAST_MIN_INTERVAL          32               /**< The fast advertising min interval (in units of 0.625 ms. This value corresponds to 160 ms). */
#define APP_ADV_FAST_MAX_INTERVAL          48               /**< The fast advertising max interval (in units of 0.625 ms. This value corresponds to 1000 ms). */
#define APP_ADV_SLOW_MIN_INTERVAL          1600 * 2              /**< The slow advertising min interval (in units of 0.625 ms). */
#define APP_ADV_SLOW_MAX_INTERVAL          1600 * 2              /**< The slow advertising max interval (in units of 0.625 ms). */
#define APP_ADV_TIMEOUT_IN_SECONDS         0                /**< The advertising timeout in units of seconds. */
#define MIN_CONN_INTERVAL                  320              /**< Minimum acceptable connection interval (0.4 seconds). */
#define MAX_CONN_INTERVAL                  520              /**< Maximum acceptable connection interval (0.65 second). */
#define SLAVE_LATENCY                      0                /**< Slave latency. */
#define CONN_SUP_TIMEOUT                   400              /**< Connection supervisory timeout (4 seconds). */

4)注意修改services_init函数

static void services_init(void)
{
	sdk_err_t   error_code;
	gus_init_t  gus_init;
	
#if DFU_ENABLE
    dfu_service_init(NULL);
#endif
	
	gus_init.evt_handler = gus_service_process_event;
	error_code = gus_service_init(&gus_init);
    APP_ERROR_CHECK(error_code);
	
#if APP_LOG_STORE_ENABLE
    app_log_dump_service_init();
#endif
}

4.烧写到评估版,使用电流分析仪连接测试

可以看到2秒的定时任务,还要2秒的广播周期,平均电流约9.5uA

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Tristan Tsai

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值