zoukankan      html  css  js  c++  java
  • Examples

    今天在ble_app_blinky例程中移植定时器驱动,在编译过程中报出了两个错误,在此记录一下。

    1. 在nRF_Dreivers中添加nrfx_timer.c文件

    选中“nRF_Dreivers ” -> 右键选择“Add Existing Files to Group....” -> 选择nrf_timer.c文件

    注:添加完成nrf_timer.c后,发现文件图标上面没有和其他文件图标上面的雪花形状的标记,原因是:

    该文件没有被单独设置过option。

    方法是:右击该文件打开它的option,随便改个属性然后点确定,它就会被标上雪花。

        

    2. 参考examplesperipheral imer timer定时器中的逻辑,调用相关接口。

    #include "nrf_drv_timer.h"

    const nrf_drv_timer_t TIMER_LED = NRF_DRV_TIMER_INSTANCE(0); ---编译报错

    int main()

    {

    uint32_t time_ms = 500;
    uint32_t time_ticks;
    uint32_t err_code = NRF_SUCCESS;
    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
    err_code = nrf_drv_timer_init(&TIMER_LED, &timer_cfg, timer_led_event_handler);
    APP_ERROR_CHECK(err_code);

    time_ticks = nrf_drv_timer_ms_to_ticks(&TIMER_LED, time_ms);

    nrf_drv_timer_extended_compare(
    &TIMER_LED, NRF_TIMER_CC_CHANNEL0, time_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);

    nrf_drv_timer_enable(&TIMER_LED);

    }

    nrfx_timer.c中:

    #if !(NRFX_CHECK(NRFX_TIMER0_ENABLED) || NRFX_CHECK(NRFX_TIMER1_ENABLED) ||
    NRFX_CHECK(NRFX_TIMER2_ENABLED) || NRFX_CHECK(NRFX_TIMER3_ENABLED) ||
    NRFX_CHECK(NRFX_TIMER4_ENABLED))

    #error "No enabled TIMER instances. Check <nrfx_config.h>."          ----------编译报错
    #endif

    3. 编译

    编译程序,发现两处地方报错,最后发现问题原因:

    sdk_config.h中,需要将

    #ifndef TIMER0_ENABLED
    #define TIMER0_ENABLED 1
    #endif

    #ifndef TIMER_ENABLED
    #define TIMER_ENABLED 1 
    #endif

  • 相关阅读:
    构造月份选择框
    自定义验证
    设置队列中文件上的“X”号的点击事件+uploadLimit动态加1
    easyui在table单元格中添加进度条
    js里生成guid
    宽高
    获取iframe中的tree
    form表单
    position详解
    java通过jdbc连接数据库并更新数据(包括java.util.Date类型数据的更新)
  • 原文地址:https://www.cnblogs.com/hjj801006/p/12690197.html
Copyright © 2011-2022 走看看