Commit 8d72c2a7 authored by Dmitry Frank's avatar Dmitry Frank Committed by Cesanta Bot

Add HTTP example for nRF

PUBLISHED_FROM=d9d979057d5269ac32d16545dd2489485bda642a
parent c722cfec
......@@ -3,7 +3,7 @@
# `wildcard ./*/` works in both linux and linux/wine, while `wildcard */` enumerates nothing under wine
SUBDIRS = $(sort $(dir $(wildcard ./*/)))
SUBDIRS:=$(filter-out ./ ./CC3200/ ./ESP8266_RTOS/ ./MSP432/ ./NXP_K64/ ./PIC32/ ./STM32F4_CC3100/ ./mbed/, $(SUBDIRS))
SUBDIRS:=$(filter-out ./ ./CC3200/ ./ESP8266_RTOS/ ./MSP432/ ./NXP_K64/ ./PIC32/ ./STM32F4_CC3100/ ./mbed/ ./nRF52/, $(SUBDIRS))
ifeq ($(OS), Windows_NT)
SUBDIRS:=$(filter-out ./load_balancer/ ./netcat/ ./raspberry_pi_mjpeg_led/ ./captive_dns_server/, $(SUBDIRS))
......
target extended-remote localhost:2331
file out/example.out
SDK ?= $(shell cat sdk.version)
SRC_DIR ?= $(realpath ../../..)
.PHONY: all clean flash gdbserver gdb jlinkexe rtt
MAKEFLAGS += w
ifeq ("$(VERBOSE)","1")
V :=
else
V := @
endif
ADD_DOCKER_ARGS =
# For communication with the device, we need docker container to be able
# to access it.
flash gdbserver gdb jlinkexe rtt: \
ADD_DOCKER_ARGS = --privileged -v /dev/bus/usb:/dev/bus/usb --net=host
all clean flash gdbserver gdb jlinkexe rtt:
$(V)docker run --rm -it $(ADD_DOCKER_ARGS) -v $(SRC_DIR):/src $(SDK) \
/bin/bash -c "\
make -C /src/mongoose mongoose.c mongoose.h && \
make -C /src/mongoose/examples/nRF52 -f Makefile.build $@ -$(MAKEFLAGS) \
"
This diff is collapsed.
# nRF52 example project
This example shows how to use mongoose on nRF52 boards.
To run it you will need:
- [nRF52 DK](https://www.nordicsemi.com/Products/Getting-started-with-the-nRF52-Development-Kit) dev board
- Linux machine with 6lowpan module enabled. There are a few tutorials out there,
e.g [this one](https://devzone.nordicsemi.com/blogs/972/setting-up-ipv6-over-ble-using-nrf52-series-and-co/)
- [Docker](https://docs.docker.com/engine/installation/linux/)
## Building firmware and cleaning
Nothing special: `make` and `make clean`.
## Flashing
`make flash`
## Watch debug output
This is a two-step process:
- In a separate terminal, invoke `make jlinkexe`. It will run `JLinkExe`
utility, in which you'll need to type `connect`. You can actually do a lot of
things there, including halting and stopping the target, flashing firmware,
etc. You can type `?` to get the list of all available commands.
- Now, in another terminal, invoke `make rtt`. It will start RTT client which
will connect to the running `JLinkExe` and will show logs from the device.
## Debug with GDB
This is a two-step process:
- In a separate terminal, invoke `make gdbserver`. Note that `make jlinkexe`
and `make gdbserver`, unfortunately, cannot run sumultaneously.
- Now, in another terminal, invoke `make gdb`. It will start GDB session which
will connect to the running GDB server.
This diff is collapsed.
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
* All rights reserved
*/
/* clang-format off */
void bleconfig_init(void);
void bleconfig_poll(void);
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
* All rights reserved
*/
#if !defined(COMMISSIONING_ENABLED) /* ifdef-ok */
# define COMMISSIONING_ENABLED 0
#endif
/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is property of Nordic Semiconductor ASA.
* Terms and conditions of usage are described in detail in NORDIC
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
*
* Licensees are granted free, non-transferable use of the information. NO
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
* the file.
*/
/** @cond To make doxygen skip this file */
/** @file
* This header contains defines with respect to the IPv6 medium that are specific to
* the BLE implementation and the application use case.
* @{
*/
#ifndef IPV6_MEDIUM_BLE_CONFIG_H__
#define IPV6_MEDIUM_BLE_CONFIG_H__
#include "app_util.h"
#define DEVICE_NAME "TCP_Server" /**< Device name used in BLE undirected advertisement. */
#define IS_SRVC_CHANGED_CHARACT_PRESENT 0
#define COMPANY_IDENTIFIER 0x0059 /**< Company identifier for Nordic Semiconductor ASA as per www.bluetooth.org. */
#define APP_TIMER_PRESCALER 31 /**< Value of the RTC1 PRESCALER register. */
#define APP_ADV_ADV_INTERVAL MSEC_TO_UNITS(333, UNIT_0_625_MS) /**< The advertising interval. This value can vary between 100ms to 10.24s). */
#define APP_ADV_TIMEOUT 0 /**< Time for which the device must be advertising in non-connectable mode (in seconds). 0 disables timeout. */
/*lint -emacro(524, MIN_CONN_INTERVAL) // Loss of precision */
#define MIN_CONN_INTERVAL MSEC_TO_UNITS(7.5, UNIT_1_25_MS) /**< Minimum connection interval (7.5 ms) */
#define MAX_CONN_INTERVAL MSEC_TO_UNITS(30, UNIT_1_25_MS) /**< Maximum connection interval (30 ms). */
#define SLAVE_LATENCY 6 /**< Slave latency. */
#define CONN_SUP_TIMEOUT MSEC_TO_UNITS(430, UNIT_10_MS) /**< Connection supervisory timeout (430 ms). */
#ifdef COMMISSIONING_ENABLED
#define CONFIG_MODE_DEVICE_NAME "NodeCFG" /**< Name of device. Will be included in the advertising data. */
/*lint -emacro(524, MIN_CONN_INTERVAL) // Loss of precision */
#define CONFIG_MODE_MIN_CONN_INTERVAL MSEC_TO_UNITS(400, UNIT_1_25_MS) /**< Config mode: Minimum acceptable connection interval (0.4 seconds). */
#define CONFIG_MODE_MAX_CONN_INTERVAL MSEC_TO_UNITS(650, UNIT_1_25_MS) /**< Config mode: Maximum acceptable connection interval (0.65 second). */
#define CONFIG_MODE_SLAVE_LATENCY 0 /**< Config mode: Slave latency. */
#define CONFIG_MODE_CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS) /**< Config mode: Connection supervisory timeout (4 seconds). */
#define CONFIG_MODE_ADV_ADV_INTERVAL MSEC_TO_UNITS(333, UNIT_0_625_MS) /**< Config mode: The advertising interval. This value can vary between 100ms to 10.24s). */
#define CONFIG_MODE_ADV_TIMEOUT 0 /**< Config mode: Time for which the device must be advertising in non-connectable mode (in seconds). 0 disables timeout. */
#define JOINING_MODE_MIN_CONN_INTERVAL MSEC_TO_UNITS(400, UNIT_1_25_MS) /**< Joining mode: Minimum acceptable connection interval (0.4 seconds). */
#define JOINING_MODE_MAX_CONN_INTERVAL MSEC_TO_UNITS(650, UNIT_1_25_MS) /**< Joining mode: Maximum acceptable connection interval (0.65 second). */
#define JOINING_MODE_SLAVE_LATENCY 0 /**< Joining mode: Slave latency. */
#define JOINING_MODE_CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS) /**< Joining mode: Connection supervisory timeout (4 seconds). */
#define JOINING_MODE_ADV_ADV_INTERVAL MSEC_TO_UNITS(333, UNIT_0_625_MS) /**< Joining mode: The advertising interval. This value can vary between 100ms to 10.24s). */
#define JOINING_MODE_ADV_TIMEOUT 0 /**< Joining mode: Time for which the device must be advertising in non-connectable mode (in seconds). 0 disables timeout. */
#endif // COMMISSIONING_ENABLED
#endif // IPV6_MEDIUM_BLE_CONFIG_H__
/** @} */
/** @endcond */
/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is property of Nordic Semiconductor ASA.
* Terms and conditions of usage are described in detail in NORDIC
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
*
* Licensees are granted free, non-transferable use of the information. NO
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
* the file.
*/
/** @cond To make doxygen skip this file */
/** @file
* This header needs to include the desired IPv6 medium implementation(s).
* Based on the chosen implementation, it also definitions that are specific to
* the IPv6 medium implementation(s) and the application use case.
* @{
*/
#ifndef IPV6_MEDIUM_PLATFORM_H__
#define IPV6_MEDIUM_PLATFORM_H__
#include "ipv6_medium_ble.h"
#ifdef COMMISSIONING_ENABLED
#include "commissioning.h"
#endif // COMMISSIONING_ENABLED
typedef union
{
ipv6_medium_ble_cb_params_t ble;
#ifdef COMMISSIONING_ENABLED
commissioning_evt_t commissioning;
#endif // COMMISSIONING_ENABLED
} ipv6_medium_cb_params_union_t;
typedef union
{
ipv6_medium_ble_error_params_t ble;
#ifdef COMMISSIONING_ENABLED
commissioning_evt_t commissioning;
#endif // COMMISSIONING_ENABLED
} ipv6_medium_err_params_union_t;
#endif // IPV6_MEDIUM_PLATFORM_H__
/** @} */
/** @endcond */
/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is property of Nordic Semiconductor ASA.
* Terms and conditions of usage are described in detail in NORDIC
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
*
* Licensees are granted free, non-transferable use of the information. NO
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
* the file.
*
*/
#ifndef NRF_DRV_CONFIG_H
#define NRF_DRV_CONFIG_H
/* CLOCK */
#define CLOCK_CONFIG_XTAL_FREQ NRF_CLOCK_XTALFREQ_Default
#define CLOCK_CONFIG_LF_SRC NRF_CLOCK_LF_SRC_Xtal
#define CLOCK_CONFIG_LF_RC_CAL_INTERVAL RC_2000MS_CALIBRATION_INTERVAL
#define CLOCK_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
/* GPIOTE */
#define GPIOTE_ENABLED 1
#if (GPIOTE_ENABLED == 1)
#define GPIOTE_CONFIG_USE_SWI_EGU false
#define GPIOTE_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 4
#endif
/* TIMER */
#define TIMER0_ENABLED 0
#if (TIMER0_ENABLED == 1)
#define TIMER0_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
#define TIMER0_CONFIG_MODE TIMER_MODE_MODE_Timer
#define TIMER0_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_32Bit
#define TIMER0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define TIMER0_INSTANCE_INDEX 0
#endif
#define TIMER1_ENABLED 0
#if (TIMER1_ENABLED == 1)
#define TIMER1_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
#define TIMER1_CONFIG_MODE TIMER_MODE_MODE_Timer
#define TIMER1_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit
#define TIMER1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define TIMER1_INSTANCE_INDEX (TIMER0_ENABLED)
#endif
#define TIMER2_ENABLED 0
#if (TIMER2_ENABLED == 1)
#define TIMER2_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
#define TIMER2_CONFIG_MODE TIMER_MODE_MODE_Timer
#define TIMER2_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit
#define TIMER2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define TIMER2_INSTANCE_INDEX (TIMER1_ENABLED+TIMER0_ENABLED)
#endif
#define TIMER3_ENABLED 0
#if (TIMER3_ENABLED == 1)
#define TIMER3_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
#define TIMER3_CONFIG_MODE TIMER_MODE_MODE_Timer
#define TIMER3_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit
#define TIMER3_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define TIMER3_INSTANCE_INDEX (TIMER2_ENABLED+TIMER1_ENABLED+TIMER0_ENABLED)
#endif
#define TIMER4_ENABLED 0
#if (TIMER4_ENABLED == 1)
#define TIMER4_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
#define TIMER4_CONFIG_MODE TIMER_MODE_MODE_Timer
#define TIMER4_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit
#define TIMER4_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define TIMER4_INSTANCE_INDEX (TIMER3_ENABLED+TIMER2_ENABLED+TIMER1_ENABLED+TIMER0_ENABLED)
#endif
#define TIMER_COUNT (TIMER0_ENABLED + TIMER1_ENABLED + TIMER2_ENABLED + TIMER3_ENABLED + TIMER4_ENABLED)
/* RTC */
#define RTC0_ENABLED 0
#if (RTC0_ENABLED == 1)
#define RTC0_CONFIG_FREQUENCY 32678
#define RTC0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define RTC0_CONFIG_RELIABLE false
#define RTC0_INSTANCE_INDEX 0
#endif
#define RTC1_ENABLED 0
#if (RTC1_ENABLED == 1)
#define RTC1_CONFIG_FREQUENCY 32768
#define RTC1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define RTC1_CONFIG_RELIABLE false
#define RTC1_INSTANCE_INDEX (RTC0_ENABLED)
#endif
#define RTC_COUNT (RTC0_ENABLED+RTC1_ENABLED)
#define NRF_MAXIMUM_LATENCY_US 2000
/* RNG */
#define RNG_ENABLED 0
#if (RNG_ENABLED == 1)
#define RNG_CONFIG_ERROR_CORRECTION true
#define RNG_CONFIG_POOL_SIZE 8
#define RNG_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#endif
/* SPI */
#define SPI0_ENABLED 0
#if (SPI0_ENABLED == 1)
#define SPI0_USE_EASY_DMA 0
#define SPI0_CONFIG_SCK_PIN 2
#define SPI0_CONFIG_MOSI_PIN 3
#define SPI0_CONFIG_MISO_PIN 4
#define SPI0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define SPI0_INSTANCE_INDEX 0
#endif
#define SPI1_ENABLED 0
#if (SPI1_ENABLED == 1)
#define SPI1_USE_EASY_DMA 0
#define SPI1_CONFIG_SCK_PIN 2
#define SPI1_CONFIG_MOSI_PIN 3
#define SPI1_CONFIG_MISO_PIN 4
#define SPI1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define SPI1_INSTANCE_INDEX (SPI0_ENABLED)
#endif
#define SPI2_ENABLED 0
#if (SPI2_ENABLED == 1)
#define SPI2_USE_EASY_DMA 0
#define SPI2_CONFIG_SCK_PIN 2
#define SPI2_CONFIG_MOSI_PIN 3
#define SPI2_CONFIG_MISO_PIN 4
#define SPI2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define SPI2_INSTANCE_INDEX (SPI0_ENABLED + SPI1_ENABLED)
#endif
#define SPI_COUNT (SPI0_ENABLED + SPI1_ENABLED + SPI2_ENABLED)
/* SPIS */
#define SPIS0_ENABLED 0
#if (SPIS0_ENABLED == 1)
#define SPIS0_CONFIG_SCK_PIN 2
#define SPIS0_CONFIG_MOSI_PIN 3
#define SPIS0_CONFIG_MISO_PIN 4
#define SPIS0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define SPIS0_INSTANCE_INDEX 0
#endif
#define SPIS1_ENABLED 0
#if (SPIS1_ENABLED == 1)
#define SPIS1_CONFIG_SCK_PIN 2
#define SPIS1_CONFIG_MOSI_PIN 3
#define SPIS1_CONFIG_MISO_PIN 4
#define SPIS1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define SPIS1_INSTANCE_INDEX SPIS0_ENABLED
#endif
#define SPIS2_ENABLED 0
#if (SPIS2_ENABLED == 1)
#define SPIS2_CONFIG_SCK_PIN 2
#define SPIS2_CONFIG_MOSI_PIN 3
#define SPIS2_CONFIG_MISO_PIN 4
#define SPIS2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define SPIS2_INSTANCE_INDEX (SPIS0_ENABLED + SPIS1_ENABLED)
#endif
#define SPIS_COUNT (SPIS0_ENABLED + SPIS1_ENABLED + SPIS2_ENABLED)
/* UART */
#define UART0_ENABLED 1
#if (UART0_ENABLED == 1)
#define UART0_CONFIG_HWFC NRF_UART_HWFC_DISABLED
#define UART0_CONFIG_PARITY NRF_UART_PARITY_EXCLUDED
#define UART0_CONFIG_BAUDRATE NRF_UART_BAUDRATE_38400
#define UART0_CONFIG_PSEL_TXD 6
#define UART0_CONFIG_PSEL_RXD 8
#define UART0_CONFIG_PSEL_CTS 7
#define UART0_CONFIG_PSEL_RTS 5
#define UART0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#ifdef NRF52
#define UART0_CONFIG_USE_EASY_DMA false
//Compile time flag
#define UART_EASY_DMA_SUPPORT 1
#define UART_LEGACY_SUPPORT 1
#endif //NRF52
#endif
#define TWI0_ENABLED 0
#if (TWI0_ENABLED == 1)
#define TWI0_CONFIG_FREQUENCY NRF_TWI_FREQ_100K
#define TWI0_CONFIG_SCL 0
#define TWI0_CONFIG_SDA 1
#define TWI0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define TWI0_INSTANCE_INDEX 0
#endif
#define TWI1_ENABLED 0
#if (TWI1_ENABLED == 1)
#define TWI1_CONFIG_FREQUENCY NRF_TWI_FREQ_100K
#define TWI1_CONFIG_SCL 0
#define TWI1_CONFIG_SDA 1
#define TWI1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define TWI1_INSTANCE_INDEX (TWI0_ENABLED)
#endif
#define TWI_COUNT (TWI0_ENABLED+TWI1_ENABLED)
/* TWIS */
#define TWIS0_ENABLED 0
#if (TWIS0_ENABLED == 1)
#define TWIS0_CONFIG_ADDR0 0
#define TWIS0_CONFIG_ADDR1 0 /* 0: Disabled */
#define TWIS0_CONFIG_SCL 0
#define TWIS0_CONFIG_SDA 1
#define TWIS0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define TWIS0_INSTANCE_INDEX 0
#endif
#define TWIS1_ENABLED 0
#if (TWIS1_ENABLED == 1)
#define TWIS1_CONFIG_ADDR0 0
#define TWIS1_CONFIG_ADDR1 0 /* 0: Disabled */
#define TWIS1_CONFIG_SCL 0
#define TWIS1_CONFIG_SDA 1
#define TWIS1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define TWIS1_INSTANCE_INDEX (TWIS0_ENABLED)
#endif
#define TWIS_COUNT (TWIS0_ENABLED + TWIS1_ENABLED)
/* For more documentation see nrf_drv_twis.h file */
#define TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0
/* For more documentation see nrf_drv_twis.h file */
#define TWIS_NO_SYNC_MODE 0
/**
* @brief Definition for patching PAN problems
*
* Set this definition to nonzero value to patch anomalies
* from MPW3 - first lunch microcontroller.
*
* Concerns:
* - PAN-29: TWIS: incorrect bits in ERRORSRC
* - PAN-30: TWIS: STOP task does not work as expected
*/
#define NRF_TWIS_PATCH_FOR_MPW3 1
/* QDEC */
#define QDEC_ENABLED 0
#if (QDEC_ENABLED == 1)
#define QDEC_CONFIG_REPORTPER NRF_QDEC_REPORTPER_10
#define QDEC_CONFIG_SAMPLEPER NRF_QDEC_SAMPLEPER_16384us
#define QDEC_CONFIG_PIO_A 1
#define QDEC_CONFIG_PIO_B 2
#define QDEC_CONFIG_PIO_LED 3
#define QDEC_CONFIG_LEDPRE 511
#define QDEC_CONFIG_LEDPOL NRF_QDEC_LEPOL_ACTIVE_HIGH
#define QDEC_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define QDEC_CONFIG_DBFEN false
#define QDEC_CONFIG_SAMPLE_INTEN false
#endif
/* SAADC */
#define SAADC_ENABLED 0
#if (SAADC_ENABLED == 1)
#define SAADC_CONFIG_RESOLUTION NRF_SAADC_RESOLUTION_10BIT
#define SAADC_CONFIG_OVERSAMPLE NRF_SAADC_OVERSAMPLE_DISABLED
#define SAADC_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#endif
/* LPCOMP */
#define LPCOMP_ENABLED 0
#if (LPCOMP_ENABLED == 1)
#define LPCOMP_CONFIG_REFERENCE NRF_LPCOMP_REF_SUPPLY_4_8
#define LPCOMP_CONFIG_DETECTION NRF_LPCOMP_DETECT_DOWN
#define LPCOMP_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define LPCOMP_CONFIG_INPUT NRF_LPCOMP_INPUT_0
#endif
/* WDT */
#define WDT_ENABLED 0
#if (WDT_ENABLED == 1)
#define WDT_CONFIG_BEHAVIOUR NRF_WDT_BEHAVIOUR_RUN_SLEEP
#define WDT_CONFIG_RELOAD_VALUE 2000
#define WDT_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_HIGH
#endif
/* SWI EGU */
#ifdef NRF52
#define EGU_ENABLED 0
#endif
#include "nrf_drv_config_validation.h"
#endif // NRF_DRV_CONFIG_H
/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is property of Nordic Semiconductor ASA.
* Terms and conditions of usage are described in detail in NORDIC
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
*
* Licensees are granted free, non-transferable use of the information. NO
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
* the file.
*
*/
/** @cond To make doxygen skip this file */
/** @file
* This header contains defines with respect persistent storage that are specific to
* persistent storage implementation and application use case.
*/
#ifndef PSTORAGE_PL_H__
#define PSTORAGE_PL_H__
#include <stdint.h>
#include "nrf.h"
static __INLINE uint16_t pstorage_flash_page_size()
{
return (uint16_t)NRF_FICR->CODEPAGESIZE;
}
#define PSTORAGE_FLASH_PAGE_SIZE pstorage_flash_page_size() /**< Size of one flash page. */
#define PSTORAGE_FLASH_EMPTY_MASK 0xFFFFFFFF /**< Bit mask that defines an empty address in flash. */
#ifdef NRF51
#define BOOTLOADER_ADDRESS (NRF_UICR->BOOTLOADERADDR)
#elif defined NRF52
#define BOOTLOADER_ADDRESS (PSTORAGE_FLASH_EMPTY_MASK)
#endif
#define PSTORAGE_FLASH_PAGE_END \
((BOOTLOADER_ADDRESS != PSTORAGE_FLASH_EMPTY_MASK) \
? (BOOTLOADER_ADDRESS / PSTORAGE_FLASH_PAGE_SIZE) \
: NRF_FICR->CODESIZE)
#define PSTORAGE_NUM_OF_PAGES 2 /**< Number of flash pages allocated for the pstorage module excluding the swap page, configurable based on system requirements. */
#define PSTORAGE_MIN_BLOCK_SIZE 0x0010 /**< Minimum size of block that can be registered with the module. Should be configured based on system requirements, recommendation is not have this value to be at least size of word. */
#define PSTORAGE_DATA_START_ADDR ((PSTORAGE_FLASH_PAGE_END - PSTORAGE_NUM_OF_PAGES - 1) \
* PSTORAGE_FLASH_PAGE_SIZE) /**< Start address for persistent data, configurable according to system requirements. */
#define PSTORAGE_DATA_END_ADDR ((PSTORAGE_FLASH_PAGE_END - 1) * PSTORAGE_FLASH_PAGE_SIZE) /**< End address for persistent data, configurable according to system requirements. */
#define PSTORAGE_SWAP_ADDR PSTORAGE_DATA_END_ADDR /**< Top-most page is used as swap area for clear and update. */
#define PSTORAGE_MAX_BLOCK_SIZE PSTORAGE_FLASH_PAGE_SIZE /**< Maximum size of block that can be registered with the module. Should be configured based on system requirements. And should be greater than or equal to the minimum size. */
#define PSTORAGE_CMD_QUEUE_SIZE 30 /**< Maximum number of flash access commands that can be maintained by the module for all applications. Configurable. */
/** Abstracts persistently memory block identifier. */
typedef uint32_t pstorage_block_t;
typedef struct
{
uint32_t module_id; /**< Module ID.*/
pstorage_block_t block_id; /**< Block ID.*/
} pstorage_handle_t;
typedef uint16_t pstorage_size_t; /** Size of length and offset fields. */
/**@brief Handles Flash Access Result Events. To be called in the system event dispatcher of the application. */
void pstorage_sys_event_handler (uint32_t sys_evt);
#endif // PSTORAGE_PL_H__
/** @} */
/** @endcond */
/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is property of Nordic Semiconductor ASA.
* Terms and conditions of usage are described in detail in NORDIC
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
*
* Licensees are granted free, non-transferable use of the information. NO
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
* the file.
*
*/
#ifndef SDK_CONFIG_H__
#define SDK_CONFIG_H__
/**
* @defgroup sdk_config SDK Configuration
* @{
* @ingroup sdk_common
* @{
* @details All parameters that allow configuring/tuning the SDK based on application/ use case
* are defined here.
*/
/**
* @defgroup mem_manager_config Memory Manager Configuration
* @{
* @addtogroup sdk_config
* @{
* @details This section defines configuration of memory manager module.
*/
/**
* @brief Maximum memory blocks identified as 'small' blocks.
*
* @details Maximum memory blocks identified as 'small' blocks.
* Minimum value : 0 (Setting to 0 disables all 'small' blocks)
* Maximum value : 255
* Dependencies : None.
*/
#define MEMORY_MANAGER_SMALL_BLOCK_COUNT 8
/**
* @brief Size of each memory blocks identified as 'small' block.
*
* @details Size of each memory blocks identified as 'small' block.
* Memory block are recommended to be word-sized.
* Minimum value : 32
* Maximum value : A value less than the next pool size. If only small pool is used, this
* can be any value based on availability of RAM.
* Dependencies : MEMORY_MANAGER_SMALL_BLOCK_COUNT is non-zero.
*/
#define MEMORY_MANAGER_SMALL_BLOCK_SIZE 128
/**
* @brief Maximum memory blocks identified as 'medium' blocks.
*
* @details Maximum memory blocks identified as 'medium' blocks.
* Minimum value : 0 (Setting to 0 disables all 'medium' blocks)
* Maximum value : 255
* Dependencies : None.
*/
#define MEMORY_MANAGER_MEDIUM_BLOCK_COUNT 4
/**
* @brief Size of each memory blocks identified as 'medium' block.
*
* @details Size of each memory blocks identified as 'medium' block.
* Memory block are recommended to be word-sized.
* Minimum value : A value greater than the small pool size if defined, else 32.
* Maximum value : A value less than the next pool size. If only medium pool is used, this
* can be any value based on availability of RAM.
* Dependencies : MEMORY_MANAGER_MEDIUM_BLOCK_COUNT is non-zero.
*/
#define MEMORY_MANAGER_MEDIUM_BLOCK_SIZE 256
/**
* @brief Maximum memory blocks identified as 'medium' blocks.
*
* @details Maximum memory blocks identified as 'medium' blocks.
* Minimum value : 0 (Setting to 0 disables all 'large' blocks)
* Maximum value : 255
* Dependencies : None.
*/
#define MEMORY_MANAGER_LARGE_BLOCK_COUNT 3
/**
* @brief Size of each memory blocks identified as 'medium' block.
*
* @details Size of each memory blocks identified as 'medium' block.
* Memory block are recommended to be word-sized.
* Minimum value : A value greater than the small &/ medium pool size if defined, else 32.
* Maximum value : Any value based on availability of RAM.
* Dependencies : MEMORY_MANAGER_MEDIUM_BLOCK_COUNT is non-zero.
*/
#define MEMORY_MANAGER_LARGE_BLOCK_SIZE 1024
/**
* @brief Disable debug trace in the module.
*
* @details Set this define to 1 to enable debug trace in the module, else set to 0.
* Possible values : 0 or 1.
* Dependencies : ENABLE_DEBUG_LOG_SUPPORT. If this flag is not defined, no
* trace is observed even if this define is set to 1.
*/
#define MEM_MANAGER_ENABLE_LOGS 0
/**
* @brief Disables API parameter checks in the module.
*
* @details Set this define to 1 to disable checks on API parameters in the module.
* API parameter checks are added to ensure right parameters are passed to the
* module. These checks are useful during development phase but be redundant
* once application is developed. Disabling this can result in some code saving.
* Possible values : 0 or 1.
* Dependencies : None.
*/
#define MEM_MANAGER_DISABLE_API_PARAM_CHECK 0
/** @} */
/** @} */
/**
* @defgroup iot_context_manager Context Manager Configurations.
* @{
* @addtogroup iot_config
* @{
* @details This section defines configuration of Context Manager.
*/
/**
* @brief Disable debug trace in the module.
*
* @details Set this define to 1 to enable debug trace in the module, else set to 0.
* Possible values : 0 or 1.
* Dependencies : ENABLE_DEBUG_LOG_SUPPORT. If this flag is not defined, no
* trace is observed even if this define is set to 1.
*/
#define IOT_CONTEXT_MANAGER_ENABLE_LOGS 0
/**
* @brief Disables API parameter checks in the module.
*
* @details Set this define to 1 to disable checks on API parameters in the module.
* API parameter checks are added to ensure right parameters are passed to the
* module. These checks are useful during development phase but be redundant
* once application is developed. Disabling this can result in some code saving.
* Possible values : 0 or 1.
* Dependencies : None.
*/
#define IOT_CONTEXT_MANAGER_DISABLE_API_PARAM_CHECK 0
/**
* @brief Maximum number of supported context identifiers.
*
* @details Maximum value of 16 is preferable to correct decompression.
* Minimum value : 1
* Maximum value : 16
* Dependencies : None.
*/
#define IOT_CONTEXT_MANAGER_MAX_CONTEXTS 16
/**
* @brief Maximum number of supported context's table.
*
* @details If value is equal to BLE_IPSP_MAX_CHANNELS then all interface will have
* its own table which is preferable.
* Minimum value : 1
* Maximum value : BLE_IPSP_MAX_CHANNELS
* Dependencies : None.
*/
#define IOT_CONTEXT_MANAGER_MAX_TABLES 1
/** @} */
/** @} */
/**
* @defgroup lwip_nrf_driver nRF lwIP driver
* @{
* @addtogroup iot_config
* @{
* @details This section defines configuration of nRF lwIP driver.
*/
/**
* @brief Disable debug trace in the module.
*
* @details Set this define to 1 to enable debug trace in the module, else set to 0.
* Possible values : 0 or 1.
* Dependencies : ENABLE_DEBUG_LOG_SUPPORT. If this flag is not defined, no
* trace is observed even if this define is set to 1.
*/
#define NRF_LWIP_DRIVER_ENABLE_LOGS 0
/** @} */
/** @} */
/**
* @defgroup iot_timer IoT SDK Timer
* @{
* @addtogroup iot_config
* @{
* @details This section defines configuration of the IoT Timer.
*/
/**
* @brief Wall clock resolution in milliseconds.
*
* @details The wall clock of the IoT Timer module has to be updated from an external source at
* regular intervals. This define needs to be set to the interval between updates.
* Minimum value : 1.
* Dependencies : None.
*
*/
#define IOT_TIMER_RESOLUTION_IN_MS 100
/**
* @brief Disables API parameter checks in the module.
*
* @details Set this define to 1 to disable checks on API parameters in the module.
* API parameter checks are added to ensure right parameters are passed to the
* module. These checks are useful during development phase but be redundant
* once application is developed. Disabling this can result in some code saving.
* Possible values : 0 or 1.
* Dependencies : None.
*/
#define IOT_TIMER_DISABLE_API_PARAM_CHECK 0
/** @} */
/** @} */
#endif // SDK_CONFIG_H__
This diff is collapsed.
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
MEMORY
{
FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x61000
RAM (rwx) : ORIGIN = 0x20002800, LENGTH = 0xd800
}
INCLUDE "nrf5x_common.ld"
\ No newline at end of file
/* Linker script for Nordic Semiconductor nRF5 devices
*
* Version: Sourcery G++ 4.5-1
* Support: https://support.codesourcery.com/GNUToolchain/
*
* Copyright (c) 2007, 2008, 2009, 2010 CodeSourcery, Inc.
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
/* Linker script to place sections and symbol values. Should be used together
* with other linker script that defines memory regions FLASH and RAM.
* It references following symbols, which must be defined in code:
* Reset_Handler : Entry of reset handler
*
* It defines following symbols, which code can use without definition:
* __exidx_start
* __exidx_end
* __etext
* __data_start__
* __preinit_array_start
* __preinit_array_end
* __init_array_start
* __init_array_end
* __fini_array_start
* __fini_array_end
* __data_end__
* __bss_start__
* __bss_end__
* __end__
* end
* __HeapLimit
* __StackLimit
* __StackTop
* __stack
*/
ENTRY(Reset_Handler)
SECTIONS
{
.text :
{
KEEP(*(.Vectors))
*(.text*)
KEEP(*(.init))
KEEP(*(.fini))
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
*(.rodata*)
*(.eh_frame*)
. = ALIGN(4);
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
. = ALIGN(4);
} > FLASH
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
. = ALIGN(4);
} > FLASH
__exidx_end = .;
__etext = .;
.data : AT (__etext)
{
__data_start__ = .;
*(vtable)
*(.data*)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
*(SORT(.init_array.*))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
*(SORT(.fini_array.*))
KEEP(*(.fini_array))
PROVIDE_HIDDEN (__fini_array_end = .);
*(.jcr)
. = ALIGN(4);
/* All data end */
__data_end__ = .;
} > RAM
.bss :
{
. = ALIGN(4);
__bss_start__ = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
__bss_end__ = .;
} > RAM
.heap (COPY):
{
__end__ = .;
end = __end__;
*(.heap*)
__HeapLimit = .;
} > RAM
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY):
{
*(.stack*)
} > RAM
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(__stack = __StackTop);
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
}
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
* All rights reserved
*/
#include "bleconfig.h"
#include "myboard.h"
#include "../../mongoose.h"
/*
* This is a callback invoked by Mongoose to signal that a poll is needed soon.
* Since we're in a tight polling loop anyway (see below), we don't need to do anything.
*/
void mg_lwip_mgr_schedule_poll(struct mg_mgr *mgr) {
}
// Define an event handler function
void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
if (ev == MG_EV_POLL) return;
/* printf("ev %d\r\n", ev); */
switch (ev) {
case MG_EV_ACCEPT: {
char addr[32];
mg_sock_addr_to_str(&nc->sa, addr, sizeof(addr),
MG_SOCK_STRINGIFY_IP | MG_SOCK_STRINGIFY_PORT);
printf("%p: Connection from %s\r\n", nc, addr);
break;
}
case MG_EV_HTTP_REQUEST: {
struct http_message *hm = (struct http_message *) ev_data;
char addr[32];
mg_sock_addr_to_str(&nc->sa, addr, sizeof(addr),
MG_SOCK_STRINGIFY_IP | MG_SOCK_STRINGIFY_PORT);
printf("%p: %.*s %.*s\r\n", nc, (int) hm->method.len, hm->method.p,
(int) hm->uri.len, hm->uri.p);
mg_send_response_line(nc, 200,
"Content-Type: text/html\r\n"
"Connection: close");
mg_printf(nc,
"\r\n<h1>Hello, %s!</h1>\r\n"
"You asked for %.*s\r\n",
addr, (int) hm->uri.len, hm->uri.p);
nc->flags |= MG_F_SEND_AND_CLOSE;
LEDS_INVERT(LED_THREE);
break;
}
case MG_EV_CLOSE: {
printf("%p: Connection closed\r\n", nc);
break;
}
}
}
/**
* @brief Function for application main entry.
*/
int main(void)
{
cs_log_set_file(stdout);
bleconfig_init();
{
struct mg_mgr mgr;
mg_mgr_init(&mgr, NULL); // Initialize event manager object
// Note that many connections can be added to a single event manager
// Connections can be created at any point, e.g. in event handler function
const char *err;
struct mg_bind_opts opts = {};
opts.error_string = &err;
struct mg_connection *nc = mg_bind_opt(&mgr, "80", ev_handler, opts); // Create listening connection and add it to the event manager
if (nc == NULL) {
printf("Failed to create listener: %s\n", err);
return 1;
}
mg_set_protocol_http_websocket(nc);
for (;;) { // Start infinite event loop
bleconfig_poll();
sys_check_timeouts();
mg_mgr_poll(&mgr, 0);
}
mg_mgr_free(&mgr);
return 0;
}
}
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
* All rights reserved
*/
/* clang-format off */
#include "boards.h"
#define LED_ONE BSP_LED_0_MASK /**< Is on when device is advertising. */
#define LED_TWO BSP_LED_1_MASK /**< Is on when device is connected. */
#define LED_THREE BSP_LED_2_MASK
#define LED_FOUR BSP_LED_3_MASK
#define TCP_CONNECTED_LED BSP_LED_2_MASK /**< Is on when a TCP connection is established. */
#define DISPLAY_LED_0 BSP_LED_0_MASK /**< LED used for displaying mod 4 of data payload received on UDP port. */
#define DISPLAY_LED_1 BSP_LED_1_MASK /**< LED used for displaying mod 4 of data payload received on UDP port. */
#define DISPLAY_LED_2 BSP_LED_2_MASK /**< LED used for displaying mod 4 of data payload received on UDP port. */
#define DISPLAY_LED_3 BSP_LED_3_MASK /**< LED used for displaying mod 4 of data payload received on UDP port. */
#define ALL_APP_LED (BSP_LED_0_MASK | BSP_LED_1_MASK | \
BSP_LED_2_MASK | BSP_LED_3_MASK) /**< Define used for simultaneous operation of all application LEDs. */
README.txt for the SEGGER RTT Implementation Pack.
Date: 17 Dec 2014
Included files:
===============
Root Directory
- Examples
- RTT_MenuApp.c - Sample application to demonstrate RTT bi-directional functionality. No OS.
- RTT_embOS_SpeedTestApp.c - Sample application for measuring RTT performance. embOS needed.
- RTT
- SEGGER_RTT.c - The RTT implementation.
- SEGGER_RTT.h - Header for RTT implementation.
- SEGGER_RTT_Conf.h - Pre-processor configuration for the RTT implementation.
- SEGGER_RTT_Printf.c - Simple implementation of printf to write formatted strings via RTT.
- Syscalls
- RTT_Syscalls_GCC.c - Low-level syscalls to retarget printf() to RTT with GCC / Newlib.
- RTT_Syscalls_IAR.c - Low-level syscalls to retarget printf() to RTT with IAR compiler.
- RTT_Syscalls_KEIL.c - Low-level syscalls to retarget printf() to RTT with KEIL/uVision compiler.
\ No newline at end of file
This diff is collapsed.
/*********************************************************************
* SEGGER MICROCONTROLLER SYSTEME GmbH *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 1996-2014 SEGGER Microcontroller Systeme GmbH *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
----------------------------------------------------------------------
File : SEGGER_RTT.h
Date : 17 Dec 2014
Purpose : Implementation of SEGGER real-time terminal which allows
real-time terminal communication on targets which support
debugger memory accesses while the CPU is running.
---------------------------END-OF-HEADER------------------------------
*/
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define SEGGER_RTT_MODE_MASK (3 << 0)
#define SEGGER_RTT_MODE_NO_BLOCK_SKIP (0)
#define SEGGER_RTT_MODE_NO_BLOCK_TRIM (1 << 0)
#define SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL (1 << 1)
#define RTT_CTRL_RESET ""
#define RTT_CTRL_CLEAR ""
#define RTT_CTRL_TEXT_BLACK ""
#define RTT_CTRL_TEXT_RED ""
#define RTT_CTRL_TEXT_GREEN ""
#define RTT_CTRL_TEXT_YELLOW ""
#define RTT_CTRL_TEXT_BLUE ""
#define RTT_CTRL_TEXT_MAGENTA ""
#define RTT_CTRL_TEXT_CYAN ""
#define RTT_CTRL_TEXT_WHITE ""
#define RTT_CTRL_TEXT_BRIGHT_BLACK ""
#define RTT_CTRL_TEXT_BRIGHT_RED ""
#define RTT_CTRL_TEXT_BRIGHT_GREEN ""
#define RTT_CTRL_TEXT_BRIGHT_YELLOW ""
#define RTT_CTRL_TEXT_BRIGHT_BLUE ""
#define RTT_CTRL_TEXT_BRIGHT_MAGENTA ""
#define RTT_CTRL_TEXT_BRIGHT_CYAN ""
#define RTT_CTRL_TEXT_BRIGHT_WHITE ""
#define RTT_CTRL_BG_BLACK ""
#define RTT_CTRL_BG_RED ""
#define RTT_CTRL_BG_GREEN ""
#define RTT_CTRL_BG_YELLOW ""
#define RTT_CTRL_BG_BLUE ""
#define RTT_CTRL_BG_MAGENTA ""
#define RTT_CTRL_BG_CYAN ""
#define RTT_CTRL_BG_WHITE ""
#define RTT_CTRL_BG_BRIGHT_BLACK ""
#define RTT_CTRL_BG_BRIGHT_RED ""
#define RTT_CTRL_BG_BRIGHT_GREEN ""
#define RTT_CTRL_BG_BRIGHT_YELLOW ""
#define RTT_CTRL_BG_BRIGHT_BLUE ""
#define RTT_CTRL_BG_BRIGHT_MAGENTA ""
#define RTT_CTRL_BG_BRIGHT_CYAN ""
#define RTT_CTRL_BG_BRIGHT_WHITE ""
/*********************************************************************
*
* RTT API functions
*
**********************************************************************
*/
int SEGGER_RTT_Read (unsigned BufferIndex, char* pBuffer, unsigned BufferSize);
int SEGGER_RTT_Write (unsigned BufferIndex, const char* pBuffer, unsigned NumBytes);
int SEGGER_RTT_WriteString (unsigned BufferIndex, const char* s);
int SEGGER_RTT_GetKey (void);
int SEGGER_RTT_WaitKey (void);
int SEGGER_RTT_HasKey (void);
int SEGGER_RTT_ConfigUpBuffer (unsigned BufferIndex, const char* sName, char* pBuffer, int BufferSize, int Flags);
int SEGGER_RTT_ConfigDownBuffer (unsigned BufferIndex, const char* sName, char* pBuffer, int BufferSize, int Flags);
void SEGGER_RTT_Init (void);
/*********************************************************************
*
* RTT "Terminal" API functions
*
**********************************************************************
*/
void SEGGER_RTT_SetTerminal (char TerminalId);
int SEGGER_RTT_TerminalOut (char TerminalId, const char* s);
/*********************************************************************
*
* RTT printf functions (require SEGGER_RTT_printf.c)
*
**********************************************************************
*/
int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...);
/*************************** End of file ****************************/
/*********************************************************************
* SEGGER MICROCONTROLLER SYSTEME GmbH *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 1996-2014 SEGGER Microcontroller Systeme GmbH *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
----------------------------------------------------------------------
File : SEGGER_RTT_Conf.h
Date : 17 Dec 2014
Purpose : Implementation of SEGGER real-time terminal which allows
real-time terminal communication on targets which support
debugger memory accesses while the CPU is running.
---------------------------END-OF-HEADER------------------------------
*/
/*********************************************************************
*
* Defines, configurable
*
**********************************************************************
*/
#define SEGGER_RTT_MAX_NUM_UP_BUFFERS (2) // Max. number of up-buffers (T->H) available on this target (Default: 2)
#define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (2) // Max. number of down-buffers (H->T) available on this target (Default: 2)
#define BUFFER_SIZE_UP (512) // Size of the buffer for terminal output of target, up to host (Default: 1k)
#define BUFFER_SIZE_DOWN (16) // Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16)
#define SEGGER_RTT_PRINTF_BUFFER_SIZE (64) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64)
//
// Target is not allowed to perform other RTT operations while string still has not been stored completely.
// Otherwise we would probably end up with a mixed string in the buffer.
// If using RTT from within interrupts, multiple tasks or multi processors, define the SEGGER_RTT_LOCK() and SEGGER_RTT_UNLOCK() function here.
//
#define SEGGER_RTT_LOCK()
#define SEGGER_RTT_UNLOCK()
//
// Define SEGGER_RTT_IN_RAM as 1
// when using RTT in RAM targets (init and data section both in RAM).
// This prevents the host to falsly identify the RTT Callback Structure
// in the init segment as the used Callback Structure.
//
// When defined as 1,
// the first call to an RTT function will modify the ID of the RTT Callback Structure.
// To speed up identifying on the host,
// especially when RTT functions are not called at the beginning of execution,
// SEGGER_RTT_Init() should be called at the start of the application.
//
#define SEGGER_RTT_IN_RAM (0)
/*************************** End of file ****************************/
This diff is collapsed.
/*********************************************************************
* SEGGER MICROCONTROLLER GmbH & Co KG *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 2014 SEGGER Microcontroller GmbH & Co KG *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
----------------------------------------------------------------------
File : RTT_Syscalls.c
Purpose : Low-level functions for using printf() via RTT in GCC
-------- END-OF-HEADER ---------------------------------------------
*/
#include <stdlib.h>
#include "SEGGER_RTT.h"
/*********************************************************************
*
* Function prototypes
*
**********************************************************************
*/
int _write(int file, char *ptr, int len);
int _write_r(struct _reent *r, int file, char *ptr, int len);
/*********************************************************************
*
* Global functions
*
**********************************************************************
*/
/*********************************************************************
*
* _write()
*
* Function description
* Low-level write function.
* libc subroutines will use this system routine for output to all files,
* including stdout.
* Write data via RTT.
*/
int _write(int file, char *ptr, int len) {
(void) file; /* Not used, avoid warning */
SEGGER_RTT_Write(0, ptr, len);
return len;
}
/*********************************************************************
*
* _write_r()
*
* Function description
* Low-level reentrant write function.
* libc subroutines will use this system routine for output to all files,
* including stdout.
* Write data via RTT.
*/
int _write_r(struct _reent *r, int file, char *ptr, int len) {
(void) file; /* Not used, avoid warning */
(void) r; /* Not used, avoid warning */
SEGGER_RTT_Write(0, ptr, len);
return len;
}
/*********************************************************************
* SEGGER MICROCONTROLLER GmbH & Co KG *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 2014 SEGGER Microcontroller GmbH & Co KG *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
----------------------------------------------------------------------
File : RTT_Syscalls.c
Purpose : Low-level functions for using printf() via RTT in IAR
-------- END-OF-HEADER ---------------------------------------------
*/
#include <yfuns.h>
#include "SEGGER_RTT.h"
#pragma module_name = "?__write"
/*********************************************************************
*
* Function prototypes
*
**********************************************************************
*/
size_t __write(int handle, const unsigned char * buffer, size_t size);
/*********************************************************************
*
* Global functions
*
**********************************************************************
*/
/*********************************************************************
*
* __write()
*
* Function description
* Low-level write function.
* libc subroutines will use this system routine for output to all files,
* including stdout.
* Write data via RTT.
*/
size_t __write(int handle, const unsigned char * buffer, size_t size) {
(void) handle; /* Not used, avoid warning */
SEGGER_RTT_Write(0, buffer, size);
return size;
}
/****** End Of File *************************************************/
\ No newline at end of file
/*********************************************************************
* SEGGER MICROCONTROLLER GmbH & Co KG *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 2014 SEGGER Microcontroller GmbH & Co KG *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
----------------------------------------------------------------------
File : RTT_Syscalls_KEIL.c
Purpose : Retargeting module for KEIL MDK-CM3.
Low-level functions for using printf() via RTT
--------- END-OF-HEADER --------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <rt_sys.h>
#include <rt_misc.h>
#include "SEGGER_RTT.h"
/*********************************************************************
*
* #pragmas
*
**********************************************************************
*/
#pragma import(__use_no_semihosting)
#ifdef _MICROLIB
#pragma import(__use_full_stdio)
#endif
/*********************************************************************
*
* Defines non-configurable
*
**********************************************************************
*/
/* Standard IO device handles - arbitrary, but any real file system handles must be
less than 0x8000. */
#define STDIN 0x8001 // Standard Input Stream
#define STDOUT 0x8002 // Standard Output Stream
#define STDERR 0x8003 // Standard Error Stream
/*********************************************************************
*
* Public const
*
**********************************************************************
*/
const char __stdin_name[] = "STDIN";
const char __stdout_name[] = "STDOUT";
const char __stderr_name[] = "STDERR";
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* _ttywrch
*
* Function description:
* Outputs a character to the console
*
* Parameters:
* c - character to output
*
*/
void _ttywrch(int c) {
fputc(c, stdout); // stdout
fflush(stdout);
}
/*********************************************************************
*
* _sys_open
*
* Function description:
* Opens the device/file in order to do read/write operations
*
* Parameters:
* sName - sName of the device/file to open
* OpenMode - This parameter is currently ignored
*
* Return value:
* != 0 - Handle to the object to open, otherwise
* == 0 -"device" is not handled by this module
*
*/
FILEHANDLE _sys_open(const char * sName, int OpenMode) {
// Register standard Input Output devices.
if (strcmp(sName, __stdout_name) == 0) {
return (STDOUT);
} else if (strcmp(sName, __stderr_name) == 0) {
return (STDERR);
} else
return (0); // Not implemented
}
/*********************************************************************
*
* _sys_close
*
* Function description:
* Closes the handle to the open device/file
*
* Parameters:
* hFile - Handle to a file opened via _sys_open
*
* Return value:
* 0 - device/file closed
*
*/
int _sys_close(FILEHANDLE hFile) {
return 0; // Not implemented
}
/*********************************************************************
*
* _sys_write
*
* Function description:
* Writes the data to an open handle.
* Currently this function only outputs data to the console
*
* Parameters:
* hFile - Handle to a file opened via _sys_open
* pBuffer - Pointer to the data that shall be written
* NumBytes - Number of bytes to write
* Mode - The Mode that shall be used
*
* Return value:
* Number of bytes *not* written to the file/device
*
*/
int _sys_write(FILEHANDLE hFile, const unsigned char * pBuffer, unsigned NumBytes, int Mode) {
int r = 0;
if (hFile == STDOUT) {
return NumBytes - SEGGER_RTT_Write(0, (const char*)pBuffer, NumBytes);
}
return r;
}
/*********************************************************************
*
* _sys_read
*
* Function description:
* Reads data from an open handle.
* Currently this modules does nothing.
*
* Parameters:
* hFile - Handle to a file opened via _sys_open
* pBuffer - Pointer to buffer to store the read data
* NumBytes - Number of bytes to read
* Mode - The Mode that shall be used
*
* Return value:
* Number of bytes read from the file/device
*
*/
int _sys_read(FILEHANDLE hFile, unsigned char * pBuffer, unsigned NumBytes, int Mode) {
return (0); // Not implemented
}
/*********************************************************************
*
* _sys_istty
*
* Function description:
* This function shall return whether the opened file
* is a console device or not.
*
* Parameters:
* hFile - Handle to a file opened via _sys_open
*
* Return value:
* 1 - Device is a console
* 0 - Device is not a console
*
*/
int _sys_istty(FILEHANDLE hFile) {
if (hFile > 0x8000) {
return (1);
}
return (0); // Not implemented
}
/*********************************************************************
*
* _sys_seek
*
* Function description:
* Seeks via the file to a specific position
*
* Parameters:
* hFile - Handle to a file opened via _sys_open
* Pos -
*
* Return value:
* int -
*
*/
int _sys_seek(FILEHANDLE hFile, long Pos) {
return (0); // Not implemented
}
/*********************************************************************
*
* _sys_ensure
*
* Function description:
*
*
* Parameters:
* hFile - Handle to a file opened via _sys_open
*
* Return value:
* int -
*
*/
int _sys_ensure(FILEHANDLE hFile) {
return (-1); // Not implemented
}
/*********************************************************************
*
* _sys_flen
*
* Function description:
* Returns the length of the opened file handle
*
* Parameters:
* hFile - Handle to a file opened via _sys_open
*
* Return value:
* Length of the file
*
*/
long _sys_flen(FILEHANDLE hFile) {
return (0); // Not implemented
}
/*********************************************************************
*
* _sys_tmpnam
*
* Function description:
* This function converts the file number fileno for a temporary
* file to a unique filename, for example, tmp0001.
*
* Parameters:
* pBuffer - Pointer to a buffer to store the name
* FileNum - file number to convert
* MaxLen - Size of the buffer
*
* Return value:
* 1 - Error
* 0 - Success
*
*/
int _sys_tmpnam(char * pBuffer, int FileNum, unsigned MaxLen) {
return (1); // Not implemented
}
/*********************************************************************
*
* _sys_command_string
*
* Function description:
* This function shall execute a system command.
*
* Parameters:
* cmd - Pointer to the command string
* len - Length of the string
*
* Return value:
* == NULL - Command was not successfully executed
* == sCmd - Command was passed successfully
*
*/
char * _sys_command_string(char * cmd, int len) {
return cmd; // Not implemented
}
/*********************************************************************
*
* _sys_exit
*
* Function description:
* This function is called when the application returns from main
*
* Parameters:
* ReturnCode - Return code from the main function
*
*
*/
void _sys_exit(int ReturnCode) {
while (1); // Not implemented
}
docker.cesanta.com/nrf52-build:0.9.0
......@@ -836,6 +836,8 @@ int inet_pton(int af, const char *src, void *dst);
#include <string.h>
#include <time.h>
#define to64(x) strtoll(x, NULL, 10)
#define MG_NET_IF MG_NET_IF_LWIP_LOW_LEVEL
#define LWIP_TIMEVAL_PRIVATE 0
#define LWIP_PROVIDE_ERRNO 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment