Commit c04e3f80 authored by Dmitry Frank's avatar Dmitry Frank Committed by Cesanta Bot

Make mongoose compile for nRF51

PUBLISHED_FROM=6af3ed56802d2619f673c36059370440a0c06397
parent 717e872f
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# `wildcard ./*/` works in both linux and linux/wine, while `wildcard */` enumerates nothing under wine # `wildcard ./*/` works in both linux and linux/wine, while `wildcard */` enumerates nothing under wine
SUBDIRS = $(sort $(dir $(wildcard ./*/))) SUBDIRS = $(sort $(dir $(wildcard ./*/)))
SUBDIRS:=$(filter-out ./ ./CC3200/ ./ESP8266_RTOS/ ./MSP432/ ./NXP_K64/ ./PIC32/ ./STM32F4_CC3100/ ./mbed/ ./nRF52/, $(SUBDIRS)) SUBDIRS:=$(filter-out ./ ./CC3200/ ./ESP8266_RTOS/ ./MSP432/ ./NXP_K64/ ./PIC32/ ./STM32F4_CC3100/ ./mbed/ ./nRF51/ ./nRF52/, $(SUBDIRS))
ifeq ($(OS), Windows_NT) ifeq ($(OS), Windows_NT)
SUBDIRS:=$(filter-out ./load_balancer/ ./netcat/ ./raspberry_pi_mjpeg_led/ ./captive_dns_server/, $(SUBDIRS)) SUBDIRS:=$(filter-out ./load_balancer/ ./netcat/ ./raspberry_pi_mjpeg_led/ ./captive_dns_server/, $(SUBDIRS))
......
This diff is collapsed.
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
* All rights reserved
*/
void bleconfig_init(void);
void bleconfig_poll(void);
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ProjectGui xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_guix.xsd">
<SchemaVersion>-5.1</SchemaVersion>
<Header>### uVision Project, (C) Keil Software</Header>
<ViewPool/>
<MDIGroups>
<Orientation>1</Orientation>
<ActiveMDIGroup>0</ActiveMDIGroup>
<MDIGroup>
<Size>100</Size>
<ActiveTab>0</ActiveTab>
<Doc>
<Name>..\..\..\..\..\..\..\components\softdevice\s1xx_iot\doc\s1xx-iot-prototype2_licence_agreement.txt</Name>
<ColumnNumber>0</ColumnNumber>
<TopLine>1</TopLine>
<CurrentLine>1</CurrentLine>
<Folding>1</Folding>
<ContractedFolders></ContractedFolders>
<PaneID>0</PaneID>
</Doc>
</MDIGroup>
</MDIGroups>
</ProjectGui>
\ No newline at end of file
This diff is collapsed.
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
MEMORY
{
FLASH (rx) : ORIGIN = 0x18000, LENGTH = 0x28000
RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0x6000
}
INCLUDE "gcc_nrf51_common.ld"
\ No newline at end of file
/* 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.
*
*/
/* clang-format off */
#ifndef NRF_DRV_CONFIG_H
#define NRF_DRV_CONFIG_H
/* CLOCK */
#define CLOCK_CONFIG_XTAL_FREQ NRF_CLOCK_XTALFREQ_16MHz
#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_HIGH
#define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 6
#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 TIMER_COUNT (TIMER0_ENABLED + TIMER1_ENABLED + TIMER2_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
/* 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
/* LPCOMP */
#define LPCOMP_ENABLED 0
#if (LPCOMP_ENABLED == 1)
#define LPCOMP_CONFIG_REFERENCE NRF_LPCOMP_REF_SUPPLY_FOUR_EIGHT
#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
#endif // NRF_DRV_CONFIG_H
/*
* 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;
struct mg_connection *nc = NULL;
memset(&opts, 0x00, sizeof(opts));
opts.error_string = &err;
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();
mg_mgr_poll(&mgr, 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. */
/* 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.
*
*/
/* clang-format off */
#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_DISABLE_LOGS 1
/**
* @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_DISABLE_LOGS 1
/**
* @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_nrf51_driver nRF51 lwIP driver
* @{
* @addtogroup iot_config
* @{
* @details This section defines configuration of nRF51 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 NRF51_LWIP_DRIVER_DISABLE_LOGS 1
/** @} */
/** @} */
/** @} */
/** @} */
#endif // SDK_CONFIG_H__
...@@ -10243,7 +10243,7 @@ int gettimeofday(struct timeval *tp, void *tzp) { ...@@ -10243,7 +10243,7 @@ int gettimeofday(struct timeval *tp, void *tzp) {
* All rights reserved * All rights reserved
*/ */
#if CS_PLATFORM == CS_P_NRF52 && defined(__ARMCC_VERSION) #if (CS_PLATFORM == CS_P_NRF51 || CS_PLATFORM == CS_P_NRF52) && defined(__ARMCC_VERSION)
int gettimeofday(struct timeval *tp, void *tzp) { int gettimeofday(struct timeval *tp, void *tzp) {
/* TODO */ /* TODO */
tp->tv_sec = 0; tp->tv_sec = 0;
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#define CS_P_NXP_KINETIS 9 #define CS_P_NXP_KINETIS 9
#define CS_P_NRF52 10 #define CS_P_NRF52 10
#define CS_P_PIC32_HARMONY 11 #define CS_P_PIC32_HARMONY 11
#define CS_P_NRF51 12
/* If not specified explicitly, we guess platform by defines. */ /* If not specified explicitly, we guess platform by defines. */
#ifndef CS_PLATFORM #ifndef CS_PLATFORM
...@@ -834,6 +835,46 @@ int inet_pton(int af, const char *src, void *dst); ...@@ -834,6 +835,46 @@ int inet_pton(int af, const char *src, void *dst);
#endif /* CS_PLATFORM == CS_P_MBED */ #endif /* CS_PLATFORM == CS_P_MBED */
#endif /* CS_COMMON_PLATFORMS_PLATFORM_MBED_H_ */ #endif /* CS_COMMON_PLATFORMS_PLATFORM_MBED_H_ */
#ifdef MG_MODULE_LINES #ifdef MG_MODULE_LINES
#line 1 "common/platforms/platform_nrf51.h"
#endif
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
* All rights reserved
*/
#ifndef CS_COMMON_PLATFORMS_PLATFORM_NRF51_H_
#define CS_COMMON_PLATFORMS_PLATFORM_NRF51_H_
#if CS_PLATFORM == CS_P_NRF51
#include <assert.h>
#include <ctype.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#define to64(x) strtoll(x, NULL, 10)
#define MG_NET_IF MG_NET_IF_LWIP_LOW_LEVEL
#define MG_ENABLE_IPV6 1
/*
* For ARM C Compiler, make lwip to export `struct timeval`; for other
* compilers, suppress it.
*/
#if !defined(__ARMCC_VERSION)
# define LWIP_TIMEVAL_PRIVATE 0
#else
struct timeval;
int gettimeofday(struct timeval *tp, void *tzp);
#endif
#define INT64_FMT PRId64
#define SIZE_T_FMT "u"
#endif /* CS_PLATFORM == CS_P_NRF51 */
#endif /* CS_COMMON_PLATFORMS_PLATFORM_NRF51_H_ */
#ifdef MG_MODULE_LINES
#line 1 "common/platforms/platform_nrf52.h" #line 1 "common/platforms/platform_nrf52.h"
#endif #endif
/* /*
......
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