nRF51 now working. makefile needs to be cleaned up. specifically when we

are/arent using the softdevice/ble. duplicate sdks for nrf51 and nrf52
is a problem that should be fixed to make code cleaner.
This commit is contained in:
Michael Dietz 2015-09-22 13:16:00 +02:00
parent e26cb825d8
commit 904ca0ac8c
9 changed files with 54 additions and 38 deletions

View File

@ -63,8 +63,6 @@
# WIZNET=1 # If compiling for a non-linux target that has internet support, use WIZnet support, not TI CC3000
# ESP8266=1 # If compiling for a non-linux target that has internet support, use ESP8266 support, not TI CC3000
NRF5X_SDK_PATH=$(ROOT)/targetlibs/nrf5x/nrf5x_sdk
ifndef SINGLETHREAD
MAKEFLAGS=-j5 # multicore
endif
@ -366,14 +364,15 @@ NRF51=1 # Define the family to set CFLAGS and LDFLAGS later in the makefile.
OPTIMIZEFLAGS+=-O3 # Set this to -O0 to enable debugging.
else ifdef NRF51822DK
EMBEDDED=1
SAVE_ON_FLASH=1
BOARD=NRF51822DK
NRF51=1 # Define the family to set CFLAGS and LDFLAGS later in the makefile.
OPTIMIZEFLAGS+=-O3 # Set this to -O0 to enable debugging.
OPTIMIZEFLAGS+=-O3
else ifdef NRF52832DK
EMBEDDED=1
BOARD=NRF52832DK
NRF52=1 # Define the family to set CFLAGS and LDFLAGS later in the makefile.
OPTIMIZEFLAGS+=-O3 # Set this to -O0 to enable debugging.
OPTIMIZEFLAGS+=-O3
else ifdef TINYCHIP
EMBEDDED=1
BOARD=TINYCHIP
@ -1018,24 +1017,28 @@ endif #USB
ifeq ($(FAMILY), NRF51)
NRF5X=1 # The nRF51 & nRF52 share a common SDK as well as many other similarites.
NRF5X=1
NRF5X_SDK_PATH=$(ROOT)/targetlibs/nrf5x/nrf51_sdk
# ARCHFLAGS are shared by both CFLAGS and LDFLAGS.
ARCHFLAGS = -mcpu=cortex-m0 -mthumb -mabi=aapcs -mfloat-abi=soft # Use nRF51 makefile provided in SDK as reference.
# nRF51 specific...
INCLUDE += -I$(NRF5X_SDK_PATH)/components/softdevice/s110/headers
SOURCES += $(NRF5X_SDK_PATH)/components/toolchain/system_nrf51.c
SOURCES += $(NRF5X_SDK_PATH)/components/toolchain/system_nrf51.c \
$(NRF5X_SDK_PATH)/components/drivers_nrf/uart/app_uart_fifo.c
PRECOMPILED_OBJS+=$(NRF5X_SDK_PATH)/components/toolchain/gcc/gcc_startup_nrf51.o
# Assume the softdevice (S110) is always enabled for now...
DEFINES += -DBOARD_PCA10028 -DSWI_DISABLE0 -DSOFTDEVICE_PRESENT -DNRF51 -DS110 -DBLE_STACK_SUPPORT_REQD #change to ds132??
LINKER_FILE = $(NRF5X_SDK_PATH)/components/toolchain/gcc/linker_nrf51_espruino.ld
DEFINES += -DBOARD_PCA10028 -DNRF51
#DEFINES += -DSWI_DISABLE0 -DSOFTDEVICE_PRESENT -DS110 -DBLE_STACK_SUPPORT_REQD
LINKER_FILE = $(NRF5X_SDK_PATH)/components/toolchain/gcc/linker_nrf51_espruino.ld
endif # FAMILY == NRF51
ifeq ($(FAMILY), NRF52)
NRF5X=1 # The nRF51 & nRF52 share a common SDK as well as many other similarites.
NRF5X=1
NRF5X_SDK_PATH=$(ROOT)/targetlibs/nrf5x/nrf52_sdk
# ARCHFLAGS are shared by both CFLAGS and LDFLAGS.
ARCHFLAGS = -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfloat-abi=hard -mfpu=fpv4-sp-d16
@ -1043,7 +1046,11 @@ ifeq ($(FAMILY), NRF52)
# nRF52 specific...
INCLUDE += -I$(NRF5X_SDK_PATH)/components/softdevice/s132/headers
INCLUDE += -I$(NRF5X_SDK_PATH)/components/softdevice/s132/headers/nrf52
SOURCES += $(NRF5X_SDK_PATH)/components/toolchain/system_nrf52.c
INCLUDE += -I$(NRF5X_SDK_PATH)/components/drivers_nrf/delay
SOURCES += $(NRF5X_SDK_PATH)/components/toolchain/system_nrf52.c \
$(NRF5X_SDK_PATH)/components/drivers_nrf/delay/nrf_delay.c \
$(NRF5X_SDK_PATH)/components/drivers_nrf/uart/nrf_drv_uart.c \
$(NRF5X_SDK_PATH)/components/libraries/uart/app_uart_fifo.c
PRECOMPILED_OBJS+=$(NRF5X_SDK_PATH)/components/toolchain/gcc/gcc_startup_nrf52.o
# Assume that softdevice (S132) is always enabled for now...
@ -1071,16 +1078,14 @@ ifdef NRF5X
INCLUDE += -I$(NRF5X_SDK_PATH)/components/drivers_nrf/config
INCLUDE += -I$(NRF5X_SDK_PATH)/examples/bsp
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/fifo
INCLUDE += -I$(NRF5X_SDK_PATH)/components/drivers_nrf/delay
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/util
INCLUDE += -I$(NRF5X_SDK_PATH)/components/drivers_nrf/uart
INCLUDE += -I$(NRF5X_SDK_PATH)/components/ble/common
INCLUDE += -I$(NRF5X_SDK_PATH)/components/drivers_nrf/pstorage
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/uart
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/uart # not nrf51?
INCLUDE += -I$(NRF5X_SDK_PATH)/components/device
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/button
INCLUDE += -I$(NRF5X_SDK_PATH)/components/libraries/timer
#INCLUDE += -I$(NRF5X_SDK_PATH)/components/softdevice/s132/headers
INCLUDE += -I$(NRF5X_SDK_PATH)/components/drivers_nrf/gpiote
INCLUDE += -I$(NRF5X_SDK_PATH)/components/ble/ble_services/ble_nus
INCLUDE += -I$(NRF5X_SDK_PATH)/components/drivers_nrf/hal
@ -1099,13 +1104,10 @@ ifdef NRF5X
$(NRF5X_SDK_PATH)/components/libraries/trace/app_trace.c \
$(NRF5X_SDK_PATH)/components/libraries/util/nrf_assert.c \
$(NRF5X_SDK_PATH)/components/libraries/uart/retarget.c \
$(NRF5X_SDK_PATH)/components/libraries/uart/app_uart_fifo.c \
$(NRF5X_SDK_PATH)/components/drivers_nrf/delay/nrf_delay.c \
$(NRF5X_SDK_PATH)/components/drivers_nrf/common/nrf_drv_common.c \
$(NRF5X_SDK_PATH)/components/drivers_nrf/gpiote/nrf_drv_gpiote.c \
$(NRF5X_SDK_PATH)/components/drivers_nrf/uart/nrf_drv_uart.c \
$(NRF5X_SDK_PATH)/components/drivers_nrf/pstorage/pstorage.c \
$(NRF5X_SDK_PATH)/examples/bsp/bsp.c \
$(NRF5X_SDK_PATH)/components/drivers_nrf/pstorage/pstorage.c \
$(NRF5X_SDK_PATH)/examples/bsp/bsp_btn_ble.c \
$(NRF5X_SDK_PATH)/components/ble/common/ble_advdata.c \
$(NRF5X_SDK_PATH)/components/ble/ble_advertising/ble_advertising.c \
@ -1259,7 +1261,7 @@ ifndef NRF5X
LDFLAGS += $(OPTIMIZEFLAGS) $(ARCHFLAGS)
else ifdef NRF5X
LDFLAGS += $(ARCHFLAGS)
endif
endif # NRF5X
ifdef EMBEDDED
DEFINES += -DEMBEDDED
@ -1313,7 +1315,7 @@ ifndef NRF5X # nRF5x devices use their own linker files that aren't automaticall
$(LINKER_FILE): scripts/build_linker.py
@echo Generating linker scripts
$(Q)python scripts/build_linker.py $(BOARD) $(LINKER_FILE) $(BUILD_LINKER_FLAGS)
endif
endif # NRF5X
$(PLATFORM_CONFIG_FILE): boards/$(BOARD).py scripts/build_platform_config.py
@echo Generating platform configs

