nrf5 SDK普通例子加上freertos
nrf5 SDK本身带的有freertos的例子,但是官方已经把需要的头文件路径和包含哪些c文件已经添加好了,为了更熟悉从不使用freertos的工程转换到使用freertos的工程修改的流程,基于\examples\peripheral\blinky\ 下的MDK工程添加freertos,测试运行任务OK。下面列下具体添加的步骤:
添加freertos头文件路径、clock时钟配置头文件路径:

在工程中添加freertos代码:

在工程中添加clock配置c文件:

在sdk_config.h中添加使能clock配置宏定义:
// <e> NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer
//==========================================================
#ifndef CLOCK_ENABLED
#define CLOCK_ENABLED 1
#endif
// <o> CLOCK_CONFIG_LF_SRC - LF Clock Source
// <0=> RC
// <1=> XTAL
// <2=> Synth
// <131073=> External Low Swing
// <196609=> External Full Swing
#ifndef CLOCK_CONFIG_LF_SRC
#define CLOCK_CONFIG_LF_SRC 1
#endif
// <o> CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority
// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
// <0=> 0 (highest)
// <1=> 1
// <2=> 2
// <3=> 3
// <4=> 4
// <5=> 5
// <6=> 6
// <7=> 7
#ifndef CLOCK_CONFIG_IRQ_PRIORITY
#define CLOCK_CONFIG_IRQ_PRIORITY 6
#endif
修改freertos配置头文件中configUSE_TIMERS

在main.c中添加头文件:
#include "nrf_drv_clock.h"
#include "FreeRTOS.h"
#include "task.h"
在main函数开始加入初始化时钟:
ret_code_t err_code;
err_code = nrf_drv_clock_init();
APP_ERROR_CHECK(err_code);
使用freertos创建个测试task让led闪烁一下



