最近因为项目开发需要,需要多任务的操作系统在nrf52832上运行,于是根据例程移植了下FreeOS系统
根据例程F:\nRF5_SDK_15.2.0_9412b96\examples\ble_peripheral\ble_app_hrs_freertos\pca10040\s132\arm5_no_packs移植
移植到例程F:\nRF5_SDK_15.2.0_9412b96\examples\ble_central_and_peripheral\experimental\ble_app_hrs_rscs_relay\pca10040\s132\arm5_no_packs,主从一体,一主多从这个例程
首先,对照两个例程ble_app_hrs_freertos,ble_app_hrs之间的不同之处,找出哪些是freeOS相关的文件,
这个目录下的都是与FreeOS相关的文件,在目录F:\nRF5_SDK_15.2.0_9412b96\external\freertos下
再次添加件..\..\..\..\..\..\components\softdevice\common\nrf_sdh_freertos.c,
..\..\..\..\..\..\..\components\libraries\timer\app_timer_freertos.c
..\..\..\..\..\..\..\components\libraries\hardfault\nrf52\handler\hardfault_handler_keil.c
去掉文件..\..\..\..\..\..\..\components\libraries\timer\app_timer.c
..\..\..\..\..\..\..\components\libraries\scheduler\app_scheduler.c
免得出现重复定义的情况
然后将宏NRF_SDH_DISPATCH_MODEL 由0改为2,configUSE_TIMERS宏由0改为1
然后再将需要的对应的头文件添加上
..\..\..\..\..\..\..\external\freertos\source\include
..\..\..\..\..\..\..\external\freertos\config
..\..\..\..\..\..\..\external\freertos\portable\ARM\nrf52
..\..\..\..\..\..\..\external\freertos\portable\CMSIS\nrf52
然后编写main函数
// Initialize modules.
log_init();
clock_init();
// Do not start any interrupt that uses system functions before system initialisation.
// The best solution is to start the OS before any other initalisation.
//#if NRF_LOG_ENABLED
// // Start execution.
// if (pdPASS != xTaskCreate(logger_thread, “LOGGER”, 256, NULL, 1, &m_logger_thread))
// {
// APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
// }
//#endif
// Activate deep sleep mode.
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
// Configure and initialize the BLE stack.
ble_stack_init();
// Initialize modules.
timer_init();
buttons_leds_init(&erase_bonds);
power_management_init();
// ble_stack_init();
scan_init();
gap_params_init();
gatt_init();
conn_params_init();
db_discovery_init();
peer_manager_init();
hrs_c_init();
rscs_c_init();
services_init();
advertising_init();
// Create a FreeRTOS task for the BLE stack.
// The task will run advertising_start() before entering its loop.
nrf_sdh_freertos_init(freeos_adv_scan_start, &erase_bonds);
NRF_LOG_INFO(“HRS FreeRTOS example started.”);
// Start FreeRTOS scheduler.
vTaskStartScheduler();
for (;;)
{
APP_ERROR_HANDLER(NRF_ERROR_FORBIDDEN);
}
再编译后通过
出现一个警告,是定义了但没有使用,不用去管它,不想用就直接删掉,没影响
以上就是Nrf52832的FreeOS的移植,可能还有些其它的问题,后续会进一步完善….