View File

@ -19,7 +19,7 @@ info = {
'name' : "nRF51 Development Kit",
'link' : [ "https://www.nordicsemi.com/Products/Bluetooth-Smart-Bluetooth-low-energy/nRF51822" ],
'default_console' : "EV_SERIAL1",
'variables' : 750, # How many variables are allocated for Espruino to use. RAM will be overflowed if this number is too high and code won't compile.
'variables' : 200, # How many variables are allocated for Espruino to use. RAM will be overflowed if this number is too high and code won't compile.
'binary_name' : 'espruino_%v_nrf51822.bin',
};

View File

@ -132,7 +132,8 @@ uint32_t ble_advertising_init(ble_advdata_t const * p_advdata,
p_advdata->p_manuf_specific_data->company_identifier;
m_advdata.p_manuf_specific_data->data.size = p_advdata->p_manuf_specific_data->data.size;
for(uint32_t i = 0; i < m_advdata.p_manuf_specific_data->data.size; i++)
uint32_t i;
for(i = 0; i < m_advdata.p_manuf_specific_data->data.size; i++)
{
m_manuf_data_array[i] = p_advdata->p_manuf_specific_data->data.p_data[i];
}
@ -146,7 +147,8 @@ uint32_t ble_advertising_init(ble_advdata_t const * p_advdata,
m_advdata.p_service_data_array->data.size = p_advdata->p_service_data_array->data.size;
m_advdata.p_service_data_array->service_uuid = p_advdata->p_service_data_array->service_uuid;
for(uint32_t i = 0; i < m_advdata.p_service_data_array->data.size; i++)
uint32_t i;
for(i = 0; i < m_advdata.p_service_data_array->data.size; i++)
{
m_service_data_array[i] = p_advdata->p_service_data_array->data.p_data[i];
}
@ -487,7 +489,8 @@ uint32_t ble_advertising_peer_addr_reply(ble_gap_addr_t * p_peer_address)
m_peer_address.addr_type = p_peer_address->addr_type;
for (int i = 0; i < BLE_GAP_ADDR_LEN; i++)
int i;
for (i = 0; i < BLE_GAP_ADDR_LEN; i++)
{
m_peer_address.addr[i] = p_peer_address->addr[i];
}

View File

@ -603,7 +603,8 @@ static void cmd_queue_init(void)
m_cmd_queue.rp = 0;
m_cmd_queue.count = 0;
for (uint32_t cmd_index = 0; cmd_index < PSTORAGE_CMD_QUEUE_SIZE; ++cmd_index)
uint32_t cmd_index;
for (cmd_index = 0; cmd_index < PSTORAGE_CMD_QUEUE_SIZE; ++cmd_index)
{
cmd_queue_element_init(cmd_index);
}
@ -1284,7 +1285,8 @@ uint32_t pstorage_init(void)
m_next_page_addr = PSTORAGE_DATA_START_ADDR;
m_current_page_id = 0;
for (uint32_t index = 0; index < PSTORAGE_NUM_OF_PAGES; index++)
uint32_t index;
for (index = 0; index < PSTORAGE_NUM_OF_PAGES; index++)
{
m_app_table[index].cb = NULL;
m_app_table[index].block_size = 0;

View File

@ -5,8 +5,8 @@ GROUP(-lgcc -lc -lnosys)
MEMORY
{
FLASH (rx) : ORIGIN = 0x18000, LENGTH = 0x28000
RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0x6000
FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x40000
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x8000
}
/* Linker script for Nordic Semiconductor nRF5 devices

View File

@ -650,7 +650,8 @@ uint32_t bsp_buttons_disable()
uint32_t bsp_wakeup_buttons_set(uint32_t wakeup_buttons)
{
#if (BUTTONS_NUMBER > 0) && !defined(BSP_SIMPLE)
for (uint32_t i = 0; i < BUTTONS_NUMBER; i++)
uint32_t i;
for (i = 0; i < BUTTONS_NUMBER; i++)
{
uint32_t new_cnf = NRF_GPIO->PIN_CNF[m_buttons_list[i]];
uint32_t new_sense = ((1 << i) & wakeup_buttons) ? GPIO_PIN_CNF_SENSE_Low : GPIO_PIN_CNF_SENSE_Disabled;

View File

@ -81,7 +81,7 @@ bool jshIsUSBSERIALConnected() {
/// Get the system time (in ticks)
JsSysTime jshGetSystemTime()
{
//return (JsSysTime) nrf_utils_get_system_time();
return (JsSysTime) nrf_utils_get_system_time();
}
/// Set the system time (in ticks) - this should only be called rarely as it could mess up things like jsinteractive's timers!
@ -222,8 +222,7 @@ void jshUSARTKick(IOEventFlags device) {
{
uint8_t character = (uint8_t) check_valid_char;
while (app_uart_put(character) != NRF_SUCCESS); // FIX THIS!!
nrf_utils_app_uart_put(character);
}
}
@ -277,19 +276,20 @@ void jshI2CRead(IOEventFlags device, unsigned char address, int nBytes, unsigned
/// Return start address and size of the flash page the given address resides in. Returns false if no page
bool jshFlashGetPage(uint32_t addr, uint32_t *startAddr, uint32_t *pageSize) {
if (addr < 0 || addr > (FLASH_PAGE_SIZE * NUMBER_OF_PAGES))
/*if (addr < 0 || addr > (FLASH_PAGE_SIZE * NUMBER_OF_PAGES))
{
return false; // Exception?
}
&startAddr = (floor(addr / FLASH_PAGE_SIZE) * FLASH_PAGE_SIZE);
&pageSize = FLASH_PAGE_SIZE;
return true;
return true;*/
return false;
}
/// Erase the flash page containing the address
void jshFlashErasePage(uint32_t addr) {
nrf_utils_erase_flash_page(addr);
//nrf_utils_erase_flash_page(addr);
}
/// Read data from flash memory into the buffer

View File

@ -19,6 +19,8 @@
#include "nrf_gpio.h"
#include "nrf_delay.h"
#include "nrf_temp.h"
#include "app_uart.h"
#include "nrf_error.h"
#define LED1 17
#define LED2 18
@ -140,7 +142,11 @@ uint32_t nrf_utils_read_temperature(void) {
}
void nrf_utils_erase_flash_page(uint32_t addr) {
void nrf_utils_app_uart_put(uint8_t character) {
while (app_uart_put(character) != NRF_SUCCESS);
}
/*void nrf_utils_erase_flash_page(uint32_t addr) {
NRF_NVMC->CONFIG = (2UL); // Configure the NVMC for erasing.
while (NRF_NVMC->READY != (1UL)); // Wait for the NVMC to be ready.
@ -148,4 +154,4 @@ void nrf_utils_erase_flash_page(uint32_t addr) {
while (NRF_NVMC->READY != (1UL)); // Wait for the erase operation to complete.
NRF_NVMC->CONFIG = (0x0); // Set NVMC back to read only.
}
}*/

View File

@ -40,7 +40,9 @@ uint8_t nrf_utils_get_random_number(void);
uint32_t nrf_utils_get_system_time(void);
uint32_t nrf_utils_read_temperature(void);
void nrf_utils_erase_flash_page(uint32_t addr);
void nrf_utils_app_uart_put(uint8_t character);
//void nrf_utils_erase_flash_page(uint32_t addr);
#endif // NRF5X_UTILS_H__