Use softdevice S130.
This commit is contained in:
parent
67ca0cb61f
commit
5e8181aa2b
46
Makefile
46
Makefile
|
@ -6,7 +6,7 @@ SDK_ROOT := $(PWD)/../../nRF_SDK/nRF5_SDK_12.3.0_d7731ad
|
|||
PROJ_DIR := $(PWD)
|
||||
|
||||
$(OUTPUT_DIRECTORY)/nrf51822_xxaa.out: \
|
||||
LINKER_SCRIPT := nrf51_xxaa.ld
|
||||
LINKER_SCRIPT := nrf51_xxaa_softdevice.ld
|
||||
|
||||
# Source files common to all targets
|
||||
SRC_FILES += \
|
||||
|
@ -25,6 +25,8 @@ SRC_FILES += \
|
|||
$(SDK_ROOT)/components/libraries/util/sdk_errors.c \
|
||||
$(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_serial.c \
|
||||
$(SDK_ROOT)/components/libraries/log/src/nrf_log_frontend.c \
|
||||
$(SDK_ROOT)/components/libraries/timer/app_timer_freertos.c \
|
||||
$(SDK_ROOT)/components/softdevice/common/softdevice_handler/softdevice_handler.c \
|
||||
$(SDK_ROOT)/external/freertos/source/tasks.c \
|
||||
$(SDK_ROOT)/external/freertos/source/list.c \
|
||||
$(SDK_ROOT)/external/freertos/source/timers.c \
|
||||
|
@ -40,18 +42,35 @@ INC_FOLDERS += \
|
|||
$(PROJ_DIR)/config \
|
||||
$(SDK_ROOT)/components \
|
||||
$(SDK_ROOT)/components/boards \
|
||||
$(SDK_ROOT)/components/ble/common \
|
||||
$(SDK_ROOT)/components/ble/ble_advertising \
|
||||
$(SDK_ROOT)/components/ble/nrf_ble_gatt \
|
||||
$(SDK_ROOT)/components/ble/peer_manager \
|
||||
$(SDK_ROOT)/components/ble/ble_services/ble_bas_c \
|
||||
$(SDK_ROOT)/components/ble/ble_services/ble_hrs_c \
|
||||
$(SDK_ROOT)/components/ble/ble_services/ble_bas \
|
||||
$(SDK_ROOT)/components/ble/ble_services/ble_hrs \
|
||||
$(SDK_ROOT)/components/ble/ble_services/ble_dis \
|
||||
$(SDK_ROOT)/components/device \
|
||||
$(SDK_ROOT)/components/drivers_nrf/common \
|
||||
$(SDK_ROOT)/components/drivers_nrf/hal \
|
||||
$(SDK_ROOT)/components/drivers_nrf/clock \
|
||||
$(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd \
|
||||
$(SDK_ROOT)/components/drivers_nrf/gpiote \
|
||||
$(SDK_ROOT)/components/drivers_nrf/uart \
|
||||
$(SDK_ROOT)/components/drivers_nrf/timer \
|
||||
$(SDK_ROOT)/components/libraries/bsp \
|
||||
$(SDK_ROOT)/components/libraries/button \
|
||||
$(SDK_ROOT)/components/libraries/util \
|
||||
$(SDK_ROOT)/components/libraries/log \
|
||||
$(SDK_ROOT)/components/libraries/log/src \
|
||||
$(SDK_ROOT)/components/libraries/timer \
|
||||
$(SDK_ROOT)/components/libraries/hci \
|
||||
$(SDK_ROOT)/components/libraries/fds \
|
||||
$(SDK_ROOT)/components/libraries/fstorage \
|
||||
$(SDK_ROOT)/components/libraries/sensorsim \
|
||||
$(SDK_ROOT)/components/libraries/experimental_section_vars \
|
||||
$(SDK_ROOT)/components/softdevice/s130/headers \
|
||||
$(SDK_ROOT)/components/softdevice/common/softdevice_handler \
|
||||
$(SDK_ROOT)/components/toolchain \
|
||||
$(SDK_ROOT)/components/toolchain/cmsis/include \
|
||||
$(SDK_ROOT)/external/freertos/source/include \
|
||||
|
@ -63,10 +82,6 @@ INC_FOLDERS += \
|
|||
LIB_FILES += \
|
||||
|
||||
# C flags common to all targets
|
||||
CFLAGS += -DNRF51
|
||||
CFLAGS += -DNRF51822
|
||||
CFLAGS += -DFREERTOS
|
||||
CFLAGS += -DBOARD_CUSTOM
|
||||
CFLAGS += -mcpu=cortex-m0
|
||||
CFLAGS += -mthumb -mabi=aapcs
|
||||
CFLAGS += -Wall -Werror -O3 -g3
|
||||
|
@ -74,6 +89,15 @@ CFLAGS += -mfloat-abi=soft
|
|||
# keep every function in separate section, this allows linker to discard unused ones
|
||||
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
|
||||
CFLAGS += -fno-builtin --short-enums
|
||||
CFLAGS += -DNRF51
|
||||
CFLAGS += -DNRF51822
|
||||
CFLAGS += -DFREERTOS
|
||||
CFLAGS += -DBOARD_CUSTOM
|
||||
CFLAGS += -DSOFTDEVICE_PRESENT
|
||||
CFLAGS += -DS130
|
||||
CFLAGS += -DBLE_STACK_SUPPORT_REQD
|
||||
CFLAGS += -DNRF_SD_BLE_API_VERSION=2
|
||||
CFLAGS += -D__STACK_SIZE=2048
|
||||
|
||||
# C++ flags common to all targets
|
||||
CXXFLAGS += \
|
||||
|
@ -82,8 +106,14 @@ CXXFLAGS += \
|
|||
ASMFLAGS += -x assembler-with-cpp
|
||||
ASMFLAGS += -DNRF51
|
||||
ASMFLAGS += -DNRF51822
|
||||
ASMFLAGS += -DFREERTOS
|
||||
ASMFLAGS += -DBOARD_CUSTOM
|
||||
ASMFLAGS += -DBSP_DEFINES_ONLY
|
||||
ASMFLAGS += -DSOFTDEVICE_PRESENT
|
||||
ASMFLAGS += -DS130
|
||||
ASMFLAGS += -DBLE_STACK_SUPPORT_REQD
|
||||
ASMFLAGS += -DNRF_SD_BLE_API_VERSION=2
|
||||
ASMFLAGS += -D__STACK_SIZE=2048
|
||||
|
||||
|
||||
# Linker flags
|
||||
LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT)
|
||||
|
@ -111,7 +141,7 @@ include $(TEMPLATE_PATH)/Makefile.common
|
|||
$(foreach target, $(TARGETS), $(call define_target, $(target)))
|
||||
|
||||
# Flash the program
|
||||
flash: $(OUTPUT_DIRECTORY)/nrf51422_xxac.hex
|
||||
flash: $(OUTPUT_DIRECTORY)/nrf51822_xxaa.hex
|
||||
@echo Flashing: $<
|
||||
nrfjprog --program $< -f nrf51 --sectorerase
|
||||
nrfjprog --reset -f nrf51
|
||||
|
|
|
@ -99,7 +99,7 @@
|
|||
#define configTICK_RATE_HZ 1000
|
||||
#define configMAX_PRIORITIES ( 3 )
|
||||
#define configMINIMAL_STACK_SIZE ( 60 )
|
||||
#define configTOTAL_HEAP_SIZE ( 8192 )
|
||||
#define configTOTAL_HEAP_SIZE ( 4096 )
|
||||
#define configMAX_TASK_NAME_LEN ( 4 )
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
|
@ -114,7 +114,7 @@
|
|||
#define configENABLE_BACKWARD_COMPATIBILITY 1
|
||||
|
||||
/* Hook function related definitions. */
|
||||
#define configUSE_IDLE_HOOK 0
|
||||
#define configUSE_IDLE_HOOK 1
|
||||
#define configUSE_TICK_HOOK 0
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 0
|
||||
#define configUSE_MALLOC_FAILED_HOOK 0
|
||||
|
|
|
@ -456,7 +456,7 @@
|
|||
// <i> Function for getting the timestamp is provided by the user
|
||||
|
||||
#ifndef NRF_LOG_USES_TIMESTAMP
|
||||
#define NRF_LOG_USES_TIMESTAMP 0
|
||||
#define NRF_LOG_USES_TIMESTAMP 1
|
||||
#endif
|
||||
|
||||
#endif //NRF_LOG_ENABLED
|
||||
|
|
63
main.c
63
main.c
|
@ -4,10 +4,37 @@
|
|||
|
||||
#include "bsp.h"
|
||||
|
||||
#include "nrf_drv_clock.h"
|
||||
#include "nordic_common.h"
|
||||
#include "nrf.h"
|
||||
#include "ble.h"
|
||||
#include "ble_hci.h"
|
||||
#include "ble_srv_common.h"
|
||||
#include "ble_advdata.h"
|
||||
#include "ble_advertising.h"
|
||||
#include "ble_bas.h"
|
||||
#include "ble_hrs.h"
|
||||
#include "ble_dis.h"
|
||||
#include "ble_conn_params.h"
|
||||
|
||||
#include "boards.h"
|
||||
#include "sensorsim.h"
|
||||
|
||||
#include "sdk_errors.h"
|
||||
#include "app_error.h"
|
||||
#include "app_timer.h"
|
||||
#include "softdevice_handler.h"
|
||||
|
||||
#include "peer_manager.h"
|
||||
#include "bsp.h"
|
||||
#include "bsp_btn_ble.h"
|
||||
#include "fds.h"
|
||||
#include "fstorage.h"
|
||||
#include "ble_conn_state.h"
|
||||
|
||||
#include "nrf_drv_clock.h"
|
||||
|
||||
#define NRF_LOG_MODULE_NAME "APP"
|
||||
|
||||
#include "nrf_log.h"
|
||||
#include "nrf_log_ctrl.h"
|
||||
|
||||
|
@ -19,9 +46,16 @@
|
|||
#define APP_TIMER_PRESCALER 0
|
||||
#define APP_TIMER_OP_QUEUE_SIZE 4
|
||||
|
||||
/* Task Definitions */
|
||||
|
||||
TaskHandle_t xTaskBlinkLEDHandle = NULL;
|
||||
void vTaskBlinkLED(void *pvParameters);
|
||||
|
||||
TaskHandle_t xTaskLoggerHandle = NULL;
|
||||
void vTaskLogger(void *pvParameters);
|
||||
|
||||
/* Timers */
|
||||
|
||||
TimerHandle_t xTimerBlinkAnotherLEDHandle = NULL;
|
||||
void xTimerBlinkAnotherLEDCallback(TimerHandle_t xTimer);
|
||||
|
||||
|
@ -34,16 +68,24 @@ int main(void) {
|
|||
bsp_board_leds_init();
|
||||
bsp_board_leds_off();
|
||||
|
||||
err_code = NRF_LOG_INIT(xTaskGetTickCount);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
|
||||
|
||||
UNUSED_VARIABLE(xTaskCreate(vTaskBlinkLED, "TASKLED0", 128, NULL, 2, xTaskBlinkLEDHandle));
|
||||
if(pdPASS != xTaskCreate(vTaskBlinkLED, "TASKLED0", 128, NULL, 2, &xTaskBlinkLEDHandle)) {
|
||||
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
|
||||
}
|
||||
|
||||
if(pdPASS != xTaskCreate(vTaskLogger, "TASKLOG0", 256, NULL, 1, &xTaskLoggerHandle));
|
||||
|
||||
xTimerBlinkAnotherLEDHandle = xTimerCreate("TIMERLED1", pdMS_TO_TICKS(200), pdTRUE, NULL, xTimerBlinkAnotherLEDCallback);
|
||||
UNUSED_VARIABLE(xTimerStart(xTimerBlinkAnotherLEDHandle, 0));
|
||||
|
||||
vTaskStartScheduler();
|
||||
|
||||
for(;;) {
|
||||
//
|
||||
APP_ERROR_HANDLER(NRF_ERROR_FORBIDDEN);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,11 +94,26 @@ void vTaskBlinkLED(void *pvParameters) {
|
|||
|
||||
for(;;) {
|
||||
bsp_board_led_invert(BSP_BOARD_LED_0);
|
||||
NRF_LOG_INFO("Toggle LED0...\r\n");
|
||||
vTaskDelay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
void xTimerBlinkAnotherLEDCallback(TimerHandle_t xTimer) {
|
||||
UNUSED_VARIABLE(xTimer);
|
||||
NRF_LOG_DEBUG("FreeRTOS timer FIRED!\r\n");
|
||||
bsp_board_led_invert(BSP_BOARD_LED_1);
|
||||
}
|
||||
|
||||
void vTaskLogger(void *pvParameters) {
|
||||
UNUSED_VARIABLE(pvParameters);
|
||||
|
||||
for(;;) {
|
||||
NRF_LOG_FLUSH();
|
||||
vTaskSuspend(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void vApplicationIdleHook(void) {
|
||||
vTaskResume(xTaskLoggerHandle);
|
||||
}
|
Loading…
Reference in New Issue