Initial hello-world project.
This commit is contained in:
commit
0c48cd9013
|
@ -0,0 +1,114 @@
|
|||
PROJECT_NAME := uart_pca10028
|
||||
TARGETS := nrf51822_xxaa
|
||||
OUTPUT_DIRECTORY := _build
|
||||
|
||||
SDK_ROOT := $(PWD)/../../nRF_SDK/nRF5_SDK_12.3.0_d7731ad
|
||||
PROJ_DIR := ./
|
||||
|
||||
$(OUTPUT_DIRECTORY)/nrf51822_xxaa.out: \
|
||||
LINKER_SCRIPT := uart_gcc_nrf51.ld
|
||||
|
||||
# Source files common to all targets
|
||||
SRC_FILES += \
|
||||
$(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/util/app_error.c \
|
||||
$(SDK_ROOT)/components/libraries/util/app_error_weak.c \
|
||||
$(SDK_ROOT)/components/libraries/fifo/app_fifo.c \
|
||||
$(SDK_ROOT)/components/libraries/uart/app_uart_fifo.c \
|
||||
$(SDK_ROOT)/components/libraries/util/app_util_platform.c \
|
||||
$(SDK_ROOT)/components/libraries/util/nrf_assert.c \
|
||||
$(SDK_ROOT)/components/libraries/uart/retarget.c \
|
||||
$(SDK_ROOT)/components/libraries/util/sdk_errors.c \
|
||||
$(SDK_ROOT)/components/boards/boards.c \
|
||||
$(SDK_ROOT)/components/drivers_nrf/common/nrf_drv_common.c \
|
||||
$(SDK_ROOT)/components/drivers_nrf/uart/nrf_drv_uart.c \
|
||||
$(PROJ_DIR)/main.c \
|
||||
$(SDK_ROOT)/external/segger_rtt/RTT_Syscalls_GCC.c \
|
||||
$(SDK_ROOT)/external/segger_rtt/SEGGER_RTT.c \
|
||||
$(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_printf.c \
|
||||
$(SDK_ROOT)/components/toolchain/gcc/gcc_startup_nrf51.S \
|
||||
$(SDK_ROOT)/components/toolchain/system_nrf51.c \
|
||||
|
||||
# Include folders common to all targets
|
||||
INC_FOLDERS += \
|
||||
$(SDK_ROOT)/components \
|
||||
$(SDK_ROOT)/components/libraries/util \
|
||||
$(SDK_ROOT)/components/toolchain/gcc \
|
||||
$(SDK_ROOT)/components/drivers_nrf/uart \
|
||||
config \
|
||||
$(SDK_ROOT)/external/segger_rtt \
|
||||
$(SDK_ROOT)/components/drivers_nrf/common \
|
||||
$(PROJ_DIR) \
|
||||
$(SDK_ROOT)/components/libraries/fifo \
|
||||
$(SDK_ROOT)/components/libraries/bsp \
|
||||
$(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd \
|
||||
$(SDK_ROOT)/components/toolchain \
|
||||
$(SDK_ROOT)/components/libraries/uart \
|
||||
$(SDK_ROOT)/components/device \
|
||||
$(SDK_ROOT)/components/libraries/log \
|
||||
$(SDK_ROOT)/components/boards \
|
||||
$(SDK_ROOT)/components/drivers_nrf/delay \
|
||||
$(SDK_ROOT)/components/toolchain/cmsis/include \
|
||||
$(SDK_ROOT)/components/drivers_nrf/hal \
|
||||
$(SDK_ROOT)/components/libraries/log/src \
|
||||
|
||||
# Libraries common to all targets
|
||||
LIB_FILES += \
|
||||
|
||||
# C flags common to all targets
|
||||
CFLAGS += -DNRF51
|
||||
CFLAGS += -DNRF51822
|
||||
CFLAGS += -DBOARD_CUSTOM
|
||||
CFLAGS += -DBSP_DEFINES_ONLY
|
||||
CFLAGS += -mcpu=cortex-m0
|
||||
CFLAGS += -mthumb -mabi=aapcs
|
||||
CFLAGS += -Wall -Werror -O3 -g3
|
||||
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
|
||||
|
||||
# C++ flags common to all targets
|
||||
CXXFLAGS += \
|
||||
|
||||
# Assembler flags common to all targets
|
||||
ASMFLAGS += -x assembler-with-cpp
|
||||
ASMFLAGS += -DNRF51
|
||||
ASMFLAGS += -DNRF51822
|
||||
ASMFLAGS += -DBOARD_CUSTOM
|
||||
ASMFLAGS += -DBSP_DEFINES_ONLY
|
||||
|
||||
# Linker flags
|
||||
LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT)
|
||||
LDFLAGS += -mcpu=cortex-m0
|
||||
# let linker to dump unused sections
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
# use newlib in nano version
|
||||
LDFLAGS += --specs=nano.specs -lc -lnosys
|
||||
|
||||
|
||||
.PHONY: $(TARGETS) default all clean help flash
|
||||
|
||||
# Default target - first one defined
|
||||
default: nrf51822_xxaa
|
||||
|
||||
# Print all targets that can be built
|
||||
help:
|
||||
@echo following targets are available:
|
||||
@echo nrf51822_xxaa
|
||||
|
||||
TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc
|
||||
|
||||
include $(TEMPLATE_PATH)/Makefile.common
|
||||
|
||||
$(foreach target, $(TARGETS), $(call define_target, $(target)))
|
||||
|
||||
# Flash the program
|
||||
flash: $(OUTPUT_DIRECTORY)/nrf51422_xxac.hex
|
||||
@echo Flashing: $<
|
||||
nrfjprog --program $< -f nrf51 --sectorerase
|
||||
nrfjprog --reset -f nrf51
|
||||
|
||||
erase:
|
||||
nrfjprog --eraseall -f nrf52
|
|
@ -0,0 +1,88 @@
|
|||
/**
|
||||
* Copyright (c) 2014 - 2017, Nordic Semiconductor ASA
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form, except as embedded into a Nordic
|
||||
* Semiconductor ASA integrated circuit in a product or a software update for
|
||||
* such product, must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef AQI_SENSOR_H
|
||||
#define AQI_SENSOR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LEDS_NUMBER 4
|
||||
|
||||
#define LED_1 10
|
||||
#define LED_2 9
|
||||
#define LED_3 21
|
||||
#define LED_4 22
|
||||
|
||||
#define LEDS_LIST { LED_1, LED_2, LED_3, LED_4 }
|
||||
|
||||
#define LEDS_ACTIVE_STATE 1
|
||||
|
||||
#define BSP_LED_0 LED_1
|
||||
#define BSP_LED_1 LED_2
|
||||
#define BSP_LED_2 LED_3
|
||||
#define BSP_LED_3 LED_4
|
||||
|
||||
#define LEDS_INV_MASK LEDS_MASK
|
||||
|
||||
#define BUTTONS_NUMBER 1
|
||||
|
||||
#define SW_1 0
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
#define BUTTONS_LIST { SW_1 }
|
||||
|
||||
#define BUTTONS_ACTIVE_STATE 0
|
||||
|
||||
#define BSP_BUTTON_0 SW_1
|
||||
|
||||
#define RX_PIN_NUMBER 6
|
||||
#define TX_PIN_NUMBER 7
|
||||
#define HWFC false
|
||||
|
||||
#define SER_CON_RX_PIN 6
|
||||
#define SER_CON_TX_PIN 7
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,512 @@
|
|||
|
||||
|
||||
#ifndef SDK_CONFIG_H
|
||||
#define SDK_CONFIG_H
|
||||
// <<< Use Configuration Wizard in Context Menu >>>\n
|
||||
#ifdef USE_APP_CONFIG
|
||||
#include "app_config.h"
|
||||
#endif
|
||||
// <h> nRF_Drivers
|
||||
|
||||
//==========================================================
|
||||
// <e> PERIPHERAL_RESOURCE_SHARING_ENABLED - nrf_drv_common - Peripheral drivers common module
|
||||
//==========================================================
|
||||
#ifndef PERIPHERAL_RESOURCE_SHARING_ENABLED
|
||||
#define PERIPHERAL_RESOURCE_SHARING_ENABLED 0
|
||||
#endif
|
||||
#if PERIPHERAL_RESOURCE_SHARING_ENABLED
|
||||
// <e> COMMON_CONFIG_LOG_ENABLED - Enables logging in the module.
|
||||
//==========================================================
|
||||
#ifndef COMMON_CONFIG_LOG_ENABLED
|
||||
#define COMMON_CONFIG_LOG_ENABLED 0
|
||||
#endif
|
||||
#if COMMON_CONFIG_LOG_ENABLED
|
||||
// <o> COMMON_CONFIG_LOG_LEVEL - Default Severity level
|
||||
|
||||
// <0=> Off
|
||||
// <1=> Error
|
||||
// <2=> Warning
|
||||
// <3=> Info
|
||||
// <4=> Debug
|
||||
|
||||
#ifndef COMMON_CONFIG_LOG_LEVEL
|
||||
#define COMMON_CONFIG_LOG_LEVEL 3
|
||||
#endif
|
||||
|
||||
// <o> COMMON_CONFIG_INFO_COLOR - ANSI escape code prefix.
|
||||
|
||||
// <0=> Default
|
||||
// <1=> Black
|
||||
// <2=> Red
|
||||
// <3=> Green
|
||||
// <4=> Yellow
|
||||
// <5=> Blue
|
||||
// <6=> Magenta
|
||||
// <7=> Cyan
|
||||
// <8=> White
|
||||
|
||||
#ifndef COMMON_CONFIG_INFO_COLOR
|
||||
#define COMMON_CONFIG_INFO_COLOR 0
|
||||
#endif
|
||||
|
||||
// <o> COMMON_CONFIG_DEBUG_COLOR - ANSI escape code prefix.
|
||||
|
||||
// <0=> Default
|
||||
// <1=> Black
|
||||
// <2=> Red
|
||||
// <3=> Green
|
||||
// <4=> Yellow
|
||||
// <5=> Blue
|
||||
// <6=> Magenta
|
||||
// <7=> Cyan
|
||||
// <8=> White
|
||||
|
||||
#ifndef COMMON_CONFIG_DEBUG_COLOR
|
||||
#define COMMON_CONFIG_DEBUG_COLOR 0
|
||||
#endif
|
||||
|
||||
#endif //COMMON_CONFIG_LOG_ENABLED
|
||||
// </e>
|
||||
|
||||
#endif //PERIPHERAL_RESOURCE_SHARING_ENABLED
|
||||
// </e>
|
||||
|
||||
// <e> UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver
|
||||
//==========================================================
|
||||
#ifndef UART_ENABLED
|
||||
#define UART_ENABLED 1
|
||||
#endif
|
||||
#if UART_ENABLED
|
||||
// <o> UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control
|
||||
|
||||
// <0=> Disabled
|
||||
// <1=> Enabled
|
||||
|
||||
#ifndef UART_DEFAULT_CONFIG_HWFC
|
||||
#define UART_DEFAULT_CONFIG_HWFC 0
|
||||
#endif
|
||||
|
||||
// <o> UART_DEFAULT_CONFIG_PARITY - Parity
|
||||
|
||||
// <0=> Excluded
|
||||
// <14=> Included
|
||||
|
||||
#ifndef UART_DEFAULT_CONFIG_PARITY
|
||||
#define UART_DEFAULT_CONFIG_PARITY 0
|
||||
#endif
|
||||
|
||||
// <o> UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate
|
||||
|
||||
// <323584=> 1200 baud
|
||||
// <643072=> 2400 baud
|
||||
// <1290240=> 4800 baud
|
||||
// <2576384=> 9600 baud
|
||||
// <3862528=> 14400 baud
|
||||
// <5152768=> 19200 baud
|
||||
// <7716864=> 28800 baud
|
||||
// <10289152=> 38400 baud
|
||||
// <15400960=> 57600 baud
|
||||
// <20615168=> 76800 baud
|
||||
// <30924800=> 115200 baud
|
||||
// <61865984=> 230400 baud
|
||||
// <67108864=> 250000 baud
|
||||
// <121634816=> 460800 baud
|
||||
// <251658240=> 921600 baud
|
||||
// <268435456=> 57600 baud
|
||||
|
||||
#ifndef UART_DEFAULT_CONFIG_BAUDRATE
|
||||
#define UART_DEFAULT_CONFIG_BAUDRATE 30924800
|
||||
#endif
|
||||
|
||||
// <o> UART_DEFAULT_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
|
||||
|
||||
#ifndef UART_DEFAULT_CONFIG_IRQ_PRIORITY
|
||||
#define UART_DEFAULT_CONFIG_IRQ_PRIORITY 3
|
||||
#endif
|
||||
|
||||
// <q> UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA
|
||||
|
||||
|
||||
#ifndef UART_EASY_DMA_SUPPORT
|
||||
#define UART_EASY_DMA_SUPPORT 1
|
||||
#endif
|
||||
|
||||
// <q> UART_LEGACY_SUPPORT - Driver supporting Legacy mode
|
||||
|
||||
|
||||
#ifndef UART_LEGACY_SUPPORT
|
||||
#define UART_LEGACY_SUPPORT 1
|
||||
#endif
|
||||
|
||||
// <e> UART0_ENABLED - Enable UART0 instance
|
||||
//==========================================================
|
||||
#ifndef UART0_ENABLED
|
||||
#define UART0_ENABLED 1
|
||||
#endif
|
||||
#if UART0_ENABLED
|
||||
// <q> UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA
|
||||
|
||||
|
||||
#ifndef UART0_CONFIG_USE_EASY_DMA
|
||||
#define UART0_CONFIG_USE_EASY_DMA 1
|
||||
#endif
|
||||
|
||||
#endif //UART0_ENABLED
|
||||
// </e>
|
||||
|
||||
// <e> UART_CONFIG_LOG_ENABLED - Enables logging in the module.
|
||||
//==========================================================
|
||||
#ifndef UART_CONFIG_LOG_ENABLED
|
||||
#define UART_CONFIG_LOG_ENABLED 0
|
||||
#endif
|
||||
#if UART_CONFIG_LOG_ENABLED
|
||||
// <o> UART_CONFIG_LOG_LEVEL - Default Severity level
|
||||
|
||||
// <0=> Off
|
||||
// <1=> Error
|
||||
// <2=> Warning
|
||||
// <3=> Info
|
||||
// <4=> Debug
|
||||
|
||||
#ifndef UART_CONFIG_LOG_LEVEL
|
||||
#define UART_CONFIG_LOG_LEVEL 3
|
||||
#endif
|
||||
|
||||
// <o> UART_CONFIG_INFO_COLOR - ANSI escape code prefix.
|
||||
|
||||
// <0=> Default
|
||||
// <1=> Black
|
||||
// <2=> Red
|
||||
// <3=> Green
|
||||
// <4=> Yellow
|
||||
// <5=> Blue
|
||||
// <6=> Magenta
|
||||
// <7=> Cyan
|
||||
// <8=> White
|
||||
|
||||
#ifndef UART_CONFIG_INFO_COLOR
|
||||
#define UART_CONFIG_INFO_COLOR 0
|
||||
#endif
|
||||
|
||||
// <o> UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix.
|
||||
|
||||
// <0=> Default
|
||||
// <1=> Black
|
||||
// <2=> Red
|
||||
// <3=> Green
|
||||
// <4=> Yellow
|
||||
// <5=> Blue
|
||||
// <6=> Magenta
|
||||
// <7=> Cyan
|
||||
// <8=> White
|
||||
|
||||
#ifndef UART_CONFIG_DEBUG_COLOR
|
||||
#define UART_CONFIG_DEBUG_COLOR 0
|
||||
#endif
|
||||
|
||||
#endif //UART_CONFIG_LOG_ENABLED
|
||||
// </e>
|
||||
|
||||
#endif //UART_ENABLED
|
||||
// </e>
|
||||
|
||||
// </h>
|
||||
//==========================================================
|
||||
|
||||
// <h> nRF_Libraries
|
||||
|
||||
//==========================================================
|
||||
// <q> APP_FIFO_ENABLED - app_fifo - Software FIFO implementation
|
||||
|
||||
|
||||
#ifndef APP_FIFO_ENABLED
|
||||
#define APP_FIFO_ENABLED 1
|
||||
#endif
|
||||
|
||||
// <e> APP_UART_ENABLED - app_uart - UART driver
|
||||
//==========================================================
|
||||
#ifndef APP_UART_ENABLED
|
||||
#define APP_UART_ENABLED 1
|
||||
#endif
|
||||
#if APP_UART_ENABLED
|
||||
// <o> APP_UART_DRIVER_INSTANCE - UART instance used
|
||||
|
||||
// <0=> 0
|
||||
|
||||
#ifndef APP_UART_DRIVER_INSTANCE
|
||||
#define APP_UART_DRIVER_INSTANCE 0
|
||||
#endif
|
||||
|
||||
#endif //APP_UART_ENABLED
|
||||
// </e>
|
||||
|
||||
// <q> RETARGET_ENABLED - retarget - Retargeting stdio functions
|
||||
|
||||
|
||||
#ifndef RETARGET_ENABLED
|
||||
#define RETARGET_ENABLED 1
|
||||
#endif
|
||||
|
||||
// </h>
|
||||
//==========================================================
|
||||
|
||||
// <h> nRF_Log
|
||||
|
||||
//==========================================================
|
||||
// <e> NRF_LOG_ENABLED - nrf_log - Logging
|
||||
//==========================================================
|
||||
#ifndef NRF_LOG_ENABLED
|
||||
#define NRF_LOG_ENABLED 0
|
||||
#endif
|
||||
#if NRF_LOG_ENABLED
|
||||
// <e> NRF_LOG_USES_COLORS - If enabled then ANSI escape code for colors is prefixed to every string
|
||||
//==========================================================
|
||||
#ifndef NRF_LOG_USES_COLORS
|
||||
#define NRF_LOG_USES_COLORS 0
|
||||
#endif
|
||||
#if NRF_LOG_USES_COLORS
|
||||
// <o> NRF_LOG_COLOR_DEFAULT - ANSI escape code prefix.
|
||||
|
||||
// <0=> Default
|
||||
// <1=> Black
|
||||
// <2=> Red
|
||||
// <3=> Green
|
||||
// <4=> Yellow
|
||||
// <5=> Blue
|
||||
// <6=> Magenta
|
||||
// <7=> Cyan
|
||||
// <8=> White
|
||||
|
||||
#ifndef NRF_LOG_COLOR_DEFAULT
|
||||
#define NRF_LOG_COLOR_DEFAULT 0
|
||||
#endif
|
||||
|
||||
// <o> NRF_LOG_ERROR_COLOR - ANSI escape code prefix.
|
||||
|
||||
// <0=> Default
|
||||
// <1=> Black
|
||||
// <2=> Red
|
||||
// <3=> Green
|
||||
// <4=> Yellow
|
||||
// <5=> Blue
|
||||
// <6=> Magenta
|
||||
// <7=> Cyan
|
||||
// <8=> White
|
||||
|
||||
#ifndef NRF_LOG_ERROR_COLOR
|
||||
#define NRF_LOG_ERROR_COLOR 0
|
||||
#endif
|
||||
|
||||
// <o> NRF_LOG_WARNING_COLOR - ANSI escape code prefix.
|
||||
|
||||
// <0=> Default
|
||||
// <1=> Black
|
||||
// <2=> Red
|
||||
// <3=> Green
|
||||
// <4=> Yellow
|
||||
// <5=> Blue
|
||||
// <6=> Magenta
|
||||
// <7=> Cyan
|
||||
// <8=> White
|
||||
|
||||
#ifndef NRF_LOG_WARNING_COLOR
|
||||
#define NRF_LOG_WARNING_COLOR 0
|
||||
#endif
|
||||
|
||||
#endif //NRF_LOG_USES_COLORS
|
||||
// </e>
|
||||
|
||||
// <o> NRF_LOG_DEFAULT_LEVEL - Default Severity level
|
||||
|
||||
// <0=> Off
|
||||
// <1=> Error
|
||||
// <2=> Warning
|
||||
// <3=> Info
|
||||
// <4=> Debug
|
||||
|
||||
#ifndef NRF_LOG_DEFAULT_LEVEL
|
||||
#define NRF_LOG_DEFAULT_LEVEL 3
|
||||
#endif
|
||||
|
||||
// <e> NRF_LOG_DEFERRED - Enable deffered logger.
|
||||
|
||||
// <i> Log data is buffered and can be processed in idle.
|
||||
//==========================================================
|
||||
#ifndef NRF_LOG_DEFERRED
|
||||
#define NRF_LOG_DEFERRED 1
|
||||
#endif
|
||||
#if NRF_LOG_DEFERRED
|
||||
// <o> NRF_LOG_DEFERRED_BUFSIZE - Size of the buffer for logs in words.
|
||||
// <i> Must be power of 2
|
||||
|
||||
#ifndef NRF_LOG_DEFERRED_BUFSIZE
|
||||
#define NRF_LOG_DEFERRED_BUFSIZE 256
|
||||
#endif
|
||||
|
||||
#endif //NRF_LOG_DEFERRED
|
||||
// </e>
|
||||
|
||||
// <q> NRF_LOG_USES_TIMESTAMP - Enable timestamping
|
||||
|
||||
|
||||
// <i> Function for getting the timestamp is provided by the user
|
||||
|
||||
#ifndef NRF_LOG_USES_TIMESTAMP
|
||||
#define NRF_LOG_USES_TIMESTAMP 0
|
||||
#endif
|
||||
|
||||
#endif //NRF_LOG_ENABLED
|
||||
// </e>
|
||||
|
||||
// <h> nrf_log_backend - Logging sink
|
||||
|
||||
//==========================================================
|
||||
// <o> NRF_LOG_BACKEND_MAX_STRING_LENGTH - Buffer for storing single output string
|
||||
// <i> Logger backend RAM usage is determined by this value.
|
||||
|
||||
#ifndef NRF_LOG_BACKEND_MAX_STRING_LENGTH
|
||||
#define NRF_LOG_BACKEND_MAX_STRING_LENGTH 256
|
||||
#endif
|
||||
|
||||
// <o> NRF_LOG_TIMESTAMP_DIGITS - Number of digits for timestamp
|
||||
// <i> If higher resolution timestamp source is used it might be needed to increase that
|
||||
|
||||
#ifndef NRF_LOG_TIMESTAMP_DIGITS
|
||||
#define NRF_LOG_TIMESTAMP_DIGITS 8
|
||||
#endif
|
||||
|
||||
// <e> NRF_LOG_BACKEND_SERIAL_USES_UART - If enabled data is printed over UART
|
||||
//==========================================================
|
||||
#ifndef NRF_LOG_BACKEND_SERIAL_USES_UART
|
||||
#define NRF_LOG_BACKEND_SERIAL_USES_UART 1
|
||||
#endif
|
||||
#if NRF_LOG_BACKEND_SERIAL_USES_UART
|
||||
// <o> NRF_LOG_BACKEND_SERIAL_UART_BAUDRATE - Default Baudrate
|
||||
|
||||
// <323584=> 1200 baud
|
||||
// <643072=> 2400 baud
|
||||
// <1290240=> 4800 baud
|
||||
// <2576384=> 9600 baud
|
||||
// <3862528=> 14400 baud
|
||||
// <5152768=> 19200 baud
|
||||
// <7716864=> 28800 baud
|
||||
// <10289152=> 38400 baud
|
||||
// <15400960=> 57600 baud
|
||||
// <20615168=> 76800 baud
|
||||
// <30924800=> 115200 baud
|
||||
// <61865984=> 230400 baud
|
||||
// <67108864=> 250000 baud
|
||||
// <121634816=> 460800 baud
|
||||
// <251658240=> 921600 baud
|
||||
// <268435456=> 57600 baud
|
||||
|
||||
#ifndef NRF_LOG_BACKEND_SERIAL_UART_BAUDRATE
|
||||
#define NRF_LOG_BACKEND_SERIAL_UART_BAUDRATE 30924800
|
||||
#endif
|
||||
|
||||
// <o> NRF_LOG_BACKEND_SERIAL_UART_TX_PIN - UART TX pin
|
||||
#ifndef NRF_LOG_BACKEND_SERIAL_UART_TX_PIN
|
||||
#define NRF_LOG_BACKEND_SERIAL_UART_TX_PIN 9
|
||||
#endif
|
||||
|
||||
// <o> NRF_LOG_BACKEND_SERIAL_UART_RX_PIN - UART RX pin
|
||||
#ifndef NRF_LOG_BACKEND_SERIAL_UART_RX_PIN
|
||||
#define NRF_LOG_BACKEND_SERIAL_UART_RX_PIN 11
|
||||
#endif
|
||||
|
||||
// <o> NRF_LOG_BACKEND_SERIAL_UART_RTS_PIN - UART RTS pin
|
||||
#ifndef NRF_LOG_BACKEND_SERIAL_UART_RTS_PIN
|
||||
#define NRF_LOG_BACKEND_SERIAL_UART_RTS_PIN 8
|
||||
#endif
|
||||
|
||||
// <o> NRF_LOG_BACKEND_SERIAL_UART_CTS_PIN - UART CTS pin
|
||||
#ifndef NRF_LOG_BACKEND_SERIAL_UART_CTS_PIN
|
||||
#define NRF_LOG_BACKEND_SERIAL_UART_CTS_PIN 10
|
||||
#endif
|
||||
|
||||
// <o> NRF_LOG_BACKEND_SERIAL_UART_FLOW_CONTROL - Hardware Flow Control
|
||||
|
||||
// <0=> Disabled
|
||||
// <1=> Enabled
|
||||
|
||||
#ifndef NRF_LOG_BACKEND_SERIAL_UART_FLOW_CONTROL
|
||||
#define NRF_LOG_BACKEND_SERIAL_UART_FLOW_CONTROL 0
|
||||
#endif
|
||||
|
||||
// <o> NRF_LOG_BACKEND_UART_INSTANCE - UART instance used
|
||||
|
||||
// <0=> 0
|
||||
|
||||
#ifndef NRF_LOG_BACKEND_UART_INSTANCE
|
||||
#define NRF_LOG_BACKEND_UART_INSTANCE 0
|
||||
#endif
|
||||
|
||||
#endif //NRF_LOG_BACKEND_SERIAL_USES_UART
|
||||
// </e>
|
||||
|
||||
// <e> NRF_LOG_BACKEND_SERIAL_USES_RTT - If enabled data is printed using RTT
|
||||
//==========================================================
|
||||
#ifndef NRF_LOG_BACKEND_SERIAL_USES_RTT
|
||||
#define NRF_LOG_BACKEND_SERIAL_USES_RTT 0
|
||||
#endif
|
||||
#if NRF_LOG_BACKEND_SERIAL_USES_RTT
|
||||
// <o> NRF_LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE - RTT output buffer size.
|
||||
// <i> Should be equal or bigger than \ref NRF_LOG_BACKEND_MAX_STRING_LENGTH.
|
||||
// <i> This value is used in Segger RTT configuration to set the buffer size
|
||||
// <i> if it is bigger than default RTT buffer size.
|
||||
|
||||
#ifndef NRF_LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE
|
||||
#define NRF_LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE 512
|
||||
#endif
|
||||
|
||||
#endif //NRF_LOG_BACKEND_SERIAL_USES_RTT
|
||||
// </e>
|
||||
|
||||
// </h>
|
||||
//==========================================================
|
||||
|
||||
// </h>
|
||||
//==========================================================
|
||||
|
||||
// <h> nRF_Segger_RTT
|
||||
|
||||
//==========================================================
|
||||
// <h> segger_rtt - SEGGER RTT
|
||||
|
||||
//==========================================================
|
||||
// <o> SEGGER_RTT_CONFIG_BUFFER_SIZE_UP - Size of upstream buffer.
|
||||
#ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_UP
|
||||
#define SEGGER_RTT_CONFIG_BUFFER_SIZE_UP 64
|
||||
#endif
|
||||
|
||||
// <o> SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Size of upstream buffer.
|
||||
#ifndef SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS
|
||||
#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 2
|
||||
#endif
|
||||
|
||||
// <o> SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of upstream buffer.
|
||||
#ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN
|
||||
#define SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN 16
|
||||
#endif
|
||||
|
||||
// <o> SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS - Size of upstream buffer.
|
||||
#ifndef SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS
|
||||
#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 2
|
||||
#endif
|
||||
|
||||
// </h>
|
||||
//==========================================================
|
||||
|
||||
// </h>
|
||||
//==========================================================
|
||||
|
||||
// <<< end of configuration section >>>
|
||||
#endif //SDK_CONFIG_H
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "app_uart.h"
|
||||
#include "app_error.h"
|
||||
#include "nrf_delay.h"
|
||||
#include "nrf.h"
|
||||
#include "bsp.h"
|
||||
|
||||
int main(void) {
|
||||
bsp_board_leds_init();
|
||||
while (true) {
|
||||
nrf_delay_ms(1000);
|
||||
bsp_board_led_invert(3);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
#
|
||||
# script for Nordic nRF51 series, a Cortex-M0 chip
|
||||
#
|
||||
|
||||
source [find target/swj-dp.tcl]
|
||||
|
||||
if { [info exists CHIPNAME] } {
|
||||
set _CHIPNAME $CHIPNAME
|
||||
} else {
|
||||
set _CHIPNAME nrf51
|
||||
}
|
||||
|
||||
if { [info exists ENDIAN] } {
|
||||
set _ENDIAN $ENDIAN
|
||||
} else {
|
||||
set _ENDIAN little
|
||||
}
|
||||
|
||||
# Work-area is a space in RAM used for flash programming
|
||||
# By default use 16kB
|
||||
if { [info exists WORKAREASIZE] } {
|
||||
set _WORKAREASIZE $WORKAREASIZE
|
||||
} else {
|
||||
set _WORKAREASIZE 0
|
||||
}
|
||||
|
||||
if { [info exists CPUTAPID] } {
|
||||
set _CPUTAPID $CPUTAPID
|
||||
} else {
|
||||
set _CPUTAPID 0x0bb11477
|
||||
}
|
||||
|
||||
swj_newdap $_CHIPNAME cpu -expected-id $_CPUTAPID
|
||||
dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
|
||||
|
||||
set _TARGETNAME $_CHIPNAME.cpu
|
||||
target create $_TARGETNAME cortex_m -dap $_CHIPNAME.dap
|
||||
|
||||
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
|
||||
|
||||
if {![using_hla]} {
|
||||
# The chip supports standard ARM/Cortex-M0 SYSRESETREQ signal
|
||||
cortex_m reset_config sysresetreq
|
||||
}
|
||||
|
||||
flash bank $_CHIPNAME.flash nrf51 0x00000000 0 1 1 $_TARGETNAME
|
||||
flash bank $_CHIPNAME.uicr nrf51 0x10001000 0 1 1 $_TARGETNAME
|
||||
|
||||
#
|
||||
# The chip should start up from internal 16Mhz RC, so setting adapter
|
||||
# clock to 1Mhz should be OK
|
||||
#
|
||||
adapter speed 1000
|
||||
|
||||
proc enable_all_ram {} {
|
||||
# nRF51822 Product Anomaly Notice (PAN) #16 explains that not all RAM banks
|
||||
# are reliably enabled after reset on some revisions (contrary to spec.) So after
|
||||
# resetting we enable all banks via the RAMON register
|
||||
mww 0x40000524 0xF
|
||||
}
|
||||
$_TARGETNAME configure -event reset-end { enable_all_ram }
|
|
@ -0,0 +1,28 @@
|
|||
/* Linker script to configure memory regions. */
|
||||
|
||||
SEARCH_DIR(.)
|
||||
GROUP(-lgcc -lc -lnosys)
|
||||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x40000
|
||||
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x4000
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.fs_data :
|
||||
{
|
||||
PROVIDE(__start_fs_data = .);
|
||||
KEEP(*(.fs_data))
|
||||
PROVIDE(__stop_fs_data = .);
|
||||
} > RAM
|
||||
.pwr_mgmt_data :
|
||||
{
|
||||
PROVIDE(__start_pwr_mgmt_data = .);
|
||||
KEEP(*(.pwr_mgmt_data))
|
||||
PROVIDE(__stop_pwr_mgmt_data = .);
|
||||
} > RAM
|
||||
} INSERT AFTER .data;
|
||||
|
||||
INCLUDE "nrf5x_common.ld"
|
Loading…
Reference in New Issue