diff --git a/Makefile b/Makefile index 5fe2e74..867cce8 100644 --- a/Makefile +++ b/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_softdevice.ld + LINKER_SCRIPT := nrf51_xxac_softdevice.ld # Source files common to all targets SRC_FILES += \ diff --git a/config/FreeRTOSConfig.h b/config/FreeRTOSConfig.h index 74dd881..aba13c8 100644 --- a/config/FreeRTOSConfig.h +++ b/config/FreeRTOSConfig.h @@ -99,7 +99,7 @@ #define configTICK_RATE_HZ 1000 #define configMAX_PRIORITIES ( 3 ) #define configMINIMAL_STACK_SIZE ( 60 ) -#define configTOTAL_HEAP_SIZE ( 4096 ) +#define configTOTAL_HEAP_SIZE ( 8192 ) #define configMAX_TASK_NAME_LEN ( 4 ) #define configUSE_16_BIT_TICKS 0 #define configIDLE_SHOULD_YIELD 1 diff --git a/include/user_config.h b/include/user_config.h index 314bf8d..1df778b 100644 --- a/include/user_config.h +++ b/include/user_config.h @@ -2,5 +2,7 @@ #define __USER_CONFIG_H #define APP_TIMER_PRESCALER 0 /**< Value of the RTC1 PRESCALER register. */ +#define CENTRAL_LINK_COUNT 0 /**< Number of central links used by the application. When changing this number remember to adjust the RAM settings*/ +#define PERIPHERAL_LINK_COUNT 1 /**< Number of peripheral links used by the application. When changing this number remember to adjust the RAM settings*/ #endif \ No newline at end of file diff --git a/nrf51_xxaa_softdevice.ld b/nrf51_xxaa_softdevice.ld index 8d0701a..8ef137e 100644 --- a/nrf51_xxaa_softdevice.ld +++ b/nrf51_xxaa_softdevice.ld @@ -6,7 +6,7 @@ GROUP(-lgcc -lc -lnosys) MEMORY { FLASH (rx) : ORIGIN = 0x1b000, LENGTH = 0x25000 /* --- */ - RAM (rwx) : ORIGIN = 0x200013c8, LENGTH = 0x2c38 /* Nordic S130 SDS v2 */ + RAM (rwx) : ORIGIN = 0x20001fe8, LENGTH = 0x2018 /* Nordic S130 SDS v2 */ } SECTIONS diff --git a/src/user_tasks.c b/src/user_tasks.c index 5dbc345..bf0e269 100644 --- a/src/user_tasks.c +++ b/src/user_tasks.c @@ -10,6 +10,7 @@ #include "task.h" #include "semphr.h" +#include "user_config.h" #include "user_functions.h" #include "user_tasks.h" @@ -30,9 +31,10 @@ void init_tasks(void) { APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); } - if(pdPASS != xTaskCreate(vTaskBlinkLED, "TASKBLINK0", 64, NULL, 2, &xTaskBlinkLEDHandle)) { + if(pdPASS != xTaskCreate(vTaskBlinkLED, "TASKBLINK0", 128, NULL, 2, &xTaskBlinkLEDHandle)) { APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); } + if(pdPASS != xTaskCreate(vTaskBLE, "TASKBLE0", 256, NULL, 2, &xTaskBLEHandle)) { APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); } @@ -57,7 +59,14 @@ void vTaskBLE(void *pvParameters) { nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC; SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, ble_new_event_handler); - NRF_LOG_INFO("Softdevice handler created, waiting for events\r\n"); + ble_enable_params_t ble_enable_params; + uint32_t err_code = softdevice_enable_get_default_config(CENTRAL_LINK_COUNT, PERIPHERAL_LINK_COUNT, &ble_enable_params); + APP_ERROR_CHECK(err_code); + CHECK_RAM_START_ADDR(CENTRAL_LINK_COUNT, PERIPHERAL_LINK_COUNT); + err_code = softdevice_enable(&ble_enable_params); + APP_ERROR_CHECK(err_code); + + NRF_LOG_INFO("Softdevice enabled, waiting for events\r\n"); for(;;) { while(pdFALSE == xSemaphoreTake(xSemaphoreBLEEventReadyHandle, portMAX_DELAY)) {