You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2017/04/26 22:40:49 UTC
[01/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-729
SensorAPI: Send sensor data over OIC
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/bluetooth5 4c2a8d984 -> 87329b514
MYNEWT-729 SensorAPI: Send sensor data over OIC
- Cleaning up
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/be12bfb2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/be12bfb2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/be12bfb2
Branch: refs/heads/bluetooth5
Commit: be12bfb26d4cccf286d45491ce3ae5706d4cd3f9
Parents: 686b92d
Author: Vipul Rahane <vi...@apache.org>
Authored: Tue Apr 11 18:33:09 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Mon Apr 17 16:14:20 2017 -0700
----------------------------------------------------------------------
apps/sensors_test/syscfg.yml | 2 ++
hw/sensor/src/sensor_oic.c | 12 ++++++++++--
kernel/os/syscfg.yml | 2 +-
net/oic/syscfg.yml | 2 +-
4 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/be12bfb2/apps/sensors_test/syscfg.yml
----------------------------------------------------------------------
diff --git a/apps/sensors_test/syscfg.yml b/apps/sensors_test/syscfg.yml
index 1d650b1..04adddc 100644
--- a/apps/sensors_test/syscfg.yml
+++ b/apps/sensors_test/syscfg.yml
@@ -52,6 +52,8 @@ syscfg.vals:
OC_TRANSPORT_GATT: 1
OC_APP_RESOURCES : 20
+ FLOAT_USER: 1
+
syscfg.defs:
TSL2561_PRESENT:
description: 'TSL2561 is present'
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/be12bfb2/hw/sensor/src/sensor_oic.c
----------------------------------------------------------------------
diff --git a/hw/sensor/src/sensor_oic.c b/hw/sensor/src/sensor_oic.c
index 132b940..987e2a7 100644
--- a/hw/sensor/src/sensor_oic.c
+++ b/hw/sensor/src/sensor_oic.c
@@ -460,9 +460,15 @@ sensor_oic_get_data(oc_request_t *request, oc_interface_mask_t interface)
char *typename;
sensor_type_t type;
const char s[2] = "/";
+ char *tmpstr;
+
+ tmpstr = calloc(request->resource->uri.os_sz, request->resource->uri.os_sz);
+
+ memcpy(tmpstr, (char *)&(request->resource->uri.os_str[1]),
+ request->resource->uri.os_sz - 1);
/* Parse the sensor device name from the uri */
- devname = strtok((char *)&(request->resource->uri.os_str[1]), s);
+ devname = strtok(tmpstr, s);
typename = strtok(NULL, s);
/* Look up sensor by name */
@@ -511,11 +517,13 @@ sensor_oic_get_data(oc_request_t *request, oc_interface_mask_t interface)
break;
}
+ free(tmpstr);
sensor_unregister_listener(sensor, &listener);
oc_rep_end_root_object();
oc_send_response(request, OC_STATUS_OK);
return;
err:
+ free(tmpstr);
sensor_unregister_listener(sensor, &listener);
oc_send_response(request, OC_STATUS_NOT_FOUND);
}
@@ -562,7 +570,7 @@ sensor_oic_init(void)
res = oc_new_resource(tmpstr, 1, 0);
free(tmpstr);
- bufsize = strlen(sensor->s_dev->od_name) + strlen("sensors.r.");
+ bufsize = strlen(sensor->s_dev->od_name) + sizeof("sensors.r.");
tmpstr = (char *)calloc(bufsize, bufsize);
sprintf(tmpstr, "sensors.r.%s", sensor->s_dev->od_name);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/be12bfb2/kernel/os/syscfg.yml
----------------------------------------------------------------------
diff --git a/kernel/os/syscfg.yml b/kernel/os/syscfg.yml
index d56c283..66eae3f 100644
--- a/kernel/os/syscfg.yml
+++ b/kernel/os/syscfg.yml
@@ -80,4 +80,4 @@ syscfg.defs:
value: 0
FLOAT_USER:
descriptiong: 'Enable float support for users'
- value: 1
+ value: 0
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/be12bfb2/net/oic/syscfg.yml
----------------------------------------------------------------------
diff --git a/net/oic/syscfg.yml b/net/oic/syscfg.yml
index 08eb9b9..51d86e2 100644
--- a/net/oic/syscfg.yml
+++ b/net/oic/syscfg.yml
@@ -58,7 +58,7 @@ syscfg.defs:
OC_APP_RESOURCES:
description: 'Maximum number of server resources'
- value: 7
+ value: 3
OC_NUM_DEVICES:
description: 'Number of devices on the OCF platform'
[14/50] [abbrv] incubator-mynewt-core git commit: Merge branch
'ruuvi' of https://github.com/wes3/incubator-mynewt-core
Posted by ja...@apache.org.
Merge branch 'ruuvi' of https://github.com/wes3/incubator-mynewt-core
This closes #236.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/84927494
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/84927494
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/84927494
Branch: refs/heads/bluetooth5
Commit: 84927494547020e75dc1fd191666f1283a751f6f
Parents: 73c8953 f4e2b34
Author: aditihilbert <ad...@runtime.io>
Authored: Wed Apr 19 11:11:21 2017 -0700
Committer: aditihilbert <ad...@runtime.io>
Committed: Wed Apr 19 11:11:21 2017 -0700
----------------------------------------------------------------------
hw/bsp/ruuvi_tag_revb2/boot-nrf52xxaa.ld | 25 ++
hw/bsp/ruuvi_tag_revb2/bsp.yml | 64 ++++
hw/bsp/ruuvi_tag_revb2/include/bsp/boards.h | 19 ++
hw/bsp/ruuvi_tag_revb2/include/bsp/bsp.h | 73 +++++
hw/bsp/ruuvi_tag_revb2/include/bsp/cmsis_nvic.h | 29 ++
hw/bsp/ruuvi_tag_revb2/nrf52dk_debug.cmd | 22 ++
hw/bsp/ruuvi_tag_revb2/nrf52dk_debug.sh | 46 +++
hw/bsp/ruuvi_tag_revb2/nrf52dk_download.cmd | 22 ++
hw/bsp/ruuvi_tag_revb2/nrf52dk_download.sh | 40 +++
hw/bsp/ruuvi_tag_revb2/nrf52dk_no_boot.ld | 191 ++++++++++++
hw/bsp/ruuvi_tag_revb2/nrf52xxaa.ld | 25 ++
hw/bsp/ruuvi_tag_revb2/pkg.yml | 97 ++++++
hw/bsp/ruuvi_tag_revb2/split-nrf52dk.ld | 208 +++++++++++++
.../src/arch/cortex_m4/gcc_startup_nrf52.s | 301 ++++++++++++++++++
.../arch/cortex_m4/gcc_startup_nrf52_split.s | 166 ++++++++++
hw/bsp/ruuvi_tag_revb2/src/hal_bsp.c | 303 +++++++++++++++++++
hw/bsp/ruuvi_tag_revb2/src/sbrk.c | 59 ++++
hw/bsp/ruuvi_tag_revb2/syscfg.yml | 95 ++++++
18 files changed, 1785 insertions(+)
----------------------------------------------------------------------
[02/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-729
SensorAPI: Send sensor data over OIC
Posted by ja...@apache.org.
MYNEWT-729 SensorAPI: Send sensor data over OIC
- Add multiple sensor oic reqource support
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/686b92db
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/686b92db
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/686b92db
Branch: refs/heads/bluetooth5
Commit: 686b92dbbccb7dee7e1ebb12c718df065946c14c
Parents: a6b41a5
Author: Vipul Rahane <vi...@apache.org>
Authored: Tue Apr 11 17:24:17 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Mon Apr 17 16:14:20 2017 -0700
----------------------------------------------------------------------
apps/sensors_test/src/main.c | 35 +++---
apps/sensors_test/syscfg.yml | 5 +-
hw/sensor/src/sensor_oic.c | 244 ++++++++++++++++++++++++++++++++++++--
3 files changed, 256 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/686b92db/apps/sensors_test/src/main.c
----------------------------------------------------------------------
diff --git a/apps/sensors_test/src/main.c b/apps/sensors_test/src/main.c
index 8b5a975..81dcc9f 100755
--- a/apps/sensors_test/src/main.c
+++ b/apps/sensors_test/src/main.c
@@ -92,6 +92,8 @@ static struct os_sem g_test_sem;
/* For LED toggling */
static int g_led_pin;
+extern int oc_stack_errno;
+
STATS_SECT_START(gpio_stats)
STATS_SECT_ENTRY(toggles)
STATS_SECT_END
@@ -659,21 +661,6 @@ main(int argc, char **argv)
/* Initialize the OIC */
log_register("oic", &oc_log, &log_console_handler, NULL, LOG_SYSLEVEL);
- oc_ble_coap_gatt_srv_init();
-
- ble_hs_cfg.reset_cb = sensor_oic_on_reset;
- ble_hs_cfg.sync_cb = sensor_oic_on_sync;
- ble_hs_cfg.gatts_register_cb = gatt_svr_register_cb;
-
- /* Set the default device name. */
- rc = ble_svc_gap_device_name_set("pi");
- assert(rc == 0);
-
- oc_main_init((oc_handler_t *)&sensor_oic_handler);
-
- oc_init_platform("MyNewt", NULL, NULL);
- oc_add_device("/oic/d", "oic.d.color", "color0", "1.0", "1.0", NULL,
- NULL);
flash_test_init();
@@ -710,6 +697,24 @@ main(int argc, char **argv)
config_sensor();
+ oc_ble_coap_gatt_srv_init();
+
+ ble_hs_cfg.reset_cb = sensor_oic_on_reset;
+ ble_hs_cfg.sync_cb = sensor_oic_on_sync;
+ ble_hs_cfg.gatts_register_cb = gatt_svr_register_cb;
+
+ /* Set the default device name. */
+ rc = ble_svc_gap_device_name_set("pi");
+ assert(rc == 0);
+
+ rc = oc_main_init((oc_handler_t *)&sensor_oic_handler);
+ assert(!rc);
+
+ oc_init_platform("MyNewt", NULL, NULL);
+ oc_add_device("/oic/d", "oic.d.color", "color0", "1.0", "1.0", NULL,
+ NULL);
+ assert(!oc_stack_errno);
+
/*
* As the last thing, process events from default event queue.
*/
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/686b92db/apps/sensors_test/syscfg.yml
----------------------------------------------------------------------
diff --git a/apps/sensors_test/syscfg.yml b/apps/sensors_test/syscfg.yml
index 5097574..1d650b1 100644
--- a/apps/sensors_test/syscfg.yml
+++ b/apps/sensors_test/syscfg.yml
@@ -42,7 +42,7 @@ syscfg.vals:
CONFIG_NEWTMGR: 0
TSL2561_CLI: 0
- BNO055_CLI: 0
+ BNO055_CLI: 1
TCS34725_CLI: 1
SENSOR_BLE_OIC: 1
@@ -50,6 +50,7 @@ syscfg.vals:
BLE_ROLE_OBSERVER: 0
OC_SERVER: 1
OC_TRANSPORT_GATT: 1
+ OC_APP_RESOURCES : 20
syscfg.defs:
TSL2561_PRESENT:
@@ -60,7 +61,7 @@ syscfg.defs:
value : 0
BNO055_PRESENT:
description: 'BNO055 is present'
- value : 0
+ value : 1
TCS34725_PRESENT:
description: 'TCS34725 is present'
value : 1
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/686b92db/hw/sensor/src/sensor_oic.c
----------------------------------------------------------------------
diff --git a/hw/sensor/src/sensor_oic.c b/hw/sensor/src/sensor_oic.c
index b30f417..132b940 100644
--- a/hw/sensor/src/sensor_oic.c
+++ b/hw/sensor/src/sensor_oic.c
@@ -289,17 +289,187 @@ err:
return rc;
}
+static int
+sensor_typename_to_type(char *typename, sensor_type_t *type,
+ struct sensor *sensor)
+{
+ if (!strcmp(typename, "acc")) {
+ /* Accelerometer functionality supported */
+ *type = SENSOR_TYPE_ACCELEROMETER;
+ } else if (!strcmp(typename, "mag")) {
+ /* Magnetic field supported */
+ *type = SENSOR_TYPE_MAGNETIC_FIELD;
+ } else if (!strcmp(typename, "gyr")) {
+ /* Gyroscope supported */
+ *type = SENSOR_TYPE_GYROSCOPE;
+ } else if (!strcmp(typename, "lt")) {
+ /* Light supported */
+ *type = SENSOR_TYPE_LIGHT;
+ } else if (!strcmp(typename, "tmp")) {
+ /* Temperature supported */
+ *type = SENSOR_TYPE_TEMPERATURE;
+ } else if (!strcmp(typename, "ambtmp")) {
+ /* Ambient temperature supported */
+ *type = SENSOR_TYPE_AMBIENT_TEMPERATURE;
+ } else if (!strcmp(typename, "psr")) {
+ /* Pressure sensor supported */
+ *type = SENSOR_TYPE_PRESSURE;
+ } else if (!strcmp(typename, "prox")) {
+ /* Proximity sensor supported */
+ *type = SENSOR_TYPE_PROXIMITY;
+ } else if (!strcmp(typename, "rhmty")) {
+ /* Relative humidity supported */
+ *type = SENSOR_TYPE_RELATIVE_HUMIDITY;
+ } else if (!strcmp(typename, "quat")) {
+ /* Rotation vector (quaternion)) supported */
+ *type = SENSOR_TYPE_ROTATION_VECTOR;
+ } else if (!strcmp(typename, "alt")) {
+ /* Altitude Supported */
+ *type = SENSOR_TYPE_ALTITUDE;
+ } else if (!strcmp(typename, "wt")) {
+ /* Weight Supported */
+ *type = SENSOR_TYPE_WEIGHT;
+ } else if (!strcmp(typename, "lacc")) {
+ /* Linear Accelerometer (Without Gravity)) */
+ *type = SENSOR_TYPE_LINEAR_ACCEL;
+ } else if (!strcmp(typename, "grav")) {
+ /* Gravity Sensor */
+ *type = SENSOR_TYPE_GRAVITY;
+ } else if (!strcmp(typename, "eul")) {
+ /* Euler Orientation Sensor */
+ *type = SENSOR_TYPE_EULER;
+ } else if (!strcmp(typename, "col")) {
+ /* Color Sensor */
+ *type = SENSOR_TYPE_COLOR;
+ } else if (!strcmp(typename, "udef1")) {
+ /* User defined sensor type 1 */
+ *type = SENSOR_TYPE_USER_DEFINED_1;
+ } else if (!strcmp(typename, "udef2")) {
+ /* User defined sensor type 2 */
+ *type = SENSOR_TYPE_USER_DEFINED_2;
+ } else {
+ goto err;
+ }
+
+ if (!(*type & sensor->s_types)) {
+ goto err;
+ }
+
+ return SYS_EOK;
+err:
+ return SYS_EINVAL;
+}
+
+static int
+sensor_type_to_typename(char **typename, sensor_type_t type,
+ struct sensor *sensor)
+{
+ switch(type) {
+ /* Accelerometer functionality supported */
+ case SENSOR_TYPE_ACCELEROMETER:
+ *typename = "acc";
+ break;
+ /* Magnetic field supported */
+ case SENSOR_TYPE_MAGNETIC_FIELD:
+ *typename = "mag";
+ break;
+ /* Gyroscope supported */
+ case SENSOR_TYPE_GYROSCOPE:
+ *typename = "gyr";
+ break;
+ /* Light supported */
+ case SENSOR_TYPE_LIGHT:
+ *typename = "lt";
+ break;
+ /* Temperature supported */
+ case SENSOR_TYPE_TEMPERATURE:
+ *typename = "tmp";
+ break;
+ /* Ambient temperature supported */
+ case SENSOR_TYPE_AMBIENT_TEMPERATURE:
+ *typename = "ambtmp";
+ break;
+ /* Pressure sensor supported */
+ case SENSOR_TYPE_PRESSURE:
+ *typename = "psr";
+ break;
+ /* Proximity sensor supported */
+ case SENSOR_TYPE_PROXIMITY:
+ *typename = "prox";
+ break;
+ /* Relative humidity supported */
+ case SENSOR_TYPE_RELATIVE_HUMIDITY:
+ *typename = "rhmty";
+ break;
+ /* Rotation vector (quaternion)) supported */
+ case SENSOR_TYPE_ROTATION_VECTOR:
+ *typename = "quat";
+ break;
+ /* Altitude Supported */
+ case SENSOR_TYPE_ALTITUDE:
+ *typename = "alt";
+ break;
+ /* Weight Supported */
+ case SENSOR_TYPE_WEIGHT:
+ *typename = "wt";
+ break;
+ /* Linear Accelerometer (Without Gravity)) */
+ case SENSOR_TYPE_LINEAR_ACCEL:
+ *typename = "lacc";
+ break;
+ /* Gravity Sensor */
+ case SENSOR_TYPE_GRAVITY:
+ *typename = "grav";
+ break;
+ /* Euler Orientation Sensor */
+ case SENSOR_TYPE_EULER:
+ *typename = "eul";
+ break;
+ /* Color Sensor */
+ case SENSOR_TYPE_COLOR:
+ *typename = "col";
+ break;
+ /* User defined sensor type 1 */
+ case SENSOR_TYPE_USER_DEFINED_1:
+ *typename = "udef1";
+ break;
+ /* User defined sensor type 2 */
+ case SENSOR_TYPE_USER_DEFINED_2:
+ *typename = "udef2";
+ break;
+ default:
+ goto err;
+ }
+
+ if (!(type & sensor->s_types)) {
+ goto err;
+ }
+
+ return SYS_EOK;
+err:
+ return SYS_EINVAL;
+}
+
static void
sensor_oic_get_data(oc_request_t *request, oc_interface_mask_t interface)
{
int rc;
struct sensor *sensor;
struct sensor_listener listener;
+ char *devname;
+ char *typename;
+ sensor_type_t type;
+ const char s[2] = "/";
+
+ /* Parse the sensor device name from the uri */
+ devname = strtok((char *)&(request->resource->uri.os_str[1]), s);
+ typename = strtok(NULL, s);
/* Look up sensor by name */
- sensor = sensor_mgr_find_next_bydevname("color0", NULL);
+ sensor = sensor_mgr_find_next_bydevname(devname, NULL);
if (!sensor) {
- console_printf("Sensor %s not found!\n", "color0");
+ rc = SYS_EINVAL;
+ goto err;
}
oc_rep_start_root_object();
@@ -311,7 +481,13 @@ sensor_oic_get_data(oc_request_t *request, oc_interface_mask_t interface)
/* Register a listener and then trigger/read a bunch of samples */
memset(&listener, 0, sizeof(listener));
- listener.sl_sensor_type = sensor->s_types & SENSOR_TYPE_COLOR;
+ rc = sensor_typename_to_type(typename, &type, sensor);
+ if (rc) {
+ /* Type either not supported by sensor or not found */
+ goto err;
+ }
+
+ listener.sl_sensor_type = type;
listener.sl_func = sensor_oic_encode;
listener.sl_arg = (void *)&listener.sl_sensor_type;
@@ -348,16 +524,62 @@ void
sensor_oic_init(void)
{
oc_resource_t *res;
+ struct sensor *sensor;
+ char *tmpstr;
+ size_t bufsize;
+ char *typename;
+ int i;
+ int rc;
+
+ sensor = NULL;
+
+ while (1) {
+
+ sensor_mgr_lock();
+
+ sensor = sensor_mgr_find_next_bytype(SENSOR_TYPE_ALL, sensor);
- res = oc_new_resource("/color0", 1, 0);
- oc_resource_bind_resource_type(res, "sensors.r.color0");
- oc_resource_bind_resource_interface(res, OC_IF_R);
- oc_resource_set_default_interface(res, OC_IF_R);
+ sensor_mgr_unlock();
- oc_resource_set_discoverable(res);
- oc_resource_set_periodic_observable(res, 1);
- oc_resource_set_request_handler(res, OC_GET, sensor_oic_get_data);
- oc_add_resource(res);
+ if (sensor == NULL) {
+ /* Sensor not found */
+ break;
+ }
+
+ i = 0;
+ typename = NULL;
+
+ /* Iterate through N types of sensors */
+ while (i < 32) {
+ if (sensor->s_types & (1 << i)) {
+ rc = sensor_type_to_typename(&typename, (1 << i), sensor);
+ if (rc) {
+ break;
+ }
+ bufsize = strlen(sensor->s_dev->od_name) + 1;
+ tmpstr = (char *)calloc(bufsize, bufsize);
+ sprintf(tmpstr, "/%s/%s", sensor->s_dev->od_name, typename);
+ res = oc_new_resource(tmpstr, 1, 0);
+ free(tmpstr);
+
+ bufsize = strlen(sensor->s_dev->od_name) + strlen("sensors.r.");
+ tmpstr = (char *)calloc(bufsize, bufsize);
+ sprintf(tmpstr, "sensors.r.%s", sensor->s_dev->od_name);
+
+ oc_resource_bind_resource_type(res, tmpstr);
+ free(tmpstr);
+
+ oc_resource_bind_resource_interface(res, OC_IF_R);
+ oc_resource_set_default_interface(res, OC_IF_R);
+
+ oc_resource_set_discoverable(res);
+ oc_resource_set_periodic_observable(res, 1);
+ oc_resource_set_request_handler(res, OC_GET, sensor_oic_get_data);
+ oc_add_resource(res);
+ }
+ i++;
+ }
+ }
}
#endif
[26/50] [abbrv] incubator-mynewt-core git commit: This closes #221.
Posted by ja...@apache.org.
This closes #221.
Merge branch 'hcioversocket' of https://github.com/mkiiskila/incubator-mynewt-core
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/a34f6538
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/a34f6538
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/a34f6538
Branch: refs/heads/bluetooth5
Commit: a34f65387d3b5299ad68380f87558d4cce944bee
Parents: 431e500 52a585c
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Apr 20 08:29:39 2017 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Apr 20 08:29:39 2017 -0700
----------------------------------------------------------------------
.../socket/include/socket/ble_hci_socket.h | 34 +
net/nimble/transport/socket/pkg.yml | 38 +
.../transport/socket/src/ble_hci_socket.c | 802 +++++++++++++++++++
net/nimble/transport/socket/syscfg.yml | 66 ++
4 files changed, 940 insertions(+)
----------------------------------------------------------------------
[27/50] [abbrv] incubator-mynewt-core git commit: This closes #238.
Posted by ja...@apache.org.
This closes #238.
Merge branch 'raspberry_pi' of https://github.com/mkiiskila/incubator-mynewt-core
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/e13e309d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/e13e309d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/e13e309d
Branch: refs/heads/bluetooth5
Commit: e13e309d92c7d86b6c14e8d672a7b4e52c24d68e
Parents: a34f653 1b5f14c
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Apr 20 10:11:37 2017 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Apr 20 10:11:37 2017 -0700
----------------------------------------------------------------------
compiler/sim-armv7/compiler.yml | 41 ++
compiler/sim-armv7/pkg.yml | 28 ++
hw/mcu/native/pkg.yml | 1 -
.../os/include/os/arch/sim-armv7/os/os_arch.h | 82 ++++
kernel/os/src/arch/sim-armv7/os_arch_sim.c | 457 +++++++++++++++++++
.../os/src/arch/sim-armv7/os_arch_stack_frame.s | 47 ++
kernel/os/src/arch/sim-armv7/os_fault.c | 39 ++
7 files changed, 694 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
[46/50] [abbrv] incubator-mynewt-core git commit: sys/console:
migrated to new console functionality
Posted by ja...@apache.org.
sys/console: migrated to new console functionality
This patch brings improved console functionality.
Some of the features:
* support for different console backends; UART and RTT for now
* improved ANSI codes handling
* backward compatible API, so it doesn't break existing apps
although the old API is deprecated and will be deleted in the future
* support for tab completion, which will be added later
* ability to compile out input handling code to save flash
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/4863008f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/4863008f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/4863008f
Branch: refs/heads/bluetooth5
Commit: 4863008f847b25d86a7f180d7a7635682bf03420
Parents: f7acf77
Author: Micha\u0142 Narajowski <mi...@codecoup.pl>
Authored: Thu Apr 20 07:51:19 2017 +0200
Committer: Micha\u0142 Narajowski <mi...@codecoup.pl>
Committed: Tue Apr 25 17:49:15 2017 -0700
----------------------------------------------------------------------
sys/console/full/include/console/console.h | 18 +-
sys/console/full/include/console/prompt.h | 21 +-
sys/console/full/pkg.yml | 3 +
sys/console/full/src/cons_fmt.c | 112 ----
sys/console/full/src/cons_tty.c | 574 ---------------------
sys/console/full/src/console.c | 447 ++++++++++++++++
sys/console/full/src/console_fmt.c | 103 ++++
sys/console/full/src/console_priv.h | 37 ++
sys/console/full/src/prompt.c | 57 --
sys/console/full/src/rtt_console.c | 96 ++++
sys/console/full/src/ticks.c | 2 +-
sys/console/full/src/uart_console.c | 193 +++++++
sys/console/full/syscfg.yml | 42 +-
sys/console/minimal/include/console/console.h | 63 ---
sys/console/minimal/include/console/prompt.h | 55 --
sys/console/minimal/include/console/ticks.h | 51 --
sys/console/minimal/pkg.yml | 33 --
sys/console/minimal/src/cons_tty.c | 253 ---------
sys/console/minimal/syscfg.yml | 33 --
sys/console/stub/include/console/console.h | 37 +-
20 files changed, 970 insertions(+), 1260 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4863008f/sys/console/full/include/console/console.h
----------------------------------------------------------------------
diff --git a/sys/console/full/include/console/console.h b/sys/console/full/include/console/console.h
index c7ae04c..0f37b79 100644
--- a/sys/console/full/include/console/console.h
+++ b/sys/console/full/include/console/console.h
@@ -16,28 +16,44 @@
* specific language governing permissions and limitations
* under the License.
*/
+
#ifndef __CONSOLE_H__
#define __CONSOLE_H__
-#include <stdarg.h>
+#include <inttypes.h>
+#include "syscfg/syscfg.h"
#ifdef __cplusplus
extern "C" {
#endif
+struct os_eventq;
+
+struct console_input {
+ char line[MYNEWT_VAL(CONSOLE_MAX_INPUT_LEN)];
+};
+
typedef void (*console_rx_cb)(void);
int console_init(console_rx_cb rx_cb);
int console_is_init(void);
void console_write(const char *str, int cnt);
+#if MYNEWT_VAL(CONSOLE_COMPAT)
int console_read(char *str, int cnt, int *newline);
+#endif
void console_blocking_mode(void);
void console_echo(int on);
int console_printf(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));;
+void console_set_queues(struct os_eventq *avail_queue,
+ struct os_eventq *cmd_queue);
+void console_set_completion_cb(uint8_t (*completion)(char *str, uint8_t len));
+int console_handle_char(uint8_t byte);
+
extern int console_is_midline;
+extern int console_out(int character);
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4863008f/sys/console/full/include/console/prompt.h
----------------------------------------------------------------------
diff --git a/sys/console/full/include/console/prompt.h b/sys/console/full/include/console/prompt.h
index d4bf8bf..ab5518b 100644
--- a/sys/console/full/include/console/prompt.h
+++ b/sys/console/full/include/console/prompt.h
@@ -28,13 +28,26 @@ extern "C" {
#endif
/* print console prompt */
-void console_print_prompt();
+static void inline
+console_print_prompt(void)
+{
+}
+
/* set the console prompt character */
-void console_set_prompt(char);
+static void inline
+console_set_prompt(char ch)
+{
+}
-void console_no_prompt(void);
+static void inline
+console_no_prompt(void)
+{
+}
-void console_yes_prompt(void);
+static void inline
+console_yes_prompt(void)
+{
+}
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4863008f/sys/console/full/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/console/full/pkg.yml b/sys/console/full/pkg.yml
index e56c7fd..d69fbb0 100644
--- a/sys/console/full/pkg.yml
+++ b/sys/console/full/pkg.yml
@@ -26,7 +26,10 @@ pkg.keywords:
pkg.deps:
- hw/hal
- kernel/os
+pkg.deps.CONSOLE_UART:
- hw/drivers/uart
+pkg.deps.CONSOLE_RTT:
+ - hw/drivers/rtt
pkg.apis: console
pkg.init:
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4863008f/sys/console/full/src/cons_fmt.c
----------------------------------------------------------------------
diff --git a/sys/console/full/src/cons_fmt.c b/sys/console/full/src/cons_fmt.c
deleted file mode 100644
index cd848c6..0000000
--- a/sys/console/full/src/cons_fmt.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-#include <stdarg.h>
-#include <stdio.h>
-#include "syscfg/syscfg.h"
-#include "console/console.h"
-#include "console/ticks.h"
-#include "os/os_time.h"
-
-#define CONS_OUTPUT_MAX_LINE 128
-
-
-#if MYNEWT_VAL(BASELIBC_PRESENT)
-size_t console_file_write(FILE *p, const char *str, size_t cnt);
-
-static const struct File_methods console_file_ops = {
- .write = console_file_write,
- .read = NULL
-};
-
-static const FILE console_file = {
- .vmt = &console_file_ops
-};
-
-/**
- * Prints the specified format string to the console.
- *
- * @return The number of characters that would have been
- * printed if the console buffer were
- * unlimited. This return value is analogous
- * to that of snprintf.
- */
-int
-console_printf(const char *fmt, ...)
-{
- va_list args;
- int num_chars;
-
- num_chars = 0;
-
- if (console_get_ticks()) {
- /* Prefix each line with a timestamp. */
- if (!console_is_midline) {
- num_chars += fprintf((FILE *)&console_file, "%lu:",
- (unsigned long)os_time_get());
- }
- }
- va_start(args, fmt);
- num_chars += vfprintf((FILE *)&console_file, fmt, args);
- va_end(args);
-
- return num_chars;
-}
-
-#else
-
-/**
- * Prints the specified format string to the console.
- *
- * @return The number of characters that would have been
- * printed if the console buffer were
- * unlimited. This return value is analogous
- * to that of snprintf.
- */
-int
-console_printf(const char *fmt, ...)
-{
- va_list args;
- char buf[CONS_OUTPUT_MAX_LINE];
- int num_chars;
- int len;
-
- num_chars = 0;
-
- if (console_get_ticks()) {
- /* Prefix each line with a timestamp. */
- if (!console_is_midline) {
- len = snprintf(buf, sizeof(buf), "%lu:",
- (unsigned long)os_time_get());
- num_chars += len;
- console_write(buf, len);
- }
- }
-
- va_start(args, fmt);
- len = vsnprintf(buf, sizeof(buf), fmt, args);
- num_chars += len;
- if (len >= sizeof(buf)) {
- len = sizeof(buf) - 1;
- }
- console_write(buf, len);
- va_end(args);
-
- return num_chars;
-}
-#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4863008f/sys/console/full/src/cons_tty.c
----------------------------------------------------------------------
diff --git a/sys/console/full/src/cons_tty.c b/sys/console/full/src/cons_tty.c
deleted file mode 100644
index 50870f1..0000000
--- a/sys/console/full/src/cons_tty.c
+++ /dev/null
@@ -1,574 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <inttypes.h>
-#include <assert.h>
-#include "syscfg/syscfg.h"
-#include "sysinit/sysinit.h"
-#include "os/os.h"
-#include "uart/uart.h"
-#include "bsp/bsp.h"
-
-#include "console/console.h"
-#include "console/prompt.h"
-
-/** Indicates whether the previous line of output was completed. */
-int console_is_midline;
-
-#define CONSOLE_RX_CHUNK 16
-
-#if MYNEWT_VAL(CONSOLE_HIST_ENABLE)
-#define CONSOLE_HIST_SZ 32
-#endif
-
-#define CONSOLE_DEL 0x7f /* del character */
-#define CONSOLE_ESC 0x1b /* esc character */
-#define CONSOLE_LEFT 'D' /* esc-[-D emitted when moving left */
-#define CONSOLE_UP 'A' /* esc-[-A moving up */
-#define CONSOLE_RIGHT 'C' /* esc-[-C moving right */
-#define CONSOLE_DOWN 'B' /* esc-[-B moving down */
-
-#define CONSOLE_HEAD_INC(cr) (((cr)->cr_head + 1) & ((cr)->cr_size - 1))
-#define CONSOLE_TAIL_INC(cr) (((cr)->cr_tail + 1) & ((cr)->cr_size - 1))
-
-typedef void (*console_write_char)(char);
-void console_print_prompt(void);
-
-struct console_ring {
- uint8_t cr_head;
- uint8_t cr_tail;
- uint16_t cr_size;
- uint8_t *cr_buf;
-};
-
-struct console_tty {
- struct uart_dev *ct_dev;
-
- struct console_ring ct_tx;
- /* must be after console_ring */
- uint8_t ct_tx_buf[MYNEWT_VAL(CONSOLE_TX_BUF_SIZE)];
-
- struct console_ring ct_rx;
- /* must be after console_ring */
- uint8_t ct_rx_buf[MYNEWT_VAL(CONSOLE_RX_BUF_SIZE)];
-
- console_rx_cb ct_rx_cb; /* callback that input is ready */
- console_write_char ct_write_char;
- uint8_t ct_echo_off:1;
- uint8_t ct_esc_seq:2;
-} console_tty;
-
-#if MYNEWT_VAL(CONSOLE_HIST_ENABLE)
-struct console_hist {
- uint8_t ch_head;
- uint8_t ch_tail;
- uint8_t ch_size;
- uint8_t ch_curr;
- uint8_t ch_buf[CONSOLE_HIST_SZ][MYNEWT_VAL(CONSOLE_RX_BUF_SIZE)];
-} console_hist;
-#endif
-
-static void
-console_add_char(struct console_ring *cr, char ch)
-{
- cr->cr_buf[cr->cr_head] = ch;
- cr->cr_head = CONSOLE_HEAD_INC(cr);
-}
-
-static uint8_t
-console_pull_char(struct console_ring *cr)
-{
- uint8_t ch;
-
- ch = cr->cr_buf[cr->cr_tail];
- cr->cr_tail = CONSOLE_TAIL_INC(cr);
- return ch;
-}
-
-static int
-console_pull_char_head(struct console_ring *cr)
-{
- if (cr->cr_head != cr->cr_tail) {
- cr->cr_head = (cr->cr_head - 1) & (cr->cr_size - 1);
- return 0;
- } else {
- return -1;
- }
-}
-
-static void
-console_queue_char(char ch)
-{
- struct console_tty *ct = &console_tty;
- int sr;
-
- OS_ENTER_CRITICAL(sr);
- while (CONSOLE_HEAD_INC(&ct->ct_tx) == ct->ct_tx.cr_tail) {
- /* TX needs to drain */
- uart_start_tx(ct->ct_dev);
- OS_EXIT_CRITICAL(sr);
- if (os_started()) {
- os_time_delay(1);
- }
- OS_ENTER_CRITICAL(sr);
- }
- console_add_char(&ct->ct_tx, ch);
- OS_EXIT_CRITICAL(sr);
-}
-
-#if MYNEWT_VAL(CONSOLE_HIST_ENABLE)
-static void
-console_hist_init(void)
-{
- struct console_hist *ch = &console_hist;
-
- ch->ch_head = 0;
- ch->ch_tail = 0;
- ch->ch_curr = 0;
- ch->ch_size = CONSOLE_HIST_SZ;
-}
-
-static void
-console_hist_add(struct console_ring *rx)
-{
- struct console_hist *ch = &console_hist;
- uint8_t *str = ch->ch_buf[ch->ch_head];
- uint8_t tail;
- uint8_t empty = 1;
-
- tail = rx->cr_tail;
- while (tail != rx->cr_head) {
- *str = rx->cr_buf[tail];
- if (*str != ' ' && *str != '\t' && *str != '\n') {
- empty = 0;
- }
- if (*str == '\n') {
- *str = '\0';
- /* don't save empty history */
- if (empty) {
- return;
- }
- break;
- }
- str++;
- tail = (tail + 1) % MYNEWT_VAL(CONSOLE_RX_BUF_SIZE);
- }
-
- ch->ch_head = (ch->ch_head + 1) & (ch->ch_size - 1);
- ch->ch_curr = ch->ch_head;
-
- /* buffer full, start overwriting old history */
- if (ch->ch_head == ch->ch_tail) {
- ch->ch_tail = (ch->ch_tail + 1) & (ch->ch_size - 1);
- }
-}
-
-static int
-console_hist_move(struct console_ring *rx, uint8_t *tx_buf, uint8_t direction)
-{
- struct console_hist *ch = &console_hist;
- uint8_t *str = NULL;
- int space = 0;
- int i;
- uint8_t limit = direction == CONSOLE_UP ? ch->ch_tail : ch->ch_head;
-
- /* no more history to return in this direction */
- if (ch->ch_curr == limit) {
- return 0;
- }
-
- if (direction == CONSOLE_UP) {
- ch->ch_curr = (ch->ch_curr - 1) & (ch->ch_size - 1);
- } else {
- ch->ch_curr = (ch->ch_curr + 1) & (ch->ch_size - 1);
- }
-
- /* consume all chars */
- while (console_pull_char_head(rx) == 0) {
- /* do nothing */
- }
-
- str = ch->ch_buf[ch->ch_curr];
- for (i = 0; i < MYNEWT_VAL(CONSOLE_RX_BUF_SIZE); ++i) {
- if (str[i] == '\0') {
- break;
- }
- tx_buf[i] = str[i];
- console_add_char(rx, str[i]);
- space++;
- }
-
- return space;
-}
-#endif
-
-static void
-console_blocking_tx(char ch)
-{
- struct console_tty *ct = &console_tty;
-
- uart_blocking_tx(ct->ct_dev, ch);
-}
-
-/*
- * Flush cnt characters from console output queue.
- */
-static void
-console_tx_flush(struct console_tty *ct, int cnt)
-{
- int i;
- uint8_t byte;
-
- for (i = 0; i < cnt; i++) {
- if (ct->ct_tx.cr_head == ct->ct_tx.cr_tail) {
- /*
- * Queue is empty.
- */
- break;
- }
- byte = console_pull_char(&ct->ct_tx);
- console_blocking_tx(byte);
- }
-}
-
-void
-console_blocking_mode(void)
-{
- struct console_tty *ct = &console_tty;
- int sr;
-
- OS_ENTER_CRITICAL(sr);
- if (ct->ct_write_char) {
- ct->ct_write_char = console_blocking_tx;
-
- console_tx_flush(ct, MYNEWT_VAL(CONSOLE_TX_BUF_SIZE));
- }
- OS_EXIT_CRITICAL(sr);
-}
-
-void
-console_echo(int on)
-{
- struct console_tty *ct = &console_tty;
-
- ct->ct_echo_off = !on;
-}
-
-size_t
-console_file_write(void *arg, const char *str, size_t cnt)
-{
- struct console_tty *ct = &console_tty;
- int i;
-
- if (!ct->ct_write_char) {
- return cnt;
- }
- for (i = 0; i < cnt; i++) {
- if (str[i] == '\n') {
- ct->ct_write_char('\r');
- }
- ct->ct_write_char(str[i]);
- }
- if (cnt > 0) {
- console_is_midline = str[cnt - 1] != '\n';
- }
- uart_start_tx(ct->ct_dev);
- return cnt;
-}
-
-void
-console_write(const char *str, int cnt)
-{
- console_file_write(NULL, str, cnt);
-}
-
-int
-console_read(char *str, int cnt, int *newline)
-{
- struct console_tty *ct = &console_tty;
- struct console_ring *cr = &ct->ct_rx;
- int sr;
- int i;
- uint8_t ch;
-
- *newline = 0;
- OS_ENTER_CRITICAL(sr);
- for (i = 0; i < cnt; i++) {
- if (cr->cr_head == cr->cr_tail) {
- break;
- }
-
- if ((i & (CONSOLE_RX_CHUNK - 1)) == (CONSOLE_RX_CHUNK - 1)) {
- /*
- * Make a break from blocking interrupts during the copy.
- */
- OS_EXIT_CRITICAL(sr);
- OS_ENTER_CRITICAL(sr);
- }
-
- ch = console_pull_char(cr);
- if (ch == '\n') {
- *str = '\0';
- *newline = 1;
- break;
- }
- *str++ = ch;
- }
- OS_EXIT_CRITICAL(sr);
- if (i > 0 || *newline) {
- uart_start_rx(ct->ct_dev);
- }
- return i;
-}
-
-/*
- * Interrupts disabled when console_tx_char/console_rx_char are called.
- */
-static int
-console_tx_char(void *arg)
-{
- struct console_tty *ct = (struct console_tty *)arg;
- struct console_ring *cr = &ct->ct_tx;
-
- if (cr->cr_head == cr->cr_tail) {
- /*
- * No more data.
- */
- return -1;
- }
- return console_pull_char(cr);
-}
-
-static int
-console_buf_space(struct console_ring *cr)
-{
- int space;
-
- space = (cr->cr_tail - cr->cr_head) & (cr->cr_size - 1);
- return space - 1;
-}
-
-static int
-console_rx_char(void *arg, uint8_t data)
-{
- struct console_tty *ct = (struct console_tty *)arg;
- struct console_ring *tx = &ct->ct_tx;
- struct console_ring *rx = &ct->ct_rx;
- int tx_space = 0;
- int i;
-#if MYNEWT_VAL(CONSOLE_HIST_ENABLE)
- uint8_t tx_buf[MYNEWT_VAL(CONSOLE_RX_BUF_SIZE)];
-#else
- uint8_t tx_buf[3];
-#endif
-
- if (CONSOLE_HEAD_INC(&ct->ct_rx) == ct->ct_rx.cr_tail) {
- /*
- * RX queue full. Reader must drain this.
- */
- if (ct->ct_rx_cb) {
- ct->ct_rx_cb();
- }
- return -1;
- }
-
- /* echo */
- switch (data) {
- case '\r':
- case '\n':
- /*
- * linefeed
- */
- tx_buf[0] = '\n';
- tx_buf[1] = '\r';
- tx_space = 2;
- console_add_char(rx, '\n');
-#if MYNEWT_VAL(CONSOLE_HIST_ENABLE)
- console_hist_add(rx);
-#endif
- if (ct->ct_rx_cb) {
- ct->ct_rx_cb();
- }
- break;
- case CONSOLE_ESC:
- ct->ct_esc_seq = 1;
- goto out;
- case '[':
- if (ct->ct_esc_seq == 1) {
- ct->ct_esc_seq = 2;
- goto out;
- } else {
- goto queue_char;
- }
- break;
- case CONSOLE_LEFT:
- if (ct->ct_esc_seq == 2) {
- goto backspace;
- } else {
- goto queue_char;
- }
- break;
- case CONSOLE_UP:
- case CONSOLE_DOWN:
- if (ct->ct_esc_seq != 2) {
- goto queue_char;
- }
-#if MYNEWT_VAL(CONSOLE_HIST_ENABLE)
- tx_space = console_hist_move(rx, tx_buf, data);
- tx_buf[tx_space] = 0;
- ct->ct_esc_seq = 0;
- /*
- * when moving up, stop on oldest history entry
- * when moving down, let it delete input before leaving...
- */
- if (data == CONSOLE_UP && tx_space == 0) {
- goto out;
- }
- if (!ct->ct_echo_off) {
- /* HACK: clean line by backspacing up to maximum possible space */
- for (i = 0; i < MYNEWT_VAL(CONSOLE_TX_BUF_SIZE); i++) {
- if (console_buf_space(tx) < 3) {
- console_tx_flush(ct, 3);
- }
- console_add_char(tx, '\b');
- console_add_char(tx, ' ');
- console_add_char(tx, '\b');
- uart_start_tx(ct->ct_dev);
- }
- if (tx_space == 0) {
- goto out;
- }
- } else {
- goto queue_char;
- }
- break;
-#else
- ct->ct_esc_seq = 0;
- goto out;
-#endif
- case CONSOLE_RIGHT:
- if (ct->ct_esc_seq == 2) {
- data = ' '; /* add space */
- }
- goto queue_char;
- case '\b':
- case CONSOLE_DEL:
-backspace:
- /*
- * backspace
- */
- ct->ct_esc_seq = 0;
- if (console_pull_char_head(rx) == 0) {
- /*
- * Only wipe out char if we can pull stuff off from head.
- */
- tx_buf[0] = '\b';
- tx_buf[1] = ' ';
- tx_buf[2] = '\b';
- tx_space = 3;
- } else {
- goto out;
- }
- break;
- default:
-queue_char:
- tx_buf[0] = data;
- tx_space = 1;
- ct->ct_esc_seq = 0;
- console_add_char(rx, data);
- break;
- }
- if (!ct->ct_echo_off) {
- if (console_buf_space(tx) < tx_space) {
- console_tx_flush(ct, tx_space);
- }
- for (i = 0; i < tx_space; i++) {
- console_add_char(tx, tx_buf[i]);
- }
- uart_start_tx(ct->ct_dev);
- }
-out:
- return 0;
-}
-
-int
-console_is_init(void)
-{
- struct console_tty *ct = &console_tty;
-
- return (ct->ct_dev != NULL);
-}
-
-static int is_power_of_two (unsigned int x)
-{
- return ((x != 0) && !(x & (x - 1)));
-}
-
-int
-console_init(console_rx_cb rx_cb)
-{
- struct console_tty *ct = &console_tty;
- struct uart_conf uc = {
- .uc_speed = MYNEWT_VAL(CONSOLE_BAUD),
- .uc_databits = 8,
- .uc_stopbits = 1,
- .uc_parity = UART_PARITY_NONE,
- .uc_flow_ctl = MYNEWT_VAL(CONSOLE_FLOW_CONTROL),
- .uc_tx_char = console_tx_char,
- .uc_rx_char = console_rx_char,
- .uc_cb_arg = ct
- };
-
- ct->ct_rx_cb = rx_cb;
- if (!ct->ct_dev) {
- ct->ct_tx.cr_size = MYNEWT_VAL(CONSOLE_TX_BUF_SIZE);
- ct->ct_tx.cr_buf = ct->ct_tx_buf;
- ct->ct_rx.cr_size = MYNEWT_VAL(CONSOLE_RX_BUF_SIZE);
- ct->ct_rx.cr_buf = ct->ct_rx_buf;
- ct->ct_write_char = console_queue_char;
-
- ct->ct_dev = (struct uart_dev *)os_dev_open(CONSOLE_UART,
- OS_TIMEOUT_NEVER, &uc);
- if (!ct->ct_dev) {
- return -1;
- }
- ct->ct_echo_off = ! MYNEWT_VAL(CONSOLE_ECHO);
- }
-
- /* must be a power of 2 */
- assert(is_power_of_two(MYNEWT_VAL(CONSOLE_RX_BUF_SIZE)));
-
-#if MYNEWT_VAL(CONSOLE_HIST_ENABLE)
- console_hist_init();
-#endif
-
- return 0;
-}
-
-void
-console_pkg_init(void)
-{
- int rc;
-
- /* Ensure this function only gets called by sysinit. */
- SYSINIT_ASSERT_ACTIVE();
-
- rc = console_init(NULL);
- SYSINIT_PANIC_ASSERT(rc == 0);
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4863008f/sys/console/full/src/console.c
----------------------------------------------------------------------
diff --git a/sys/console/full/src/console.c b/sys/console/full/src/console.c
new file mode 100644
index 0000000..18ff755
--- /dev/null
+++ b/sys/console/full/src/console.c
@@ -0,0 +1,447 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <assert.h>
+#include <inttypes.h>
+#include <ctype.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "syscfg/syscfg.h"
+#include "os/os.h"
+#include "sysinit/sysinit.h"
+#include "console/console.h"
+#include "console/ticks.h"
+#include "console_priv.h"
+
+/* Control characters */
+#define ESC 0x1b
+#define DEL 0x7f
+
+/* ANSI escape sequences */
+#define ANSI_ESC '['
+#define ANSI_UP 'A'
+#define ANSI_DOWN 'B'
+#define ANSI_FORWARD 'C'
+#define ANSI_BACKWARD 'D'
+#define ANSI_END 'F'
+#define ANSI_HOME 'H'
+#define ANSI_DEL '~'
+
+#define ESC_ESC (1 << 0)
+#define ESC_ANSI (1 << 1)
+#define ESC_ANSI_FIRST (1 << 2)
+#define ESC_ANSI_VAL (1 << 3)
+#define ESC_ANSI_VAL_2 (1 << 4)
+
+/* Indicates whether the previous line of output was completed. */
+int console_is_midline;
+
+#if MYNEWT_VAL(CONSOLE_COMPAT)
+#define CONSOLE_COMPAT_MAX_CMD_QUEUED 1
+static struct console_input buf[CONSOLE_COMPAT_MAX_CMD_QUEUED];
+static struct os_event shell_console_ev[CONSOLE_COMPAT_MAX_CMD_QUEUED];
+static console_rx_cb console_compat_rx_cb; /* callback that input is ready */
+static struct os_eventq compat_avail_queue;
+static struct os_eventq compat_lines_queue;
+#endif
+
+static int esc_state;
+static int echo = 1;
+static unsigned int ansi_val, ansi_val_2;
+
+static uint8_t cur, end;
+static struct os_eventq *avail_queue;
+static struct os_eventq *lines_queue;
+static uint8_t (*completion_cb)(char *line, uint8_t len);
+
+void
+console_echo(int on)
+{
+ echo = on;
+}
+
+void
+console_write(const char *str, int cnt)
+{
+ int i;
+
+ for (i = 0; i < cnt; i++) {
+ if (console_out((int)str[i]) == EOF) {
+ break;
+ }
+ }
+}
+
+#if MYNEWT_VAL(CONSOLE_COMPAT)
+int
+console_read(char *str, int cnt, int *newline)
+{
+ struct os_event *ev;
+ struct console_input *cmd;
+ size_t len;
+
+ *newline = 0;
+ ev = os_eventq_get_no_wait(lines_queue);
+ if (!ev) {
+ return 0;
+ }
+ cmd = ev->ev_arg;
+ len = strlen(cmd->line);
+ strncpy(str, cmd->line, len+1);
+ os_eventq_put(avail_queue, ev);
+ *newline = 1;
+ return len;
+}
+#endif
+
+void
+console_blocking_mode(void)
+{
+#if MYNEWT_VAL(CONSOLE_UART)
+ uart_console_blocking_mode();
+#endif
+}
+
+static inline void
+cursor_forward(unsigned int count)
+{
+ console_printf("\x1b[%uC", count);
+}
+
+static inline void
+cursor_backward(unsigned int count)
+{
+ console_printf("\x1b[%uD", count);
+}
+
+static inline void
+cursor_save(void)
+{
+ console_out(ESC);
+ console_out('[');
+ console_out('s');
+}
+
+static inline void
+cursor_restore(void)
+{
+ console_out(ESC);
+ console_out('[');
+ console_out('u');
+}
+
+static void
+insert_char(char *pos, char c, uint8_t end)
+{
+ char tmp;
+
+ if (echo) {
+ /* Echo back to console */
+ console_out(c);
+ }
+
+ if (end == 0) {
+ *pos = c;
+ return;
+ }
+
+ tmp = *pos;
+ *(pos++) = c;
+
+ cursor_save();
+
+ while (end-- > 0) {
+ console_out(tmp);
+ c = *pos;
+ *(pos++) = tmp;
+ tmp = c;
+ }
+
+ /* Move cursor back to right place */
+ cursor_restore();
+}
+
+static void
+del_char(char *pos, uint8_t end)
+{
+ console_out('\b');
+
+ if (end == 0) {
+ console_out(' ');
+ console_out('\b');
+ return;
+ }
+
+ cursor_save();
+
+ while (end-- > 0) {
+ *pos = *(pos + 1);
+ console_out(*(pos++));
+ }
+
+ console_out(' ');
+
+ /* Move cursor back to right place */
+ cursor_restore();
+}
+
+static void
+handle_ansi(uint8_t byte, char *line)
+{
+ if (esc_state & ESC_ANSI_FIRST) {
+ esc_state &= ~ESC_ANSI_FIRST;
+ if (!isdigit(byte)) {
+ ansi_val = 1;
+ goto ansi_cmd;
+ }
+
+ esc_state |= ESC_ANSI_VAL;
+ ansi_val = byte - '0';
+ ansi_val_2 = 0;
+ return;
+ }
+
+ if (esc_state & ESC_ANSI_VAL) {
+ if (isdigit(byte)) {
+ if (esc_state & ESC_ANSI_VAL_2) {
+ ansi_val_2 *= 10;
+ ansi_val_2 += byte - '0';
+ } else {
+ ansi_val *= 10;
+ ansi_val += byte - '0';
+ }
+ return;
+ }
+
+ /* Multi value sequence, e.g. Esc[Line;ColumnH */
+ if (byte == ';' && !(esc_state & ESC_ANSI_VAL_2)) {
+ esc_state |= ESC_ANSI_VAL_2;
+ return;
+ }
+
+ esc_state &= ~ESC_ANSI_VAL;
+ esc_state &= ~ESC_ANSI_VAL_2;
+ }
+
+ansi_cmd:
+ switch (byte) {
+ case ANSI_BACKWARD:
+ if (ansi_val > cur) {
+ break;
+ }
+
+ end += ansi_val;
+ cur -= ansi_val;
+ cursor_backward(ansi_val);
+ break;
+ case ANSI_FORWARD:
+ if (ansi_val > end) {
+ break;
+ }
+
+ end -= ansi_val;
+ cur += ansi_val;
+ cursor_forward(ansi_val);
+ break;
+ case ANSI_HOME:
+ if (!cur) {
+ break;
+ }
+
+ cursor_backward(cur);
+ end += cur;
+ cur = 0;
+ break;
+ case ANSI_END:
+ if (!end) {
+ break;
+ }
+
+ cursor_forward(end);
+ cur += end;
+ end = 0;
+ break;
+ case ANSI_DEL:
+ if (!end) {
+ break;
+ }
+
+ cursor_forward(1);
+ del_char(&line[cur], --end);
+ break;
+ default:
+ break;
+ }
+
+ esc_state &= ~ESC_ANSI;
+}
+
+int
+console_handle_char(uint8_t byte)
+{
+#if !MYNEWT_VAL(CONSOLE_INPUT)
+ return 0;
+#endif
+
+ static struct os_event *ev;
+ static struct console_input *input;
+
+ if (!avail_queue || !lines_queue) {
+ return 0;
+ }
+
+ if (!ev) {
+ ev = os_eventq_get_no_wait(avail_queue);
+ if (!ev)
+ return 0;
+ input = ev->ev_arg;
+ }
+
+ /* Handle ANSI escape mode */
+ if (esc_state & ESC_ANSI) {
+ handle_ansi(byte, input->line);
+ return 0;
+ }
+
+ /* Handle escape mode */
+ if (esc_state & ESC_ESC) {
+ esc_state &= ~ESC_ESC;
+ handle_ansi(byte, input->line);
+ switch (byte) {
+ case ANSI_ESC:
+ esc_state |= ESC_ANSI;
+ esc_state |= ESC_ANSI_FIRST;
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+ }
+
+ /* Handle special control characters */
+ if (!isprint(byte)) {
+ handle_ansi(byte, input->line);
+ switch (byte) {
+ case DEL:
+ if (cur > 0) {
+ del_char(&input->line[--cur], end);
+ }
+ break;
+ case ESC:
+ esc_state |= ESC_ESC;
+ break;
+ case '\r':
+ input->line[cur + end] = '\0';
+ console_out('\r');
+ console_out('\n');
+ cur = 0;
+ end = 0;
+ os_eventq_put(lines_queue, ev);
+
+#if MYNEWT_VAL(CONSOLE_COMPAT)
+ if (console_compat_rx_cb) {
+ console_compat_rx_cb();
+ }
+#endif
+
+ input = NULL;
+ ev = NULL;
+ break;
+ case '\t':
+ if (completion_cb && !end) {
+ cur += completion_cb(input->line, cur);
+ }
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+ }
+
+ /* Ignore characters if there's no more buffer space */
+ if (cur + end < sizeof(input->line) - 1) {
+ insert_char(&input->line[cur++], byte, end);
+ }
+ return 0;
+}
+
+int
+console_is_init(void)
+{
+#if MYNEWT_VAL(CONSOLE_UART)
+ return uart_console_is_init();
+#endif
+#if MYNEWT_VAL(CONSOLE_RTT)
+ return rtt_console_is_init();
+#endif
+ return 0;
+}
+
+void
+console_set_queues(struct os_eventq *avail, struct os_eventq *lines)
+{
+ avail_queue = avail;
+ lines_queue = lines;
+}
+
+void
+console_set_completion_cb(uint8_t (*completion)(char *str, uint8_t len))
+{
+ completion_cb = completion;
+}
+
+#if MYNEWT_VAL(CONSOLE_COMPAT)
+int
+console_init(console_rx_cb rx_cb)
+{
+ int i;
+
+ os_eventq_init(&compat_lines_queue);
+ os_eventq_init(&compat_avail_queue);
+ console_set_queues(&compat_avail_queue, &compat_lines_queue);
+
+ for (i = 0; i < CONSOLE_COMPAT_MAX_CMD_QUEUED; i++) {
+ shell_console_ev[i].ev_arg = &buf[i];
+ os_eventq_put(avail_queue, &shell_console_ev[i]);
+ }
+ console_compat_rx_cb = rx_cb;
+ return 0;
+}
+#endif
+
+void
+console_pkg_init(void)
+{
+ int rc = 0;
+
+ /* Ensure this function only gets called by sysinit. */
+ SYSINIT_ASSERT_ACTIVE();
+
+#if MYNEWT_VAL(CONSOLE_UART)
+ rc = uart_console_init();
+#endif
+#if MYNEWT_VAL(CONSOLE_RTT)
+ rc = rtt_console_init();
+#endif
+ SYSINIT_PANIC_ASSERT(rc == 0);
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4863008f/sys/console/full/src/console_fmt.c
----------------------------------------------------------------------
diff --git a/sys/console/full/src/console_fmt.c b/sys/console/full/src/console_fmt.c
new file mode 100644
index 0000000..32b68e3
--- /dev/null
+++ b/sys/console/full/src/console_fmt.c
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include <stdarg.h>
+#include <stdio.h>
+#include "syscfg/syscfg.h"
+#include "console/console.h"
+#include "console/ticks.h"
+#include "os/os_time.h"
+
+#define CONS_OUTPUT_MAX_LINE 128
+
+
+#if MYNEWT_VAL(BASELIBC_PRESENT)
+
+/**
+ * Prints the specified format string to the console.
+ *
+ * @return The number of characters that would have been
+ * printed if the console buffer were
+ * unlimited. This return value is analogous
+ * to that of snprintf.
+ */
+int
+console_printf(const char *fmt, ...)
+{
+ va_list args;
+ int num_chars;
+
+ num_chars = 0;
+
+ if (console_get_ticks()) {
+ /* Prefix each line with a timestamp. */
+ if (!console_is_midline) {
+ num_chars += printf("%06lu ", (unsigned long)os_time_get());
+ }
+ }
+
+ va_start(args, fmt);
+ num_chars += vprintf(fmt, args);
+ va_end(args);
+
+ return num_chars;
+}
+
+
+#else
+
+/**
+ * Prints the specified format string to the console.
+ *
+ * @return The number of characters that would have been
+ * printed if the console buffer were
+ * unlimited. This return value is analogous
+ * to that of snprintf.
+ */
+int
+console_printf(const char *fmt, ...)
+{
+ va_list args;
+ char buf[CONS_OUTPUT_MAX_LINE];
+ int num_chars;
+ int len;
+
+ num_chars = 0;
+
+ if (console_get_ticks()) {
+ /* Prefix each line with a timestamp. */
+ if (!console_is_midline) {
+ len = snprintf(buf, sizeof(buf), "%06lu ",
+ (unsigned long)os_time_get());
+ num_chars += len;
+ console_write(buf, len);
+ }
+ }
+
+ va_start(args, fmt);
+ len = vsnprintf(buf, sizeof(buf), fmt, args);
+ num_chars += len;
+ if (len >= sizeof(buf)) {
+ len = sizeof(buf) - 1;
+ }
+ console_write(buf, len);
+ va_end(args);
+
+ return num_chars;
+}
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4863008f/sys/console/full/src/console_priv.h
----------------------------------------------------------------------
diff --git a/sys/console/full/src/console_priv.h b/sys/console/full/src/console_priv.h
new file mode 100644
index 0000000..d307b5d
--- /dev/null
+++ b/sys/console/full/src/console_priv.h
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef __CONSOLE_PRIV_H__
+#define __CONSOLE_PRIV_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int uart_console_is_init(void);
+int uart_console_init(void);
+void uart_console_blocking_mode(void);
+int rtt_console_is_init(void);
+int rtt_console_init(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CONSOLE_PRIV_H__ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4863008f/sys/console/full/src/prompt.c
----------------------------------------------------------------------
diff --git a/sys/console/full/src/prompt.c b/sys/console/full/src/prompt.c
deleted file mode 100644
index 251c249..0000000
--- a/sys/console/full/src/prompt.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-#include "console/console.h"
-#include "console/prompt.h"
-#include <syscfg/syscfg.h>
-
-/* console prompt, always followed by a space */
-static char console_prompt[] = " > ";
-static char do_prompt = MYNEWT_VAL(CONSOLE_PROMPT);
-
-
-/* set the prompt character, leave the space */
-void
-console_set_prompt(char p)
-{
- do_prompt = 1;
- console_prompt[1] = p;
-}
-
-void
-console_no_prompt(void)
-{
- do_prompt = 0;
-}
-
-void
-console_yes_prompt(void)
-{
- do_prompt = 1;
-}
-
-/* print the prompt to the console */
-void
-console_print_prompt(void)
-{
- if (do_prompt) {
- console_printf("%s", console_prompt);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4863008f/sys/console/full/src/rtt_console.c
----------------------------------------------------------------------
diff --git a/sys/console/full/src/rtt_console.c b/sys/console/full/src/rtt_console.c
new file mode 100644
index 0000000..63067c1
--- /dev/null
+++ b/sys/console/full/src/rtt_console.c
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "syscfg/syscfg.h"
+
+#if MYNEWT_VAL(CONSOLE_RTT)
+#include <ctype.h>
+
+#include "os/os.h"
+#include "os/os_cputime.h"
+#include "rtt/SEGGER_RTT.h"
+#include "console/console.h"
+#include "console_priv.h"
+
+#if MYNEWT_VAL(CONSOLE_INPUT)
+static struct hal_timer rtt_timer;
+#endif
+
+static const char CR = '\r';
+
+int
+console_out(int character)
+{
+ char c = (char)character;
+
+ if ('\n' == c) {
+ SEGGER_RTT_WriteNoLock(0, &CR, 1);
+ console_is_midline = 0;
+ } else {
+ console_is_midline = 1;
+ }
+
+ SEGGER_RTT_WriteNoLock(0, &c, 1);
+
+ return character;
+}
+
+#if MYNEWT_VAL(CONSOLE_INPUT)
+void
+rtt(void *arg)
+{
+ int key;
+ int i = 0;
+ uint32_t timeout;
+
+ key = SEGGER_RTT_GetKey();
+ if (key >= 0) {
+ console_handle_char((char)key);
+ i = 0;
+ }
+ /* These values were selected to keep the shell responsive
+ * and at the same time reduce context switches.
+ * Min sleep is 50ms and max is 250ms.
+ */
+ if (i < 5) {
+ ++i;
+ }
+ timeout = 50000 * i;
+ os_cputime_timer_relative(&rtt_timer, timeout);
+}
+#endif
+
+int
+rtt_console_is_init(void)
+{
+ return 1;
+}
+
+int
+rtt_console_init(void)
+{
+#if MYNEWT_VAL(CONSOLE_INPUT)
+ os_cputime_timer_init(&rtt_timer, rtt, NULL);
+ /* start after a second */
+ os_cputime_timer_relative(&rtt_timer, 1000000);
+#endif
+ return 0;
+}
+
+#endif /* MYNEWT_VAL(CONSOLE_RTT) */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4863008f/sys/console/full/src/ticks.c
----------------------------------------------------------------------
diff --git a/sys/console/full/src/ticks.c b/sys/console/full/src/ticks.c
index 1a442aa..06d1c8f 100644
--- a/sys/console/full/src/ticks.c
+++ b/sys/console/full/src/ticks.c
@@ -18,9 +18,9 @@
*/
+#include "syscfg/syscfg.h"
#include "console/console.h"
#include "console/prompt.h"
-#include "syscfg/syscfg.h"
static char do_ticks = MYNEWT_VAL(CONSOLE_TICKS);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4863008f/sys/console/full/src/uart_console.c
----------------------------------------------------------------------
diff --git a/sys/console/full/src/uart_console.c b/sys/console/full/src/uart_console.c
new file mode 100644
index 0000000..44943d2
--- /dev/null
+++ b/sys/console/full/src/uart_console.c
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "syscfg/syscfg.h"
+
+#if MYNEWT_VAL(CONSOLE_UART)
+#include <ctype.h>
+#include <assert.h>
+
+#include "os/os.h"
+#include "uart/uart.h"
+#include "bsp/bsp.h"
+
+#include "console/console.h"
+#include "console_priv.h"
+
+#define CONSOLE_HEAD_INC(cr) (((cr)->cr_head + 1) & ((cr)->cr_size - 1))
+#define CONSOLE_TAIL_INC(cr) (((cr)->cr_tail + 1) & ((cr)->cr_size - 1))
+
+static struct uart_dev *uart_dev;
+static struct console_ring cr_tx;
+/* must be after console_ring */
+static uint8_t cr_tx_buf[MYNEWT_VAL(CONSOLE_UART_TX_BUF_SIZE)];
+typedef void (*console_write_char)(struct uart_dev*, uint8_t);
+static console_write_char write_char_cb;
+
+struct console_ring {
+ uint8_t cr_head;
+ uint8_t cr_tail;
+ uint16_t cr_size;
+ uint8_t *cr_buf;
+};
+
+static void
+console_add_char(struct console_ring *cr, char ch)
+{
+ cr->cr_buf[cr->cr_head] = ch;
+ cr->cr_head = CONSOLE_HEAD_INC(cr);
+}
+
+static uint8_t
+console_pull_char(struct console_ring *cr)
+{
+ uint8_t ch;
+
+ ch = cr->cr_buf[cr->cr_tail];
+ cr->cr_tail = CONSOLE_TAIL_INC(cr);
+ return ch;
+}
+
+static void
+console_queue_char(struct uart_dev *uart_dev, uint8_t ch)
+{
+ int sr;
+
+ OS_ENTER_CRITICAL(sr);
+ while (CONSOLE_HEAD_INC(&cr_tx) == cr_tx.cr_tail) {
+ /* TX needs to drain */
+ uart_start_tx(uart_dev);
+ OS_EXIT_CRITICAL(sr);
+ if (os_started()) {
+ os_time_delay(1);
+ }
+ OS_ENTER_CRITICAL(sr);
+ }
+ console_add_char(&cr_tx, ch);
+ OS_EXIT_CRITICAL(sr);
+}
+
+/*
+ * Flush cnt characters from console output queue.
+ */
+static void
+console_tx_flush(int cnt)
+{
+ int i;
+ uint8_t byte;
+
+ for (i = 0; i < cnt; i++) {
+ if (cr_tx.cr_head == cr_tx.cr_tail) {
+ /*
+ * Queue is empty.
+ */
+ break;
+ }
+ byte = console_pull_char(&cr_tx);
+ uart_blocking_tx(uart_dev, byte);
+ }
+}
+
+void
+uart_console_blocking_mode(void)
+{
+ int sr;
+
+ OS_ENTER_CRITICAL(sr);
+ if (write_char_cb) {
+ write_char_cb = uart_blocking_tx;
+
+ console_tx_flush(MYNEWT_VAL(CONSOLE_UART_TX_BUF_SIZE));
+ }
+ OS_EXIT_CRITICAL(sr);
+}
+
+int
+console_out(int c)
+{
+ if ('\n' == c) {
+ write_char_cb(uart_dev, '\r');
+ console_is_midline = 0;
+ } else {
+ console_is_midline = 1;
+ }
+ write_char_cb(uart_dev, c);
+ uart_start_tx(uart_dev);
+
+ return c;
+}
+
+/*
+ * Interrupts disabled when console_tx_char/console_rx_char are called.
+ * Characters sent only in blocking mode.
+ */
+static int
+console_tx_char(void *arg)
+{
+ if (cr_tx.cr_head == cr_tx.cr_tail) {
+ /*
+ * No more data.
+ */
+ return -1;
+ }
+ return console_pull_char(&cr_tx);
+}
+
+/*
+ * Interrupts disabled when console_tx_char/console_rx_char are called.
+ */
+static int
+console_rx_char(void *arg, uint8_t byte)
+{
+ return console_handle_char(byte);
+}
+
+int
+uart_console_is_init(void)
+{
+ return uart_dev != NULL;
+}
+
+int
+uart_console_init(void)
+{
+ struct uart_conf uc = {
+ .uc_speed = MYNEWT_VAL(CONSOLE_UART_BAUD),
+ .uc_databits = 8,
+ .uc_stopbits = 1,
+ .uc_parity = UART_PARITY_NONE,
+ .uc_flow_ctl = MYNEWT_VAL(CONSOLE_UART_FLOW_CONTROL),
+ .uc_tx_char = console_tx_char,
+ .uc_rx_char = console_rx_char,
+ };
+
+ cr_tx.cr_size = MYNEWT_VAL(CONSOLE_UART_TX_BUF_SIZE);
+ cr_tx.cr_buf = cr_tx_buf;
+ write_char_cb = console_queue_char;
+
+ if (!uart_dev) {
+ uart_dev = (struct uart_dev *)os_dev_open(CONSOLE_UART,
+ OS_TIMEOUT_NEVER, &uc);
+ if (!uart_dev) {
+ return -1;
+ }
+ }
+ return 0;
+}
+#endif /* MYNEWT_VAL(CONSOLE_UART) */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4863008f/sys/console/full/syscfg.yml
----------------------------------------------------------------------
diff --git a/sys/console/full/syscfg.yml b/sys/console/full/syscfg.yml
index 68eedaf..45fc2ed 100644
--- a/sys/console/full/syscfg.yml
+++ b/sys/console/full/syscfg.yml
@@ -19,27 +19,31 @@
# Package: sys/console/full
syscfg.defs:
- CONSOLE_BAUD:
+ CONSOLE_UART:
+ description: 'Set console output to UART'
+ value: 1
+ CONSOLE_RTT:
+ description: 'Set console output to RTT'
+ value: 0
+ CONSOLE_INPUT:
+ description: 'Enable console input'
+ value: 1
+ CONSOLE_TICKS:
+ description: 'Print OS Ticks'
+ value: 1
+ CONSOLE_COMPAT:
+ description: 'Console backward compatibility'
+ value: 1
+ CONSOLE_MAX_INPUT_LEN:
+ description: 'Maximum input line length'
+ value: 256
+
+ CONSOLE_UART_BAUD:
description: 'Console UART baud rate.'
value: '115200'
- CONSOLE_FLOW_CONTROL:
+ CONSOLE_UART_FLOW_CONTROL:
description: 'Console UART flow control.'
value: 'UART_FLOW_CTL_NONE'
- CONSOLE_TX_BUF_SIZE:
- description: 'Console transmit buffer size; must be power of 2.'
+ CONSOLE_UART_TX_BUF_SIZE:
+ description: 'UART console transmit buffer size; must be power of 2.'
value: 32
- CONSOLE_RX_BUF_SIZE:
- description: 'Console receive buffer size.'
- value: 128
- CONSOLE_TICKS:
- description: 'Print OS Ticks'
- value: '1'
- CONSOLE_PROMPT:
- description: 'Default console prompt '
- value: '0'
- CONSOLE_ECHO:
- description: 'Default console echo '
- value: '1'
- CONSOLE_HIST_ENABLE:
- description: 'Console history '
- value: 0
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4863008f/sys/console/minimal/include/console/console.h
----------------------------------------------------------------------
diff --git a/sys/console/minimal/include/console/console.h b/sys/console/minimal/include/console/console.h
deleted file mode 100644
index 61f6534..0000000
--- a/sys/console/minimal/include/console/console.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-#ifndef __CONSOLE_H__
-#define __CONSOLE_H__
-
-#include <stdarg.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void (*console_rx_cb)(void);
-
-int console_init(console_rx_cb rx_cb);
-static int inline
-console_is_init(void)
-{
- return 0;
-}
-
-void console_write(const char *str, int cnt);
-int console_read(char *str, int cnt, int *newline);
-static void inline
-console_blocking_mode(void)
-{
-}
-
-static void inline
-console_echo(int on)
-{
-}
-
-static int console_printf(const char *fmt, ...)
- __attribute__ ((format (printf, 1, 2)));;
-static int inline
-console_printf(const char *fmt, ...)
-{
- return 0;
-}
-
-#define console_is_midline 0
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CONSOLE_H__ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4863008f/sys/console/minimal/include/console/prompt.h
----------------------------------------------------------------------
diff --git a/sys/console/minimal/include/console/prompt.h b/sys/console/minimal/include/console/prompt.h
deleted file mode 100644
index 6de36f5..0000000
--- a/sys/console/minimal/include/console/prompt.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef __CONSOLE_PROMPT_H__
-#define __CONSOLE_PROMPT_H__
-
-#include <stdarg.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* print console prompt */
-static void inline
-console_print_prompt(void)
-{
-}
-
-/* set the console prompt character */
-static void inline
-console_set_prompt(char ch)
-{
-}
-
-static void inline
-console_no_prompt(void)
-{
-}
-
-static void inline
-console_yes_prompt(void)
-{
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CONSOLE_PROMPT_H__ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4863008f/sys/console/minimal/include/console/ticks.h
----------------------------------------------------------------------
diff --git a/sys/console/minimal/include/console/ticks.h b/sys/console/minimal/include/console/ticks.h
deleted file mode 100644
index 97f6a05..0000000
--- a/sys/console/minimal/include/console/ticks.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef __CONSOLE_TICKS_H__
-#define __CONSOLE_TICKS_H__
-
-#include <stdarg.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-static void inline
-console_no_ticks(void)
-{
-}
-
-static void inline
-console_yes_ticks(void)
-{
-}
-
-static char inline
-console_get_ticks(void)
-{
- return 0;
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CONSOLE_PROMPT_H__ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4863008f/sys/console/minimal/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/console/minimal/pkg.yml b/sys/console/minimal/pkg.yml
deleted file mode 100644
index 40e8980..0000000
--- a/sys/console/minimal/pkg.yml
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-pkg.name: sys/console/minimal
-pkg.description: Text-based IO interface (minimized).
-pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
-pkg.homepage: "http://mynewt.apache.org/"
-pkg.keywords:
-
-pkg.deps:
- - hw/hal
- - kernel/os
- - hw/drivers/uart
-pkg.apis: console
-
-pkg.init:
- console_pkg_init: 20
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4863008f/sys/console/minimal/src/cons_tty.c
----------------------------------------------------------------------
diff --git a/sys/console/minimal/src/cons_tty.c b/sys/console/minimal/src/cons_tty.c
deleted file mode 100644
index d837878..0000000
--- a/sys/console/minimal/src/cons_tty.c
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*
- * Minimal line-based console implementation. Does not include
- * echo, command line history, prompt or console_printf().
- * Only offers console_write() and console_read().
- */
-#include <inttypes.h>
-#include <assert.h>
-#include "syscfg/syscfg.h"
-#include "sysinit/sysinit.h"
-#include "os/os.h"
-#include "uart/uart.h"
-#include "bsp/bsp.h"
-
-#include "console/console.h"
-#include "console/prompt.h"
-
-#define CONSOLE_RX_CHUNK 16
-
-#define CONSOLE_HEAD_INC(cr) (((cr)->cr_head + 1) & ((cr)->cr_size - 1))
-#define CONSOLE_TAIL_INC(cr) (((cr)->cr_tail + 1) & ((cr)->cr_size - 1))
-
-struct console_ring {
- uint8_t cr_head;
- uint8_t cr_tail;
- uint16_t cr_size;
- uint8_t *cr_buf;
-};
-
-struct console_tty {
- struct uart_dev *ct_dev;
-
- struct console_ring ct_tx;
- /* must be after console_ring */
- uint8_t ct_tx_buf[MYNEWT_VAL(CONSOLE_TX_BUF_SIZE)];
-
- struct console_ring ct_rx;
- /* must be after console_ring */
- uint8_t ct_rx_buf[MYNEWT_VAL(CONSOLE_RX_BUF_SIZE)];
-
- console_rx_cb ct_rx_cb; /* callback that input is ready */
-} console_tty;
-
-static void
-console_add_char(struct console_ring *cr, char ch)
-{
- cr->cr_buf[cr->cr_head] = ch;
- cr->cr_head = CONSOLE_HEAD_INC(cr);
-}
-
-static uint8_t
-console_pull_char(struct console_ring *cr)
-{
- uint8_t ch;
-
- ch = cr->cr_buf[cr->cr_tail];
- cr->cr_tail = CONSOLE_TAIL_INC(cr);
- return ch;
-}
-
-static void
-console_queue_char(char ch)
-{
- struct console_tty *ct = &console_tty;
- int sr;
-
- OS_ENTER_CRITICAL(sr);
- while (CONSOLE_HEAD_INC(&ct->ct_tx) == ct->ct_tx.cr_tail) {
- /* TX needs to drain */
- uart_start_tx(ct->ct_dev);
- OS_EXIT_CRITICAL(sr);
- OS_ENTER_CRITICAL(sr);
- }
- console_add_char(&ct->ct_tx, ch);
- OS_EXIT_CRITICAL(sr);
-}
-
-void
-console_write(const char *str, int cnt)
-{
- struct console_tty *ct = &console_tty;
- int i;
-
- for (i = 0; i < cnt; i++) {
- if (str[i] == '\n') {
- console_queue_char('\r');
- }
- console_queue_char(str[i]);
- }
- uart_start_tx(ct->ct_dev);
-}
-
-int
-console_read(char *str, int cnt, int *newline)
-{
- struct console_tty *ct = &console_tty;
- struct console_ring *cr = &ct->ct_rx;
- int sr;
- int i;
- uint8_t ch;
-
- *newline = 0;
- OS_ENTER_CRITICAL(sr);
- for (i = 0; i < cnt; i++) {
- if (cr->cr_head == cr->cr_tail) {
- break;
- }
-
- if ((i & (CONSOLE_RX_CHUNK - 1)) == (CONSOLE_RX_CHUNK - 1)) {
- /*
- * Make a break from blocking interrupts during the copy.
- */
- OS_EXIT_CRITICAL(sr);
- OS_ENTER_CRITICAL(sr);
- }
-
- ch = console_pull_char(cr);
- if (ch == '\n') {
- *str = '\0';
- *newline = 1;
- break;
- }
- *str++ = ch;
- }
- OS_EXIT_CRITICAL(sr);
- if (i > 0 || *newline) {
- uart_start_rx(ct->ct_dev);
- }
- return i;
-}
-
-/*
- * Interrupts disabled when console_tx_char/console_rx_char are called.
- */
-static int
-console_tx_char(void *arg)
-{
- struct console_tty *ct = (struct console_tty *)arg;
- struct console_ring *cr = &ct->ct_tx;
-
- if (cr->cr_head == cr->cr_tail) {
- /*
- * No more data.
- */
- return -1;
- }
- return console_pull_char(cr);
-}
-
-static int
-console_rx_char(void *arg, uint8_t data)
-{
- struct console_tty *ct = (struct console_tty *)arg;
- struct console_ring *rx = &ct->ct_rx;
-
- if (CONSOLE_HEAD_INC(&ct->ct_rx) == ct->ct_rx.cr_tail) {
- /*
- * RX queue full. Reader must drain this.
- */
- if (ct->ct_rx_cb) {
- ct->ct_rx_cb();
- }
- return -1;
- }
-
- /* echo */
- switch (data) {
- case '\r':
- case '\n':
- /*
- * linefeed
- */
- console_add_char(rx, '\n');
- if (ct->ct_rx_cb) {
- ct->ct_rx_cb();
- }
- break;
- default:
- console_add_char(rx, data);
- break;
- }
- return 0;
-}
-
-static int is_power_of_two (unsigned int x)
-{
- return ((x != 0) && !(x & (x - 1)));
-}
-
-int
-console_init(console_rx_cb rx_cb)
-{
- struct console_tty *ct = &console_tty;
- struct uart_conf uc = {
- .uc_speed = MYNEWT_VAL(CONSOLE_BAUD),
- .uc_databits = 8,
- .uc_stopbits = 1,
- .uc_parity = UART_PARITY_NONE,
- .uc_flow_ctl = MYNEWT_VAL(CONSOLE_FLOW_CONTROL),
- .uc_tx_char = console_tx_char,
- .uc_rx_char = console_rx_char,
- .uc_cb_arg = ct
- };
-
- ct->ct_rx_cb = rx_cb;
- if (!ct->ct_dev) {
- ct->ct_tx.cr_size = MYNEWT_VAL(CONSOLE_TX_BUF_SIZE);
- ct->ct_tx.cr_buf = ct->ct_tx_buf;
- ct->ct_rx.cr_size = MYNEWT_VAL(CONSOLE_RX_BUF_SIZE);
- ct->ct_rx.cr_buf = ct->ct_rx_buf;
-
- ct->ct_dev = (struct uart_dev *)os_dev_open(CONSOLE_UART,
- OS_TIMEOUT_NEVER, &uc);
- if (!ct->ct_dev) {
- return -1;
- }
- }
-
- /* must be a power of 2 */
- assert(is_power_of_two(MYNEWT_VAL(CONSOLE_RX_BUF_SIZE)));
-
- return 0;
-}
-
-void
-console_pkg_init(void)
-{
- int rc;
-
- /* Ensure this function only gets called by sysinit. */
- SYSINIT_ASSERT_ACTIVE();
-
- rc = console_init(NULL);
- SYSINIT_PANIC_ASSERT(rc == 0);
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4863008f/sys/console/minimal/syscfg.yml
----------------------------------------------------------------------
diff --git a/sys/console/minimal/syscfg.yml b/sys/console/minimal/syscfg.yml
deleted file mode 100644
index 8b4732b..0000000
--- a/sys/console/minimal/syscfg.yml
+++ /dev/null
@@ -1,33 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-# Package: sys/console/minimal
-
-syscfg.defs:
- CONSOLE_BAUD:
- description: 'Console UART baud rate.'
- value: '115200'
- CONSOLE_FLOW_CONTROL:
- description: 'Console UART flow control.'
- value: 'UART_FLOW_CTL_NONE'
- CONSOLE_TX_BUF_SIZE:
- description: 'Console transmit buffer size; must be power of 2.'
- value: 32
- CONSOLE_RX_BUF_SIZE:
- description: 'Console receive buffer size.'
- value: 128
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4863008f/sys/console/stub/include/console/console.h
----------------------------------------------------------------------
diff --git a/sys/console/stub/include/console/console.h b/sys/console/stub/include/console/console.h
index 3c83b9d..d60aaf8 100644
--- a/sys/console/stub/include/console/console.h
+++ b/sys/console/stub/include/console/console.h
@@ -19,12 +19,18 @@
#ifndef __CONSOLE_H__
#define __CONSOLE_H__
-#include <stdarg.h>
+#include <inttypes.h>
#ifdef __cplusplus
extern "C" {
#endif
+struct os_eventq;
+
+struct console_input {
+ char line[0];
+};
+
typedef void (*console_rx_cb)(void);
static int inline
@@ -34,11 +40,16 @@ console_is_init(void)
}
static int inline
-console_init(console_rx_cb rxcb)
+console_init(console_rx_cb rx_cb)
{
return 0;
}
+static void inline
+console_write(const char *str, int cnt)
+{
+}
+
static int inline
console_read(char *str, int cnt, int *newline)
{
@@ -52,7 +63,7 @@ console_blocking_mode(void)
}
static void inline
-console_write(const char *str, int cnt)
+console_echo(int on)
{
}
@@ -66,8 +77,26 @@ console_printf(const char *fmt, ...)
}
static void inline
-console_echo(int on)
+console_set_queues(struct os_eventq *avail_queue,
+ struct os_eventq *cmd_queue)
+{
+}
+
+static void inline
+console_set_completion_cb(uint8_t (*completion)(char *str, uint8_t len))
+{
+}
+
+static int inline
+console_handle_char(uint8_t byte)
{
+ return 0;
+}
+
+static int inline
+console_out(int character)
+{
+ return 0;
}
#define console_is_midline (0)
[45/50] [abbrv] incubator-mynewt-core git commit: sys/console: bring
back console/minimal
Posted by ja...@apache.org.
sys/console: bring back console/minimal
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/5008f7c9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/5008f7c9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/5008f7c9
Branch: refs/heads/bluetooth5
Commit: 5008f7c98a760b0e66d59b05be7ba6356281bca8
Parents: c7b6f80
Author: Micha\u0142 Narajowski <mi...@codecoup.pl>
Authored: Thu Apr 20 08:32:03 2017 +0200
Committer: Micha\u0142 Narajowski <mi...@codecoup.pl>
Committed: Tue Apr 25 17:49:15 2017 -0700
----------------------------------------------------------------------
sys/console/minimal/include/console/console.h | 80 ++++++
sys/console/minimal/include/console/prompt.h | 55 ++++
sys/console/minimal/pkg.yml | 36 +++
sys/console/minimal/src/console.c | 303 +++++++++++++++++++++
sys/console/minimal/src/console_priv.h | 38 +++
sys/console/minimal/src/rtt_console.c | 96 +++++++
sys/console/minimal/src/uart_console.c | 205 ++++++++++++++
sys/console/minimal/syscfg.yml | 49 ++++
8 files changed, 862 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5008f7c9/sys/console/minimal/include/console/console.h
----------------------------------------------------------------------
diff --git a/sys/console/minimal/include/console/console.h b/sys/console/minimal/include/console/console.h
new file mode 100644
index 0000000..ede7269
--- /dev/null
+++ b/sys/console/minimal/include/console/console.h
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef __CONSOLE_H__
+#define __CONSOLE_H__
+
+#include <inttypes.h>
+#include "syscfg/syscfg.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct os_eventq;
+
+struct console_input {
+ char line[MYNEWT_VAL(CONSOLE_MAX_INPUT_LEN)];
+};
+
+typedef void (*console_rx_cb)(void);
+
+int console_init(console_rx_cb rx_cb);
+int console_is_init(void);
+
+void console_write(const char *str, int cnt);
+#if MYNEWT_VAL(CONSOLE_COMPAT)
+int console_read(char *str, int cnt, int *newline);
+#endif
+
+void console_blocking_mode(void);
+void console_non_blocking_mode(void);
+
+static void inline
+console_echo(int on)
+{
+}
+
+static int console_printf(const char *fmt, ...)
+ __attribute__ ((format (printf, 1, 2)));;
+static int inline
+console_printf(const char *fmt, ...)
+{
+ return 0;
+}
+
+void console_set_queues(struct os_eventq *avail_queue,
+ struct os_eventq *cmd_queue);
+
+static void inline
+console_set_completion_cb(uint8_t (*completion)(char *str, uint8_t len))
+{
+}
+
+int console_handle_char(uint8_t byte);
+
+extern int console_is_midline;
+extern int console_out(int character);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CONSOLE_H__ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5008f7c9/sys/console/minimal/include/console/prompt.h
----------------------------------------------------------------------
diff --git a/sys/console/minimal/include/console/prompt.h b/sys/console/minimal/include/console/prompt.h
new file mode 100644
index 0000000..6de36f5
--- /dev/null
+++ b/sys/console/minimal/include/console/prompt.h
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef __CONSOLE_PROMPT_H__
+#define __CONSOLE_PROMPT_H__
+
+#include <stdarg.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* print console prompt */
+static void inline
+console_print_prompt(void)
+{
+}
+
+/* set the console prompt character */
+static void inline
+console_set_prompt(char ch)
+{
+}
+
+static void inline
+console_no_prompt(void)
+{
+}
+
+static void inline
+console_yes_prompt(void)
+{
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CONSOLE_PROMPT_H__ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5008f7c9/sys/console/minimal/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/console/minimal/pkg.yml b/sys/console/minimal/pkg.yml
new file mode 100644
index 0000000..862b46b
--- /dev/null
+++ b/sys/console/minimal/pkg.yml
@@ -0,0 +1,36 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+pkg.name: sys/console/minimal
+pkg.description: Text-based IO interface (minimized).
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
+pkg.keywords:
+
+pkg.deps:
+ - hw/hal
+ - kernel/os
+pkg.deps.CONSOLE_UART:
+ - hw/drivers/uart
+pkg.deps.CONSOLE_RTT:
+ - hw/drivers/rtt
+pkg.apis: console
+
+pkg.init:
+ console_pkg_init: 20
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5008f7c9/sys/console/minimal/src/console.c
----------------------------------------------------------------------
diff --git a/sys/console/minimal/src/console.c b/sys/console/minimal/src/console.c
new file mode 100644
index 0000000..0dbccaf
--- /dev/null
+++ b/sys/console/minimal/src/console.c
@@ -0,0 +1,303 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <assert.h>
+#include <inttypes.h>
+#include <ctype.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "syscfg/syscfg.h"
+#include "os/os.h"
+#include "sysinit/sysinit.h"
+#include "console/console.h"
+#include "console_priv.h"
+
+/* Indicates whether the previous line of output was completed. */
+int console_is_midline;
+
+#define CONSOLE_NLIP_PKT_START1 (6)
+#define CONSOLE_NLIP_PKT_START2 (9)
+#define CONSOLE_NLIP_DATA_START1 (4)
+#define CONSOLE_NLIP_DATA_START2 (20)
+
+#define NLIP_PKT_START1 (1 << 0)
+#define NLIP_PKT_START2 (1 << 1)
+#define NLIP_DATA_START1 (1 << 2)
+#define NLIP_DATA_START2 (1 << 3)
+
+#if MYNEWT_VAL(CONSOLE_COMPAT)
+#define CONSOLE_COMPAT_MAX_CMD_QUEUED 1
+static struct console_input buf[CONSOLE_COMPAT_MAX_CMD_QUEUED];
+static struct os_event shell_console_ev[CONSOLE_COMPAT_MAX_CMD_QUEUED];
+static console_rx_cb console_compat_rx_cb; /* callback that input is ready */
+static struct os_eventq compat_avail_queue;
+static struct os_eventq compat_lines_queue;
+#endif
+
+static int nlip_state;
+static int echo = MYNEWT_VAL(CONSOLE_ECHO);
+
+static uint8_t cur, end;
+static struct os_eventq *avail_queue;
+static struct os_eventq *lines_queue;
+
+void
+console_write(const char *str, int cnt)
+{
+ int i;
+
+ for (i = 0; i < cnt; i++) {
+ if (console_out((int)str[i]) == EOF) {
+ break;
+ }
+ }
+}
+
+#if MYNEWT_VAL(CONSOLE_COMPAT)
+int
+console_read(char *str, int cnt, int *newline)
+{
+ struct os_event *ev;
+ struct console_input *cmd;
+ size_t len;
+
+ *newline = 0;
+ ev = os_eventq_get_no_wait(lines_queue);
+ if (!ev) {
+ return 0;
+ }
+ cmd = ev->ev_arg;
+ len = strlen(cmd->line);
+ strncpy(str, cmd->line, len+1);
+ os_eventq_put(avail_queue, ev);
+ *newline = 1;
+ return len;
+}
+#endif
+
+void
+console_blocking_mode(void)
+{
+#if MYNEWT_VAL(CONSOLE_UART)
+ uart_console_blocking_mode();
+#endif
+}
+
+void
+console_non_blocking_mode(void)
+{
+#if MYNEWT_VAL(CONSOLE_UART)
+ uart_console_non_blocking_mode();
+#endif
+}
+
+static void
+insert_char(char *pos, char c, uint8_t end)
+{
+ if (cur + end >= MYNEWT_VAL(CONSOLE_MAX_INPUT_LEN) - 1) {
+ return;
+ }
+
+ if (echo) {
+ /* Echo back to console */
+ console_out(c);
+ }
+
+ *pos = c;
+ return;
+
+}
+
+static int
+handle_nlip(uint8_t byte)
+{
+ if (((nlip_state & NLIP_PKT_START1) &&
+ (nlip_state & NLIP_PKT_START2)) ||
+ ((nlip_state & NLIP_DATA_START1) &&
+ (nlip_state & NLIP_DATA_START2)))
+ {
+ return 1;
+ }
+
+ if ((nlip_state & NLIP_PKT_START1) &&
+ (byte == CONSOLE_NLIP_PKT_START2)) {
+ nlip_state |= NLIP_PKT_START2;
+ return 1;
+ } else if ((nlip_state & NLIP_DATA_START1) &&
+ (byte == CONSOLE_NLIP_DATA_START2)) {
+ nlip_state |= NLIP_DATA_START2;
+ return 1;
+ } else {
+ nlip_state = 0;
+ return 0;
+ }
+}
+
+int
+console_handle_char(uint8_t byte)
+{
+#if !MYNEWT_VAL(CONSOLE_INPUT)
+ return 0;
+#endif
+
+ static struct os_event *ev;
+ static struct console_input *input;
+
+ if (!avail_queue || !lines_queue) {
+ return 0;
+ }
+
+ if (!ev) {
+ ev = os_eventq_get_no_wait(avail_queue);
+ if (!ev)
+ return 0;
+ input = ev->ev_arg;
+ }
+
+ if (handle_nlip(byte)) {
+ if (byte == '\n') {
+ insert_char(&input->line[cur++], byte, end);
+ input->line[cur] = '\0';
+ cur = 0;
+ end = 0;
+ os_eventq_put(lines_queue, ev);
+ nlip_state = 0;
+
+#if MYNEWT_VAL(CONSOLE_COMPAT)
+ if (console_compat_rx_cb) {
+ console_compat_rx_cb();
+ }
+#endif
+
+ input = NULL;
+ ev = NULL;
+ console_echo(1);
+ return 0;
+ /* Ignore characters if there's no more buffer space */
+ } else if (byte == CONSOLE_NLIP_PKT_START2) {
+ /* Disable echo to not flood the UART */
+ console_echo(0);
+ insert_char(&input->line[cur++], CONSOLE_NLIP_PKT_START1, end);
+ } else if (byte == CONSOLE_NLIP_DATA_START2) {
+ /* Disable echo to not flood the UART */
+ console_echo(0);
+ insert_char(&input->line[cur++], CONSOLE_NLIP_DATA_START1, end);
+ }
+
+ insert_char(&input->line[cur++], byte, end);
+
+ return 0;
+ }
+
+ /* Handle special control characters */
+ if (!isprint(byte)) {
+ switch (byte) {
+ case CONSOLE_NLIP_PKT_START1:
+ nlip_state |= NLIP_PKT_START1;
+ break;
+ case CONSOLE_NLIP_DATA_START1:
+ nlip_state |= NLIP_DATA_START1;
+ break;
+ case '\r':
+ input->line[cur + end] = '\0';
+ console_out('\r');
+ console_out('\n');
+ cur = 0;
+ end = 0;
+ os_eventq_put(lines_queue, ev);
+
+#if MYNEWT_VAL(CONSOLE_COMPAT)
+ if (console_compat_rx_cb) {
+ console_compat_rx_cb();
+ }
+#endif
+
+ input = NULL;
+ ev = NULL;
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+ }
+
+ /* Ignore characters if there's no more buffer space */
+ if (cur + end < sizeof(input->line) - 1) {
+ insert_char(&input->line[cur++], byte, end);
+ }
+ return 0;
+}
+
+int
+console_is_init(void)
+{
+#if MYNEWT_VAL(CONSOLE_UART)
+ return uart_console_is_init();
+#endif
+#if MYNEWT_VAL(CONSOLE_RTT)
+ return rtt_console_is_init();
+#endif
+ return 0;
+}
+
+void
+console_set_queues(struct os_eventq *avail, struct os_eventq *lines)
+{
+ avail_queue = avail;
+ lines_queue = lines;
+}
+
+#if MYNEWT_VAL(CONSOLE_COMPAT)
+int
+console_init(console_rx_cb rx_cb)
+{
+ int i;
+
+ os_eventq_init(&compat_lines_queue);
+ os_eventq_init(&compat_avail_queue);
+ console_set_queues(&compat_avail_queue, &compat_lines_queue);
+
+ for (i = 0; i < CONSOLE_COMPAT_MAX_CMD_QUEUED; i++) {
+ shell_console_ev[i].ev_arg = &buf[i];
+ os_eventq_put(avail_queue, &shell_console_ev[i]);
+ }
+ console_compat_rx_cb = rx_cb;
+ return 0;
+}
+#endif
+
+void
+console_pkg_init(void)
+{
+ int rc = 0;
+
+ /* Ensure this function only gets called by sysinit. */
+ SYSINIT_ASSERT_ACTIVE();
+
+#if MYNEWT_VAL(CONSOLE_UART)
+ rc = uart_console_init();
+#endif
+#if MYNEWT_VAL(CONSOLE_RTT)
+ rc = rtt_console_init();
+#endif
+ SYSINIT_PANIC_ASSERT(rc == 0);
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5008f7c9/sys/console/minimal/src/console_priv.h
----------------------------------------------------------------------
diff --git a/sys/console/minimal/src/console_priv.h b/sys/console/minimal/src/console_priv.h
new file mode 100644
index 0000000..5d448c4
--- /dev/null
+++ b/sys/console/minimal/src/console_priv.h
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef __CONSOLE_PRIV_H__
+#define __CONSOLE_PRIV_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int uart_console_is_init(void);
+int uart_console_init(void);
+void uart_console_blocking_mode(void);
+void uart_console_non_blocking_mode(void);
+int rtt_console_is_init(void);
+int rtt_console_init(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CONSOLE_PRIV_H__ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5008f7c9/sys/console/minimal/src/rtt_console.c
----------------------------------------------------------------------
diff --git a/sys/console/minimal/src/rtt_console.c b/sys/console/minimal/src/rtt_console.c
new file mode 100644
index 0000000..63067c1
--- /dev/null
+++ b/sys/console/minimal/src/rtt_console.c
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "syscfg/syscfg.h"
+
+#if MYNEWT_VAL(CONSOLE_RTT)
+#include <ctype.h>
+
+#include "os/os.h"
+#include "os/os_cputime.h"
+#include "rtt/SEGGER_RTT.h"
+#include "console/console.h"
+#include "console_priv.h"
+
+#if MYNEWT_VAL(CONSOLE_INPUT)
+static struct hal_timer rtt_timer;
+#endif
+
+static const char CR = '\r';
+
+int
+console_out(int character)
+{
+ char c = (char)character;
+
+ if ('\n' == c) {
+ SEGGER_RTT_WriteNoLock(0, &CR, 1);
+ console_is_midline = 0;
+ } else {
+ console_is_midline = 1;
+ }
+
+ SEGGER_RTT_WriteNoLock(0, &c, 1);
+
+ return character;
+}
+
+#if MYNEWT_VAL(CONSOLE_INPUT)
+void
+rtt(void *arg)
+{
+ int key;
+ int i = 0;
+ uint32_t timeout;
+
+ key = SEGGER_RTT_GetKey();
+ if (key >= 0) {
+ console_handle_char((char)key);
+ i = 0;
+ }
+ /* These values were selected to keep the shell responsive
+ * and at the same time reduce context switches.
+ * Min sleep is 50ms and max is 250ms.
+ */
+ if (i < 5) {
+ ++i;
+ }
+ timeout = 50000 * i;
+ os_cputime_timer_relative(&rtt_timer, timeout);
+}
+#endif
+
+int
+rtt_console_is_init(void)
+{
+ return 1;
+}
+
+int
+rtt_console_init(void)
+{
+#if MYNEWT_VAL(CONSOLE_INPUT)
+ os_cputime_timer_init(&rtt_timer, rtt, NULL);
+ /* start after a second */
+ os_cputime_timer_relative(&rtt_timer, 1000000);
+#endif
+ return 0;
+}
+
+#endif /* MYNEWT_VAL(CONSOLE_RTT) */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5008f7c9/sys/console/minimal/src/uart_console.c
----------------------------------------------------------------------
diff --git a/sys/console/minimal/src/uart_console.c b/sys/console/minimal/src/uart_console.c
new file mode 100644
index 0000000..fcf6c6f
--- /dev/null
+++ b/sys/console/minimal/src/uart_console.c
@@ -0,0 +1,205 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "syscfg/syscfg.h"
+
+#if MYNEWT_VAL(CONSOLE_UART)
+#include <ctype.h>
+#include <assert.h>
+
+#include "os/os.h"
+#include "uart/uart.h"
+#include "bsp/bsp.h"
+
+#include "console/console.h"
+#include "console_priv.h"
+
+#define CONSOLE_HEAD_INC(cr) (((cr)->cr_head + 1) & ((cr)->cr_size - 1))
+#define CONSOLE_TAIL_INC(cr) (((cr)->cr_tail + 1) & ((cr)->cr_size - 1))
+
+static struct uart_dev *uart_dev;
+static struct console_ring cr_tx;
+/* must be after console_ring */
+static uint8_t cr_tx_buf[MYNEWT_VAL(CONSOLE_UART_TX_BUF_SIZE)];
+typedef void (*console_write_char)(struct uart_dev*, uint8_t);
+static console_write_char write_char_cb;
+
+struct console_ring {
+ uint8_t cr_head;
+ uint8_t cr_tail;
+ uint16_t cr_size;
+ uint8_t *cr_buf;
+};
+
+static void
+console_add_char(struct console_ring *cr, char ch)
+{
+ cr->cr_buf[cr->cr_head] = ch;
+ cr->cr_head = CONSOLE_HEAD_INC(cr);
+}
+
+static uint8_t
+console_pull_char(struct console_ring *cr)
+{
+ uint8_t ch;
+
+ ch = cr->cr_buf[cr->cr_tail];
+ cr->cr_tail = CONSOLE_TAIL_INC(cr);
+ return ch;
+}
+
+static void
+console_queue_char(struct uart_dev *uart_dev, uint8_t ch)
+{
+ int sr;
+
+ OS_ENTER_CRITICAL(sr);
+ while (CONSOLE_HEAD_INC(&cr_tx) == cr_tx.cr_tail) {
+ /* TX needs to drain */
+ uart_start_tx(uart_dev);
+ OS_EXIT_CRITICAL(sr);
+ if (os_started()) {
+ os_time_delay(1);
+ }
+ OS_ENTER_CRITICAL(sr);
+ }
+ console_add_char(&cr_tx, ch);
+ OS_EXIT_CRITICAL(sr);
+}
+
+/*
+ * Flush cnt characters from console output queue.
+ */
+static void
+console_tx_flush(int cnt)
+{
+ int i;
+ uint8_t byte;
+
+ for (i = 0; i < cnt; i++) {
+ if (cr_tx.cr_head == cr_tx.cr_tail) {
+ /*
+ * Queue is empty.
+ */
+ break;
+ }
+ byte = console_pull_char(&cr_tx);
+ uart_blocking_tx(uart_dev, byte);
+ }
+}
+
+void
+uart_console_blocking_mode(void)
+{
+ int sr;
+
+ OS_ENTER_CRITICAL(sr);
+ if (write_char_cb) {
+ write_char_cb = uart_blocking_tx;
+
+ console_tx_flush(MYNEWT_VAL(CONSOLE_UART_TX_BUF_SIZE));
+ }
+ OS_EXIT_CRITICAL(sr);
+}
+
+void
+uart_console_non_blocking_mode(void)
+{
+ int sr;
+
+ OS_ENTER_CRITICAL(sr);
+ if (write_char_cb) {
+ write_char_cb = console_queue_char;
+ }
+ OS_EXIT_CRITICAL(sr);
+}
+
+int
+console_out(int c)
+{
+ if ('\n' == c) {
+ write_char_cb(uart_dev, '\r');
+ console_is_midline = 0;
+ } else {
+ console_is_midline = 1;
+ }
+ write_char_cb(uart_dev, c);
+ uart_start_tx(uart_dev);
+
+ return c;
+}
+
+/*
+ * Interrupts disabled when console_tx_char/console_rx_char are called.
+ * Characters sent only in blocking mode.
+ */
+static int
+console_tx_char(void *arg)
+{
+ if (cr_tx.cr_head == cr_tx.cr_tail) {
+ /*
+ * No more data.
+ */
+ return -1;
+ }
+ return console_pull_char(&cr_tx);
+}
+
+/*
+ * Interrupts disabled when console_tx_char/console_rx_char are called.
+ */
+static int
+console_rx_char(void *arg, uint8_t byte)
+{
+ return console_handle_char(byte);
+}
+
+int
+uart_console_is_init(void)
+{
+ return uart_dev != NULL;
+}
+
+int
+uart_console_init(void)
+{
+ struct uart_conf uc = {
+ .uc_speed = MYNEWT_VAL(CONSOLE_UART_BAUD),
+ .uc_databits = 8,
+ .uc_stopbits = 1,
+ .uc_parity = UART_PARITY_NONE,
+ .uc_flow_ctl = MYNEWT_VAL(CONSOLE_UART_FLOW_CONTROL),
+ .uc_tx_char = console_tx_char,
+ .uc_rx_char = console_rx_char,
+ };
+
+ cr_tx.cr_size = MYNEWT_VAL(CONSOLE_UART_TX_BUF_SIZE);
+ cr_tx.cr_buf = cr_tx_buf;
+ write_char_cb = console_queue_char;
+
+ if (!uart_dev) {
+ uart_dev = (struct uart_dev *)os_dev_open(CONSOLE_UART,
+ OS_TIMEOUT_NEVER, &uc);
+ if (!uart_dev) {
+ return -1;
+ }
+ }
+ return 0;
+}
+#endif /* MYNEWT_VAL(CONSOLE_UART) */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5008f7c9/sys/console/minimal/syscfg.yml
----------------------------------------------------------------------
diff --git a/sys/console/minimal/syscfg.yml b/sys/console/minimal/syscfg.yml
new file mode 100644
index 0000000..f1f25f2
--- /dev/null
+++ b/sys/console/minimal/syscfg.yml
@@ -0,0 +1,49 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Package: sys/console/minimal
+
+syscfg.defs:
+ CONSOLE_UART:
+ description: 'Set console output to UART'
+ value: 1
+ CONSOLE_RTT:
+ description: 'Set console output to RTT'
+ value: 0
+ CONSOLE_INPUT:
+ description: 'Enable console input'
+ value: 1
+ CONSOLE_ECHO:
+ description: 'Default console echo'
+ value: 1
+ CONSOLE_COMPAT:
+ description: 'Console backward compatibility'
+ value: 1
+ CONSOLE_MAX_INPUT_LEN:
+ description: 'Maximum input line length'
+ value: 256
+
+ CONSOLE_UART_BAUD:
+ description: 'Console UART baud rate.'
+ value: '115200'
+ CONSOLE_UART_FLOW_CONTROL:
+ description: 'Console UART flow control.'
+ value: 'UART_FLOW_CTL_NONE'
+ CONSOLE_UART_TX_BUF_SIZE:
+ description: 'UART console transmit buffer size; must be power of 2.'
+ value: 32
\ No newline at end of file
[50/50] [abbrv] incubator-mynewt-core git commit: This closes #250.
Posted by ja...@apache.org.
This closes #250.
Merge branch 'master' into bluetooth5
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/87329b51
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/87329b51
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/87329b51
Branch: refs/heads/bluetooth5
Commit: 87329b51421d24d87b3ca17862e236cd985f8196
Parents: 4c2a8d9 02fd7c7
Author: Szymon Janc <sz...@codecoup.pl>
Authored: Wed Apr 26 14:23:02 2017 -0700
Committer: Szymon Janc <sz...@codecoup.pl>
Committed: Wed Apr 26 15:39:37 2017 -0700
----------------------------------------------------------------------
apps/bleprph/syscfg.yml | 1 +
apps/bletest/src/bletest_hci.c | 3 +-
apps/bletiny/src/bletiny.h | 2 +-
apps/bletiny/src/main.c | 7 +-
apps/iptest/pkg.yml | 46 +
apps/iptest/src/main.c | 441 +
apps/iptest/syscfg.yml | 45 +
apps/sensors_test/pkg.yml | 16 +-
apps/sensors_test/src/bleprph.h | 59 +
apps/sensors_test/src/gatt_svr.c | 313 +
apps/sensors_test/src/main.c | 437 +-
apps/sensors_test/src/misc.c | 43 +
apps/sensors_test/syscfg.yml | 33 +-
apps/testbench/pkg.yml | 57 +-
apps/testbench/src/tbb.c | 280 +
apps/testbench/src/tbb.h | 44 +
apps/testbench/src/testbench.c | 75 +-
apps/testbench/syscfg.yml | 16 +-
compiler/sim-armv7/compiler.yml | 41 +
compiler/sim-armv7/pkg.yml | 28 +
compiler/xc32/compiler.yml | 2 +-
encoding/cborattr/pkg.yml | 2 +-
encoding/json/pkg.yml | 2 +-
encoding/tinycbor/pkg.yml | 2 +-
fs/fcb/src/fcb.c | 2 +-
fs/fcb/test/src/testcases/fcb_test_len.c | 5 +-
fs/nffs/src/nffs_block.c | 2 +
fs/nffs/src/nffs_inode.c | 2 +
fs/nffs/test/src/nffs_test_utils.c | 6 +-
fs/nffs/test/src/testcases/large_unlink_test.c | 9 +-
.../src/arch/cortex_m4/gcc_startup_nrf52.s | 2 +
.../arch/cortex_m4/gcc_startup_nrf52_split.s | 3 +
hw/bsp/ada_feather_nrf52/syscfg.yml | 1 +
.../src/arch/cortex_m4/gcc_startup_nrf52.s | 2 +
.../arch/cortex_m4/gcc_startup_nrf52_split.s | 3 +
hw/bsp/arduino_primo_nrf52/syscfg.yml | 1 +
.../src/arch/cortex_m0/gcc_startup_nrf51.s | 3 +
.../arch/cortex_m0/gcc_startup_nrf51_split.s | 3 +
hw/bsp/ble400/ble400.cfg | 22 +
hw/bsp/ble400/ble400_debug.cmd | 22 +
hw/bsp/ble400/ble400_debug.sh | 38 +
hw/bsp/ble400/ble400_download.cmd | 22 +
hw/bsp/ble400/ble400_download.sh | 42 +
hw/bsp/ble400/ble400_no_boot.ld | 179 +
hw/bsp/ble400/boot-nrf51xxac.ld | 25 +
hw/bsp/ble400/bsp.yml | 64 +
hw/bsp/ble400/include/bsp/boards.h | 19 +
hw/bsp/ble400/include/bsp/bsp.h | 53 +
hw/bsp/ble400/include/bsp/cmsis_nvic.h | 30 +
hw/bsp/ble400/nrf51xxac.ld | 25 +
hw/bsp/ble400/pkg.yml | 90 +
hw/bsp/ble400/split-ble400.ld | 185 +
.../src/arch/cortex_m0/gcc_startup_nrf51.s | 283 +
.../arch/cortex_m0/gcc_startup_nrf51_split.s | 185 +
hw/bsp/ble400/src/hal_bsp.c | 189 +
hw/bsp/ble400/src/sbrk.c | 57 +
hw/bsp/ble400/syscfg.yml | 97 +
.../src/arch/cortex_m0/gcc_startup_nrf51.s | 3 +
.../arch/cortex_m0/gcc_startup_nrf51_split.s | 3 +
hw/bsp/bmd200/src/sbrk.c | 2 -
hw/bsp/bmd200/syscfg.yml | 1 +
.../src/arch/cortex_m4/gcc_startup_nrf52.s | 2 +
.../arch/cortex_m4/gcc_startup_nrf52_split.s | 3 +
hw/bsp/bmd300eval/src/sbrk.c | 2 -
hw/bsp/bmd300eval/syscfg.yml | 1 +
.../src/arch/cortex_m4/gcc_startup_nrf52.s | 2 +
.../arch/cortex_m4/gcc_startup_nrf52_split.s | 3 +
hw/bsp/nina-b1/syscfg.yml | 1 +
.../src/arch/cortex_m0/gcc_startup_nrf51.s | 3 +
hw/bsp/nrf51-blenano/pkg.yml | 2 +-
hw/bsp/nrf51-blenano/split-nrf51dk.ld | 4 +-
.../src/arch/cortex_m0/gcc_startup_nrf51.s | 3 +
.../arch/cortex_m0/gcc_startup_nrf51_split.s | 3 +
hw/bsp/nrf51-blenano/syscfg.yml | 1 +
hw/bsp/nrf51dk-16kbram/split-nrf51dk-16kbram.ld | 4 +-
.../src/arch/cortex_m0/gcc_startup_nrf51.s | 3 +
.../arch/cortex_m0/gcc_startup_nrf51_split.s | 3 +
hw/bsp/nrf51dk-16kbram/src/sbrk.c | 2 -
hw/bsp/nrf51dk-16kbram/syscfg.yml | 1 +
.../src/arch/cortex_m0/gcc_startup_nrf51.s | 3 +
.../arch/cortex_m0/gcc_startup_nrf51_split.s | 3 +
hw/bsp/nrf51dk/src/hal_bsp.c | 4 +
hw/bsp/nrf51dk/src/sbrk.c | 2 -
hw/bsp/nrf51dk/syscfg.yml | 1 +
.../src/arch/cortex_m4/gcc_startup_nrf52840.s | 2 +
.../arch/cortex_m4/gcc_startup_nrf52_split.s | 3 +
hw/bsp/nrf52840pdk/src/hal_bsp.c | 86 +
hw/bsp/nrf52840pdk/syscfg.yml | 1 +
hw/bsp/nrf52dk/include/bsp/boards.h | 19 -
.../src/arch/cortex_m4/gcc_startup_nrf52.s | 2 +
.../arch/cortex_m4/gcc_startup_nrf52_split.s | 3 +
hw/bsp/nrf52dk/src/hal_bsp.c | 14 +-
hw/bsp/nrf52dk/syscfg.yml | 1 +
.../include/bsp/stm32f4xx_hal_conf.h | 1 +
hw/bsp/olimex_stm32-e407_devboard/pkg.yml | 4 +-
hw/bsp/olimex_stm32-e407_devboard/src/hal_bsp.c | 41 +-
hw/bsp/olimex_stm32-e407_devboard/syscfg.yml | 4 +
hw/bsp/pic32mx470_6LP_clicker/bsp.yml | 53 -
hw/bsp/pic32mx470_6LP_clicker/include/bsp/bsp.h | 52 -
.../include/bsp/bsp_sysid.h | 36 -
hw/bsp/pic32mx470_6LP_clicker/pkg.yml | 46 -
hw/bsp/pic32mx470_6LP_clicker/src/hal_bsp.c | 27 -
hw/bsp/pic32mx470_6LP_clicker/src/os_bsp.c | 85 -
hw/bsp/pic32mx470_6LP_clicker/src/sbrk.c | 51 -
hw/bsp/pic32mx470_6LP_clicker/syscfg.yml | 41 -
hw/bsp/pic32mx470_6lp_clicker/bsp.yml | 53 +
hw/bsp/pic32mx470_6lp_clicker/include/bsp/bsp.h | 52 +
.../include/bsp/bsp_sysid.h | 36 +
hw/bsp/pic32mx470_6lp_clicker/pkg.yml | 46 +
hw/bsp/pic32mx470_6lp_clicker/src/hal_bsp.c | 27 +
hw/bsp/pic32mx470_6lp_clicker/src/os_bsp.c | 85 +
hw/bsp/pic32mx470_6lp_clicker/src/sbrk.c | 51 +
hw/bsp/pic32mx470_6lp_clicker/syscfg.yml | 41 +
hw/bsp/pic32mz2048_wi-fire/bsp.yml | 2 +-
hw/bsp/pic32mz2048_wi-fire/syscfg.yml | 2 +-
.../src/arch/cortex_m4/gcc_startup_nrf52.s | 2 +
.../arch/cortex_m4/gcc_startup_nrf52_split.s | 3 +
hw/bsp/rb-blend2/syscfg.yml | 1 +
.../src/arch/cortex_m4/gcc_startup_nrf52.s | 2 +
.../arch/cortex_m4/gcc_startup_nrf52_split.s | 3 +
hw/bsp/rb-nano2/syscfg.yml | 1 +
hw/bsp/ruuvi_tag_revb2/boot-nrf52xxaa.ld | 25 +
hw/bsp/ruuvi_tag_revb2/bsp.yml | 64 +
hw/bsp/ruuvi_tag_revb2/include/bsp/boards.h | 19 +
hw/bsp/ruuvi_tag_revb2/include/bsp/bsp.h | 73 +
hw/bsp/ruuvi_tag_revb2/include/bsp/cmsis_nvic.h | 29 +
hw/bsp/ruuvi_tag_revb2/nrf52dk_debug.cmd | 22 +
hw/bsp/ruuvi_tag_revb2/nrf52dk_debug.sh | 46 +
hw/bsp/ruuvi_tag_revb2/nrf52dk_download.cmd | 22 +
hw/bsp/ruuvi_tag_revb2/nrf52dk_download.sh | 40 +
hw/bsp/ruuvi_tag_revb2/nrf52dk_no_boot.ld | 191 +
hw/bsp/ruuvi_tag_revb2/nrf52xxaa.ld | 25 +
hw/bsp/ruuvi_tag_revb2/pkg.yml | 97 +
hw/bsp/ruuvi_tag_revb2/split-nrf52dk.ld | 208 +
.../src/arch/cortex_m4/gcc_startup_nrf52.s | 301 +
.../arch/cortex_m4/gcc_startup_nrf52_split.s | 166 +
hw/bsp/ruuvi_tag_revb2/src/hal_bsp.c | 303 +
hw/bsp/ruuvi_tag_revb2/src/sbrk.c | 59 +
hw/bsp/ruuvi_tag_revb2/syscfg.yml | 95 +
hw/bsp/stm32f767-nucleo/pkg.yml | 3 +
hw/bsp/stm32f767-nucleo/src/hal_bsp.c | 50 +
hw/bsp/stm32f767-nucleo/syscfg.yml | 4 +
.../src/arch/cortex_m4/gcc_startup_nrf52.s | 2 +
.../arch/cortex_m4/gcc_startup_nrf52_split.s | 3 +
hw/bsp/telee02/syscfg.yml | 1 +
hw/bsp/usbmkw41z/src/sbrk.c | 2 -
.../stm32_eth/include/stm32_eth/stm32_eth.h | 49 +
.../stm32_eth/include/stm32_eth/stm32_eth_cfg.h | 47 +
hw/drivers/lwip/stm32_eth/pkg.yml | 41 +
hw/drivers/lwip/stm32_eth/src/stm32_eth.c | 538 +
.../include/stm32f4_eth/stm32f4_eth.h | 27 -
.../include/stm32f4_eth/stm32f4_eth_cfg.h | 32 -
hw/drivers/lwip/stm32f4_eth/pkg.yml | 33 -
hw/drivers/lwip/stm32f4_eth/src/stm32f4_eth.c | 746 -
hw/drivers/rtt/include/rtt/SEGGER_RTT.h | 244 +
hw/drivers/rtt/include/rtt/SEGGER_RTT_Conf.h | 267 +
hw/drivers/rtt/pkg.yml | 28 +
hw/drivers/rtt/src/SEGGER_RTT.c | 1462 +
hw/drivers/rtt/src/SEGGER_RTT_printf.c | 511 +
hw/drivers/rtt/syscfg.yml | 24 +
.../sensors/bno055/include/bno055/bno055.h | 33 -
hw/drivers/sensors/bno055/src/bno055_priv.h | 34 +
hw/hal/include/hal/hal_timer.h | 5 +
.../pic32mx470F512H/include/mcu/mips_bsp.h | 24 -
.../pic32mx470F512H/include/mcu/mips_hal.h | 39 -
.../pic32mx470F512H/include/mcu/pic32mx470.h | 25 -
hw/mcu/microchip/pic32mx470F512H/pkg.yml | 31 -
.../microchip/pic32mx470F512H/src/hal_os_tick.c | 36 -
.../microchip/pic32mx470F512H/src/hal_system.c | 35 -
hw/mcu/microchip/pic32mx470F512H/src/hal_uart.c | 463 -
.../pic32mx470F512H/src/hal_watchdog.c | 39 -
.../microchip/pic32mx470f512h/include/mcu/mcu.h | 25 +
.../pic32mx470f512h/include/mcu/mips_bsp.h | 24 +
.../pic32mx470f512h/include/mcu/mips_hal.h | 39 +
.../pic32mx470f512h/include/mcu/p32mx470f512h.h | 17933 ++++++
.../pic32mx470f512h/include/mcu/pic32.h | 25 +
.../pic32mx470f512h/include/mcu/ppic32mx.h | 1280 +
hw/mcu/microchip/pic32mx470f512h/pkg.yml | 31 +
.../microchip/pic32mx470f512h/src/hal_os_tick.c | 36 +
.../microchip/pic32mx470f512h/src/hal_system.c | 35 +
hw/mcu/microchip/pic32mx470f512h/src/hal_uart.c | 463 +
.../pic32mx470f512h/src/hal_watchdog.c | 39 +
.../pic32mz2048efg100/include/mcu/mcu.h | 25 +
.../include/mcu/p32mz2048efg100.h | 51671 +++++++++++++++++
.../pic32mz2048efg100/include/mcu/pic32.h | 25 +
.../pic32mz2048efg100/include/mcu/pic32mz2048.h | 25 -
hw/mcu/native/pkg.yml | 1 -
hw/mcu/nordic/nrf51xxx/src/hal_system.c | 18 +
hw/mcu/nordic/nrf51xxx/syscfg.yml | 7 +
hw/mcu/nordic/nrf52xxx/src/hal_flash.c | 12 +
hw/mcu/nordic/nrf52xxx/src/hal_system.c | 18 +
hw/mcu/nordic/nrf52xxx/syscfg.yml | 7 +
hw/mcu/stm/stm32f4xx/src/hal_flash.c | 11 +-
hw/mcu/stm/stm32f4xx/syscfg.yml | 4 +
hw/mcu/stm/stm32f7xx/syscfg.yml | 4 +
hw/sensor/include/sensor/quat.h | 3 +-
hw/sensor/include/sensor/sensor.h | 27 +-
hw/sensor/pkg.yml | 10 +
hw/sensor/src/sensor_oic.c | 587 +
hw/sensor/syscfg.yml | 6 +
kernel/os/include/os/arch/pic32/os/cp0defs.h | 1215 +
kernel/os/include/os/arch/pic32/os/os_arch.h | 83 +
.../os/include/os/arch/pic32/os/os_arch_defs.h | 60 +
kernel/os/include/os/arch/pic32mx/os/os_arch.h | 84 -
kernel/os/include/os/arch/pic32mz/os/os_arch.h | 84 -
.../os/include/os/arch/sim-armv7/os/os_arch.h | 82 +
kernel/os/include/os/os.h | 5 +-
kernel/os/include/os/os_eventq.h | 1 +
kernel/os/src/arch/mips/asm/ctx.S | 16 +-
kernel/os/src/arch/mips/os_arch_mips.c | 2 +-
kernel/os/src/arch/pic32/asm/ctx.S | 190 +
kernel/os/src/arch/pic32/os_arch_pic32.c | 221 +
kernel/os/src/arch/pic32/os_fault.c | 122 +
kernel/os/src/arch/pic32mx/asm/ctx.S | 163 -
kernel/os/src/arch/pic32mx/os_arch_pic32mx.c | 213 -
kernel/os/src/arch/pic32mx/os_fault.c | 122 -
kernel/os/src/arch/pic32mz/asm/ctx.S | 163 -
kernel/os/src/arch/pic32mz/os_arch_pic32mz.c | 213 -
kernel/os/src/arch/pic32mz/os_fault.c | 122 -
kernel/os/src/arch/sim-armv7/os_arch_sim.c | 457 +
.../os/src/arch/sim-armv7/os_arch_stack_frame.s | 47 +
kernel/os/src/arch/sim-armv7/os_fault.c | 39 +
kernel/os/src/os_eventq.c | 14 +
kernel/os/syscfg.yml | 3 +
libc/baselibc/include/string.h | 1 +
libc/baselibc/src/strstr.c | 5 +
libc/baselibc/src/tinyprintf.c | 20 +-
net/ip/include/arch/sys_arch.h | 304 +-
net/ip/include/ip/init.h | 32 -
net/ip/include/lwipopts.h | 15 +-
net/ip/inet_def_service/src/inet_def_service.c | 110 +-
net/ip/lwip_base/CHANGELOG | 146 +
net/ip/lwip_base/UPGRADING | 16 +-
net/ip/lwip_base/doc/NO_SYS_SampleCode.c | 16 +-
net/ip/lwip_base/doc/doxygen/generate.sh | 2 +
net/ip/lwip_base/doc/doxygen/lwip.Doxyfile | 7 +-
net/ip/lwip_base/doc/doxygen/main_page.h | 75 +-
net/ip/lwip_base/doc/mqtt_client.txt | 162 +
net/ip/lwip_base/doc/ppp.txt | 6 +-
net/ip/lwip_base/doc/rawapi.txt | 8 +-
net/ip/lwip_base/doc/sys_arch.txt | 2 +-
net/ip/lwip_base/include/lwip/api.h | 31 +-
net/ip/lwip_base/include/lwip/apps/httpd_opts.h | 30 -
net/ip/lwip_base/include/lwip/apps/mdns.h | 10 +-
net/ip/lwip_base/include/lwip/apps/mdns_opts.h | 10 +-
net/ip/lwip_base/include/lwip/apps/mdns_priv.h | 10 +-
net/ip/lwip_base/include/lwip/apps/mqtt.h | 244 +
net/ip/lwip_base/include/lwip/apps/mqtt_opts.h | 103 +
net/ip/lwip_base/include/lwip/apps/netbiosns.h | 8 -
.../include/lwip/apps/netbiosns_opts.h | 18 -
net/ip/lwip_base/include/lwip/apps/snmp_opts.h | 8 -
net/ip/lwip_base/include/lwip/apps/snmpv3.h | 8 -
net/ip/lwip_base/include/lwip/apps/sntp_opts.h | 8 -
net/ip/lwip_base/include/lwip/apps/tftp_opts.h | 105 +
.../lwip_base/include/lwip/apps/tftp_server.h | 94 +
net/ip/lwip_base/include/lwip/arch.h | 299 +-
net/ip/lwip_base/include/lwip/autoip.h | 2 +
net/ip/lwip_base/include/lwip/debug.h | 81 +-
net/ip/lwip_base/include/lwip/def.h | 95 +-
net/ip/lwip_base/include/lwip/dhcp.h | 2 +
net/ip/lwip_base/include/lwip/dhcp6.h | 8 -
net/ip/lwip_base/include/lwip/dns.h | 18 +-
net/ip/lwip_base/include/lwip/err.h | 4 +
net/ip/lwip_base/include/lwip/errno.h | 193 +
net/ip/lwip_base/include/lwip/icmp.h | 2 +-
net/ip/lwip_base/include/lwip/icmp6.h | 89 +-
net/ip/lwip_base/include/lwip/igmp.h | 6 +-
net/ip/lwip_base/include/lwip/inet.h | 8 +-
net/ip/lwip_base/include/lwip/inet_chksum.h | 8 +-
net/ip/lwip_base/include/lwip/init.h | 4 +-
net/ip/lwip_base/include/lwip/ip4_addr.h | 36 +-
net/ip/lwip_base/include/lwip/ip6_addr.h | 66 +-
net/ip/lwip_base/include/lwip/ip_addr.h | 73 +-
net/ip/lwip_base/include/lwip/mem.h | 3 +-
net/ip/lwip_base/include/lwip/mld6.h | 7 +-
net/ip/lwip_base/include/lwip/nd6.h | 93 +-
net/ip/lwip_base/include/lwip/netdb.h | 3 +-
net/ip/lwip_base/include/lwip/netif.h | 10 +-
net/ip/lwip_base/include/lwip/netifapi.h | 12 +-
net/ip/lwip_base/include/lwip/opt.h | 116 +-
net/ip/lwip_base/include/lwip/pbuf.h | 20 +-
net/ip/lwip_base/include/lwip/priv/api_msg.h | 3 +-
net/ip/lwip_base/include/lwip/priv/memp_std.h | 8 -
net/ip/lwip_base/include/lwip/priv/nd6_priv.h | 144 +
net/ip/lwip_base/include/lwip/priv/tcp_priv.h | 27 +-
net/ip/lwip_base/include/lwip/priv/tcpip_priv.h | 4 +-
net/ip/lwip_base/include/lwip/prot/dns.h | 18 +
net/ip/lwip_base/include/lwip/prot/ethernet.h | 2 +-
net/ip/lwip_base/include/lwip/prot/icmp6.h | 87 +
net/ip/lwip_base/include/lwip/prot/ip.h | 8 -
net/ip/lwip_base/include/lwip/prot/ip4.h | 16 +
net/ip/lwip_base/include/lwip/prot/ip6.h | 27 +-
net/ip/lwip_base/include/lwip/prot/mld6.h | 2 +-
net/ip/lwip_base/include/lwip/prot/nd6.h | 24 +
net/ip/lwip_base/include/lwip/prot/tcp.h | 14 +-
net/ip/lwip_base/include/lwip/raw.h | 2 +
net/ip/lwip_base/include/lwip/sockets.h | 5 +-
net/ip/lwip_base/include/lwip/stats.h | 4 +-
net/ip/lwip_base/include/lwip/sys.h | 44 +-
net/ip/lwip_base/include/lwip/tcp.h | 12 +-
net/ip/lwip_base/include/lwip/tcpip.h | 2 +
net/ip/lwip_base/include/lwip/timeouts.h | 2 +-
net/ip/lwip_base/include/netif/lowpan6_opts.h | 8 -
net/ip/lwip_base/include/netif/ppp/ccp.h | 8 -
net/ip/lwip_base/include/netif/ppp/chap-new.h | 8 -
net/ip/lwip_base/include/netif/ppp/chap_ms.h | 8 -
net/ip/lwip_base/include/netif/ppp/eui64.h | 10 +-
net/ip/lwip_base/include/netif/ppp/fsm.h | 8 -
net/ip/lwip_base/include/netif/ppp/ipcp.h | 8 -
net/ip/lwip_base/include/netif/ppp/ipv6cp.h | 8 -
net/ip/lwip_base/include/netif/ppp/lcp.h | 8 -
net/ip/lwip_base/include/netif/ppp/magic.h | 8 -
net/ip/lwip_base/include/netif/ppp/mppe.h | 10 +-
net/ip/lwip_base/include/netif/ppp/ppp.h | 12 +-
net/ip/lwip_base/include/netif/ppp/ppp_impl.h | 12 +-
net/ip/lwip_base/include/netif/ppp/ppp_opts.h | 8 -
net/ip/lwip_base/include/netif/ppp/pppcrypt.h | 8 -
net/ip/lwip_base/include/netif/ppp/pppdebug.h | 8 -
net/ip/lwip_base/include/netif/ppp/pppoe.h | 8 -
net/ip/lwip_base/include/netif/ppp/pppol2tp.h | 8 -
net/ip/lwip_base/include/netif/ppp/pppos.h | 8 -
net/ip/lwip_base/include/netif/ppp/upap.h | 8 -
net/ip/lwip_base/include/netif/ppp/vj.h | 8 -
net/ip/lwip_base/include/posix/errno.h | 33 +
net/ip/lwip_base/src/Filelists.mk | 10 +-
net/ip/lwip_base/src/api/api_lib.c | 69 +-
net/ip/lwip_base/src/api/api_msg.c | 127 +-
net/ip/lwip_base/src/api/err.c | 40 +
net/ip/lwip_base/src/api/netdb.c | 10 +-
net/ip/lwip_base/src/api/netifapi.c | 14 +-
net/ip/lwip_base/src/api/sockets.c | 204 +-
net/ip/lwip_base/src/api/tcpip.c | 3 +-
net/ip/lwip_base/src/apps/httpd/fsdata.h | 8 -
net/ip/lwip_base/src/apps/httpd/httpd.c | 180 +-
net/ip/lwip_base/src/apps/httpd/httpd_structs.h | 8 -
net/ip/lwip_base/src/apps/lwiperf/lwiperf.c | 16 +-
net/ip/lwip_base/src/apps/mdns/mdns.c | 161 +-
net/ip/lwip_base/src/apps/mqtt/mqtt.c | 1341 +
net/ip/lwip_base/src/apps/netbiosns/netbiosns.c | 5 +-
net/ip/lwip_base/src/apps/snmp/snmp_asn1.c | 8 +-
net/ip/lwip_base/src/apps/snmp/snmp_core.c | 84 +-
net/ip/lwip_base/src/apps/snmp/snmp_mib2_ip.c | 12 +-
net/ip/lwip_base/src/apps/snmp/snmp_mib2_tcp.c | 6 +-
net/ip/lwip_base/src/apps/snmp/snmp_msg.c | 11 +-
net/ip/lwip_base/src/apps/snmp/snmp_netconn.c | 5 +-
net/ip/lwip_base/src/apps/snmp/snmp_raw.c | 2 +-
.../lwip_base/src/apps/snmp/snmp_threadsync.c | 1 +
net/ip/lwip_base/src/apps/snmp/snmp_traps.c | 9 +-
net/ip/lwip_base/src/apps/snmp/snmpv3_priv.h | 8 -
net/ip/lwip_base/src/apps/sntp/sntp.c | 9 +-
net/ip/lwip_base/src/apps/tftp/tftp_server.c | 417 +
net/ip/lwip_base/src/core/def.c | 177 +-
net/ip/lwip_base/src/core/dns.c | 239 +-
net/ip/lwip_base/src/core/inet_chksum.c | 15 +-
net/ip/lwip_base/src/core/init.c | 12 +-
net/ip/lwip_base/src/core/ipv4/autoip.c | 16 +-
net/ip/lwip_base/src/core/ipv4/dhcp.c | 114 +-
net/ip/lwip_base/src/core/ipv4/etharp.c | 69 +-
net/ip/lwip_base/src/core/ipv4/icmp.c | 14 +-
net/ip/lwip_base/src/core/ipv4/igmp.c | 75 +-
net/ip/lwip_base/src/core/ipv4/ip4.c | 57 +-
net/ip/lwip_base/src/core/ipv4/ip4_addr.c | 10 +-
net/ip/lwip_base/src/core/ipv4/ip4_frag.c | 88 +-
net/ip/lwip_base/src/core/ipv6/ethip6.c | 42 +-
net/ip/lwip_base/src/core/ipv6/ip6.c | 62 +-
net/ip/lwip_base/src/core/ipv6/ip6_addr.c | 10 +-
net/ip/lwip_base/src/core/ipv6/ip6_frag.c | 49 +-
net/ip/lwip_base/src/core/ipv6/mld6.c | 7 +-
net/ip/lwip_base/src/core/ipv6/nd6.c | 355 +-
net/ip/lwip_base/src/core/mem.c | 8 +-
net/ip/lwip_base/src/core/memp.c | 25 +-
net/ip/lwip_base/src/core/netif.c | 127 +-
net/ip/lwip_base/src/core/pbuf.c | 91 +-
net/ip/lwip_base/src/core/raw.c | 51 +-
net/ip/lwip_base/src/core/stats.c | 6 +-
net/ip/lwip_base/src/core/sys.c | 38 +
net/ip/lwip_base/src/core/tcp.c | 149 +-
net/ip/lwip_base/src/core/tcp_in.c | 88 +-
net/ip/lwip_base/src/core/tcp_out.c | 195 +-
net/ip/lwip_base/src/core/timeouts.c | 4 +-
net/ip/lwip_base/src/core/udp.c | 72 +-
net/ip/lwip_base/src/netif/ethernet.c | 20 +-
net/ip/lwip_base/src/netif/lowpan6.c | 103 +-
net/ip/lwip_base/src/netif/ppp/auth.c | 10 +-
net/ip/lwip_base/src/netif/ppp/ipcp.c | 120 +-
net/ip/lwip_base/src/netif/ppp/ipv6cp.c | 4 +-
net/ip/lwip_base/src/netif/ppp/multilink.c | 4 +-
net/ip/lwip_base/src/netif/ppp/ppp.c | 19 +-
net/ip/lwip_base/src/netif/ppp/pppapi.c | 5 +
net/ip/lwip_base/src/netif/ppp/pppoe.c | 19 +-
net/ip/lwip_base/src/netif/ppp/pppol2tp.c | 9 +-
net/ip/lwip_base/src/netif/ppp/pppos.c | 40 +-
net/ip/lwip_base/src/netif/ppp/utils.c | 4 +-
net/ip/lwip_base/src/netif/ppp/vj.c | 62 +-
net/ip/lwip_base/src/netif/slipif.c | 2 +-
net/ip/lwip_base/test/fuzz/Makefile | 53 +
net/ip/lwip_base/test/fuzz/README | 34 +
net/ip/lwip_base/test/fuzz/config.h | 0
net/ip/lwip_base/test/fuzz/fuzz.c | 136 +
.../lwip_base/test/fuzz/inputs/arp/arp_req.bin | Bin 0 -> 42 bytes
.../test/fuzz/inputs/icmp/icmp_ping.bin | Bin 0 -> 98 bytes
.../fuzz/inputs/ipv6/neighbor_solicitation.bin | Bin 0 -> 86 bytes
.../test/fuzz/inputs/ipv6/router_adv.bin | Bin 0 -> 118 bytes
.../lwip_base/test/fuzz/inputs/tcp/tcp_syn.bin | Bin 0 -> 74 bytes
.../test/fuzz/inputs/udp/udp_port_5000.bin | Bin 0 -> 50 bytes
net/ip/lwip_base/test/fuzz/lwipopts.h | 68 +
net/ip/lwip_base/test/fuzz/output_to_pcap.sh | 31 +
net/ip/lwip_base/test/unit/core/test_mem.h | 8 -
net/ip/lwip_base/test/unit/core/test_pbuf.h | 8 -
net/ip/lwip_base/test/unit/dhcp/test_dhcp.c | 113 +-
net/ip/lwip_base/test/unit/dhcp/test_dhcp.h | 8 -
net/ip/lwip_base/test/unit/etharp/test_etharp.h | 8 -
net/ip/lwip_base/test/unit/lwip_check.h | 8 -
net/ip/lwip_base/test/unit/lwipopts.h | 8 -
net/ip/lwip_base/test/unit/mdns/test_mdns.c | 71 +-
net/ip/lwip_base/test/unit/mdns/test_mdns.h | 8 -
net/ip/lwip_base/test/unit/tcp/tcp_helper.c | 23 +-
net/ip/lwip_base/test/unit/tcp/tcp_helper.h | 8 -
net/ip/lwip_base/test/unit/tcp/test_tcp.c | 18 +-
net/ip/lwip_base/test/unit/tcp/test_tcp.h | 8 -
net/ip/lwip_base/test/unit/tcp/test_tcp_oos.h | 8 -
net/ip/lwip_base/test/unit/udp/test_udp.h | 8 -
net/ip/mn_socket/include/mn_socket/mn_socket.h | 7 +
net/ip/mn_socket/src/mn_socket.c | 16 +
net/ip/mn_socket/src/mn_socket_aconv.c | 2 +-
net/ip/native_sockets/src/native_itf.c | 5 +-
net/ip/pkg.yml | 7 +
net/ip/src/ip_init.c | 5 +
net/ip/src/ip_priv.h | 3 +
net/ip/src/lwip_cli.c | 140 +
net/ip/src/lwip_if.c | 17 +-
net/ip/src/lwip_socket.c | 179 +-
net/ip/syscfg.yml | 26 +
.../controller/include/controller/ble_ll_conn.h | 3 +-
net/nimble/controller/pkg.yml | 2 +-
net/nimble/controller/src/ble_ll_conn.c | 8 +-
net/nimble/controller/src/ble_ll_conn_hci.c | 2 +-
net/nimble/controller/src/ble_ll_ctrl.c | 21 +-
net/nimble/host/pts/pts-l2cap.txt | 75 +-
.../host/pts/tpg/90359-20161220-172100175.tpg | 1022 -
.../host/pts/tpg/90359-20161220-172113981.pts | 288 -
.../host/pts/tpg/94654-20170317-085122560.tpg | 1026 +
.../host/pts/tpg/94654-20170317-085441153.pts | 289 +
net/nimble/host/src/ble_att.c | 3 +
net/nimble/host/src/ble_att_clt.c | 650 +-
net/nimble/host/src/ble_att_cmd.c | 310 +-
net/nimble/host/src/ble_att_cmd_priv.h | 52 +-
net/nimble/host/src/ble_att_priv.h | 51 +-
net/nimble/host/src/ble_att_svr.c | 601 +-
net/nimble/host/src/ble_gatt_priv.h | 4 +-
net/nimble/host/src/ble_gattc.c | 184 +-
net/nimble/host/src/ble_hs_endian_priv.h | 65 -
net/nimble/host/src/ble_hs_priv.h | 1 -
net/nimble/host/src/ble_l2cap_coc.c | 21 +-
net/nimble/host/src/ble_l2cap_sig.c | 20 +-
net/nimble/host/src/ble_l2cap_sig_cmd.c | 22 +-
net/nimble/host/src/ble_l2cap_sig_priv.h | 7 +-
net/nimble/host/src/ble_sm.c | 56 +-
net/nimble/host/src/ble_sm_lgcy.c | 19 +-
net/nimble/host/src/ble_sm_priv.h | 8 +-
net/nimble/host/src/ble_sm_sc.c | 51 +-
net/nimble/host/test/src/ble_att_clt_test.c | 67 +-
net/nimble/host/test/src/ble_gatt_disc_s_test.c | 2 +
net/nimble/host/test/src/ble_hs_test_util.c | 108 +
net/nimble/host/test/src/ble_hs_test_util.h | 13 +
net/nimble/host/test/src/ble_l2cap_test.c | 696 +-
net/nimble/host/test/syscfg.yml | 1 +
.../socket/include/socket/ble_hci_socket.h | 34 +
net/nimble/transport/socket/pkg.yml | 38 +
.../transport/socket/src/ble_hci_socket.c | 802 +
net/nimble/transport/socket/syscfg.yml | 66 +
net/nimble/transport/uart/src/ble_hci_uart.c | 68 +-
repository.yml | 9 +-
sys/console/full/include/console/console.h | 21 +-
sys/console/full/include/console/prompt.h | 21 +-
sys/console/full/pkg.yml | 3 +
sys/console/full/src/cons_fmt.c | 80 -
sys/console/full/src/cons_tty.c | 574 -
sys/console/full/src/console.c | 535 +
sys/console/full/src/console_fmt.c | 103 +
sys/console/full/src/console_priv.h | 38 +
sys/console/full/src/prompt.c | 57 -
sys/console/full/src/rtt_console.c | 96 +
sys/console/full/src/ticks.c | 2 +-
sys/console/full/src/uart_console.c | 205 +
sys/console/full/syscfg.yml | 45 +-
sys/console/minimal/include/console/console.h | 44 +-
sys/console/minimal/include/console/ticks.h | 51 -
sys/console/minimal/pkg.yml | 3 +
sys/console/minimal/src/cons_tty.c | 253 -
sys/console/minimal/src/console.c | 303 +
sys/console/minimal/src/console_priv.h | 38 +
sys/console/minimal/src/rtt_console.c | 96 +
sys/console/minimal/src/uart_console.c | 205 +
sys/console/minimal/syscfg.yml | 32 +-
sys/console/stub/include/console/console.h | 47 +-
sys/reboot/src/log_reboot.c | 6 +-
sys/stats/full/include/stats/stats.h | 1 +
time/datetime/src/datetime.c | 13 +-
uncrustify.cfg | 1959 +
500 files changed, 99065 insertions(+), 10052 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/87329b51/apps/bletiny/src/main.c
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/87329b51/net/nimble/controller/include/controller/ble_ll_conn.h
----------------------------------------------------------------------
diff --cc net/nimble/controller/include/controller/ble_ll_conn.h
index 404d88a,000e308..cf5f9b1
--- a/net/nimble/controller/include/controller/ble_ll_conn.h
+++ b/net/nimble/controller/include/controller/ble_ll_conn.h
@@@ -271,7 -270,7 +271,8 @@@ struct ble_ll_conn_s
#define CONN_F_ENCRYPTED(csm) ((csm)->csmflags.cfbit.encrypted)
#define CONN_F_ENC_CHANGE_SENT(csm) ((csm)->csmflags.cfbit.encrypt_chg_sent)
#define CONN_F_LE_PING_SUPP(csm) ((csm)->csmflags.cfbit.le_ping_supp)
+ #define CONN_F_TERMINATE_STARTED(csm) ((csm)->csmflags.cfbit.terminate_started)
+#define CONN_F_CSA2_SUPP(csm) ((csm)->csmflags.cfbit.csa2_supp)
/* Role */
#define CONN_IS_MASTER(csm) (csm->conn_role == BLE_LL_CONN_ROLE_MASTER)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/87329b51/net/nimble/controller/src/ble_ll_conn.c
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/87329b51/net/nimble/controller/src/ble_ll_conn_hci.c
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/87329b51/net/nimble/controller/src/ble_ll_ctrl.c
----------------------------------------------------------------------
[44/50] [abbrv] incubator-mynewt-core git commit: sys/console: switch
to blocking mode for tab completion
Posted by ja...@apache.org.
sys/console: switch to blocking mode for tab completion
This patch solves an issue with tab completion and async console.
Tab completion is triggered in interrupt context and it outputs
text into the buffer. As the buffer fills up, the console tries to
wait until the uart pulls out the data from the buffer, but since
it all happens in the interrupt context, the uart cannot issue another
interrupt to pull the data thus freezing the console.
To avoid this we switch the console to blocking mode until the
completion is finished.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/6f739538
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/6f739538
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/6f739538
Branch: refs/heads/bluetooth5
Commit: 6f739538e1eacf35948bcbd53702306cda869e14
Parents: 4863008
Author: Micha\u0142 Narajowski <mi...@codecoup.pl>
Authored: Thu Apr 13 10:40:19 2017 +0200
Committer: Micha\u0142 Narajowski <mi...@codecoup.pl>
Committed: Tue Apr 25 17:49:15 2017 -0700
----------------------------------------------------------------------
sys/console/full/include/console/console.h | 1 +
sys/console/full/src/console.c | 10 ++++++++++
sys/console/full/src/console_priv.h | 1 +
sys/console/full/src/uart_console.c | 12 ++++++++++++
sys/console/stub/include/console/console.h | 5 +++++
5 files changed, 29 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6f739538/sys/console/full/include/console/console.h
----------------------------------------------------------------------
diff --git a/sys/console/full/include/console/console.h b/sys/console/full/include/console/console.h
index 0f37b79..3126c5c 100644
--- a/sys/console/full/include/console/console.h
+++ b/sys/console/full/include/console/console.h
@@ -42,6 +42,7 @@ void console_write(const char *str, int cnt);
int console_read(char *str, int cnt, int *newline);
#endif
void console_blocking_mode(void);
+void console_non_blocking_mode(void);
void console_echo(int on);
int console_printf(const char *fmt, ...)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6f739538/sys/console/full/src/console.c
----------------------------------------------------------------------
diff --git a/sys/console/full/src/console.c b/sys/console/full/src/console.c
index 18ff755..f4a0257 100644
--- a/sys/console/full/src/console.c
+++ b/sys/console/full/src/console.c
@@ -120,6 +120,14 @@ console_blocking_mode(void)
#endif
}
+void
+console_non_blocking_mode(void)
+{
+#if MYNEWT_VAL(CONSOLE_UART)
+ uart_console_non_blocking_mode();
+#endif
+}
+
static inline void
cursor_forward(unsigned int count)
{
@@ -368,7 +376,9 @@ console_handle_char(uint8_t byte)
break;
case '\t':
if (completion_cb && !end) {
+ console_blocking_mode();
cur += completion_cb(input->line, cur);
+ console_non_blocking_mode();
}
break;
default:
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6f739538/sys/console/full/src/console_priv.h
----------------------------------------------------------------------
diff --git a/sys/console/full/src/console_priv.h b/sys/console/full/src/console_priv.h
index d307b5d..5d448c4 100644
--- a/sys/console/full/src/console_priv.h
+++ b/sys/console/full/src/console_priv.h
@@ -27,6 +27,7 @@ extern "C" {
int uart_console_is_init(void);
int uart_console_init(void);
void uart_console_blocking_mode(void);
+void uart_console_non_blocking_mode(void);
int rtt_console_is_init(void);
int rtt_console_init(void);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6f739538/sys/console/full/src/uart_console.c
----------------------------------------------------------------------
diff --git a/sys/console/full/src/uart_console.c b/sys/console/full/src/uart_console.c
index 44943d2..fcf6c6f 100644
--- a/sys/console/full/src/uart_console.c
+++ b/sys/console/full/src/uart_console.c
@@ -118,6 +118,18 @@ uart_console_blocking_mode(void)
OS_EXIT_CRITICAL(sr);
}
+void
+uart_console_non_blocking_mode(void)
+{
+ int sr;
+
+ OS_ENTER_CRITICAL(sr);
+ if (write_char_cb) {
+ write_char_cb = console_queue_char;
+ }
+ OS_EXIT_CRITICAL(sr);
+}
+
int
console_out(int c)
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6f739538/sys/console/stub/include/console/console.h
----------------------------------------------------------------------
diff --git a/sys/console/stub/include/console/console.h b/sys/console/stub/include/console/console.h
index d60aaf8..b54ae1e 100644
--- a/sys/console/stub/include/console/console.h
+++ b/sys/console/stub/include/console/console.h
@@ -63,6 +63,11 @@ console_blocking_mode(void)
}
static void inline
+console_non_blocking_mode(void)
+{
+}
+
+static void inline
console_echo(int on)
{
}
[24/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-736 NimBLE -
UART xport can't send multibuf
Posted by ja...@apache.org.
MYNEWT-736 NimBLE - UART xport can't send multibuf
The UART transport assumes outgoing ACL data packets consist of a single
mbuf. If the chain contains multiple buffers, the later part of the
outgoing packet consists of all zeros.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/7669e971
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/7669e971
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/7669e971
Branch: refs/heads/bluetooth5
Commit: 7669e9715e9eee5cccea0074208e6915258d3d3a
Parents: fd7bf2b
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Apr 19 20:13:59 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Apr 19 20:13:59 2017 -0700
----------------------------------------------------------------------
net/nimble/transport/uart/src/ble_hci_uart.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7669e971/net/nimble/transport/uart/src/ble_hci_uart.c
----------------------------------------------------------------------
diff --git a/net/nimble/transport/uart/src/ble_hci_uart.c b/net/nimble/transport/uart/src/ble_hci_uart.c
index 6584112..9de4ad7 100755
--- a/net/nimble/transport/uart/src/ble_hci_uart.c
+++ b/net/nimble/transport/uart/src/ble_hci_uart.c
@@ -275,6 +275,7 @@ ble_hci_uart_tx_pkt_type(void)
static int
ble_hci_uart_tx_char(void *arg)
{
+ uint8_t u8;
int rc = -1;
switch (ble_hci_uart_state.tx_type) {
@@ -293,12 +294,19 @@ ble_hci_uart_tx_char(void *arg)
break;
case BLE_HCI_UART_H4_ACL:
- rc = *OS_MBUF_DATA(ble_hci_uart_state.tx_acl, uint8_t *);
+ /* Copy the first unsent byte from the tx buffer and remove it from the
+ * source.
+ */
+ os_mbuf_copydata(ble_hci_uart_state.tx_acl, 0, 1, &u8);
os_mbuf_adj(ble_hci_uart_state.tx_acl, 1);
- if (!OS_MBUF_PKTLEN(ble_hci_uart_state.tx_acl)) {
+
+ /* Free the tx buffer if this is the last byte to send. */
+ if (OS_MBUF_PKTLEN(ble_hci_uart_state.tx_acl) == 0) {
os_mbuf_free_chain(ble_hci_uart_state.tx_acl);
ble_hci_uart_state.tx_type = BLE_HCI_UART_H4_NONE;
}
+
+ rc = u8;
break;
}
[18/50] [abbrv] incubator-mynewt-core git commit: fs/fcb;
fix a bug when storing variable of 127 bytes in length.
Posted by ja...@apache.org.
fs/fcb; fix a bug when storing variable of 127 bytes in length.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/31d00cb0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/31d00cb0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/31d00cb0
Branch: refs/heads/bluetooth5
Commit: 31d00cb0a86368ce2c2f25a0c4ade94fc1680e76
Parents: 43e3f72
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Apr 19 14:35:19 2017 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Apr 19 14:35:19 2017 -0700
----------------------------------------------------------------------
fs/fcb/src/fcb.c | 2 +-
fs/fcb/test/src/testcases/fcb_test_len.c | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31d00cb0/fs/fcb/src/fcb.c
----------------------------------------------------------------------
diff --git a/fs/fcb/src/fcb.c b/fs/fcb/src/fcb.c
index 30c76b5..ea106ad 100644
--- a/fs/fcb/src/fcb.c
+++ b/fs/fcb/src/fcb.c
@@ -127,7 +127,7 @@ fcb_is_empty(struct fcb *fcb)
int
fcb_put_len(uint8_t *buf, uint16_t len)
{
- if (len < CHAR_MAX) {
+ if (len < 0x80) {
buf[0] = len;
return 1;
} else if (len < FCB_MAX_LEN) {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31d00cb0/fs/fcb/test/src/testcases/fcb_test_len.c
----------------------------------------------------------------------
diff --git a/fs/fcb/test/src/testcases/fcb_test_len.c b/fs/fcb/test/src/testcases/fcb_test_len.c
index 9aa036f..a2851cb 100644
--- a/fs/fcb/test/src/testcases/fcb_test_len.c
+++ b/fs/fcb/test/src/testcases/fcb_test_len.c
@@ -24,13 +24,14 @@ TEST_CASE(fcb_test_len)
uint16_t len;
uint16_t len2;
int rc;
+ int rc2;
for (len = 0; len < FCB_MAX_LEN; len++) {
rc = fcb_put_len(buf, len);
TEST_ASSERT(rc == 1 || rc == 2);
- rc = fcb_get_len(buf, &len2);
- TEST_ASSERT(rc == 1 || rc == 2);
+ rc2 = fcb_get_len(buf, &len2);
+ TEST_ASSERT(rc2 == rc);
TEST_ASSERT(len == len2);
}
[36/50] [abbrv] incubator-mynewt-core git commit: nimble/transport;
MYNEWT-737: Make ble_hci_uart_tx_char more efficient
Posted by ja...@apache.org.
nimble/transport; MYNEWT-737: Make ble_hci_uart_tx_char more efficient
Per pull request review, add assert() if om is NULL. Did not
modify the rest of the code in case assert() is compiled out
by NDEBUG being defined.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/5a869e3e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/5a869e3e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/5a869e3e
Branch: refs/heads/bluetooth5
Commit: 5a869e3e2e791fd83e763a02fcecb4803de6ce37
Parents: be6ce3c
Author: William San Filippo <wi...@runtime.io>
Authored: Mon Apr 24 12:19:01 2017 -0700
Committer: William San Filippo <wi...@runtime.io>
Committed: Mon Apr 24 12:19:01 2017 -0700
----------------------------------------------------------------------
net/nimble/transport/uart/src/ble_hci_uart.c | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5a869e3e/net/nimble/transport/uart/src/ble_hci_uart.c
----------------------------------------------------------------------
diff --git a/net/nimble/transport/uart/src/ble_hci_uart.c b/net/nimble/transport/uart/src/ble_hci_uart.c
index a4c1855..19b89ae 100755
--- a/net/nimble/transport/uart/src/ble_hci_uart.c
+++ b/net/nimble/transport/uart/src/ble_hci_uart.c
@@ -338,6 +338,7 @@ ble_hci_uart_tx_char(void *arg)
}
/* NOTE: om should never be NULL! What to do? */
if (om == NULL) {
+ assert(0);
ble_hci_uart_state.tx_type = BLE_HCI_UART_H4_NONE;
} else {
ble_hci_uart_state.tx_pkt.dptr = om->om_data;
[29/50] [abbrv] incubator-mynewt-core git commit: Initial BLE400 BSP
Posted by ja...@apache.org.
Initial BLE400 BSP
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/323f7849
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/323f7849
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/323f7849
Branch: refs/heads/bluetooth5
Commit: 323f7849aa15fe3e02ce3609eccd893c6ff9be11
Parents: 271ab1b
Author: Fabio Utzig <ut...@utzig.org>
Authored: Thu Apr 20 15:02:30 2017 -0300
Committer: Fabio Utzig <ut...@utzig.org>
Committed: Thu Apr 20 22:26:08 2017 -0300
----------------------------------------------------------------------
hw/bsp/ble400/ble400.cfg | 22 ++
hw/bsp/ble400/ble400_debug.cmd | 22 ++
hw/bsp/ble400/ble400_debug.sh | 38 +++
hw/bsp/ble400/ble400_download.cmd | 22 ++
hw/bsp/ble400/ble400_download.sh | 42 +++
hw/bsp/ble400/ble400_no_boot.ld | 179 ++++++++++++
hw/bsp/ble400/boot-nrf51xxac.ld | 25 ++
hw/bsp/ble400/bsp.yml | 64 +++++
hw/bsp/ble400/include/bsp/boards.h | 19 ++
hw/bsp/ble400/include/bsp/bsp.h | 53 ++++
hw/bsp/ble400/include/bsp/cmsis_nvic.h | 30 ++
hw/bsp/ble400/nrf51xxac.ld | 25 ++
hw/bsp/ble400/pkg.yml | 90 ++++++
hw/bsp/ble400/split-ble400.ld | 185 ++++++++++++
.../src/arch/cortex_m0/gcc_startup_nrf51.s | 283 +++++++++++++++++++
.../arch/cortex_m0/gcc_startup_nrf51_split.s | 185 ++++++++++++
hw/bsp/ble400/src/hal_bsp.c | 189 +++++++++++++
hw/bsp/ble400/src/sbrk.c | 57 ++++
hw/bsp/ble400/syscfg.yml | 97 +++++++
19 files changed, 1627 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/323f7849/hw/bsp/ble400/ble400.cfg
----------------------------------------------------------------------
diff --git a/hw/bsp/ble400/ble400.cfg b/hw/bsp/ble400/ble400.cfg
new file mode 100644
index 0000000..336079f
--- /dev/null
+++ b/hw/bsp/ble400/ble400.cfg
@@ -0,0 +1,22 @@
+#!/bin/sh
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+source [find interface/stlink-v2.cfg]
+transport select hla_swd
+set WORKAREASIZE 0x4000
+source [find target/nrf51.cfg]
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/323f7849/hw/bsp/ble400/ble400_debug.cmd
----------------------------------------------------------------------
diff --git a/hw/bsp/ble400/ble400_debug.cmd b/hw/bsp/ble400/ble400_debug.cmd
new file mode 100755
index 0000000..96f0b26
--- /dev/null
+++ b/hw/bsp/ble400/ble400_debug.cmd
@@ -0,0 +1,22 @@
+@rem
+@rem Licensed to the Apache Software Foundation (ASF) under one
+@rem or more contributor license agreements. See the NOTICE file
+@rem distributed with this work for additional information
+@rem regarding copyright ownership. The ASF licenses this file
+@rem to you under the Apache License, Version 2.0 (the
+@rem "License"); you may not use this file except in compliance
+@rem with the License. You may obtain a copy of the License at
+@rem
+@rem http://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing,
+@rem software distributed under the License is distributed on an
+@rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@rem KIND, either express or implied. See the License for the
+@rem specific language governing permissions and limitations
+@rem under the License.
+@rem
+
+@rem Execute a shell with a script of the same name and .sh extension
+
+@bash "%~dp0%~n0.sh"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/323f7849/hw/bsp/ble400/ble400_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/ble400/ble400_debug.sh b/hw/bsp/ble400/ble400_debug.sh
new file mode 100755
index 0000000..27f7ecb
--- /dev/null
+++ b/hw/bsp/ble400/ble400_debug.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Called with following variables set:
+# - CORE_PATH is absolute path to @apache-mynewt-core
+# - BSP_PATH is absolute path to hw/bsp/bsp_name
+# - BIN_BASENAME is the path to prefix to target binary,
+# .elf appended to name is the ELF file
+# - FEATURES holds the target features string
+# - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
+# - RESET set if target should be reset when attaching
+# - NO_GDB set if we should not start gdb to debug
+#
+
+. $CORE_PATH/hw/scripts/openocd.sh
+
+CFG="-s $BSP_PATH -f ble400.cfg"
+
+FILE_NAME=$BIN_BASENAME.elf
+EXTRA_JTAG_CMD="$EXTRA_JTAG_CMD; nrf51.cpu configure -event gdb-detach {if {[nrf51.cpu curstate] eq \"halted\"} resume;shutdown}"
+
+openocd_debug
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/323f7849/hw/bsp/ble400/ble400_download.cmd
----------------------------------------------------------------------
diff --git a/hw/bsp/ble400/ble400_download.cmd b/hw/bsp/ble400/ble400_download.cmd
new file mode 100755
index 0000000..96f0b26
--- /dev/null
+++ b/hw/bsp/ble400/ble400_download.cmd
@@ -0,0 +1,22 @@
+@rem
+@rem Licensed to the Apache Software Foundation (ASF) under one
+@rem or more contributor license agreements. See the NOTICE file
+@rem distributed with this work for additional information
+@rem regarding copyright ownership. The ASF licenses this file
+@rem to you under the Apache License, Version 2.0 (the
+@rem "License"); you may not use this file except in compliance
+@rem with the License. You may obtain a copy of the License at
+@rem
+@rem http://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing,
+@rem software distributed under the License is distributed on an
+@rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@rem KIND, either express or implied. See the License for the
+@rem specific language governing permissions and limitations
+@rem under the License.
+@rem
+
+@rem Execute a shell with a script of the same name and .sh extension
+
+@bash "%~dp0%~n0.sh"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/323f7849/hw/bsp/ble400/ble400_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/ble400/ble400_download.sh b/hw/bsp/ble400/ble400_download.sh
new file mode 100755
index 0000000..3fc610b
--- /dev/null
+++ b/hw/bsp/ble400/ble400_download.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Called with following variables set:
+# - CORE_PATH is absolute path to @apache-mynewt-core
+# - BSP_PATH is absolute path to hw/bsp/bsp_name
+# - BIN_BASENAME is the path to prefix to target binary,
+# .elf appended to name is the ELF file
+# - IMAGE_SLOT is the image slot to download to (for non-mfg-image, non-boot)
+# - FEATURES holds the target features string
+# - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
+# - MFG_IMAGE is "1" if this is a manufacturing image
+# - FLASH_OFFSET contains the flash offset to download to
+# - BOOT_LOADER is set if downloading a bootloader
+
+. $CORE_PATH/hw/scripts/openocd.sh
+
+CFG="-s $BSP_PATH -f ble400.cfg"
+
+if [ "$MFG_IMAGE" ]; then
+ FLASH_OFFSET=0x0
+fi
+
+common_file_to_load
+openocd_load
+openocd_reset_run
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/323f7849/hw/bsp/ble400/ble400_no_boot.ld
----------------------------------------------------------------------
diff --git a/hw/bsp/ble400/ble400_no_boot.ld b/hw/bsp/ble400/ble400_no_boot.ld
new file mode 100644
index 0000000..b5547fc
--- /dev/null
+++ b/hw/bsp/ble400/ble400_no_boot.ld
@@ -0,0 +1,179 @@
+/* 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")
+
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x40000
+ RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x8000
+}
+
+/* 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__
+ * __HeapBase
+ * __HeapLimit
+ * __StackLimit
+ * __StackTop
+ * __stack
+ * __bssnz_start__
+ * __bssnz_end__
+ */
+ENTRY(Reset_Handler)
+
+SECTIONS
+{
+ .text :
+ {
+ __isr_vector_start = .;
+ KEEP(*(.isr_vector))
+ __isr_vector_end = .;
+ *(.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 = .;
+
+ /* Keep first in RAM, as well as in bootloader */
+ .vector_relocation :
+ {
+ . = ALIGN(4);
+ __vector_tbl_reloc__ = .;
+ . = . + (__isr_vector_end - __isr_vector_start);
+ . = ALIGN(4);
+ } > RAM
+
+ .data : AT (__etext)
+ {
+ __data_start__ = .;
+ *(vtable)
+ *(.data*)
+
+ . = ALIGN(4);
+ /* preinit data */
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ *(.preinit_array)
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+
+ . = ALIGN(4);
+ /* init data */
+ PROVIDE_HIDDEN (__init_array_start = .);
+ *(SORT(.init_array.*))
+ *(.init_array)
+ PROVIDE_HIDDEN (__init_array_end = .);
+
+
+ . = ALIGN(4);
+ /* finit data */
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ *(SORT(.fini_array.*))
+ *(.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 starts after BSS */
+ __HeapBase = .;
+
+ /* .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);
+
+ /* Top of head is the bottom of the stack */
+ __HeapLimit = __StackLimit;
+
+ /* Check if data + heap + stack exceeds RAM limit */
+ ASSERT(__HeapBase <= __HeapLimit, "region RAM overflowed with stack")
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/323f7849/hw/bsp/ble400/boot-nrf51xxac.ld
----------------------------------------------------------------------
diff --git a/hw/bsp/ble400/boot-nrf51xxac.ld b/hw/bsp/ble400/boot-nrf51xxac.ld
new file mode 100644
index 0000000..64fcd83
--- /dev/null
+++ b/hw/bsp/ble400/boot-nrf51xxac.ld
@@ -0,0 +1,25 @@
+/* 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.
+ */
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x4000
+ RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x4000
+}
+
+/* The bootloader does not contain an image header */
+_imghdr_size = 0x0;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/323f7849/hw/bsp/ble400/bsp.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/ble400/bsp.yml b/hw/bsp/ble400/bsp.yml
new file mode 100644
index 0000000..d724bba
--- /dev/null
+++ b/hw/bsp/ble400/bsp.yml
@@ -0,0 +1,64 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+bsp.arch: cortex_m0
+bsp.compiler: compiler/arm-none-eabi-m0
+bsp.linkerscript:
+ - "hw/bsp/ble400/nrf51xxac.ld"
+ - "hw/mcu/nordic/nrf51xxx/nrf51.ld"
+bsp.linkerscript.BOOT_LOADER.OVERWRITE:
+ - "hw/bsp/ble400/boot-nrf51xxac.ld"
+ - "hw/mcu/nordic/nrf51xxx/nrf51.ld"
+bsp.part2linkerscript: "hw/bsp/ble400/split-ble400.ld"
+bsp.downloadscript: "hw/bsp/ble400/ble400_download.sh"
+bsp.debugscript: "hw/bsp/ble400/ble400_debug.sh"
+bsp.downloadscript.WINDOWS.OVERWRITE: "hw/bsp/ble400/ble400_download.cmd"
+bsp.debugscript.WINDOWS.OVERWRITE: "hw/bsp/ble400/ble400_debug.cmd"
+
+bsp.flash_map:
+ areas:
+ # System areas.
+ FLASH_AREA_BOOTLOADER:
+ device: 0
+ offset: 0x00000000
+ size: 16kB
+ FLASH_AREA_IMAGE_0:
+ device: 0
+ offset: 0x00008000
+ size: 110kB
+ FLASH_AREA_IMAGE_1:
+ device: 0
+ offset: 0x00023800
+ size: 110kB
+ FLASH_AREA_IMAGE_SCRATCH:
+ device: 0
+ offset: 0x0003f000
+ size: 2kB
+
+ # User areas.
+ FLASH_AREA_REBOOT_LOG:
+ user_id: 0
+ device: 0
+ offset: 0x00004000
+ size: 16kB
+ FLASH_AREA_NFFS:
+ user_id: 1
+ device: 0
+ offset: 0x0003f800
+ size: 2kB
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/323f7849/hw/bsp/ble400/include/bsp/boards.h
----------------------------------------------------------------------
diff --git a/hw/bsp/ble400/include/bsp/boards.h b/hw/bsp/ble400/include/bsp/boards.h
new file mode 100644
index 0000000..560c31f
--- /dev/null
+++ b/hw/bsp/ble400/include/bsp/boards.h
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/323f7849/hw/bsp/ble400/include/bsp/bsp.h
----------------------------------------------------------------------
diff --git a/hw/bsp/ble400/include/bsp/bsp.h b/hw/bsp/ble400/include/bsp/bsp.h
new file mode 100644
index 0000000..14d57ba
--- /dev/null
+++ b/hw/bsp/ble400/include/bsp/bsp.h
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BSP_H
+#define H_BSP_H
+
+#include <inttypes.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Define special stackos sections */
+#define sec_data_core __attribute__((section(".data.core")))
+#define sec_bss_core __attribute__((section(".bss.core")))
+
+/* More convenient section placement macros. */
+#define bssnz_t
+
+extern uint8_t _ram_start;
+#define RAM_SIZE 0x8000
+
+/* LED pins */
+#define LED_BLINK_PIN (18)
+#define LED_2 (19)
+
+/* UART info */
+#define CONSOLE_UART "uart0"
+
+#define NFFS_AREA_MAX (8)
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* H_BSP_H */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/323f7849/hw/bsp/ble400/include/bsp/cmsis_nvic.h
----------------------------------------------------------------------
diff --git a/hw/bsp/ble400/include/bsp/cmsis_nvic.h b/hw/bsp/ble400/include/bsp/cmsis_nvic.h
new file mode 100644
index 0000000..5d2ae83
--- /dev/null
+++ b/hw/bsp/ble400/include/bsp/cmsis_nvic.h
@@ -0,0 +1,30 @@
+/* mbed Microcontroller Library - cmsis_nvic
+ * Copyright (c) 2009-2011 ARM Limited. All rights reserved.
+ *
+ * CMSIS-style functionality to support dynamic vectors
+ */
+
+#ifndef MBED_CMSIS_NVIC_H
+#define MBED_CMSIS_NVIC_H
+
+#include <stdint.h>
+
+/* NOTE: the nrf51 SoC has 26 interrupts. */
+#define NVIC_USER_IRQ_OFFSET 16
+#define NVIC_NUM_VECTORS (NVIC_USER_IRQ_OFFSET + 26)
+
+#include "nrf51.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void NVIC_Relocate(void);
+void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector);
+uint32_t NVIC_GetVector(IRQn_Type IRQn);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/323f7849/hw/bsp/ble400/nrf51xxac.ld
----------------------------------------------------------------------
diff --git a/hw/bsp/ble400/nrf51xxac.ld b/hw/bsp/ble400/nrf51xxac.ld
new file mode 100644
index 0000000..ada638e
--- /dev/null
+++ b/hw/bsp/ble400/nrf51xxac.ld
@@ -0,0 +1,25 @@
+/* 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.
+ */
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x00008000, LENGTH = 0x1b800
+ RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x4000
+}
+
+/* This linker script is used for images and thus contains an image header */
+_imghdr_size = 0x20;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/323f7849/hw/bsp/ble400/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/ble400/pkg.yml b/hw/bsp/ble400/pkg.yml
new file mode 100644
index 0000000..dad0ee9
--- /dev/null
+++ b/hw/bsp/ble400/pkg.yml
@@ -0,0 +1,90 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+pkg.name: hw/bsp/ble400
+pkg.type: bsp
+pkg.description: BSP definition for the Waveshare BLE400 module (nRF51).
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
+pkg.keywords:
+ - nrf51
+ - ble400
+ - waveshare
+
+pkg.cflags:
+ # Nordic SDK files require these defines.
+ - '-DCLOCK_ENABLED=1'
+ - '-DCOMP_ENABLED=0'
+ - '-DEGU_ENABLED=0'
+ - '-DGPIOTE_ENABLED=1'
+ - '-DI2S_ENABLED=0'
+ - '-DLPCOMP_ENABLED=1'
+ - '-DNRF51'
+ - '-DPDM_ENABLED=0'
+ - '-DPERIPHERAL_RESOURCE_SHARING_ENABLED=1'
+ - '-DPWM0_ENABLED=1'
+ - '-DPWM1_ENABLED=0'
+ - '-DPWM2_ENABLED=0'
+ - '-DQDEC_ENABLED=1'
+ - '-DRNG_ENABLED=1'
+ - '-DRTC0_ENABLED=0'
+ - '-DRTC1_ENABLED=0'
+ - '-DRTC2_ENABLED=0'
+ - '-DSPI0_CONFIG_MISO_PIN=23'
+ - '-DSPI0_CONFIG_MOSI_PIN=24'
+ - '-DSPI0_CONFIG_SCK_PIN=25'
+ - '-DSPI0_ENABLED=1'
+ - '-DSPI0_USE_EASY_DMA=0'
+ - '-DSPI1_ENABLED=0'
+ - '-DSPI2_ENABLED=0'
+ - '-DSPIS0_CONFIG_MISO_PIN=4'
+ - '-DSPIS0_CONFIG_MOSI_PIN=3'
+ - '-DSPIS0_CONFIG_SCK_PIN=2'
+ - '-DSPIS0_ENABLED=0'
+ - '-DSPIS1_CONFIG_MISO_PIN=28'
+ - '-DSPIS1_CONFIG_MOSI_PIN=25'
+ - '-DSPIS1_CONFIG_SCK_PIN=29'
+ - '-DSPIS1_ENABLED=0'
+ - '-DSPIS2_ENABLED=0'
+ - '-DTIMER0_ENABLED=1'
+ - '-DTIMER1_ENABLED=0'
+ - '-DTIMER2_ENABLED=0'
+ - '-DTIMER3_ENABLED=0'
+ - '-DTIMER4_ENABLED=0'
+ - '-DTWI0_CONFIG_SCL=1'
+ - '-DTWI0_CONFIG_SDA=0'
+ - '-DTWI0_ENABLED=1'
+ - '-DTWI1_ENABLED=0'
+ - '-DTWIS0_ENABLED=0'
+ - '-DTWIS1_ENABLED=0'
+ - '-DUART0_ENABLED=1'
+ - '-DWDT_ENABLED=1'
+
+pkg.deps:
+ - hw/mcu/nordic/nrf51xxx
+ - libc/baselibc
+
+pkg.deps.BLE_DEVICE:
+ - hw/drivers/nimble/nrf51
+
+pkg.deps.UART_0:
+ - hw/drivers/uart/uart_hal
+
+pkg.deps.UART_1:
+ - hw/drivers/uart/uart_bitbang
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/323f7849/hw/bsp/ble400/split-ble400.ld
----------------------------------------------------------------------
diff --git a/hw/bsp/ble400/split-ble400.ld b/hw/bsp/ble400/split-ble400.ld
new file mode 100644
index 0000000..55d154e
--- /dev/null
+++ b/hw/bsp/ble400/split-ble400.ld
@@ -0,0 +1,185 @@
+/* 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")
+
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x00023800, LENGTH = 0x1b800
+ RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x8000
+}
+
+/* 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_split : 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__
+ * __HeapBase
+ * __HeapLimit
+ * __StackLimit
+ * __StackTop
+ * __stack
+ * __bssnz_start__
+ * __bssnz_end__
+ */
+ENTRY(Reset_Handler_split)
+
+SECTIONS
+{
+ .imghdr (NOLOAD):
+ {
+ . = . + 0x20;
+ } > FLASH
+
+ .text :
+ {
+ __split_isr_vector_start = .;
+ KEEP(*(.isr_vector_split))
+ __split_isr_vector_end = .;
+ *(.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 = .;
+
+ /* save RAM used by the split image. This assumes that
+ * the loader uses all the RAM up to its HeapBase */
+ .loader_ram_contents :
+ {
+ _loader_ram_start = .;
+ /* this symbol comes from the loader linker */
+ . = . + (ABSOLUTE(__HeapBase_loader) - _loader_ram_start);
+ _loader_ram_end = .;
+ } > RAM
+
+ .data :
+ {
+ __data_start__ = .;
+ *(.data*)
+
+ . = ALIGN(4);
+ /* preinit data */
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ *(.preinit_array)
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+
+ . = ALIGN(4);
+ /* init data */
+ PROVIDE_HIDDEN (__init_array_start = .);
+ *(SORT(.init_array.*))
+ *(.init_array)
+ PROVIDE_HIDDEN (__init_array_end = .);
+
+
+ . = ALIGN(4);
+ /* finit data */
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ *(SORT(.fini_array.*))
+ *(.fini_array)
+ PROVIDE_HIDDEN (__fini_array_end = .);
+
+ *(.jcr)
+ . = ALIGN(4);
+ /* All data end */
+ __data_end__ = .;
+ } > RAM AT > FLASH
+
+ .bss :
+ {
+ . = ALIGN(4);
+ __bss_start__ = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4);
+ __bss_end__ = .;
+ } > RAM
+
+ /* Heap starts after BSS */
+ __HeapBase = .;
+
+ /* .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
+
+ _ram_start = ORIGIN(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);
+
+ /* Top of head is the bottom of the stack */
+ __HeapLimit = __StackLimit;
+
+ /* Check if data + heap + stack exceeds RAM limit */
+ ASSERT(__HeapBase <= __HeapLimit, "region RAM overflowed with stack")
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/323f7849/hw/bsp/ble400/src/arch/cortex_m0/gcc_startup_nrf51.s
----------------------------------------------------------------------
diff --git a/hw/bsp/ble400/src/arch/cortex_m0/gcc_startup_nrf51.s b/hw/bsp/ble400/src/arch/cortex_m0/gcc_startup_nrf51.s
new file mode 100644
index 0000000..33463cd
--- /dev/null
+++ b/hw/bsp/ble400/src/arch/cortex_m0/gcc_startup_nrf51.s
@@ -0,0 +1,283 @@
+/*
+Copyright (c) 2015, 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:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form 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.
+
+* 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.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
+*/
+
+/*
+NOTE: Template files (including this one) are application specific and therefore
+expected to be copied into the application project folder prior to its use!
+*/
+
+ .syntax unified
+ .arch armv6-m
+
+ .section .stack
+ .align 3
+ .equ Stack_Size, 432
+ .globl __StackTop
+ .globl __StackLimit
+__StackLimit:
+ .space Stack_Size
+ .size __StackLimit, . - __StackLimit
+__StackTop:
+ .size __StackTop, . - __StackTop
+
+ .section .heap
+ .align 3
+#ifdef __HEAP_SIZE
+ .equ Heap_Size, __HEAP_SIZE
+#else
+ .equ Heap_Size, 0
+#endif
+ .globl __HeapBase
+ .globl __HeapLimit
+__HeapBase:
+ .if Heap_Size
+ .space Heap_Size
+ .endif
+ .size __HeapBase, . - __HeapBase
+__HeapLimit:
+ .size __HeapLimit, . - __HeapLimit
+
+ .section .isr_vector
+ .align 2
+ .globl __isr_vector
+__isr_vector:
+ .long __StackTop /* Top of Stack */
+ .long Reset_Handler /* Reset Handler */
+ .long _NMI_Handler /* NMI Handler */
+ .long _HardFault_Handler /* Hard Fault Handler */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long _SVC_Handler /* SVCall Handler */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long _PendSV_Handler /* PendSV Handler */
+ .long _SysTick_Handler /* SysTick Handler */
+
+ /* External Interrupts */
+ .long _POWER_CLOCK_IRQHandler
+ .long _RADIO_IRQHandler
+ .long _UART0_IRQHandler
+ .long _SPI0_TWI0_IRQHandler
+ .long _SPI1_TWI1_IRQHandler
+ .long 0 /*Reserved */
+ .long _GPIOTE_IRQHandler
+ .long ADC_IRQHandler
+ .long _TIMER0_IRQHandler
+ .long _TIMER1_IRQHandler
+ .long _TIMER2_IRQHandler
+ .long _RTC0_IRQHandler
+ .long _TEMP_IRQHandler
+ .long _RNG_IRQHandler
+ .long _ECB_IRQHandler
+ .long _CCM_AAR_IRQHandler
+ .long _WDT_IRQHandler
+ .long _RTC1_IRQHandler
+ .long _QDEC_IRQHandler
+ .long _LPCOMP_IRQHandler
+ .long _SWI0_IRQHandler
+ .long _SWI1_IRQHandler
+ .long _SWI2_IRQHandler
+ .long _SWI3_IRQHandler
+ .long _SWI4_IRQHandler
+ .long _SWI5_IRQHandler
+ .long 0 /*Reserved */
+ .long 0 /*Reserved */
+ .long 0 /*Reserved */
+ .long 0 /*Reserved */
+ .long 0 /*Reserved */
+ .long 0 /*Reserved */
+
+ .size __isr_vector, . - __isr_vector
+
+/* Reset Handler */
+
+ .equ NRF_POWER_RAMON_ADDRESS, 0x40000524
+ .equ NRF_POWER_RAMONB_ADDRESS, 0x40000554
+ .equ NRF_POWER_RAMONx_RAMxON_ONMODE_Msk, 0x3
+
+ .text
+ .thumb
+ .thumb_func
+ .align 1
+ .globl Reset_Handler
+ .type Reset_Handler, %function
+Reset_Handler:
+ .fnstart
+
+/* Make sure ALL RAM banks are powered on */
+ MOVS R1, #NRF_POWER_RAMONx_RAMxON_ONMODE_Msk
+
+ LDR R0, =NRF_POWER_RAMON_ADDRESS
+ LDR R2, [R0]
+ ORRS R2, R1
+ STR R2, [R0]
+
+ LDR R0, =NRF_POWER_RAMONB_ADDRESS
+ LDR R2, [R0]
+ ORRS R2, R1
+ STR R2, [R0]
+
+ /* Clear BSS */
+ subs r0, r0
+ ldr r2, =__bss_start__
+ ldr r3, =__bss_end__
+.bss_zero_loop:
+ cmp r2, r3
+ bhs .data_copy_loop
+ stmia r2!, {r0}
+ b .bss_zero_loop
+
+/* Loop to copy data from read only memory to RAM. The ranges
+ * of copy from/to are specified by following symbols evaluated in
+ * linker script.
+ * __etext: End of code section, i.e., begin of data sections to copy from.
+ * __data_start__/__data_end__: RAM address range that data should be
+ * copied to. Both must be aligned to 4 bytes boundary. */
+.data_copy_loop:
+ ldr r1, =__etext
+ ldr r2, =__data_start__
+ ldr r3, =__data_end__
+
+ subs r3, r2
+ ble .LC0
+
+.LC1:
+ subs r3, 4
+ ldr r0, [r1,r3]
+ str r0, [r2,r3]
+ bgt .LC1
+.LC0:
+ LDR R0, =__HeapBase
+ LDR R1, =__HeapLimit
+ BL _sbrkInit
+
+ LDR R0, =SystemInit
+ BLX R0
+
+ BL hal_system_init
+
+ LDR R0, =_start
+ BX R0
+
+ .pool
+ .cantunwind
+ .fnend
+ .size Reset_Handler,.-Reset_Handler
+
+ .section ".text"
+
+
+/* Dummy Exception Handlers (infinite loops which can be modified) */
+
+ .weak NMI_Handler
+ .type NMI_Handler, %function
+NMI_Handler:
+ B .
+ .size NMI_Handler, . - NMI_Handler
+
+ .weak SVC_Handler
+ .type SVC_Handler, %function
+SVC_Handler:
+ B .
+ .size SVC_Handler, . - SVC_Handler
+
+
+ .weak PendSV_Handler
+ .type PendSV_Handler, %function
+PendSV_Handler:
+ B .
+ .size PendSV_Handler, . - PendSV_Handler
+
+
+ .weak SysTick_Handler
+ .type SysTick_Handler, %function
+SysTick_Handler:
+ B .
+ .size SysTick_Handler, . - SysTick_Handler
+
+/* Default handler. This uses the vector in the relocated vector table */
+ .globl Default_Handler
+ .type Default_Handler, %function
+Default_Handler:
+ LDR R2, =__vector_tbl_reloc__
+ MRS R0, PSR
+ MOVS R1, #0x3F
+ ANDS R0, R1
+ LSLS R0, R0, #2
+ LDR R0, [R0, R2]
+ BX R0
+ .size Default_Handler, . - Default_Handler
+
+/*
+ * All of the following IRQ Handlers will point to the default handler unless
+ * they are defined elsewhere.
+ */
+ .macro IRQ handler
+ .weak \handler
+ .set \handler, Default_Handler
+ .endm
+
+ IRQ _NMI_Handler
+ IRQ _HardFault_Handler
+ IRQ _SVC_Handler
+ IRQ _PendSV_Handler
+ IRQ _SysTick_Handler
+ IRQ _POWER_CLOCK_IRQHandler
+ IRQ _RADIO_IRQHandler
+ IRQ _UART0_IRQHandler
+ IRQ _SPI0_TWI0_IRQHandler
+ IRQ _SPI1_TWI1_IRQHandler
+ IRQ _GPIOTE_IRQHandler
+ IRQ ADC_IRQHandler
+ IRQ _TIMER0_IRQHandler
+ IRQ _TIMER1_IRQHandler
+ IRQ _TIMER2_IRQHandler
+ IRQ _RTC0_IRQHandler
+ IRQ _TEMP_IRQHandler
+ IRQ _RNG_IRQHandler
+ IRQ _ECB_IRQHandler
+ IRQ _CCM_AAR_IRQHandler
+ IRQ _WDT_IRQHandler
+ IRQ _RTC1_IRQHandler
+ IRQ _QDEC_IRQHandler
+ IRQ _LPCOMP_IRQHandler
+ IRQ _SWI0_IRQHandler
+ IRQ _SWI1_IRQHandler
+ IRQ _SWI2_IRQHandler
+ IRQ _SWI3_IRQHandler
+ IRQ _SWI4_IRQHandler
+ IRQ _SWI5_IRQHandler
+
+ .end
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/323f7849/hw/bsp/ble400/src/arch/cortex_m0/gcc_startup_nrf51_split.s
----------------------------------------------------------------------
diff --git a/hw/bsp/ble400/src/arch/cortex_m0/gcc_startup_nrf51_split.s b/hw/bsp/ble400/src/arch/cortex_m0/gcc_startup_nrf51_split.s
new file mode 100644
index 0000000..ddcf4a4
--- /dev/null
+++ b/hw/bsp/ble400/src/arch/cortex_m0/gcc_startup_nrf51_split.s
@@ -0,0 +1,185 @@
+/*
+Copyright (c) 2015, 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:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form 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.
+
+* 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.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
+*/
+
+/*
+NOTE: Template files (including this one) are application specific and therefore
+expected to be copied into the application project folder prior to its use!
+*/
+
+ .syntax unified
+ .arch armv6-m
+
+ .section .stack
+ .align 3
+ .equ Stack_Size, 432
+ .globl __StackTop
+ .globl __StackLimit
+__StackLimit:
+ .space Stack_Size
+ .size __StackLimit, . - __StackLimit
+__StackTop:
+ .size __StackTop, . - __StackTop
+
+ .section .heap
+ .align 3
+#ifdef __HEAP_SIZE
+ .equ Heap_Size, __HEAP_SIZE
+#else
+ .equ Heap_Size, 0
+#endif
+ .globl __HeapBase
+ .globl __HeapLimit
+__HeapBase:
+ .if Heap_Size
+ .space Heap_Size
+ .endif
+ .size __HeapBase, . - __HeapBase
+__HeapLimit:
+ .size __HeapLimit, . - __HeapLimit
+
+ .section .isr_vector_split
+ .align 2
+ .globl __isr_vector_split
+__isr_vector_split:
+ .long __StackTop /* Top of Stack */
+ .long Reset_Handler_split /* Reset Handler */
+
+ .size __isr_vector_split, . - __isr_vector_split
+
+/* Reset Handler */
+
+ .equ NRF_POWER_RAMON_ADDRESS, 0x40000524
+ .equ NRF_POWER_RAMONB_ADDRESS, 0x40000554
+ .equ NRF_POWER_RAMONx_RAMxON_ONMODE_Msk, 0x3
+
+ .text
+ .thumb
+ .thumb_func
+ .align 1
+ .globl Reset_Handler_split
+ .type Reset_Handler_split, %function
+Reset_Handler_split:
+ .fnstart
+
+/* Clear CPU state before proceeding */
+ SUBS r0, r0
+ MSR CONTROL, r0
+ MSR PRIMASK, r0
+
+/* Make sure ALL RAM banks are powered on */
+ MOVS R1, #NRF_POWER_RAMONx_RAMxON_ONMODE_Msk
+
+ LDR R0, =NRF_POWER_RAMON_ADDRESS
+ LDR R2, [R0]
+ ORRS R2, R1
+ STR R2, [R0]
+
+ LDR R0, =NRF_POWER_RAMONB_ADDRESS
+ LDR R2, [R0]
+ ORRS R2, R1
+ STR R2, [R0]
+
+ /* Clear BSS */
+ subs r0, r0
+ ldr r2, =__bss_start__
+ ldr r3, =__bss_end__
+.bss_zero_loop:
+ cmp r2, r3
+ bhs .data_copy_loop
+ stmia r2!, {r0}
+ b .bss_zero_loop
+
+/* Loop to copy data from read only memory to RAM. The ranges
+ * of copy from/to are specified by following symbols evaluated in
+ * linker script.
+ * __etext: End of code section, i.e., begin of data sections to copy from.
+ * __data_start__/__data_end__: RAM address range that data should be
+ * copied to. Both must be aligned to 4 bytes boundary. */
+
+.data_copy_loop:
+ ldr r1, =__etext
+ ldr r2, =__data_start__
+ ldr r3, =__data_end__
+
+ subs r3, r2
+ ble .LC0
+
+.LC1:
+ subs r3, 4
+ ldr r0, [r1,r3]
+ str r0, [r2,r3]
+ bgt .LC1
+.LC0:
+ ldr r1, =__etext_loader
+ ldr r2, =__data_start___loader
+ ldr r3, =__data_end___loader
+
+ subs r3, r2
+ ble .LC2
+
+.LC3:
+ subs r3, 4
+ ldr r0, [r1,r3]
+ str r0, [r2,r3]
+ bgt .LC3
+.LC2:
+
+ subs r0, r0
+ ldr r2, =__bss_start___loader
+ ldr r3, =__bss_end___loader
+
+ subs r3, r2
+ ble .LC4
+
+.LC5:
+ subs r3, 4
+ str r0, [r2,r3]
+ bgt .LC5
+.LC4:
+ LDR R0, =__HeapBase
+ LDR R1, =__HeapLimit
+ BL _sbrkInit
+
+ LDR R0, =SystemInit
+ BLX R0
+
+ BL hal_system_init
+
+ LDR R0, =_start_split
+ BX R0
+
+ .pool
+ .cantunwind
+ .fnend
+ .size Reset_Handler_split,.-Reset_Handler_split
+
+ .section ".text"
+
+ .end
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/323f7849/hw/bsp/ble400/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/ble400/src/hal_bsp.c b/hw/bsp/ble400/src/hal_bsp.c
new file mode 100644
index 0000000..ed6d887
--- /dev/null
+++ b/hw/bsp/ble400/src/hal_bsp.c
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+#include <assert.h>
+#include "syscfg/syscfg.h"
+#include "hal/hal_bsp.h"
+#include "hal/hal_system.h"
+#include "mcu/nrf51_hal.h"
+#include "bsp/bsp.h"
+#include "os/os_dev.h"
+#include "os/os_cputime.h"
+#include "flash_map/flash_map.h"
+#include "hal/hal_flash.h"
+#include "hal/hal_spi.h"
+#include "hal/hal_i2c.h"
+#include "uart/uart.h"
+#include "uart_hal/uart_hal.h"
+
+#if MYNEWT_VAL(UART_0)
+static struct uart_dev os_bsp_uart0;
+static const struct nrf51_uart_cfg os_bsp_uart0_cfg = {
+ .suc_pin_tx = MYNEWT_VAL(UART_0_PIN_TX),
+ .suc_pin_rx = MYNEWT_VAL(UART_0_PIN_RX),
+ .suc_pin_rts = MYNEWT_VAL(UART_0_PIN_RTS),
+ .suc_pin_cts = MYNEWT_VAL(UART_0_PIN_CTS),
+};
+#endif
+
+#if MYNEWT_VAL(SPI_0_MASTER)
+/*
+ * NOTE: Our HAL expects that the SS pin, if used, is treated as a gpio line
+ * and is handled outside the SPI routines.
+ */
+static const struct nrf51_hal_spi_cfg os_bsp_spi0m_cfg = {
+ .sck_pin = 25,
+ .mosi_pin = 24,
+ .miso_pin = 23
+};
+#endif
+
+#if MYNEWT_VAL(SPI_1_SLAVE)
+static const struct nrf51_hal_spi_cfg os_bsp_spi1s_cfg = {
+ .sck_pin = 29,
+ .mosi_pin = 25,
+ .miso_pin = 28,
+ .ss_pin = 24
+};
+#endif
+
+#if MYNEWT_VAL(I2C_0)
+static const struct nrf51_hal_i2c_cfg hal_i2c_cfg = {
+ .scl_pin = 1,
+ .sda_pin = 0,
+ .i2c_frequency = 100 /* 100 kHz */
+};
+#endif
+
+/*
+ * What memory to include in coredump.
+ */
+static const struct hal_bsp_mem_dump dump_cfg[] = {
+ [0] = {
+ .hbmd_start = &_ram_start,
+ .hbmd_size = RAM_SIZE
+ }
+};
+
+const struct hal_flash *
+hal_bsp_flash_dev(uint8_t id)
+{
+ /*
+ * Internal flash mapped to id 0.
+ */
+ if (id != 0) {
+ return NULL;
+ }
+ return &nrf51_flash_dev;
+}
+
+const struct hal_bsp_mem_dump *
+hal_bsp_core_dump(int *area_cnt)
+{
+ *area_cnt = sizeof(dump_cfg) / sizeof(dump_cfg[0]);
+ return dump_cfg;
+}
+
+int
+hal_bsp_power_state(int state)
+{
+ return (0);
+}
+
+/**
+ * Returns the configured priority for the given interrupt. If no priority
+ * configured, return the priority passed in
+ *
+ * @param irq_num
+ * @param pri
+ *
+ * @return uint32_t
+ */
+uint32_t
+hal_bsp_get_nvic_priority(int irq_num, uint32_t pri)
+{
+ uint32_t cfg_pri;
+
+ switch (irq_num) {
+ /* Radio gets highest priority */
+ case RADIO_IRQn:
+ cfg_pri = 0;
+ break;
+ default:
+ cfg_pri = pri;
+ }
+ return cfg_pri;
+}
+
+void
+hal_bsp_init(void)
+{
+ int rc;
+
+ (void)rc;
+
+ /* Make sure system clocks have started */
+ hal_system_clock_start();
+
+#if MYNEWT_VAL(UART_0)
+ rc = os_dev_create((struct os_dev *) &os_bsp_uart0, "uart0",
+ OS_DEV_INIT_PRIMARY, 0, uart_hal_init, (void *)&os_bsp_uart0_cfg);
+ assert(rc == 0);
+#endif
+
+#if MYNEWT_VAL(TIMER_0)
+ rc = hal_timer_init(0, NULL);
+ assert(rc == 0);
+#endif
+#if MYNEWT_VAL(TIMER_1)
+ rc = hal_timer_init(1, NULL);
+ assert(rc == 0);
+#endif
+#if MYNEWT_VAL(TIMER_2)
+ rc = hal_timer_init(2, NULL);
+ assert(rc == 0);
+#endif
+
+#if MYNEWT_VAL(TIMER_3)
+ rc = hal_timer_init(3, NULL);
+ assert(rc == 0);
+#endif
+
+#if (MYNEWT_VAL(OS_CPUTIME_TIMER_NUM) >= 0)
+ rc = os_cputime_init(MYNEWT_VAL(OS_CPUTIME_FREQ));
+ assert(rc == 0);
+#endif
+
+#if MYNEWT_VAL(SPI_0_MASTER)
+ rc = hal_spi_init(0, (void *)&os_bsp_spi0m_cfg, HAL_SPI_TYPE_MASTER);
+ assert(rc == 0);
+#endif
+
+#if MYNEWT_VAL(SPI_1_SLAVE)
+ rc = hal_spi_init(1, (void *)&os_bsp_spi1s_cfg, HAL_SPI_TYPE_SLAVE);
+ assert(rc == 0);
+#endif
+
+#if MYNEWT_VAL(I2C_0)
+ rc = hal_i2c_init(0, (void *)&hal_i2c_cfg);
+ assert(rc == 0);
+#endif
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/323f7849/hw/bsp/ble400/src/sbrk.c
----------------------------------------------------------------------
diff --git a/hw/bsp/ble400/src/sbrk.c b/hw/bsp/ble400/src/sbrk.c
new file mode 100644
index 0000000..3fe253e
--- /dev/null
+++ b/hw/bsp/ble400/src/sbrk.c
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* put these in the data section so they are not cleared by _start */
+static char *sbrkBase __attribute__ ((section (".data")));
+static char *sbrkLimit __attribute__ ((section (".data")));
+static char *brk __attribute__ ((section (".data")));
+
+void
+_sbrkInit(char *base, char *limit) {
+ sbrkBase = base;
+ sbrkLimit = limit;
+ brk = base;
+}
+
+void *
+_sbrk(int incr)
+{
+ void *prev_brk;
+
+ if (incr < 0) {
+ /* Returning memory to the heap. */
+ incr = -incr;
+ if (brk - incr < sbrkBase) {
+ prev_brk = (void *)-1;
+ } else {
+ prev_brk = brk;
+ brk -= incr;
+ }
+ } else {
+ /* Allocating memory from the heap. */
+ if (sbrkLimit - brk >= incr) {
+ prev_brk = brk;
+ brk += incr;
+ } else {
+ prev_brk = (void *)-1;
+ }
+ }
+
+ return prev_brk;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/323f7849/hw/bsp/ble400/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/ble400/syscfg.yml b/hw/bsp/ble400/syscfg.yml
new file mode 100644
index 0000000..cb5837f
--- /dev/null
+++ b/hw/bsp/ble400/syscfg.yml
@@ -0,0 +1,97 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Package: hw/bsp/ble400
+
+syscfg.defs:
+ BSP_NRF51:
+ description: 'Set to indicate that BSP has NRF51'
+ value: 1
+
+ XTAL_32768:
+ description: 'External 32k oscillator available.'
+ value: 1
+ restrictions:
+ - "!XTAL_32768_SYNTH"
+
+ XTAL_32768_SYNTH:
+ description: 'Synthesize 32k clock.'
+ value: 0
+ restrictions:
+ - "!XTAL_32768"
+
+ UART_0:
+ description: 'Whether to enable UART0'
+ value: 1
+ UART_0_PIN_TX:
+ description: 'TX pin for UART0'
+ value: 9
+ UART_0_PIN_RX:
+ description: 'RX pin for UART0'
+ value: 11
+ UART_0_PIN_RTS:
+ description: 'RTS pin for UART0'
+ value: 8
+ UART_0_PIN_CTS:
+ description: 'CTS pin for UART0'
+ value: 10
+
+ SPI_0_MASTER:
+ description: 'SPI 0 master'
+ value: 0
+ SPI_0_MASTER_SS_PIN:
+ description: 'SPI 0 (master) SS pin number.'
+ value: 30
+ SPI_1_MASTER:
+ description: 'SPI 1 master'
+ value: 0
+ restrictions:
+ - "!SPI_1_SLAVE"
+ SPI_1_MASTER_SS_PIN:
+ description: 'SPI 1 (master) SS pin number.'
+ value: -1
+ SPI_1_SLAVE:
+ description: 'SPI 1 slave'
+ value: 0
+ restrictions:
+ - "!SPI_1_MASTER"
+
+ TIMER_0:
+ description: 'NRF51 Timer 0'
+ value: 1
+ TIMER_1:
+ description: 'NRF51 Timer 1'
+ value: 0
+ TIMER_2:
+ description: 'NRF51 Timer 2'
+ value: 0
+ TIMER_3:
+ description: 'NRF51 RTC0'
+ value: 0
+
+ I2C_0:
+ description: 'NRF51 I2C (TWI) interface 0'
+ value: '0'
+
+syscfg.vals:
+ CONFIG_FCB_FLASH_AREA: FLASH_AREA_NFFS
+ REBOOT_LOG_FLASH_AREA: FLASH_AREA_REBOOT_LOG
+ NFFS_FLASH_AREA: FLASH_AREA_NFFS
+ COREDUMP_FLASH_AREA: FLASH_AREA_IMAGE_1
+ MCU_DCDC_ENABLED: 0
[48/50] [abbrv] incubator-mynewt-core git commit: This closes #230.
Posted by ja...@apache.org.
This closes #230.
Merge branch 'new-console' of https://github.com/michal-narajowski/incubator-mynewt-core
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/7a1e0a8e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/7a1e0a8e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/7a1e0a8e
Branch: refs/heads/bluetooth5
Commit: 7a1e0a8e0c9d5c01efb35c6d16782a95f5d56516
Parents: 6ac1b82 5008f7c
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Apr 26 10:20:20 2017 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Apr 26 10:20:20 2017 -0700
----------------------------------------------------------------------
apps/bleprph/syscfg.yml | 1 +
hw/drivers/rtt/include/rtt/SEGGER_RTT.h | 244 ++++
hw/drivers/rtt/include/rtt/SEGGER_RTT_Conf.h | 267 ++++
hw/drivers/rtt/pkg.yml | 28 +
hw/drivers/rtt/src/SEGGER_RTT.c | 1462 ++++++++++++++++++++
hw/drivers/rtt/src/SEGGER_RTT_printf.c | 511 +++++++
hw/drivers/rtt/syscfg.yml | 24 +
kernel/os/include/os/os_eventq.h | 1 +
kernel/os/src/os_eventq.c | 14 +
sys/console/full/include/console/console.h | 19 +-
sys/console/full/include/console/prompt.h | 21 +-
sys/console/full/pkg.yml | 3 +
sys/console/full/src/cons_fmt.c | 112 --
sys/console/full/src/cons_tty.c | 574 --------
sys/console/full/src/console.c | 535 +++++++
sys/console/full/src/console_fmt.c | 103 ++
sys/console/full/src/console_priv.h | 38 +
sys/console/full/src/prompt.c | 57 -
sys/console/full/src/rtt_console.c | 96 ++
sys/console/full/src/ticks.c | 2 +-
sys/console/full/src/uart_console.c | 205 +++
sys/console/full/syscfg.yml | 45 +-
sys/console/minimal/include/console/console.h | 39 +-
sys/console/minimal/include/console/ticks.h | 51 -
sys/console/minimal/pkg.yml | 3 +
sys/console/minimal/src/cons_tty.c | 253 ----
sys/console/minimal/src/console.c | 303 ++++
sys/console/minimal/src/console_priv.h | 38 +
sys/console/minimal/src/rtt_console.c | 96 ++
sys/console/minimal/src/uart_console.c | 205 +++
sys/console/minimal/syscfg.yml | 32 +-
sys/console/stub/include/console/console.h | 42 +-
32 files changed, 4329 insertions(+), 1095 deletions(-)
----------------------------------------------------------------------
[39/50] [abbrv] incubator-mynewt-core git commit: This closes #243.
Posted by ja...@apache.org.
This closes #243.
Merge remote-tracking branch 'wes3/ble_hci_uart2'
* wes3/ble_hci_uart2:
nimble/transport; MYNEWT-737: Make ble_hci_uart_tx_char more efficient
nimble/transport; MYNEWT-737: Make ble_hci_uart_tx_char more efficient
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/843e03dd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/843e03dd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/843e03dd
Branch: refs/heads/bluetooth5
Commit: 843e03dde5aaf3119ad348a70ba195e5b9ef7e36
Parents: 3596d33 5a869e3
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Apr 24 19:10:48 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Apr 24 19:10:48 2017 -0700
----------------------------------------------------------------------
net/nimble/transport/uart/src/ble_hci_uart.c | 66 +++++++++++++++++++----
1 file changed, 55 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
[15/50] [abbrv] incubator-mynewt-core git commit: Merge branch
'lwip_updates' of https://github.com/mkiiskila/incubator-mynewt-core
Posted by ja...@apache.org.
Merge branch 'lwip_updates' of https://github.com/mkiiskila/incubator-mynewt-core
This closes #235.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/28b29f44
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/28b29f44
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/28b29f44
Branch: refs/heads/bluetooth5
Commit: 28b29f44549bcb7cec4bf47f10af45237a88d12b
Parents: 8492749 bcba6bd
Author: aditihilbert <ad...@runtime.io>
Authored: Wed Apr 19 11:12:27 2017 -0700
Committer: aditihilbert <ad...@runtime.io>
Committed: Wed Apr 19 11:12:27 2017 -0700
----------------------------------------------------------------------
apps/iptest/pkg.yml | 46 +
apps/iptest/src/main.c | 441 ++++++
apps/iptest/syscfg.yml | 45 +
.../include/bsp/stm32f4xx_hal_conf.h | 1 +
hw/bsp/olimex_stm32-e407_devboard/pkg.yml | 4 +-
hw/bsp/olimex_stm32-e407_devboard/src/hal_bsp.c | 41 +-
hw/bsp/olimex_stm32-e407_devboard/syscfg.yml | 4 +
hw/bsp/stm32f767-nucleo/pkg.yml | 3 +
hw/bsp/stm32f767-nucleo/src/hal_bsp.c | 50 +
hw/bsp/stm32f767-nucleo/syscfg.yml | 4 +
.../stm32_eth/include/stm32_eth/stm32_eth.h | 49 +
.../stm32_eth/include/stm32_eth/stm32_eth_cfg.h | 47 +
hw/drivers/lwip/stm32_eth/pkg.yml | 41 +
hw/drivers/lwip/stm32_eth/src/stm32_eth.c | 538 +++++++
.../include/stm32f4_eth/stm32f4_eth.h | 27 -
.../include/stm32f4_eth/stm32f4_eth_cfg.h | 32 -
hw/drivers/lwip/stm32f4_eth/pkg.yml | 33 -
hw/drivers/lwip/stm32f4_eth/src/stm32f4_eth.c | 746 ----------
hw/hal/include/hal/hal_timer.h | 2 +
hw/mcu/stm/stm32f4xx/syscfg.yml | 4 +
hw/mcu/stm/stm32f7xx/syscfg.yml | 4 +
libc/baselibc/include/string.h | 1 +
libc/baselibc/src/strstr.c | 5 +
net/ip/include/arch/sys_arch.h | 304 ++--
net/ip/include/ip/init.h | 32 -
net/ip/include/lwipopts.h | 15 +-
net/ip/inet_def_service/src/inet_def_service.c | 110 +-
net/ip/lwip_base/CHANGELOG | 146 ++
net/ip/lwip_base/UPGRADING | 16 +-
net/ip/lwip_base/doc/NO_SYS_SampleCode.c | 16 +-
net/ip/lwip_base/doc/doxygen/generate.sh | 2 +
net/ip/lwip_base/doc/doxygen/lwip.Doxyfile | 7 +-
net/ip/lwip_base/doc/doxygen/main_page.h | 75 +-
net/ip/lwip_base/doc/mqtt_client.txt | 162 +++
net/ip/lwip_base/doc/ppp.txt | 6 +-
net/ip/lwip_base/doc/rawapi.txt | 8 +-
net/ip/lwip_base/doc/sys_arch.txt | 2 +-
net/ip/lwip_base/include/lwip/api.h | 31 +-
net/ip/lwip_base/include/lwip/apps/httpd_opts.h | 30 -
net/ip/lwip_base/include/lwip/apps/mdns.h | 10 +-
net/ip/lwip_base/include/lwip/apps/mdns_opts.h | 10 +-
net/ip/lwip_base/include/lwip/apps/mdns_priv.h | 10 +-
net/ip/lwip_base/include/lwip/apps/mqtt.h | 244 ++++
net/ip/lwip_base/include/lwip/apps/mqtt_opts.h | 103 ++
net/ip/lwip_base/include/lwip/apps/netbiosns.h | 8 -
.../include/lwip/apps/netbiosns_opts.h | 18 -
net/ip/lwip_base/include/lwip/apps/snmp_opts.h | 8 -
net/ip/lwip_base/include/lwip/apps/snmpv3.h | 8 -
net/ip/lwip_base/include/lwip/apps/sntp_opts.h | 8 -
net/ip/lwip_base/include/lwip/apps/tftp_opts.h | 105 ++
.../lwip_base/include/lwip/apps/tftp_server.h | 94 ++
net/ip/lwip_base/include/lwip/arch.h | 299 ++--
net/ip/lwip_base/include/lwip/autoip.h | 2 +
net/ip/lwip_base/include/lwip/debug.h | 81 +-
net/ip/lwip_base/include/lwip/def.h | 95 +-
net/ip/lwip_base/include/lwip/dhcp.h | 2 +
net/ip/lwip_base/include/lwip/dhcp6.h | 8 -
net/ip/lwip_base/include/lwip/dns.h | 18 +-
net/ip/lwip_base/include/lwip/err.h | 4 +
net/ip/lwip_base/include/lwip/errno.h | 193 +++
net/ip/lwip_base/include/lwip/icmp.h | 2 +-
net/ip/lwip_base/include/lwip/icmp6.h | 89 +-
net/ip/lwip_base/include/lwip/igmp.h | 6 +-
net/ip/lwip_base/include/lwip/inet.h | 8 +-
net/ip/lwip_base/include/lwip/inet_chksum.h | 8 +-
net/ip/lwip_base/include/lwip/init.h | 4 +-
net/ip/lwip_base/include/lwip/ip4_addr.h | 36 +-
net/ip/lwip_base/include/lwip/ip6_addr.h | 66 +-
net/ip/lwip_base/include/lwip/ip_addr.h | 73 +-
net/ip/lwip_base/include/lwip/mem.h | 3 +-
net/ip/lwip_base/include/lwip/mld6.h | 7 +-
net/ip/lwip_base/include/lwip/nd6.h | 93 +-
net/ip/lwip_base/include/lwip/netdb.h | 3 +-
net/ip/lwip_base/include/lwip/netif.h | 10 +-
net/ip/lwip_base/include/lwip/netifapi.h | 12 +-
net/ip/lwip_base/include/lwip/opt.h | 116 +-
net/ip/lwip_base/include/lwip/pbuf.h | 20 +-
net/ip/lwip_base/include/lwip/priv/api_msg.h | 3 +-
net/ip/lwip_base/include/lwip/priv/memp_std.h | 8 -
net/ip/lwip_base/include/lwip/priv/nd6_priv.h | 144 ++
net/ip/lwip_base/include/lwip/priv/tcp_priv.h | 27 +-
net/ip/lwip_base/include/lwip/priv/tcpip_priv.h | 4 +-
net/ip/lwip_base/include/lwip/prot/dns.h | 18 +
net/ip/lwip_base/include/lwip/prot/ethernet.h | 2 +-
net/ip/lwip_base/include/lwip/prot/icmp6.h | 87 ++
net/ip/lwip_base/include/lwip/prot/ip.h | 8 -
net/ip/lwip_base/include/lwip/prot/ip4.h | 16 +
net/ip/lwip_base/include/lwip/prot/ip6.h | 27 +-
net/ip/lwip_base/include/lwip/prot/mld6.h | 2 +-
net/ip/lwip_base/include/lwip/prot/nd6.h | 24 +
net/ip/lwip_base/include/lwip/prot/tcp.h | 14 +-
net/ip/lwip_base/include/lwip/raw.h | 2 +
net/ip/lwip_base/include/lwip/sockets.h | 5 +-
net/ip/lwip_base/include/lwip/stats.h | 4 +-
net/ip/lwip_base/include/lwip/sys.h | 44 +-
net/ip/lwip_base/include/lwip/tcp.h | 12 +-
net/ip/lwip_base/include/lwip/tcpip.h | 2 +
net/ip/lwip_base/include/lwip/timeouts.h | 2 +-
net/ip/lwip_base/include/netif/lowpan6_opts.h | 8 -
net/ip/lwip_base/include/netif/ppp/ccp.h | 8 -
net/ip/lwip_base/include/netif/ppp/chap-new.h | 8 -
net/ip/lwip_base/include/netif/ppp/chap_ms.h | 8 -
net/ip/lwip_base/include/netif/ppp/eui64.h | 10 +-
net/ip/lwip_base/include/netif/ppp/fsm.h | 8 -
net/ip/lwip_base/include/netif/ppp/ipcp.h | 8 -
net/ip/lwip_base/include/netif/ppp/ipv6cp.h | 8 -
net/ip/lwip_base/include/netif/ppp/lcp.h | 8 -
net/ip/lwip_base/include/netif/ppp/magic.h | 8 -
net/ip/lwip_base/include/netif/ppp/mppe.h | 10 +-
net/ip/lwip_base/include/netif/ppp/ppp.h | 12 +-
net/ip/lwip_base/include/netif/ppp/ppp_impl.h | 12 +-
net/ip/lwip_base/include/netif/ppp/ppp_opts.h | 8 -
net/ip/lwip_base/include/netif/ppp/pppcrypt.h | 8 -
net/ip/lwip_base/include/netif/ppp/pppdebug.h | 8 -
net/ip/lwip_base/include/netif/ppp/pppoe.h | 8 -
net/ip/lwip_base/include/netif/ppp/pppol2tp.h | 8 -
net/ip/lwip_base/include/netif/ppp/pppos.h | 8 -
net/ip/lwip_base/include/netif/ppp/upap.h | 8 -
net/ip/lwip_base/include/netif/ppp/vj.h | 8 -
net/ip/lwip_base/include/posix/errno.h | 33 +
net/ip/lwip_base/src/Filelists.mk | 10 +-
net/ip/lwip_base/src/api/api_lib.c | 69 +-
net/ip/lwip_base/src/api/api_msg.c | 127 +-
net/ip/lwip_base/src/api/err.c | 40 +
net/ip/lwip_base/src/api/netdb.c | 10 +-
net/ip/lwip_base/src/api/netifapi.c | 14 +-
net/ip/lwip_base/src/api/sockets.c | 204 +--
net/ip/lwip_base/src/api/tcpip.c | 3 +-
net/ip/lwip_base/src/apps/httpd/fsdata.h | 8 -
net/ip/lwip_base/src/apps/httpd/httpd.c | 180 +--
net/ip/lwip_base/src/apps/httpd/httpd_structs.h | 8 -
net/ip/lwip_base/src/apps/lwiperf/lwiperf.c | 16 +-
net/ip/lwip_base/src/apps/mdns/mdns.c | 161 +--
net/ip/lwip_base/src/apps/mqtt/mqtt.c | 1341 ++++++++++++++++++
net/ip/lwip_base/src/apps/netbiosns/netbiosns.c | 5 +-
net/ip/lwip_base/src/apps/snmp/snmp_asn1.c | 8 +-
net/ip/lwip_base/src/apps/snmp/snmp_core.c | 84 +-
net/ip/lwip_base/src/apps/snmp/snmp_mib2_ip.c | 12 +-
net/ip/lwip_base/src/apps/snmp/snmp_mib2_tcp.c | 6 +-
net/ip/lwip_base/src/apps/snmp/snmp_msg.c | 11 +-
net/ip/lwip_base/src/apps/snmp/snmp_netconn.c | 5 +-
net/ip/lwip_base/src/apps/snmp/snmp_raw.c | 2 +-
.../lwip_base/src/apps/snmp/snmp_threadsync.c | 1 +
net/ip/lwip_base/src/apps/snmp/snmp_traps.c | 9 +-
net/ip/lwip_base/src/apps/snmp/snmpv3_priv.h | 8 -
net/ip/lwip_base/src/apps/sntp/sntp.c | 9 +-
net/ip/lwip_base/src/apps/tftp/tftp_server.c | 417 ++++++
net/ip/lwip_base/src/core/def.c | 177 ++-
net/ip/lwip_base/src/core/dns.c | 239 +++-
net/ip/lwip_base/src/core/inet_chksum.c | 15 +-
net/ip/lwip_base/src/core/init.c | 12 +-
net/ip/lwip_base/src/core/ipv4/autoip.c | 16 +-
net/ip/lwip_base/src/core/ipv4/dhcp.c | 114 +-
net/ip/lwip_base/src/core/ipv4/etharp.c | 69 +-
net/ip/lwip_base/src/core/ipv4/icmp.c | 14 +-
net/ip/lwip_base/src/core/ipv4/igmp.c | 75 +-
net/ip/lwip_base/src/core/ipv4/ip4.c | 57 +-
net/ip/lwip_base/src/core/ipv4/ip4_addr.c | 10 +-
net/ip/lwip_base/src/core/ipv4/ip4_frag.c | 88 +-
net/ip/lwip_base/src/core/ipv6/ethip6.c | 42 +-
net/ip/lwip_base/src/core/ipv6/ip6.c | 62 +-
net/ip/lwip_base/src/core/ipv6/ip6_addr.c | 10 +-
net/ip/lwip_base/src/core/ipv6/ip6_frag.c | 49 +-
net/ip/lwip_base/src/core/ipv6/mld6.c | 7 +-
net/ip/lwip_base/src/core/ipv6/nd6.c | 355 +++--
net/ip/lwip_base/src/core/mem.c | 8 +-
net/ip/lwip_base/src/core/memp.c | 25 +-
net/ip/lwip_base/src/core/netif.c | 127 +-
net/ip/lwip_base/src/core/pbuf.c | 91 +-
net/ip/lwip_base/src/core/raw.c | 51 +-
net/ip/lwip_base/src/core/stats.c | 6 +-
net/ip/lwip_base/src/core/sys.c | 38 +
net/ip/lwip_base/src/core/tcp.c | 149 +-
net/ip/lwip_base/src/core/tcp_in.c | 88 +-
net/ip/lwip_base/src/core/tcp_out.c | 195 ++-
net/ip/lwip_base/src/core/timeouts.c | 4 +-
net/ip/lwip_base/src/core/udp.c | 72 +-
net/ip/lwip_base/src/netif/ethernet.c | 20 +-
net/ip/lwip_base/src/netif/lowpan6.c | 103 +-
net/ip/lwip_base/src/netif/ppp/auth.c | 10 +-
net/ip/lwip_base/src/netif/ppp/ipcp.c | 120 +-
net/ip/lwip_base/src/netif/ppp/ipv6cp.c | 4 +-
net/ip/lwip_base/src/netif/ppp/multilink.c | 4 +-
net/ip/lwip_base/src/netif/ppp/ppp.c | 19 +-
net/ip/lwip_base/src/netif/ppp/pppapi.c | 5 +
net/ip/lwip_base/src/netif/ppp/pppoe.c | 19 +-
net/ip/lwip_base/src/netif/ppp/pppol2tp.c | 9 +-
net/ip/lwip_base/src/netif/ppp/pppos.c | 40 +-
net/ip/lwip_base/src/netif/ppp/utils.c | 4 +-
net/ip/lwip_base/src/netif/ppp/vj.c | 62 +-
net/ip/lwip_base/src/netif/slipif.c | 2 +-
net/ip/lwip_base/test/fuzz/Makefile | 53 +
net/ip/lwip_base/test/fuzz/README | 34 +
net/ip/lwip_base/test/fuzz/config.h | 0
net/ip/lwip_base/test/fuzz/fuzz.c | 136 ++
.../lwip_base/test/fuzz/inputs/arp/arp_req.bin | Bin 0 -> 42 bytes
.../test/fuzz/inputs/icmp/icmp_ping.bin | Bin 0 -> 98 bytes
.../fuzz/inputs/ipv6/neighbor_solicitation.bin | Bin 0 -> 86 bytes
.../test/fuzz/inputs/ipv6/router_adv.bin | Bin 0 -> 118 bytes
.../lwip_base/test/fuzz/inputs/tcp/tcp_syn.bin | Bin 0 -> 74 bytes
.../test/fuzz/inputs/udp/udp_port_5000.bin | Bin 0 -> 50 bytes
net/ip/lwip_base/test/fuzz/lwipopts.h | 68 +
net/ip/lwip_base/test/fuzz/output_to_pcap.sh | 31 +
net/ip/lwip_base/test/unit/core/test_mem.h | 8 -
net/ip/lwip_base/test/unit/core/test_pbuf.h | 8 -
net/ip/lwip_base/test/unit/dhcp/test_dhcp.c | 113 +-
net/ip/lwip_base/test/unit/dhcp/test_dhcp.h | 8 -
net/ip/lwip_base/test/unit/etharp/test_etharp.h | 8 -
net/ip/lwip_base/test/unit/lwip_check.h | 8 -
net/ip/lwip_base/test/unit/lwipopts.h | 8 -
net/ip/lwip_base/test/unit/mdns/test_mdns.c | 71 +-
net/ip/lwip_base/test/unit/mdns/test_mdns.h | 8 -
net/ip/lwip_base/test/unit/tcp/tcp_helper.c | 23 +-
net/ip/lwip_base/test/unit/tcp/tcp_helper.h | 8 -
net/ip/lwip_base/test/unit/tcp/test_tcp.c | 18 +-
net/ip/lwip_base/test/unit/tcp/test_tcp.h | 8 -
net/ip/lwip_base/test/unit/tcp/test_tcp_oos.h | 8 -
net/ip/lwip_base/test/unit/udp/test_udp.h | 8 -
net/ip/mn_socket/include/mn_socket/mn_socket.h | 7 +
net/ip/mn_socket/src/mn_socket.c | 16 +
net/ip/native_sockets/src/native_itf.c | 5 +-
net/ip/pkg.yml | 7 +
net/ip/src/ip_init.c | 5 +
net/ip/src/ip_priv.h | 3 +
net/ip/src/lwip_cli.c | 140 ++
net/ip/src/lwip_if.c | 17 +-
net/ip/src/lwip_socket.c | 179 ++-
net/ip/syscfg.yml | 26 +
228 files changed, 8399 insertions(+), 3777 deletions(-)
----------------------------------------------------------------------
[32/50] [abbrv] incubator-mynewt-core git commit: drivers/rtt: add
syscfg option to define output buffer size
Posted by ja...@apache.org.
drivers/rtt: add syscfg option to define output buffer size
bletiny's shell requires larger buffer - 8k - to work properly
with debug logs enabled
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/f7acf777
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f7acf777
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f7acf777
Branch: refs/heads/bluetooth5
Commit: f7acf777efe151b77f8cf8ef7e1408b032d1abee
Parents: d36cccb
Author: Micha\u0142 Narajowski <mi...@codecoup.pl>
Authored: Thu Apr 6 16:00:59 2017 +0200
Committer: Micha\u0142 Narajowski <mi...@codecoup.pl>
Committed: Mon Apr 24 09:27:37 2017 -0700
----------------------------------------------------------------------
hw/drivers/rtt/include/rtt/SEGGER_RTT_Conf.h | 4 +++-
hw/drivers/rtt/syscfg.yml | 24 +++++++++++++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f7acf777/hw/drivers/rtt/include/rtt/SEGGER_RTT_Conf.h
----------------------------------------------------------------------
diff --git a/hw/drivers/rtt/include/rtt/SEGGER_RTT_Conf.h b/hw/drivers/rtt/include/rtt/SEGGER_RTT_Conf.h
index 6a7a3ae..4daaa8f 100644
--- a/hw/drivers/rtt/include/rtt/SEGGER_RTT_Conf.h
+++ b/hw/drivers/rtt/include/rtt/SEGGER_RTT_Conf.h
@@ -63,6 +63,8 @@ Revision: $Rev: 4351 $
#ifndef SEGGER_RTT_CONF_H
#define SEGGER_RTT_CONF_H
+#include "syscfg/syscfg.h"
+
#ifdef __IAR_SYSTEMS_ICC__
#include <intrinsics.h>
#endif
@@ -77,7 +79,7 @@ Revision: $Rev: 4351 $
#define SEGGER_RTT_MAX_NUM_UP_BUFFERS (3) // Max. number of up-buffers (T->H) available on this target (Default: 3)
#define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (3) // Max. number of down-buffers (H->T) available on this target (Default: 3)
-#define BUFFER_SIZE_UP (1024) // Size of the buffer for terminal output of target, up to host (Default: 1k)
+#define BUFFER_SIZE_UP (MYNEWT_VAL(RTT_BUFFER_SIZE_UP)) // 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 (64u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f7acf777/hw/drivers/rtt/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/drivers/rtt/syscfg.yml b/hw/drivers/rtt/syscfg.yml
new file mode 100644
index 0000000..3463eec
--- /dev/null
+++ b/hw/drivers/rtt/syscfg.yml
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Package: hw/drivers/rtt
+
+syscfg.defs:
+ RTT_BUFFER_SIZE_UP:
+ description: 'Size of the output buffer'
+ value: 1024
[06/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-729
SensorAPI: Send sensor data over OIC
Posted by ja...@apache.org.
MYNEWT-729 SensorAPI: Send sensor data over OIC
- Use COAP_MAX_URI constant instead of calloc
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/2300485f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/2300485f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/2300485f
Branch: refs/heads/bluetooth5
Commit: 2300485f330a208f43b39f58c4766c8a8711cdf7
Parents: be12bfb
Author: Vipul Rahane <vi...@apache.org>
Authored: Wed Apr 12 16:05:33 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Mon Apr 17 16:14:20 2017 -0700
----------------------------------------------------------------------
hw/sensor/src/sensor_oic.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2300485f/hw/sensor/src/sensor_oic.c
----------------------------------------------------------------------
diff --git a/hw/sensor/src/sensor_oic.c b/hw/sensor/src/sensor_oic.c
index 987e2a7..ab296a7 100644
--- a/hw/sensor/src/sensor_oic.c
+++ b/hw/sensor/src/sensor_oic.c
@@ -460,9 +460,7 @@ sensor_oic_get_data(oc_request_t *request, oc_interface_mask_t interface)
char *typename;
sensor_type_t type;
const char s[2] = "/";
- char *tmpstr;
-
- tmpstr = calloc(request->resource->uri.os_sz, request->resource->uri.os_sz);
+ char tmpstr[COAP_MAX_URI];
memcpy(tmpstr, (char *)&(request->resource->uri.os_str[1]),
request->resource->uri.os_sz - 1);
@@ -517,13 +515,11 @@ sensor_oic_get_data(oc_request_t *request, oc_interface_mask_t interface)
break;
}
- free(tmpstr);
sensor_unregister_listener(sensor, &listener);
oc_rep_end_root_object();
oc_send_response(request, OC_STATUS_OK);
return;
err:
- free(tmpstr);
sensor_unregister_listener(sensor, &listener);
oc_send_response(request, OC_STATUS_NOT_FOUND);
}
@@ -533,8 +529,7 @@ sensor_oic_init(void)
{
oc_resource_t *res;
struct sensor *sensor;
- char *tmpstr;
- size_t bufsize;
+ char tmpstr[COAP_MAX_URI];
char *typename;
int i;
int rc;
@@ -564,25 +559,24 @@ sensor_oic_init(void)
if (rc) {
break;
}
- bufsize = strlen(sensor->s_dev->od_name) + 1;
- tmpstr = (char *)calloc(bufsize, bufsize);
- sprintf(tmpstr, "/%s/%s", sensor->s_dev->od_name, typename);
+
+ memset(tmpstr, 0, sizeof(tmpstr));
+ snprintf(tmpstr, sizeof(tmpstr), "/%s/%s",
+ sensor->s_dev->od_name, typename);
res = oc_new_resource(tmpstr, 1, 0);
- free(tmpstr);
- bufsize = strlen(sensor->s_dev->od_name) + sizeof("sensors.r.");
- tmpstr = (char *)calloc(bufsize, bufsize);
- sprintf(tmpstr, "sensors.r.%s", sensor->s_dev->od_name);
+ memset(tmpstr, 0, sizeof(tmpstr));
+ snprintf(tmpstr, sizeof(tmpstr), "sensors.r.%s", sensor->s_dev->od_name);
oc_resource_bind_resource_type(res, tmpstr);
- free(tmpstr);
oc_resource_bind_resource_interface(res, OC_IF_R);
oc_resource_set_default_interface(res, OC_IF_R);
oc_resource_set_discoverable(res);
oc_resource_set_periodic_observable(res, 1);
- oc_resource_set_request_handler(res, OC_GET, sensor_oic_get_data);
+ oc_resource_set_request_handler(res, OC_GET,
+ sensor_oic_get_data);
oc_add_resource(res);
}
i++;
[16/50] [abbrv] incubator-mynewt-core git commit: BLE Host - Check tx
of disc-svc-uuid in unit tests
Posted by ja...@apache.org.
BLE Host - Check tx of disc-svc-uuid in unit tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/a1e5c125
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/a1e5c125
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/a1e5c125
Branch: refs/heads/bluetooth5
Commit: a1e5c1253b670f90ac59decce2917c179b0dfb96
Parents: 28b29f4
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Apr 19 11:57:28 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Apr 19 12:00:05 2017 -0700
----------------------------------------------------------------------
net/nimble/host/test/src/ble_gatt_disc_s_test.c | 2 ++
net/nimble/host/test/src/ble_hs_test_util.c | 35 ++++++++++++++++++++
net/nimble/host/test/src/ble_hs_test_util.h | 6 ++++
3 files changed, 43 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1e5c125/net/nimble/host/test/src/ble_gatt_disc_s_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_gatt_disc_s_test.c b/net/nimble/host/test/src/ble_gatt_disc_s_test.c
index 0d75b6d..f4cff86 100644
--- a/net/nimble/host/test/src/ble_gatt_disc_s_test.c
+++ b/net/nimble/host/test/src/ble_gatt_disc_s_test.c
@@ -292,6 +292,8 @@ ble_gatt_disc_s_test_misc_good_uuid(
ble_gatt_disc_s_test_misc_disc_cb, NULL);
TEST_ASSERT(rc == 0);
+ ble_hs_test_util_verify_tx_disc_svc_uuid(services[0].uuid);
+
ble_gatt_disc_s_test_misc_rx_uuid_rsp(2, services);
ble_gatt_disc_s_test_misc_verify_services(services);
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1e5c125/net/nimble/host/test/src/ble_hs_test_util.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_hs_test_util.c b/net/nimble/host/test/src/ble_hs_test_util.c
index c1f7c0f..7c72d5d 100644
--- a/net/nimble/host/test/src/ble_hs_test_util.c
+++ b/net/nimble/host/test/src/ble_hs_test_util.c
@@ -1526,6 +1526,41 @@ ble_hs_test_util_verify_tx_exec_write(uint8_t expected_flags)
}
void
+ble_hs_test_util_verify_tx_find_type_value(uint16_t start_handle,
+ uint16_t end_handle,
+ uint16_t attr_type,
+ const void *value,
+ uint16_t value_len)
+{
+ struct ble_att_find_type_value_req req;
+ struct os_mbuf *om;
+
+ ble_hs_test_util_tx_all();
+ om = ble_hs_test_util_prev_tx_dequeue_pullup();
+ TEST_ASSERT_FATAL(om != NULL);
+ TEST_ASSERT(om->om_len == BLE_ATT_FIND_TYPE_VALUE_REQ_BASE_SZ + value_len);
+
+ ble_att_find_type_value_req_parse(om->om_data, om->om_len, &req);
+ TEST_ASSERT(req.bavq_start_handle == start_handle);
+ TEST_ASSERT(req.bavq_end_handle == end_handle);
+ TEST_ASSERT(req.bavq_attr_type == attr_type);
+ TEST_ASSERT(memcmp(om->om_data + BLE_ATT_FIND_TYPE_VALUE_REQ_BASE_SZ,
+ value,
+ value_len) == 0);
+}
+
+void
+ble_hs_test_util_verify_tx_disc_svc_uuid(const ble_uuid_t *uuid)
+{
+ uint8_t uuid_buf[16];
+
+ ble_uuid_flat(uuid, uuid_buf);
+ ble_hs_test_util_verify_tx_find_type_value(
+ 1, 0xffff, BLE_ATT_UUID_PRIMARY_SERVICE,
+ uuid_buf, ble_uuid_length(uuid));
+}
+
+void
ble_hs_test_util_verify_tx_read_rsp_gen(uint8_t att_op,
uint8_t *attr_data, int attr_len)
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1e5c125/net/nimble/host/test/src/ble_hs_test_util.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_hs_test_util.h b/net/nimble/host/test/src/ble_hs_test_util.h
index a8ae1f3..4f9927a 100644
--- a/net/nimble/host/test/src/ble_hs_test_util.h
+++ b/net/nimble/host/test/src/ble_hs_test_util.h
@@ -231,6 +231,12 @@ void ble_hs_test_util_verify_tx_prep_write(uint16_t attr_handle,
uint16_t offset,
const void *data, int data_len);
void ble_hs_test_util_verify_tx_exec_write(uint8_t expected_flags);
+void ble_hs_test_util_verify_tx_find_type_value(uint16_t start_handle,
+ uint16_t end_handle,
+ uint16_t attr_type,
+ const void *value,
+ uint16_t value_len);
+void ble_hs_test_util_verify_tx_disc_svc_uuid(const ble_uuid_t *uuid);
void ble_hs_test_util_verify_tx_read_rsp(uint8_t *attr_data, int attr_len);
void ble_hs_test_util_verify_tx_read_blob_rsp(uint8_t *attr_data,
int attr_len);
[11/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-731 Crash in
config_init_fcb()
Posted by ja...@apache.org.
MYNEWT-731 Crash in config_init_fcb()
- While specifying the flash layout NRF52840 and NRF52832 need to be
distinguished. Seperate structs are define for each oen now.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/a1a0647f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/a1a0647f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/a1a0647f
Branch: refs/heads/bluetooth5
Commit: a1a0647f89856a0246ec24182c9ca72139d102aa
Parents: 813463e
Author: Vipul Rahane <vi...@apache.org>
Authored: Tue Apr 18 18:47:32 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Tue Apr 18 18:47:32 2017 -0700
----------------------------------------------------------------------
hw/mcu/nordic/nrf52xxx/src/hal_flash.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1a0647f/hw/mcu/nordic/nrf52xxx/src/hal_flash.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_flash.c b/hw/mcu/nordic/nrf52xxx/src/hal_flash.c
index 7d3410b..57a8ee0 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_flash.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_flash.c
@@ -43,6 +43,15 @@ static const struct hal_flash_funcs nrf52k_flash_funcs = {
.hff_init = nrf52k_flash_init
};
+#ifdef NRF52840_XXAA
+const struct hal_flash nrf52k_flash_dev = {
+ .hf_itf = &nrf52k_flash_funcs,
+ .hf_base_addr = 0x00000000,
+ .hf_size = 1024 * 1024, /* XXX read from factory info? */
+ .hf_sector_cnt = 256, /* XXX read from factory info? */
+ .hf_align = 1
+};
+#elif defined(NRF52832_XXAA)
const struct hal_flash nrf52k_flash_dev = {
.hf_itf = &nrf52k_flash_funcs,
.hf_base_addr = 0x00000000,
@@ -50,6 +59,9 @@ const struct hal_flash nrf52k_flash_dev = {
.hf_sector_cnt = 128, /* XXX read from factory info? */
.hf_align = 1
};
+#else
+#error "Must define hal_flash struct for NRF52 type"
+#endif
#define NRF52K_FLASH_READY() (NRF_NVMC->READY == NVMC_READY_READY_Ready)
[07/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-729
SensorAPI: Send sensor data over OIC
Posted by ja...@apache.org.
MYNEWT-729 SensorAPI: Send sensor data over OIC
- Addressing review comments by @mkiiskila
- Move private apis from include/bno055.h to bno055/bno055_priv.h
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/e301553f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/e301553f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/e301553f
Branch: refs/heads/bluetooth5
Commit: e301553f5eaaa2af8f3e5f622d29fd2d5cbc6971
Parents: 5c641d1
Author: Vipul Rahane <vi...@apache.org>
Authored: Mon Apr 17 16:08:37 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Mon Apr 17 16:31:44 2017 -0700
----------------------------------------------------------------------
apps/sensors_test/pkg.yml | 4 +-
apps/sensors_test/src/gatt_svr.c | 2 +-
apps/sensors_test/src/main.c | 33 ++++++-----
apps/sensors_test/src/misc.c | 43 ++++++++++++++
apps/sensors_test/syscfg.yml | 13 ++++-
.../sensors/bno055/include/bno055/bno055.h | 33 -----------
hw/drivers/sensors/bno055/src/bno055_priv.h | 34 +++++++++++
hw/sensor/include/sensor/sensor.h | 2 +-
hw/sensor/pkg.yml | 8 ++-
hw/sensor/src/bleprph.h | 59 --------------------
hw/sensor/src/misc.c | 43 --------------
hw/sensor/src/sensor_oic.c | 3 +-
hw/sensor/syscfg.yml | 11 +---
13 files changed, 122 insertions(+), 166 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e301553f/apps/sensors_test/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/sensors_test/pkg.yml b/apps/sensors_test/pkg.yml
index 39250ae..4f8e25c 100644
--- a/apps/sensors_test/pkg.yml
+++ b/apps/sensors_test/pkg.yml
@@ -44,8 +44,10 @@ pkg.deps:
- mgmt/imgmgr
#- mgmt/newtmgr
-pkg.deps.SENSOR_BLE_OIC:
+pkg.deps.SENSOR_OIC:
- mgmt/oicmgr
+
+pkg.deps.SENSOR_BLE:
- net/nimble/controller
- net/nimble/host
- net/nimble/host/services/gap
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e301553f/apps/sensors_test/src/gatt_svr.c
----------------------------------------------------------------------
diff --git a/apps/sensors_test/src/gatt_svr.c b/apps/sensors_test/src/gatt_svr.c
index e29f007..0e2e004 100644
--- a/apps/sensors_test/src/gatt_svr.c
+++ b/apps/sensors_test/src/gatt_svr.c
@@ -17,7 +17,7 @@
* under the License.
*/
#include <syscfg/syscfg.h>
-#if MYNEWT_VAL(SENSOR_BLE_OIC)
+#if MYNEWT_VAL(SENSOR_BLE)
#include <assert.h>
#include <stdio.h>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e301553f/apps/sensors_test/src/main.c
----------------------------------------------------------------------
diff --git a/apps/sensors_test/src/main.c b/apps/sensors_test/src/main.c
index 322b83b..09f3e40 100755
--- a/apps/sensors_test/src/main.c
+++ b/apps/sensors_test/src/main.c
@@ -47,17 +47,25 @@
#include <flash_test/flash_test.h>
#include <reboot/log_reboot.h>
#include <id/id.h>
+#include <os/os_time.h>
+
+#if MYNEWT_VAL(SENSOR_OIC)
+#include <oic/oc_api.h>
+#include <oic/oc_gatt.h>
+
+extern int oc_stack_errno;
+
+static const oc_handler_t sensor_oic_handler = {
+ .init = sensor_oic_init,
+};
+
+#endif
-#if MYNEWT_VAL(SENSOR_BLE_OIC)
+#if MYNEWT_VAL(SENSOR_BLE)
/* BLE */
#include <nimble/ble.h>
#include <host/ble_hs.h>
#include <services/gap/ble_svc_gap.h>
-
-#include <os/os_time.h>
-#include <oic/oc_api.h>
-#include <oic/oc_gatt.h>
-
/* Application-specified header. */
#include "bleprph.h"
@@ -123,12 +131,7 @@ static char test_str[32];
static uint32_t cbmem_buf[MAX_CBMEM_BUF];
static struct cbmem cbmem;
-#if MYNEWT_VAL(SENSOR_BLE_OIC)
-extern int oc_stack_errno;
-
-static const oc_handler_t sensor_oic_handler = {
- .init = sensor_oic_init,
-};
+#if MYNEWT_VAL(SENSOR_OIC) && MYNEWT_VAL(SENSOR_BLE)
/**
* Logs information about a connection to the console.
@@ -632,7 +635,7 @@ sensors_dev_shell_init(void)
static void
sensor_ble_oic_server_init(void)
{
-#if MYNEWT_VAL(SENSOR_BLE_OIC)
+#if MYNEWT_VAL(SENSOR_BLE) && MYNEWT_VAL(SENSOR_OIC)
int rc;
/* Set initial BLE device address. */
@@ -661,7 +664,7 @@ sensor_ble_oic_server_init(void)
static void
ble_oic_log_init(void)
{
-#if MYNEWT_VAL(SENSOR_BLE_OIC)
+#if MYNEWT_VAL(SENSOR_BLE)
/* Initialize the bleprph log. */
log_register("bleprph", &bleprph_log, &log_console_handler, NULL,
LOG_SYSLEVEL);
@@ -669,7 +672,9 @@ ble_oic_log_init(void)
/* Initialize the NimBLE host configuration. */
log_register("ble_hs", &ble_hs_log, &log_console_handler, NULL,
LOG_SYSLEVEL);
+#endif
+#if MYNEWT_VAL(SENSOR_OIC)
/* Initialize the OIC */
log_register("oic", &oc_log, &log_console_handler, NULL, LOG_SYSLEVEL);
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e301553f/apps/sensors_test/src/misc.c
----------------------------------------------------------------------
diff --git a/apps/sensors_test/src/misc.c b/apps/sensors_test/src/misc.c
new file mode 100644
index 0000000..8ec785e
--- /dev/null
+++ b/apps/sensors_test/src/misc.c
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "bleprph.h"
+
+/**
+ * Utility function to log an array of bytes.
+ */
+void
+print_bytes(const uint8_t *bytes, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++) {
+ BLEPRPH_LOG(INFO, "%s0x%02x", i != 0 ? ":" : "", bytes[i]);
+ }
+}
+
+void
+print_addr(const void *addr)
+{
+ const uint8_t *u8p;
+
+ u8p = addr;
+ BLEPRPH_LOG(INFO, "%02x:%02x:%02x:%02x:%02x:%02x",
+ u8p[5], u8p[4], u8p[3], u8p[2], u8p[1], u8p[0]);
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e301553f/apps/sensors_test/syscfg.yml
----------------------------------------------------------------------
diff --git a/apps/sensors_test/syscfg.yml b/apps/sensors_test/syscfg.yml
index 8623667..81876bc 100644
--- a/apps/sensors_test/syscfg.yml
+++ b/apps/sensors_test/syscfg.yml
@@ -44,10 +44,13 @@ syscfg.vals:
TSL2561_CLI: 0
BNO055_CLI: 1
TCS34725_CLI: 1
- SENSOR_BLE_OIC: 1
+
+ # Setup Sensor BLE OIC GATT Server
+ SENSOR_OIC: 1
BLE_ROLE_CENTRAL: 0
BLE_ROLE_OBSERVER: 0
OC_SERVER: 1
+
OC_TRANSPORT_GATT: 1
OC_APP_RESOURCES : 20
@@ -69,3 +72,11 @@ syscfg.defs:
SIM_ACCEL_PRESENT:
description: 'SIM ACCEL is present'
value : 0
+ SENSOR_BLE:
+ description: 'BLE transport is used for sensor data'
+ value : 1
+ restrictions:
+ - BLE_ROLE_BROADCASTER
+ - '!BLE_ROLE_CENTRAL'
+ - '!BLE_ROLE_OBSERVER'
+ - BLE_ROLE_PERIPHERAL
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e301553f/hw/drivers/sensors/bno055/include/bno055/bno055.h
----------------------------------------------------------------------
diff --git a/hw/drivers/sensors/bno055/include/bno055/bno055.h b/hw/drivers/sensors/bno055/include/bno055/bno055.h
index c8bd5c6..af1c836 100644
--- a/hw/drivers/sensors/bno055/include/bno055/bno055.h
+++ b/hw/drivers/sensors/bno055/include/bno055/bno055.h
@@ -226,39 +226,6 @@ int
bno055_get_temp(int8_t *temp);
/**
- * Reads a single byte from the specified register
- *
- * @param The register address to read from
- * @param Pointer to where the register value should be written
- *
- * @return 0 on success, non-zero error on failure.
- */
-int
-bno055_read8(uint8_t reg, uint8_t *value);
-
-/**
- * Writes a single byte to the specified register
- *
- * @param The register address to write to
- * @param The value to write
- *
- * @return 0 on success, non-zero error on failure.
- */
-int
-bno055_write8(uint8_t reg, uint8_t value);
-
-/**
- * Writes a multiple bytes to the specified register
- *
- * @param The register address to write to
- * @param The data buffer to write from
- *
- * @return 0 on success, non-zero error on failure.
- */
-int
-bno055_writelen(uint8_t reg, uint8_t *buffer, uint8_t len);
-
-/**
* Gets current calibration status
*
* @param Calibration info structure to fill up calib state
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e301553f/hw/drivers/sensors/bno055/src/bno055_priv.h
----------------------------------------------------------------------
diff --git a/hw/drivers/sensors/bno055/src/bno055_priv.h b/hw/drivers/sensors/bno055/src/bno055_priv.h
index 5e78b51..e25671c 100644
--- a/hw/drivers/sensors/bno055/src/bno055_priv.h
+++ b/hw/drivers/sensors/bno055/src/bno055_priv.h
@@ -260,3 +260,37 @@
#define BNO055_INT_ACC_SM 32
#define BNO055_ID 0xA0
+
+/**
+ * Reads a single byte from the specified register
+ *
+ * @param The register address to read from
+ * @param Pointer to where the register value should be written
+ *
+ * @return 0 on success, non-zero error on failure.
+ */
+int
+bno055_read8(uint8_t reg, uint8_t *value);
+
+/**
+ * Writes a single byte to the specified register
+ *
+ * @param The register address to write to
+ * @param The value to write
+ *
+ * @return 0 on success, non-zero error on failure.
+ */
+int
+bno055_write8(uint8_t reg, uint8_t value);
+
+/**
+ * Writes a multiple bytes to the specified register
+ *
+ * @param The register address to write to
+ * @param The data buffer to write from
+ *
+ * @return 0 on success, non-zero error on failure.
+ */
+int
+bno055_writelen(uint8_t reg, uint8_t *buffer, uint8_t len);
+
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e301553f/hw/sensor/include/sensor/sensor.h
----------------------------------------------------------------------
diff --git a/hw/sensor/include/sensor/sensor.h b/hw/sensor/include/sensor/sensor.h
index 9435106..fb5bf2d 100644
--- a/hw/sensor/include/sensor/sensor.h
+++ b/hw/sensor/include/sensor/sensor.h
@@ -343,7 +343,7 @@ int
sensor_shell_stol(char *param_val, long min, long max, long *output);
#endif
-#if MYNEWT_VAL(SENSOR_BLE_OIC)
+#if MYNEWT_VAL(SENSOR_OIC)
void sensor_oic_init(void);
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e301553f/hw/sensor/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/sensor/pkg.yml b/hw/sensor/pkg.yml
index bdd0e0b..369b85d 100644
--- a/hw/sensor/pkg.yml
+++ b/hw/sensor/pkg.yml
@@ -24,10 +24,14 @@ pkg.homepage: "http://mynewt.apache.org/"
pkg.keywords:
pkg.deps:
+ - kernel/os
+
+pkg.deps.SENSOR_OIC:
+ - net/oic
+
+pkg.deps.SENSOR_CLI:
- sys/shell
- sys/console/full
- - sys/log/full
- - sys/stats/full
pkg.init:
sensor_pkg_init: 501
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e301553f/hw/sensor/src/bleprph.h
----------------------------------------------------------------------
diff --git a/hw/sensor/src/bleprph.h b/hw/sensor/src/bleprph.h
deleted file mode 100644
index 2e3f024..0000000
--- a/hw/sensor/src/bleprph.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef H_BLEPRPH_
-#define H_BLEPRPH_
-
-#include "log/log.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct ble_hs_cfg;
-struct ble_gatt_register_ctxt;
-
-extern struct log bleprph_log;
-
-/* bleprph uses the first "peruser" log module. */
-#define BLEPRPH_LOG_MODULE (LOG_MODULE_PERUSER + 0)
-
-/* Convenience macro for logging to the bleprph module. */
-#define BLEPRPH_LOG(lvl, ...) \
- LOG_ ## lvl(&bleprph_log, BLEPRPH_LOG_MODULE, __VA_ARGS__)
-
-/** GATT server. */
-#define GATT_SVR_SVC_ALERT_UUID 0x1811
-#define GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID 0x2A47
-#define GATT_SVR_CHR_NEW_ALERT 0x2A46
-#define GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID 0x2A48
-#define GATT_SVR_CHR_UNR_ALERT_STAT_UUID 0x2A45
-#define GATT_SVR_CHR_ALERT_NOT_CTRL_PT 0x2A44
-
-void gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg);
-int gatt_svr_init(void);
-
-/** Misc. */
-void print_bytes(const uint8_t *bytes, int len);
-void print_addr(const void *addr);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e301553f/hw/sensor/src/misc.c
----------------------------------------------------------------------
diff --git a/hw/sensor/src/misc.c b/hw/sensor/src/misc.c
deleted file mode 100644
index 8ec785e..0000000
--- a/hw/sensor/src/misc.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include "bleprph.h"
-
-/**
- * Utility function to log an array of bytes.
- */
-void
-print_bytes(const uint8_t *bytes, int len)
-{
- int i;
-
- for (i = 0; i < len; i++) {
- BLEPRPH_LOG(INFO, "%s0x%02x", i != 0 ? ":" : "", bytes[i]);
- }
-}
-
-void
-print_addr(const void *addr)
-{
- const uint8_t *u8p;
-
- u8p = addr;
- BLEPRPH_LOG(INFO, "%02x:%02x:%02x:%02x:%02x:%02x",
- u8p[5], u8p[4], u8p[3], u8p[2], u8p[1], u8p[0]);
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e301553f/hw/sensor/src/sensor_oic.c
----------------------------------------------------------------------
diff --git a/hw/sensor/src/sensor_oic.c b/hw/sensor/src/sensor_oic.c
index 27edafd..de9e65a 100644
--- a/hw/sensor/src/sensor_oic.c
+++ b/hw/sensor/src/sensor_oic.c
@@ -19,7 +19,7 @@
#include "syscfg/syscfg.h"
-#if MYNEWT_VAL(SENSOR_BLE_OIC)
+#if MYNEWT_VAL(SENSOR_OIC)
#include <string.h>
#include <stdio.h>
@@ -37,7 +37,6 @@
#include "sensor/quat.h"
#include "sensor/euler.h"
#include "sensor/color.h"
-#include "console/console.h"
/* OIC */
#include <oic/oc_rep.h>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e301553f/hw/sensor/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/sensor/syscfg.yml b/hw/sensor/syscfg.yml
index abe193e..3495534 100644
--- a/hw/sensor/syscfg.yml
+++ b/hw/sensor/syscfg.yml
@@ -27,15 +27,8 @@ syscfg.defs:
description: 'Whether or not to enable the sensor shell support'
value: 1
- SENSOR_BLE_OIC:
- description: 'Enable/Disable the OIC sensor gatt svr'
+ SENSOR_OIC:
+ description: 'Enable/Disable the OIC sensor server'
value: 1
restrictions:
- # Disable central and observer roles.
- - BLE_ROLE_BROADCASTER
- - '!BLE_ROLE_CENTRAL'
- - '!BLE_ROLE_OBSERVER'
- - BLE_ROLE_PERIPHERAL
- # OC server, with bluetooth transport.
- OC_SERVER
- - OC_TRANSPORT_GATT
[38/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-739
sensor_test app: improvements
Posted by ja...@apache.org.
MYNEWT-739 sensor_test app: improvements
- In the app tcs34725_config() was failing which was causing the sensor
list to not get populated. Fixing it.
- Cleaning up the sensor_test app to remove config, gpio toggle stats,
gpio toggle logs from the app
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/3596d33e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/3596d33e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/3596d33e
Branch: refs/heads/bluetooth5
Commit: 3596d33e13bd9b08f723102c107255a24f53d758
Parents: ce47d84
Author: Vipul Rahane <vi...@apache.org>
Authored: Mon Apr 24 18:22:28 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Mon Apr 24 18:28:12 2017 -0700
----------------------------------------------------------------------
apps/sensors_test/src/main.c | 147 ++++++--------------------------------
1 file changed, 21 insertions(+), 126 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3596d33e/apps/sensors_test/src/main.c
----------------------------------------------------------------------
diff --git a/apps/sensors_test/src/main.c b/apps/sensors_test/src/main.c
index 09f3e40..f6ef755 100755
--- a/apps/sensors_test/src/main.c
+++ b/apps/sensors_test/src/main.c
@@ -27,7 +27,6 @@
#include <console/console.h>
#include <shell/shell.h>
#include <log/log.h>
-#include <stats/stats.h>
#include <config/config.h>
#include <sensor/sensor.h>
#include <sim/sim_accel.h>
@@ -40,8 +39,6 @@
#if MYNEWT_VAL(SPLIT_LOADER)
#include "split/split.h"
#endif
-#include <bootutil/image.h>
-#include <bootutil/bootutil.h>
#include <assert.h>
#include <string.h>
#include <flash_test/flash_test.h>
@@ -93,44 +90,12 @@ static volatile int g_task1_loops;
static struct os_task task2;
static volatile int g_task2_loops;
-static struct log my_log;
-
/* Global test semaphore */
static struct os_sem g_test_sem;
/* For LED toggling */
static int g_led_pin;
-STATS_SECT_START(gpio_stats)
-STATS_SECT_ENTRY(toggles)
-STATS_SECT_END
-
-static STATS_SECT_DECL(gpio_stats) g_stats_gpio_toggle;
-
-static STATS_NAME_START(gpio_stats)
-STATS_NAME(gpio_stats, toggles)
-STATS_NAME_END(gpio_stats)
-
-static char *test_conf_get(int argc, char **argv, char *val, int max_len);
-static int test_conf_set(int argc, char **argv, char *val);
-static int test_conf_commit(void);
-static int test_conf_export(void (*export_func)(char *name, char *val),
- enum conf_export_tgt tgt);
-
-static struct conf_handler test_conf_handler = {
- .ch_name = "test",
- .ch_get = test_conf_get,
- .ch_set = test_conf_set,
- .ch_commit = test_conf_commit,
- .ch_export = test_conf_export
-};
-
-static uint8_t test8;
-static uint8_t test8_shadow;
-static char test_str[32];
-static uint32_t cbmem_buf[MAX_CBMEM_BUF];
-static struct cbmem cbmem;
-
#if MYNEWT_VAL(SENSOR_OIC) && MYNEWT_VAL(SENSOR_BLE)
/**
@@ -339,56 +304,10 @@ sensor_oic_gap_event(struct ble_gap_event *event, void *arg)
}
#endif
-static char *
-test_conf_get(int argc, char **argv, char *buf, int max_len)
-{
- if (argc == 1) {
- if (!strcmp(argv[0], "8")) {
- return conf_str_from_value(CONF_INT8, &test8, buf, max_len);
- } else if (!strcmp(argv[0], "str")) {
- return test_str;
- }
- }
- return NULL;
-}
-
-static int
-test_conf_set(int argc, char **argv, char *val)
-{
- if (argc == 1) {
- if (!strcmp(argv[0], "8")) {
- return CONF_VALUE_SET(val, CONF_INT8, test8_shadow);
- } else if (!strcmp(argv[0], "str")) {
- return CONF_VALUE_SET(val, CONF_STRING, test_str);
- }
- }
- return OS_ENOENT;
-}
-
-static int
-test_conf_commit(void)
-{
- test8 = test8_shadow;
-
- return 0;
-}
-
-static int
-test_conf_export(void (*func)(char *name, char *val), enum conf_export_tgt tgt)
-{
- char buf[4];
-
- conf_str_from_value(CONF_INT8, &test8, buf, sizeof(buf));
- func("test/8", buf);
- func("test/str", test_str);
- return 0;
-}
-
static void
task1_handler(void *arg)
{
struct os_task *t;
- int prev_pin_state, curr_pin_state;
/* Set the led pin for the E407 devboard */
g_led_pin = LED_BLINK_PIN;
@@ -406,11 +325,7 @@ task1_handler(void *arg)
os_time_delay(OS_TICKS_PER_SEC);
/* Toggle the LED */
- prev_pin_state = hal_gpio_read(g_led_pin);
- curr_pin_state = hal_gpio_toggle(g_led_pin);
- LOG_INFO(&my_log, LOG_MODULE_DEFAULT, "GPIO toggle from %u to %u",
- prev_pin_state, curr_pin_state);
- STATS_INC(g_stats_gpio_toggle, toggles);
+ (void)hal_gpio_toggle(g_led_pin);
/* Release semaphore to task 2 */
os_sem_release(&g_test_sem);
@@ -488,8 +403,7 @@ config_sensor(void)
rc = tcs34725_config((struct tcs34725 *)dev, &tcscfg);
if (rc) {
- os_dev_close(dev);
- goto err;
+ console_printf("config_sensor %s failed %d\n", dev->od_name, rc);
}
os_dev_close(dev);
#endif
@@ -511,8 +425,7 @@ config_sensor(void)
rc = tsl2561_config((struct tsl2561 *)dev, &tslcfg);
if (rc) {
- os_dev_close(dev);
- goto err;
+ console_printf("config_sensor %s failed %d\n", dev->od_name, rc);
}
os_dev_close(dev);
#endif
@@ -535,8 +448,7 @@ config_sensor(void)
rc = lsm303dlhc_config((struct lsm303dlhc *) dev, &lsmcfg);
if (rc) {
- os_dev_close(dev);
- goto err;
+ console_printf("config_sensor %s failed %d\n", dev->od_name, rc);
}
os_dev_close(dev);
#endif
@@ -550,7 +462,6 @@ config_sensor(void)
rc = bno055_init(dev, NULL);
if (rc) {
os_dev_close(dev);
- assert(0);
goto err;
}
@@ -566,14 +477,17 @@ config_sensor(void)
rc = bno055_config((struct bno055 *) dev, &bcfg);
if (rc) {
- os_dev_close(dev);
- goto err;
+ console_printf("config_sensor %s failed %d\n", dev->od_name, rc);
}
os_dev_close(dev);
#endif
- return (0);
+ return 0;
+
err:
+
+ console_printf("config_sensor %s init failed %d\n", dev->od_name, rc);
+
return rc;
}
@@ -610,6 +524,8 @@ config_sensor(void)
return (0);
err:
+ console_printf("config_sensor %s init failed %d\n", dev->od_name, rc);
+
return (rc);
}
#endif
@@ -692,7 +608,6 @@ ble_oic_log_init(void)
int
main(int argc, char **argv)
{
- int rc;
#ifdef ARCH_sim
mcu_sim_parse_args(argc, argv);
@@ -700,47 +615,27 @@ main(int argc, char **argv)
/* Initialize OS */
sysinit();
- rc = conf_register(&test_conf_handler);
- assert(rc == 0);
-
- cbmem_init(&cbmem, cbmem_buf, MAX_CBMEM_BUF);
- log_register("log", &my_log, &log_cbmem_handler, &cbmem, LOG_SYSLEVEL);
-
- stats_init(STATS_HDR(g_stats_gpio_toggle),
- STATS_SIZE_INIT_PARMS(g_stats_gpio_toggle, STATS_SIZE_32),
- STATS_NAME_INIT_PARMS(gpio_stats));
-
- stats_register("gpio_toggle", STATS_HDR(g_stats_gpio_toggle));
-
+ /* Initialize BLE and OIC logs */
ble_oic_log_init();
- flash_test_init();
-
+ /* Load config */
conf_load();
- reboot_start(hal_reset_cause());
-
+ /* Initialize tasks */
init_tasks();
- /* If this app is acting as the loader in a split image setup, jump into
- * the second stage application instead of starting the OS.
- */
-#if MYNEWT_VAL(SPLIT_LOADER)
- {
- void *entry;
- rc = split_app_go(&entry, true);
- if(rc == 0) {
- hal_system_restart(entry);
- }
- }
-#endif
-
+ /* Sensor device shell init */
sensors_dev_shell_init();
+ /* Configure sensors */
config_sensor();
+ /* Initialize BLE OIC GATT Server */
sensor_ble_oic_server_init();
+ /* log reboot */
+ reboot_start(hal_reset_cause());
+
/*
* As the last thing, process events from default event queue.
*/
[43/50] [abbrv] incubator-mynewt-core git commit: sys/console: fix
newtmgr over shell
Posted by ja...@apache.org.
sys/console: fix newtmgr over shell
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/c7b6f80d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c7b6f80d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c7b6f80d
Branch: refs/heads/bluetooth5
Commit: c7b6f80d4e3a5165f84a4c078c872b4a0526d6fb
Parents: 27ff319
Author: Micha\u0142 Narajowski <mi...@codecoup.pl>
Authored: Mon Apr 24 16:13:40 2017 -0700
Committer: Micha\u0142 Narajowski <mi...@codecoup.pl>
Committed: Tue Apr 25 17:49:15 2017 -0700
----------------------------------------------------------------------
sys/console/full/src/console.c | 88 ++++++++++++++++++++++++++++++++++---
sys/console/full/syscfg.yml | 3 ++
2 files changed, 86 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c7b6f80d/sys/console/full/src/console.c
----------------------------------------------------------------------
diff --git a/sys/console/full/src/console.c b/sys/console/full/src/console.c
index f4a0257..1bc4c3e 100644
--- a/sys/console/full/src/console.c
+++ b/sys/console/full/src/console.c
@@ -51,6 +51,16 @@
#define ESC_ANSI_VAL (1 << 3)
#define ESC_ANSI_VAL_2 (1 << 4)
+#define CONSOLE_NLIP_PKT_START1 (6)
+#define CONSOLE_NLIP_PKT_START2 (9)
+#define CONSOLE_NLIP_DATA_START1 (4)
+#define CONSOLE_NLIP_DATA_START2 (20)
+
+#define NLIP_PKT_START1 (1 << 0)
+#define NLIP_PKT_START2 (1 << 1)
+#define NLIP_DATA_START1 (1 << 2)
+#define NLIP_DATA_START2 (1 << 3)
+
/* Indicates whether the previous line of output was completed. */
int console_is_midline;
@@ -64,7 +74,8 @@ static struct os_eventq compat_lines_queue;
#endif
static int esc_state;
-static int echo = 1;
+static int nlip_state;
+static int echo = MYNEWT_VAL(CONSOLE_ECHO);
static unsigned int ansi_val, ansi_val_2;
static uint8_t cur, end;
@@ -161,6 +172,10 @@ insert_char(char *pos, char c, uint8_t end)
{
char tmp;
+ if (cur + end >= MYNEWT_VAL(CONSOLE_MAX_INPUT_LEN) - 1) {
+ return;
+ }
+
if (echo) {
/* Echo back to console */
console_out(c);
@@ -302,6 +317,31 @@ ansi_cmd:
esc_state &= ~ESC_ANSI;
}
+static int
+handle_nlip(uint8_t byte)
+{
+ if (((nlip_state & NLIP_PKT_START1) &&
+ (nlip_state & NLIP_PKT_START2)) ||
+ ((nlip_state & NLIP_DATA_START1) &&
+ (nlip_state & NLIP_DATA_START2)))
+ {
+ return 1;
+ }
+
+ if ((nlip_state & NLIP_PKT_START1) &&
+ (byte == CONSOLE_NLIP_PKT_START2)) {
+ nlip_state |= NLIP_PKT_START2;
+ return 1;
+ } else if ((nlip_state & NLIP_DATA_START1) &&
+ (byte == CONSOLE_NLIP_DATA_START2)) {
+ nlip_state |= NLIP_DATA_START2;
+ return 1;
+ } else {
+ nlip_state = 0;
+ return 0;
+ }
+}
+
int
console_handle_char(uint8_t byte)
{
@@ -323,6 +363,41 @@ console_handle_char(uint8_t byte)
input = ev->ev_arg;
}
+ if (handle_nlip(byte)) {
+ if (byte == '\n') {
+ insert_char(&input->line[cur++], byte, end);
+ input->line[cur] = '\0';
+ cur = 0;
+ end = 0;
+ os_eventq_put(lines_queue, ev);
+ nlip_state = 0;
+
+#if MYNEWT_VAL(CONSOLE_COMPAT)
+ if (console_compat_rx_cb) {
+ console_compat_rx_cb();
+ }
+#endif
+
+ input = NULL;
+ ev = NULL;
+ console_echo(1);
+ return 0;
+ /* Ignore characters if there's no more buffer space */
+ } else if (byte == CONSOLE_NLIP_PKT_START2) {
+ /* Disable echo to not flood the UART */
+ console_echo(0);
+ insert_char(&input->line[cur++], CONSOLE_NLIP_PKT_START1, end);
+ } else if (byte == CONSOLE_NLIP_DATA_START2) {
+ /* Disable echo to not flood the UART */
+ console_echo(0);
+ insert_char(&input->line[cur++], CONSOLE_NLIP_DATA_START1, end);
+ }
+
+ insert_char(&input->line[cur++], byte, end);
+
+ return 0;
+ }
+
/* Handle ANSI escape mode */
if (esc_state & ESC_ANSI) {
handle_ansi(byte, input->line);
@@ -349,6 +424,12 @@ console_handle_char(uint8_t byte)
if (!isprint(byte)) {
handle_ansi(byte, input->line);
switch (byte) {
+ case CONSOLE_NLIP_PKT_START1:
+ nlip_state |= NLIP_PKT_START1;
+ break;
+ case CONSOLE_NLIP_DATA_START1:
+ nlip_state |= NLIP_DATA_START1;
+ break;
case DEL:
if (cur > 0) {
del_char(&input->line[--cur], end);
@@ -388,10 +469,7 @@ console_handle_char(uint8_t byte)
return 0;
}
- /* Ignore characters if there's no more buffer space */
- if (cur + end < sizeof(input->line) - 1) {
- insert_char(&input->line[cur++], byte, end);
- }
+ insert_char(&input->line[cur++], byte, end);
return 0;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c7b6f80d/sys/console/full/syscfg.yml
----------------------------------------------------------------------
diff --git a/sys/console/full/syscfg.yml b/sys/console/full/syscfg.yml
index 45fc2ed..402892d 100644
--- a/sys/console/full/syscfg.yml
+++ b/sys/console/full/syscfg.yml
@@ -31,6 +31,9 @@ syscfg.defs:
CONSOLE_TICKS:
description: 'Print OS Ticks'
value: 1
+ CONSOLE_ECHO:
+ description: 'Default console echo'
+ value: 1
CONSOLE_COMPAT:
description: 'Console backward compatibility'
value: 1
[12/50] [abbrv] incubator-mynewt-core git commit: No Ticket: Add
sensor device creation in NRF52840
Posted by ja...@apache.org.
No Ticket: Add sensor device creation in NRF52840
- Also, change name of init functiosn so that they
don't have "slinky_" prefix in them.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/73c8953b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/73c8953b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/73c8953b
Branch: refs/heads/bluetooth5
Commit: 73c8953be37e8e3b3603b4539fa37208199dcfcc
Parents: a1a0647
Author: Vipul Rahane <vi...@apache.org>
Authored: Tue Apr 18 18:55:58 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Tue Apr 18 18:55:58 2017 -0700
----------------------------------------------------------------------
hw/bsp/nrf52840pdk/src/hal_bsp.c | 86 +++++++++++++++++++++++++++++++++++
hw/bsp/nrf52dk/src/hal_bsp.c | 14 +++---
2 files changed, 93 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/73c8953b/hw/bsp/nrf52840pdk/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52840pdk/src/hal_bsp.c b/hw/bsp/nrf52840pdk/src/hal_bsp.c
index a0c78b8..bf2dd36 100644
--- a/hw/bsp/nrf52840pdk/src/hal_bsp.c
+++ b/hw/bsp/nrf52840pdk/src/hal_bsp.c
@@ -35,6 +35,36 @@
#include "uart_hal/uart_hal.h"
#include "os/os_dev.h"
#include "bsp.h"
+#if MYNEWT_VAL(LSM303DLHC_PRESENT)
+#include <lsm303dlhc/lsm303dlhc.h>
+static struct lsm303dlhc lsm303dlhc;
+#endif
+#if MYNEWT_VAL(BNO055_PRESENT)
+#include <bno055/bno055.h>
+#endif
+#if MYNEWT_VAL(TSL2561_PRESENT)
+#include <tsl2561/tsl2561.h>
+#endif
+#if MYNEWT_VAL(TCS34725_PRESENT)
+#include <tcs34725/tcs34725.h>
+#endif
+
+#if MYNEWT_VAL(LSM303DLHC_PRESENT)
+static struct lsm303dlhc lsm303dlhc;
+#endif
+
+#if MYNEWT_VAL(BNO055_PRESENT)
+static struct bno055 bno055;
+#endif
+
+#if MYNEWT_VAL(TSL2561_PRESENT)
+static struct tsl2561 tsl2561;
+#endif
+
+#if MYNEWT_VAL(TCS34725_PRESENT)
+static struct tcs34725 tcs34725;
+#endif
+
#if MYNEWT_VAL(UART_0)
static struct uart_dev os_bsp_uart0;
@@ -144,6 +174,61 @@ hal_bsp_get_nvic_priority(int irq_num, uint32_t pri)
return cfg_pri;
}
+#if MYNEWT_VAL(LSM303DLHC_PRESENT) || MYNEWT_VAL(BNO055_PRESENT)
+static int
+accel_init(struct os_dev *dev, void *arg)
+{
+ return (0);
+}
+#endif
+
+#if MYNEWT_VAL(TSL2561_PRESENT)
+static int
+light_init(struct os_dev *dev, void *arg)
+{
+ return (0);
+}
+#endif
+
+#if MYNEWT_VAL(TCS34725_PRESENT)
+static int
+color_init(struct os_dev *dev, void *arg)
+{
+ return (0);
+}
+#endif
+
+static void
+sensor_dev_create(void)
+{
+ int rc;
+
+ (void)rc;
+#if MYNEWT_VAL(LSM303DLHC_PRESENT)
+ rc = os_dev_create((struct os_dev *) &lsm303dlhc, "accel0",
+ OS_DEV_INIT_PRIMARY, 0, accel_init, NULL);
+ assert(rc == 0);
+#endif
+
+#if MYNEWT_VAL(BNO055_PRESENT)
+ rc = os_dev_create((struct os_dev *) &bno055, "accel1",
+ OS_DEV_INIT_PRIMARY, 0, accel_init, NULL);
+ assert(rc == 0);
+#endif
+
+#if MYNEWT_VAL(TSL2561_PRESENT)
+ rc = os_dev_create((struct os_dev *) &tsl2561, "light0",
+ OS_DEV_INIT_PRIMARY, 0, light_init, NULL);
+ assert(rc == 0);
+#endif
+
+#if MYNEWT_VAL(TCS34725_PRESENT)
+ rc = os_dev_create((struct os_dev *) &tcs34725, "color0",
+ OS_DEV_INIT_PRIMARY, 0, color_init, NULL);
+ assert(rc == 0);
+#endif
+}
+
void
hal_bsp_init(void)
{
@@ -206,4 +291,5 @@ hal_bsp_init(void)
assert(rc == 0);
#endif
+ sensor_dev_create();
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/73c8953b/hw/bsp/nrf52dk/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52dk/src/hal_bsp.c b/hw/bsp/nrf52dk/src/hal_bsp.c
index 4a2a2a1..c0031b1 100644
--- a/hw/bsp/nrf52dk/src/hal_bsp.c
+++ b/hw/bsp/nrf52dk/src/hal_bsp.c
@@ -182,7 +182,7 @@ hal_bsp_get_nvic_priority(int irq_num, uint32_t pri)
#if MYNEWT_VAL(LSM303DLHC_PRESENT) || MYNEWT_VAL(BNO055_PRESENT)
static int
-slinky_accel_init(struct os_dev *dev, void *arg)
+accel_init(struct os_dev *dev, void *arg)
{
return (0);
}
@@ -190,7 +190,7 @@ slinky_accel_init(struct os_dev *dev, void *arg)
#if MYNEWT_VAL(TSL2561_PRESENT)
static int
-slinky_light_init(struct os_dev *dev, void *arg)
+light_init(struct os_dev *dev, void *arg)
{
return (0);
}
@@ -198,7 +198,7 @@ slinky_light_init(struct os_dev *dev, void *arg)
#if MYNEWT_VAL(TCS34725_PRESENT)
static int
-slinky_color_init(struct os_dev *dev, void *arg)
+color_init(struct os_dev *dev, void *arg)
{
return (0);
}
@@ -212,25 +212,25 @@ sensor_dev_create(void)
(void)rc;
#if MYNEWT_VAL(LSM303DLHC_PRESENT)
rc = os_dev_create((struct os_dev *) &lsm303dlhc, "accel0",
- OS_DEV_INIT_PRIMARY, 0, slinky_accel_init, NULL);
+ OS_DEV_INIT_PRIMARY, 0, accel_init, NULL);
assert(rc == 0);
#endif
#if MYNEWT_VAL(BNO055_PRESENT)
rc = os_dev_create((struct os_dev *) &bno055, "accel1",
- OS_DEV_INIT_PRIMARY, 0, slinky_accel_init, NULL);
+ OS_DEV_INIT_PRIMARY, 0, accel_init, NULL);
assert(rc == 0);
#endif
#if MYNEWT_VAL(TSL2561_PRESENT)
rc = os_dev_create((struct os_dev *) &tsl2561, "light0",
- OS_DEV_INIT_PRIMARY, 0, slinky_light_init, NULL);
+ OS_DEV_INIT_PRIMARY, 0, light_init, NULL);
assert(rc == 0);
#endif
#if MYNEWT_VAL(TCS34725_PRESENT)
rc = os_dev_create((struct os_dev *) &tcs34725, "color0",
- OS_DEV_INIT_PRIMARY, 0, slinky_color_init, NULL);
+ OS_DEV_INIT_PRIMARY, 0, color_init, NULL);
assert(rc == 0);
#endif
[28/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-734
console_printf() return # printed chrs.
Posted by ja...@apache.org.
MYNEWT-734 console_printf() return # printed chrs.
Fix a bug for non-baselibc builds.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/271ab1b9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/271ab1b9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/271ab1b9
Branch: refs/heads/bluetooth5
Commit: 271ab1b9cc8a1db63d785f281ca118ab1580c9c9
Parents: e13e309
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Apr 20 15:41:38 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Apr 20 15:41:38 2017 -0700
----------------------------------------------------------------------
sys/console/full/src/cons_fmt.c | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/271ab1b9/sys/console/full/src/cons_fmt.c
----------------------------------------------------------------------
diff --git a/sys/console/full/src/cons_fmt.c b/sys/console/full/src/cons_fmt.c
index 1a3c72e..cd848c6 100644
--- a/sys/console/full/src/cons_fmt.c
+++ b/sys/console/full/src/cons_fmt.c
@@ -86,6 +86,8 @@ console_printf(const char *fmt, ...)
int num_chars;
int len;
+ num_chars = 0;
+
if (console_get_ticks()) {
/* Prefix each line with a timestamp. */
if (!console_is_midline) {
[04/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-729
SensorAPI: Send sensor data over OIC
Posted by ja...@apache.org.
MYNEWT-729 SensorAPI: Send sensor data over OIC
- Clean up
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/75e65613
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/75e65613
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/75e65613
Branch: refs/heads/bluetooth5
Commit: 75e65613f2629cfe83a52deafcaa193ce378747e
Parents: 5453323
Author: Vipul Rahane <vi...@apache.org>
Authored: Fri Apr 14 18:04:02 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Mon Apr 17 16:14:20 2017 -0700
----------------------------------------------------------------------
apps/sensors_test/pkg.yml | 11 ++
apps/sensors_test/src/gatt_svr.c | 313 ++++++++++++++++++++++++++++++++++
apps/sensors_test/src/main.c | 143 +++++++++-------
apps/sensors_test/syscfg.yml | 2 -
hw/sensor/pkg.yml | 7 -
hw/sensor/src/gatt_svr.c | 309 ---------------------------------
6 files changed, 406 insertions(+), 379 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/75e65613/apps/sensors_test/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/sensors_test/pkg.yml b/apps/sensors_test/pkg.yml
index 8ea0ffe..39250ae 100644
--- a/apps/sensors_test/pkg.yml
+++ b/apps/sensors_test/pkg.yml
@@ -41,6 +41,17 @@ pkg.deps:
- sys/log/full
- sys/stats/full
- boot/split
+ - mgmt/imgmgr
+ #- mgmt/newtmgr
+
+pkg.deps.SENSOR_BLE_OIC:
+ - mgmt/oicmgr
+ - net/nimble/controller
+ - net/nimble/host
+ - net/nimble/host/services/gap
+ - net/nimble/host/services/gatt
+ - net/nimble/host/store/ram
+ - net/nimble/transport/ram
pkg.deps.CONFIG_NFFS:
- fs/nffs
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/75e65613/apps/sensors_test/src/gatt_svr.c
----------------------------------------------------------------------
diff --git a/apps/sensors_test/src/gatt_svr.c b/apps/sensors_test/src/gatt_svr.c
new file mode 100644
index 0000000..e29f007
--- /dev/null
+++ b/apps/sensors_test/src/gatt_svr.c
@@ -0,0 +1,313 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include <syscfg/syscfg.h>
+#if MYNEWT_VAL(SENSOR_BLE_OIC)
+
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+#include "bsp/bsp.h"
+#include "host/ble_hs.h"
+#include "bleprph.h"
+
+/**
+ * The vendor specific security test service consists of two characteristics:
+ * o random-number-generator: generates a random 32-bit number each time
+ * it is read. This characteristic can only be read over an encrypted
+ * connection.
+ * o static-value: a single-byte characteristic that can always be read,
+ * but can only be written over an encrypted connection.
+ */
+
+/* 59462f12-9543-9999-12c8-58b459a2712d */
+static const ble_uuid128_t gatt_svr_svc_sec_test_uuid =
+ BLE_UUID128_INIT(0x2d, 0x71, 0xa2, 0x59, 0xb4, 0x58, 0xc8, 0x12, \
+ 0x99, 0x99, 0x43, 0x95, 0x12, 0x2f, 0x46, 0x59);
+
+/* 5c3a659e-897e-45e1-b016-007107c96df6 */
+static const ble_uuid128_t gatt_svr_chr_sec_test_rand_uuid =
+ BLE_UUID128_INIT(0xf6, 0x6d, 0xc9, 0x07, 0x71, 0x00, 0x16, 0xb0, \
+ 0xe1, 0x45, 0x7e, 0x89, 0x9e, 0x65, 0x3a, 0x5c);
+
+/* 5c3a659e-897e-45e1-b016-007107c96df7 */
+static const ble_uuid128_t gatt_svr_chr_sec_test_static_uuid =
+ BLE_UUID128_INIT(0xf7, 0x6d, 0xc9, 0x07, 0x71, 0x00, 0x16, 0xb0, \
+ 0xe1, 0x45, 0x7e, 0x89, 0x9e, 0x65, 0x3a, 0x5c);
+
+static uint8_t gatt_svr_sec_test_static_val;
+
+static int
+gatt_svr_chr_access_alert(uint16_t conn_handle, uint16_t attr_handle,
+ struct ble_gatt_access_ctxt *ctxt,
+ void *arg);
+
+static int
+gatt_svr_chr_access_sec_test(uint16_t conn_handle, uint16_t attr_handle,
+ struct ble_gatt_access_ctxt *ctxt,
+ void *arg);
+
+static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
+ {
+ /*** Alert Notification Service. */
+ .type = BLE_GATT_SVC_TYPE_PRIMARY,
+ .uuid = BLE_UUID16_DECLARE(GATT_SVR_SVC_ALERT_UUID),
+ .characteristics = (struct ble_gatt_chr_def[]) { {
+ .uuid = BLE_UUID16_DECLARE(GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID),
+ .access_cb = gatt_svr_chr_access_alert,
+ .flags = BLE_GATT_CHR_F_READ,
+ }, {
+ .uuid = BLE_UUID16_DECLARE(GATT_SVR_CHR_NEW_ALERT),
+ .access_cb = gatt_svr_chr_access_alert,
+ .flags = BLE_GATT_CHR_F_NOTIFY,
+ }, {
+ .uuid = BLE_UUID16_DECLARE(GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID),
+ .access_cb = gatt_svr_chr_access_alert,
+ .flags = BLE_GATT_CHR_F_READ,
+ }, {
+ .uuid = BLE_UUID16_DECLARE(GATT_SVR_CHR_UNR_ALERT_STAT_UUID),
+ .access_cb = gatt_svr_chr_access_alert,
+ .flags = BLE_GATT_CHR_F_NOTIFY,
+ }, {
+ .uuid = BLE_UUID16_DECLARE(GATT_SVR_CHR_ALERT_NOT_CTRL_PT),
+ .access_cb = gatt_svr_chr_access_alert,
+ .flags = BLE_GATT_CHR_F_WRITE,
+ }, {
+ 0, /* No more characteristics in this service. */
+ } },
+ },
+
+ {
+ /*** Service: Security test. */
+ .type = BLE_GATT_SVC_TYPE_PRIMARY,
+ .uuid = &gatt_svr_svc_sec_test_uuid.u,
+ .characteristics = (struct ble_gatt_chr_def[]) { {
+ /*** Characteristic: Random number generator. */
+ .uuid = &gatt_svr_chr_sec_test_rand_uuid.u,
+ .access_cb = gatt_svr_chr_access_sec_test,
+ .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
+ }, {
+ /*** Characteristic: Static value. */
+ .uuid = &gatt_svr_chr_sec_test_static_uuid.u,
+ .access_cb = gatt_svr_chr_access_sec_test,
+ .flags = BLE_GATT_CHR_F_READ |
+ BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_WRITE_ENC,
+ }, {
+ 0, /* No more characteristics in this service. */
+ } },
+ },
+
+ {
+ 0, /* No more services. */
+ },
+};
+
+static int
+gatt_svr_chr_write(struct os_mbuf *om, uint16_t min_len, uint16_t max_len,
+ void *dst, uint16_t *len)
+{
+ uint16_t om_len;
+ int rc;
+
+ om_len = OS_MBUF_PKTLEN(om);
+ if (om_len < min_len || om_len > max_len) {
+ return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
+ }
+
+ rc = ble_hs_mbuf_to_flat(om, dst, max_len, len);
+ if (rc != 0) {
+ return BLE_ATT_ERR_UNLIKELY;
+ }
+
+ return 0;
+}
+
+#define GATT_SVR_NEW_ALERT_VAL_MAX_LEN 64
+
+static const uint8_t gatt_svr_new_alert_cat = 0x01; /* Simple alert. */
+static uint8_t gatt_svr_new_alert_val[GATT_SVR_NEW_ALERT_VAL_MAX_LEN];
+static uint16_t gatt_svr_new_alert_val_len;
+static const uint8_t gatt_svr_unr_alert_cat = 0x01; /* Simple alert. */
+static uint16_t gatt_svr_unr_alert_stat;
+static uint16_t gatt_svr_alert_not_ctrl_pt;
+
+static int
+gatt_svr_chr_access_alert(uint16_t conn_handle, uint16_t attr_handle,
+ struct ble_gatt_access_ctxt *ctxt,
+ void *arg)
+{
+ uint16_t uuid16;
+ int rc;
+
+ uuid16 = ble_uuid_u16(ctxt->chr->uuid);
+ assert(uuid16 != 0);
+
+ switch (uuid16) {
+ case GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID:
+ assert(ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR);
+ rc = os_mbuf_append(ctxt->om, &gatt_svr_new_alert_cat,
+ sizeof gatt_svr_new_alert_cat);
+ return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
+
+ case GATT_SVR_CHR_NEW_ALERT:
+ if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
+ rc = gatt_svr_chr_write(ctxt->om, 0,
+ sizeof gatt_svr_new_alert_val,
+ gatt_svr_new_alert_val,
+ &gatt_svr_new_alert_val_len);
+ return rc;
+ } else if (ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR) {
+ rc = os_mbuf_append(ctxt->om, &gatt_svr_new_alert_val,
+ sizeof gatt_svr_new_alert_val);
+ return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
+ }
+
+ case GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID:
+ assert(ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR);
+ rc = os_mbuf_append(ctxt->om, &gatt_svr_unr_alert_cat,
+ sizeof gatt_svr_unr_alert_cat);
+ return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
+
+ case GATT_SVR_CHR_UNR_ALERT_STAT_UUID:
+ if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
+ rc = gatt_svr_chr_write(ctxt->om, 2, 2, &gatt_svr_unr_alert_stat,
+ NULL);
+ return rc;
+ } else {
+ rc = os_mbuf_append(ctxt->om, &gatt_svr_unr_alert_stat,
+ sizeof gatt_svr_unr_alert_stat);
+ return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
+ }
+
+ case GATT_SVR_CHR_ALERT_NOT_CTRL_PT:
+ if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
+ rc = gatt_svr_chr_write(ctxt->om, 2, 2,
+ &gatt_svr_alert_not_ctrl_pt, NULL);
+ } else {
+ rc = BLE_ATT_ERR_UNLIKELY;
+ }
+ return rc;
+
+ default:
+ assert(0);
+ return BLE_ATT_ERR_UNLIKELY;
+ }
+}
+
+static int
+gatt_svr_chr_access_sec_test(uint16_t conn_handle, uint16_t attr_handle,
+ struct ble_gatt_access_ctxt *ctxt,
+ void *arg)
+{
+ const ble_uuid_t *uuid;
+ int rand_num;
+ int rc;
+
+ uuid = ctxt->chr->uuid;
+
+ /* Determine which characteristic is being accessed by examining its
+ * 128-bit UUID.
+ */
+
+ if (ble_uuid_cmp(uuid, &gatt_svr_chr_sec_test_rand_uuid.u) == 0) {
+ assert(ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR);
+
+ /* Respond with a 32-bit random number. */
+ rand_num = rand();
+ rc = os_mbuf_append(ctxt->om, &rand_num, sizeof rand_num);
+ return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
+ }
+
+ if (ble_uuid_cmp(uuid, &gatt_svr_chr_sec_test_static_uuid.u) == 0) {
+ switch (ctxt->op) {
+ case BLE_GATT_ACCESS_OP_READ_CHR:
+ rc = os_mbuf_append(ctxt->om, &gatt_svr_sec_test_static_val,
+ sizeof gatt_svr_sec_test_static_val);
+ return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
+
+ case BLE_GATT_ACCESS_OP_WRITE_CHR:
+ rc = gatt_svr_chr_write(ctxt->om,
+ sizeof gatt_svr_sec_test_static_val,
+ sizeof gatt_svr_sec_test_static_val,
+ &gatt_svr_sec_test_static_val, NULL);
+ return rc;
+
+ default:
+ assert(0);
+ return BLE_ATT_ERR_UNLIKELY;
+ }
+ }
+
+ /* Unknown characteristic; the nimble stack should not have called this
+ * function.
+ */
+ assert(0);
+ return BLE_ATT_ERR_UNLIKELY;
+}
+
+void
+gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg)
+{
+ char buf[BLE_UUID_STR_LEN];
+
+ switch (ctxt->op) {
+ case BLE_GATT_REGISTER_OP_SVC:
+ BLEPRPH_LOG(DEBUG, "registered service %s with handle=%d\n",
+ ble_uuid_to_str(ctxt->svc.svc_def->uuid, buf),
+ ctxt->svc.handle);
+ break;
+
+ case BLE_GATT_REGISTER_OP_CHR:
+ BLEPRPH_LOG(DEBUG, "registering characteristic %s with "
+ "def_handle=%d val_handle=%d\n",
+ ble_uuid_to_str(ctxt->chr.chr_def->uuid, buf),
+ ctxt->chr.def_handle,
+ ctxt->chr.val_handle);
+ break;
+
+ case BLE_GATT_REGISTER_OP_DSC:
+ BLEPRPH_LOG(DEBUG, "registering descriptor %s with handle=%d\n",
+ ble_uuid_to_str(ctxt->dsc.dsc_def->uuid, buf),
+ ctxt->dsc.handle);
+ break;
+
+ default:
+ assert(0);
+ break;
+ }
+}
+
+int
+gatt_svr_init(void)
+{
+ int rc;
+
+ rc = ble_gatts_count_cfg(gatt_svr_svcs);
+ if (rc != 0) {
+ return rc;
+ }
+
+ rc = ble_gatts_add_svcs(gatt_svr_svcs);
+ if (rc != 0) {
+ return rc;
+ }
+
+ return 0;
+}
+
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/75e65613/apps/sensors_test/src/main.c
----------------------------------------------------------------------
diff --git a/apps/sensors_test/src/main.c b/apps/sensors_test/src/main.c
index 81dcc9f..322b83b 100755
--- a/apps/sensors_test/src/main.c
+++ b/apps/sensors_test/src/main.c
@@ -42,13 +42,13 @@
#endif
#include <bootutil/image.h>
#include <bootutil/bootutil.h>
-#include <imgmgr/imgmgr.h>
#include <assert.h>
#include <string.h>
#include <flash_test/flash_test.h>
#include <reboot/log_reboot.h>
#include <id/id.h>
+#if MYNEWT_VAL(SENSOR_BLE_OIC)
/* BLE */
#include <nimble/ble.h>
#include <host/ble_hs.h>
@@ -61,6 +61,13 @@
/* Application-specified header. */
#include "bleprph.h"
+static int sensor_oic_gap_event(struct ble_gap_event *event, void *arg);
+
+/** Log data. */
+struct log bleprph_log;
+
+#endif
+
#ifdef ARCH_sim
#include <mcu/mcu_sim.h>
#endif
@@ -76,24 +83,16 @@ static volatile int g_task1_loops;
#define TASK2_PRIO (9)
#define TASK2_STACK_SIZE OS_STACK_ALIGN(64)
static struct os_task task2;
-
-static int sensor_oic_gap_event(struct ble_gap_event *event, void *arg);
-
-/** Log data. */
-struct log bleprph_log;
+static volatile int g_task2_loops;
static struct log my_log;
-static volatile int g_task2_loops;
-
/* Global test semaphore */
static struct os_sem g_test_sem;
/* For LED toggling */
static int g_led_pin;
-extern int oc_stack_errno;
-
STATS_SECT_START(gpio_stats)
STATS_SECT_ENTRY(toggles)
STATS_SECT_END
@@ -124,6 +123,9 @@ static char test_str[32];
static uint32_t cbmem_buf[MAX_CBMEM_BUF];
static struct cbmem cbmem;
+#if MYNEWT_VAL(SENSOR_BLE_OIC)
+extern int oc_stack_errno;
+
static const oc_handler_t sensor_oic_handler = {
.init = sensor_oic_init,
};
@@ -332,6 +334,7 @@ sensor_oic_gap_event(struct ble_gap_event *event, void *arg)
return 0;
}
+#endif
static char *
test_conf_get(int argc, char **argv, char *buf, int max_len)
@@ -383,19 +386,12 @@ task1_handler(void *arg)
{
struct os_task *t;
int prev_pin_state, curr_pin_state;
- struct image_version ver;
/* Set the led pin for the E407 devboard */
g_led_pin = LED_BLINK_PIN;
hal_gpio_init_out(g_led_pin, 1);
- if (imgr_my_version(&ver) == 0) {
- console_printf("\nSensors Test %u.%u.%u.%u\n",
- ver.iv_major, ver.iv_minor, ver.iv_revision,
- (unsigned int)ver.iv_build_num);
- } else {
- console_printf("\nSensors Test\n");
- }
+ console_printf("\nSensors Test App\n");
while (1) {
t = os_sched_get_current_task();
@@ -578,9 +574,8 @@ err:
return rc;
}
-#endif
+#else
-#ifdef ARCH_sim
static int
config_sensor(void)
{
@@ -616,6 +611,70 @@ err:
}
#endif
+static void
+sensors_dev_shell_init(void)
+{
+
+#if MYNEWT_VAL(TCS34725_CLI)
+ tcs34725_shell_init();
+#endif
+
+#if MYNEWT_VAL(TSL2561_CLI)
+ tsl2561_shell_init();
+#endif
+
+#if MYNEWT_VAL(BNO055_CLI)
+ bno055_shell_init();
+#endif
+
+}
+
+static void
+sensor_ble_oic_server_init(void)
+{
+#if MYNEWT_VAL(SENSOR_BLE_OIC)
+ int rc;
+
+ /* Set initial BLE device address. */
+ memcpy(g_dev_addr, (uint8_t[6]){0x0a, 0xfa, 0xcf, 0xac, 0xfa, 0xc0}, 6);
+
+ oc_ble_coap_gatt_srv_init();
+
+ ble_hs_cfg.reset_cb = sensor_oic_on_reset;
+ ble_hs_cfg.sync_cb = sensor_oic_on_sync;
+ ble_hs_cfg.gatts_register_cb = gatt_svr_register_cb;
+
+ /* Set the default device name. */
+ rc = ble_svc_gap_device_name_set("pi");
+ assert(rc == 0);
+
+ rc = oc_main_init((oc_handler_t *)&sensor_oic_handler);
+ assert(!rc);
+
+ oc_init_platform("MyNewt", NULL, NULL);
+ oc_add_device("/oic/d", "oic.d.pi", "pi", "1.0", "1.0", NULL,
+ NULL);
+ assert(!oc_stack_errno);
+#endif
+}
+
+static void
+ble_oic_log_init(void)
+{
+#if MYNEWT_VAL(SENSOR_BLE_OIC)
+ /* Initialize the bleprph log. */
+ log_register("bleprph", &bleprph_log, &log_console_handler, NULL,
+ LOG_SYSLEVEL);
+
+ /* Initialize the NimBLE host configuration. */
+ log_register("ble_hs", &ble_hs_log, &log_console_handler, NULL,
+ LOG_SYSLEVEL);
+
+ /* Initialize the OIC */
+ log_register("oic", &oc_log, &log_console_handler, NULL, LOG_SYSLEVEL);
+#endif
+}
+
/**
* main
*
@@ -648,19 +707,7 @@ main(int argc, char **argv)
stats_register("gpio_toggle", STATS_HDR(g_stats_gpio_toggle));
- /* Set initial BLE device address. */
- memcpy(g_dev_addr, (uint8_t[6]){0x0a, 0xfa, 0xcf, 0xac, 0xfa, 0xc0}, 6);
-
- /* Initialize the bleprph log. */
- log_register("bleprph", &bleprph_log, &log_console_handler, NULL,
- LOG_SYSLEVEL);
-
- /* Initialize the NimBLE host configuration. */
- log_register("ble_hs", &ble_hs_log, &log_console_handler, NULL,
- LOG_SYSLEVEL);
-
- /* Initialize the OIC */
- log_register("oic", &oc_log, &log_console_handler, NULL, LOG_SYSLEVEL);
+ ble_oic_log_init();
flash_test_init();
@@ -683,37 +730,11 @@ main(int argc, char **argv)
}
#endif
-#if MYNEWT_VAL(TCS34725_CLI)
- tcs34725_shell_init();
-#endif
-
-#if MYNEWT_VAL(TSL2561_CLI)
- tsl2561_shell_init();
-#endif
-
-#if MYNEWT_VAL(BNO055_CLI)
- bno055_shell_init();
-#endif
+ sensors_dev_shell_init();
config_sensor();
- oc_ble_coap_gatt_srv_init();
-
- ble_hs_cfg.reset_cb = sensor_oic_on_reset;
- ble_hs_cfg.sync_cb = sensor_oic_on_sync;
- ble_hs_cfg.gatts_register_cb = gatt_svr_register_cb;
-
- /* Set the default device name. */
- rc = ble_svc_gap_device_name_set("pi");
- assert(rc == 0);
-
- rc = oc_main_init((oc_handler_t *)&sensor_oic_handler);
- assert(!rc);
-
- oc_init_platform("MyNewt", NULL, NULL);
- oc_add_device("/oic/d", "oic.d.color", "color0", "1.0", "1.0", NULL,
- NULL);
- assert(!oc_stack_errno);
+ sensor_ble_oic_server_init();
/*
* As the last thing, process events from default event queue.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/75e65613/apps/sensors_test/syscfg.yml
----------------------------------------------------------------------
diff --git a/apps/sensors_test/syscfg.yml b/apps/sensors_test/syscfg.yml
index 04adddc..8623667 100644
--- a/apps/sensors_test/syscfg.yml
+++ b/apps/sensors_test/syscfg.yml
@@ -45,7 +45,6 @@ syscfg.vals:
BNO055_CLI: 1
TCS34725_CLI: 1
SENSOR_BLE_OIC: 1
-
BLE_ROLE_CENTRAL: 0
BLE_ROLE_OBSERVER: 0
OC_SERVER: 1
@@ -70,4 +69,3 @@ syscfg.defs:
SIM_ACCEL_PRESENT:
description: 'SIM ACCEL is present'
value : 0
-
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/75e65613/hw/sensor/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/sensor/pkg.yml b/hw/sensor/pkg.yml
index c83dcf1..bdd0e0b 100644
--- a/hw/sensor/pkg.yml
+++ b/hw/sensor/pkg.yml
@@ -24,13 +24,6 @@ pkg.homepage: "http://mynewt.apache.org/"
pkg.keywords:
pkg.deps:
- - net/nimble/controller
- - net/nimble/host
- - net/nimble/host/services/gap
- - net/nimble/host/services/gatt
- - net/nimble/host/store/ram
- - net/nimble/transport/ram
- - mgmt/oicmgr
- sys/shell
- sys/console/full
- sys/log/full
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/75e65613/hw/sensor/src/gatt_svr.c
----------------------------------------------------------------------
diff --git a/hw/sensor/src/gatt_svr.c b/hw/sensor/src/gatt_svr.c
deleted file mode 100644
index 659a9c1..0000000
--- a/hw/sensor/src/gatt_svr.c
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-#include "bsp/bsp.h"
-#include "host/ble_hs.h"
-#include "bleprph.h"
-
-/**
- * The vendor specific security test service consists of two characteristics:
- * o random-number-generator: generates a random 32-bit number each time
- * it is read. This characteristic can only be read over an encrypted
- * connection.
- * o static-value: a single-byte characteristic that can always be read,
- * but can only be written over an encrypted connection.
- */
-
-/* 59462f12-9543-9999-12c8-58b459a2712d */
-static const ble_uuid128_t gatt_svr_svc_sec_test_uuid =
- BLE_UUID128_INIT(0x2d, 0x71, 0xa2, 0x59, 0xb4, 0x58, 0xc8, 0x12, \
- 0x99, 0x99, 0x43, 0x95, 0x12, 0x2f, 0x46, 0x59);
-
-/* 5c3a659e-897e-45e1-b016-007107c96df6 */
-static const ble_uuid128_t gatt_svr_chr_sec_test_rand_uuid =
- BLE_UUID128_INIT(0xf6, 0x6d, 0xc9, 0x07, 0x71, 0x00, 0x16, 0xb0, \
- 0xe1, 0x45, 0x7e, 0x89, 0x9e, 0x65, 0x3a, 0x5c);
-
-/* 5c3a659e-897e-45e1-b016-007107c96df7 */
-static const ble_uuid128_t gatt_svr_chr_sec_test_static_uuid =
- BLE_UUID128_INIT(0xf7, 0x6d, 0xc9, 0x07, 0x71, 0x00, 0x16, 0xb0, \
- 0xe1, 0x45, 0x7e, 0x89, 0x9e, 0x65, 0x3a, 0x5c);
-
-static uint8_t gatt_svr_sec_test_static_val;
-
-static int
-gatt_svr_chr_access_alert(uint16_t conn_handle, uint16_t attr_handle,
- struct ble_gatt_access_ctxt *ctxt,
- void *arg);
-
-static int
-gatt_svr_chr_access_sec_test(uint16_t conn_handle, uint16_t attr_handle,
- struct ble_gatt_access_ctxt *ctxt,
- void *arg);
-
-static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
- {
- /*** Alert Notification Service. */
- .type = BLE_GATT_SVC_TYPE_PRIMARY,
- .uuid = BLE_UUID16_DECLARE(GATT_SVR_SVC_ALERT_UUID),
- .characteristics = (struct ble_gatt_chr_def[]) { {
- .uuid = BLE_UUID16_DECLARE(GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID),
- .access_cb = gatt_svr_chr_access_alert,
- .flags = BLE_GATT_CHR_F_READ,
- }, {
- .uuid = BLE_UUID16_DECLARE(GATT_SVR_CHR_NEW_ALERT),
- .access_cb = gatt_svr_chr_access_alert,
- .flags = BLE_GATT_CHR_F_NOTIFY,
- }, {
- .uuid = BLE_UUID16_DECLARE(GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID),
- .access_cb = gatt_svr_chr_access_alert,
- .flags = BLE_GATT_CHR_F_READ,
- }, {
- .uuid = BLE_UUID16_DECLARE(GATT_SVR_CHR_UNR_ALERT_STAT_UUID),
- .access_cb = gatt_svr_chr_access_alert,
- .flags = BLE_GATT_CHR_F_NOTIFY,
- }, {
- .uuid = BLE_UUID16_DECLARE(GATT_SVR_CHR_ALERT_NOT_CTRL_PT),
- .access_cb = gatt_svr_chr_access_alert,
- .flags = BLE_GATT_CHR_F_WRITE,
- }, {
- 0, /* No more characteristics in this service. */
- } },
- },
-
- {
- /*** Service: Security test. */
- .type = BLE_GATT_SVC_TYPE_PRIMARY,
- .uuid = &gatt_svr_svc_sec_test_uuid.u,
- .characteristics = (struct ble_gatt_chr_def[]) { {
- /*** Characteristic: Random number generator. */
- .uuid = &gatt_svr_chr_sec_test_rand_uuid.u,
- .access_cb = gatt_svr_chr_access_sec_test,
- .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
- }, {
- /*** Characteristic: Static value. */
- .uuid = &gatt_svr_chr_sec_test_static_uuid.u,
- .access_cb = gatt_svr_chr_access_sec_test,
- .flags = BLE_GATT_CHR_F_READ |
- BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_WRITE_ENC,
- }, {
- 0, /* No more characteristics in this service. */
- } },
- },
-
- {
- 0, /* No more services. */
- },
-};
-
-static int
-gatt_svr_chr_write(struct os_mbuf *om, uint16_t min_len, uint16_t max_len,
- void *dst, uint16_t *len)
-{
- uint16_t om_len;
- int rc;
-
- om_len = OS_MBUF_PKTLEN(om);
- if (om_len < min_len || om_len > max_len) {
- return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
- }
-
- rc = ble_hs_mbuf_to_flat(om, dst, max_len, len);
- if (rc != 0) {
- return BLE_ATT_ERR_UNLIKELY;
- }
-
- return 0;
-}
-
-#define GATT_SVR_NEW_ALERT_VAL_MAX_LEN 64
-
-static const uint8_t gatt_svr_new_alert_cat = 0x01; /* Simple alert. */
-static uint8_t gatt_svr_new_alert_val[GATT_SVR_NEW_ALERT_VAL_MAX_LEN];
-static uint16_t gatt_svr_new_alert_val_len;
-static const uint8_t gatt_svr_unr_alert_cat = 0x01; /* Simple alert. */
-static uint16_t gatt_svr_unr_alert_stat;
-static uint16_t gatt_svr_alert_not_ctrl_pt;
-
-static int
-gatt_svr_chr_access_alert(uint16_t conn_handle, uint16_t attr_handle,
- struct ble_gatt_access_ctxt *ctxt,
- void *arg)
-{
- uint16_t uuid16;
- int rc;
-
- uuid16 = ble_uuid_u16(ctxt->chr->uuid);
- assert(uuid16 != 0);
-
- switch (uuid16) {
- case GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID:
- assert(ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR);
- rc = os_mbuf_append(ctxt->om, &gatt_svr_new_alert_cat,
- sizeof gatt_svr_new_alert_cat);
- return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
-
- case GATT_SVR_CHR_NEW_ALERT:
- if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
- rc = gatt_svr_chr_write(ctxt->om, 0,
- sizeof gatt_svr_new_alert_val,
- gatt_svr_new_alert_val,
- &gatt_svr_new_alert_val_len);
- return rc;
- } else if (ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR) {
- rc = os_mbuf_append(ctxt->om, &gatt_svr_new_alert_val,
- sizeof gatt_svr_new_alert_val);
- return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
- }
-
- case GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID:
- assert(ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR);
- rc = os_mbuf_append(ctxt->om, &gatt_svr_unr_alert_cat,
- sizeof gatt_svr_unr_alert_cat);
- return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
-
- case GATT_SVR_CHR_UNR_ALERT_STAT_UUID:
- if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
- rc = gatt_svr_chr_write(ctxt->om, 2, 2, &gatt_svr_unr_alert_stat,
- NULL);
- return rc;
- } else {
- rc = os_mbuf_append(ctxt->om, &gatt_svr_unr_alert_stat,
- sizeof gatt_svr_unr_alert_stat);
- return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
- }
-
- case GATT_SVR_CHR_ALERT_NOT_CTRL_PT:
- if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
- rc = gatt_svr_chr_write(ctxt->om, 2, 2,
- &gatt_svr_alert_not_ctrl_pt, NULL);
- } else {
- rc = BLE_ATT_ERR_UNLIKELY;
- }
- return rc;
-
- default:
- assert(0);
- return BLE_ATT_ERR_UNLIKELY;
- }
-}
-
-static int
-gatt_svr_chr_access_sec_test(uint16_t conn_handle, uint16_t attr_handle,
- struct ble_gatt_access_ctxt *ctxt,
- void *arg)
-{
- const ble_uuid_t *uuid;
- int rand_num;
- int rc;
-
- uuid = ctxt->chr->uuid;
-
- /* Determine which characteristic is being accessed by examining its
- * 128-bit UUID.
- */
-
- if (ble_uuid_cmp(uuid, &gatt_svr_chr_sec_test_rand_uuid.u) == 0) {
- assert(ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR);
-
- /* Respond with a 32-bit random number. */
- rand_num = rand();
- rc = os_mbuf_append(ctxt->om, &rand_num, sizeof rand_num);
- return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
- }
-
- if (ble_uuid_cmp(uuid, &gatt_svr_chr_sec_test_static_uuid.u) == 0) {
- switch (ctxt->op) {
- case BLE_GATT_ACCESS_OP_READ_CHR:
- rc = os_mbuf_append(ctxt->om, &gatt_svr_sec_test_static_val,
- sizeof gatt_svr_sec_test_static_val);
- return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
-
- case BLE_GATT_ACCESS_OP_WRITE_CHR:
- rc = gatt_svr_chr_write(ctxt->om,
- sizeof gatt_svr_sec_test_static_val,
- sizeof gatt_svr_sec_test_static_val,
- &gatt_svr_sec_test_static_val, NULL);
- return rc;
-
- default:
- assert(0);
- return BLE_ATT_ERR_UNLIKELY;
- }
- }
-
- /* Unknown characteristic; the nimble stack should not have called this
- * function.
- */
- assert(0);
- return BLE_ATT_ERR_UNLIKELY;
-}
-
-void
-gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg)
-{
- char buf[BLE_UUID_STR_LEN];
-
- switch (ctxt->op) {
- case BLE_GATT_REGISTER_OP_SVC:
- BLEPRPH_LOG(DEBUG, "registered service %s with handle=%d\n",
- ble_uuid_to_str(ctxt->svc.svc_def->uuid, buf),
- ctxt->svc.handle);
- break;
-
- case BLE_GATT_REGISTER_OP_CHR:
- BLEPRPH_LOG(DEBUG, "registering characteristic %s with "
- "def_handle=%d val_handle=%d\n",
- ble_uuid_to_str(ctxt->chr.chr_def->uuid, buf),
- ctxt->chr.def_handle,
- ctxt->chr.val_handle);
- break;
-
- case BLE_GATT_REGISTER_OP_DSC:
- BLEPRPH_LOG(DEBUG, "registering descriptor %s with handle=%d\n",
- ble_uuid_to_str(ctxt->dsc.dsc_def->uuid, buf),
- ctxt->dsc.handle);
- break;
-
- default:
- assert(0);
- break;
- }
-}
-
-int
-gatt_svr_init(void)
-{
- int rc;
-
- rc = ble_gatts_count_cfg(gatt_svr_svcs);
- if (rc != 0) {
- return rc;
- }
-
- rc = ble_gatts_add_svcs(gatt_svr_svcs);
- if (rc != 0) {
- return rc;
- }
-
- return 0;
-}
[25/50] [abbrv] incubator-mynewt-core git commit: This closes #241
Posted by ja...@apache.org.
This closes #241
The UART transport assumes outgoing ACL data packets consist of a single
mbuf. If the chain contains multiple buffers, the later part of the
outgoing packet consists of all zeros.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/431e500a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/431e500a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/431e500a
Branch: refs/heads/bluetooth5
Commit: 431e500adc76efe84d336da9e278b8bb480cc5bb
Parents: 813463e 7669e97
Author: William San Filippo <wi...@runtime.io>
Authored: Wed Apr 19 22:05:05 2017 -0700
Committer: William San Filippo <wi...@runtime.io>
Committed: Wed Apr 19 22:05:05 2017 -0700
----------------------------------------------------------------------
apps/iptest/pkg.yml | 46 +
apps/iptest/src/main.c | 441 ++++++
apps/iptest/syscfg.yml | 45 +
fs/fcb/src/fcb.c | 2 +-
fs/fcb/test/src/testcases/fcb_test_len.c | 5 +-
hw/bsp/nrf52840pdk/src/hal_bsp.c | 86 ++
hw/bsp/nrf52dk/src/hal_bsp.c | 14 +-
.../include/bsp/stm32f4xx_hal_conf.h | 1 +
hw/bsp/olimex_stm32-e407_devboard/pkg.yml | 4 +-
hw/bsp/olimex_stm32-e407_devboard/src/hal_bsp.c | 41 +-
hw/bsp/olimex_stm32-e407_devboard/syscfg.yml | 4 +
hw/bsp/ruuvi_tag_revb2/boot-nrf52xxaa.ld | 25 +
hw/bsp/ruuvi_tag_revb2/bsp.yml | 64 +
hw/bsp/ruuvi_tag_revb2/include/bsp/boards.h | 19 +
hw/bsp/ruuvi_tag_revb2/include/bsp/bsp.h | 73 +
hw/bsp/ruuvi_tag_revb2/include/bsp/cmsis_nvic.h | 29 +
hw/bsp/ruuvi_tag_revb2/nrf52dk_debug.cmd | 22 +
hw/bsp/ruuvi_tag_revb2/nrf52dk_debug.sh | 46 +
hw/bsp/ruuvi_tag_revb2/nrf52dk_download.cmd | 22 +
hw/bsp/ruuvi_tag_revb2/nrf52dk_download.sh | 40 +
hw/bsp/ruuvi_tag_revb2/nrf52dk_no_boot.ld | 191 +++
hw/bsp/ruuvi_tag_revb2/nrf52xxaa.ld | 25 +
hw/bsp/ruuvi_tag_revb2/pkg.yml | 97 ++
hw/bsp/ruuvi_tag_revb2/split-nrf52dk.ld | 208 +++
.../src/arch/cortex_m4/gcc_startup_nrf52.s | 301 ++++
.../arch/cortex_m4/gcc_startup_nrf52_split.s | 166 +++
hw/bsp/ruuvi_tag_revb2/src/hal_bsp.c | 303 ++++
hw/bsp/ruuvi_tag_revb2/src/sbrk.c | 59 +
hw/bsp/ruuvi_tag_revb2/syscfg.yml | 95 ++
hw/bsp/stm32f767-nucleo/pkg.yml | 3 +
hw/bsp/stm32f767-nucleo/src/hal_bsp.c | 50 +
hw/bsp/stm32f767-nucleo/syscfg.yml | 4 +
.../stm32_eth/include/stm32_eth/stm32_eth.h | 49 +
.../stm32_eth/include/stm32_eth/stm32_eth_cfg.h | 47 +
hw/drivers/lwip/stm32_eth/pkg.yml | 41 +
hw/drivers/lwip/stm32_eth/src/stm32_eth.c | 538 +++++++
.../include/stm32f4_eth/stm32f4_eth.h | 27 -
.../include/stm32f4_eth/stm32f4_eth_cfg.h | 32 -
hw/drivers/lwip/stm32f4_eth/pkg.yml | 33 -
hw/drivers/lwip/stm32f4_eth/src/stm32f4_eth.c | 746 ----------
hw/hal/include/hal/hal_timer.h | 2 +
hw/mcu/nordic/nrf52xxx/src/hal_flash.c | 12 +
hw/mcu/stm/stm32f4xx/syscfg.yml | 4 +
hw/mcu/stm/stm32f7xx/syscfg.yml | 4 +
libc/baselibc/include/string.h | 1 +
libc/baselibc/src/strstr.c | 5 +
libc/baselibc/src/tinyprintf.c | 20 +-
net/ip/include/arch/sys_arch.h | 304 ++--
net/ip/include/ip/init.h | 32 -
net/ip/include/lwipopts.h | 15 +-
net/ip/inet_def_service/src/inet_def_service.c | 110 +-
net/ip/lwip_base/CHANGELOG | 146 ++
net/ip/lwip_base/UPGRADING | 16 +-
net/ip/lwip_base/doc/NO_SYS_SampleCode.c | 16 +-
net/ip/lwip_base/doc/doxygen/generate.sh | 2 +
net/ip/lwip_base/doc/doxygen/lwip.Doxyfile | 7 +-
net/ip/lwip_base/doc/doxygen/main_page.h | 75 +-
net/ip/lwip_base/doc/mqtt_client.txt | 162 +++
net/ip/lwip_base/doc/ppp.txt | 6 +-
net/ip/lwip_base/doc/rawapi.txt | 8 +-
net/ip/lwip_base/doc/sys_arch.txt | 2 +-
net/ip/lwip_base/include/lwip/api.h | 31 +-
net/ip/lwip_base/include/lwip/apps/httpd_opts.h | 30 -
net/ip/lwip_base/include/lwip/apps/mdns.h | 10 +-
net/ip/lwip_base/include/lwip/apps/mdns_opts.h | 10 +-
net/ip/lwip_base/include/lwip/apps/mdns_priv.h | 10 +-
net/ip/lwip_base/include/lwip/apps/mqtt.h | 244 ++++
net/ip/lwip_base/include/lwip/apps/mqtt_opts.h | 103 ++
net/ip/lwip_base/include/lwip/apps/netbiosns.h | 8 -
.../include/lwip/apps/netbiosns_opts.h | 18 -
net/ip/lwip_base/include/lwip/apps/snmp_opts.h | 8 -
net/ip/lwip_base/include/lwip/apps/snmpv3.h | 8 -
net/ip/lwip_base/include/lwip/apps/sntp_opts.h | 8 -
net/ip/lwip_base/include/lwip/apps/tftp_opts.h | 105 ++
.../lwip_base/include/lwip/apps/tftp_server.h | 94 ++
net/ip/lwip_base/include/lwip/arch.h | 299 ++--
net/ip/lwip_base/include/lwip/autoip.h | 2 +
net/ip/lwip_base/include/lwip/debug.h | 81 +-
net/ip/lwip_base/include/lwip/def.h | 95 +-
net/ip/lwip_base/include/lwip/dhcp.h | 2 +
net/ip/lwip_base/include/lwip/dhcp6.h | 8 -
net/ip/lwip_base/include/lwip/dns.h | 18 +-
net/ip/lwip_base/include/lwip/err.h | 4 +
net/ip/lwip_base/include/lwip/errno.h | 193 +++
net/ip/lwip_base/include/lwip/icmp.h | 2 +-
net/ip/lwip_base/include/lwip/icmp6.h | 89 +-
net/ip/lwip_base/include/lwip/igmp.h | 6 +-
net/ip/lwip_base/include/lwip/inet.h | 8 +-
net/ip/lwip_base/include/lwip/inet_chksum.h | 8 +-
net/ip/lwip_base/include/lwip/init.h | 4 +-
net/ip/lwip_base/include/lwip/ip4_addr.h | 36 +-
net/ip/lwip_base/include/lwip/ip6_addr.h | 66 +-
net/ip/lwip_base/include/lwip/ip_addr.h | 73 +-
net/ip/lwip_base/include/lwip/mem.h | 3 +-
net/ip/lwip_base/include/lwip/mld6.h | 7 +-
net/ip/lwip_base/include/lwip/nd6.h | 93 +-
net/ip/lwip_base/include/lwip/netdb.h | 3 +-
net/ip/lwip_base/include/lwip/netif.h | 10 +-
net/ip/lwip_base/include/lwip/netifapi.h | 12 +-
net/ip/lwip_base/include/lwip/opt.h | 116 +-
net/ip/lwip_base/include/lwip/pbuf.h | 20 +-
net/ip/lwip_base/include/lwip/priv/api_msg.h | 3 +-
net/ip/lwip_base/include/lwip/priv/memp_std.h | 8 -
net/ip/lwip_base/include/lwip/priv/nd6_priv.h | 144 ++
net/ip/lwip_base/include/lwip/priv/tcp_priv.h | 27 +-
net/ip/lwip_base/include/lwip/priv/tcpip_priv.h | 4 +-
net/ip/lwip_base/include/lwip/prot/dns.h | 18 +
net/ip/lwip_base/include/lwip/prot/ethernet.h | 2 +-
net/ip/lwip_base/include/lwip/prot/icmp6.h | 87 ++
net/ip/lwip_base/include/lwip/prot/ip.h | 8 -
net/ip/lwip_base/include/lwip/prot/ip4.h | 16 +
net/ip/lwip_base/include/lwip/prot/ip6.h | 27 +-
net/ip/lwip_base/include/lwip/prot/mld6.h | 2 +-
net/ip/lwip_base/include/lwip/prot/nd6.h | 24 +
net/ip/lwip_base/include/lwip/prot/tcp.h | 14 +-
net/ip/lwip_base/include/lwip/raw.h | 2 +
net/ip/lwip_base/include/lwip/sockets.h | 5 +-
net/ip/lwip_base/include/lwip/stats.h | 4 +-
net/ip/lwip_base/include/lwip/sys.h | 44 +-
net/ip/lwip_base/include/lwip/tcp.h | 12 +-
net/ip/lwip_base/include/lwip/tcpip.h | 2 +
net/ip/lwip_base/include/lwip/timeouts.h | 2 +-
net/ip/lwip_base/include/netif/lowpan6_opts.h | 8 -
net/ip/lwip_base/include/netif/ppp/ccp.h | 8 -
net/ip/lwip_base/include/netif/ppp/chap-new.h | 8 -
net/ip/lwip_base/include/netif/ppp/chap_ms.h | 8 -
net/ip/lwip_base/include/netif/ppp/eui64.h | 10 +-
net/ip/lwip_base/include/netif/ppp/fsm.h | 8 -
net/ip/lwip_base/include/netif/ppp/ipcp.h | 8 -
net/ip/lwip_base/include/netif/ppp/ipv6cp.h | 8 -
net/ip/lwip_base/include/netif/ppp/lcp.h | 8 -
net/ip/lwip_base/include/netif/ppp/magic.h | 8 -
net/ip/lwip_base/include/netif/ppp/mppe.h | 10 +-
net/ip/lwip_base/include/netif/ppp/ppp.h | 12 +-
net/ip/lwip_base/include/netif/ppp/ppp_impl.h | 12 +-
net/ip/lwip_base/include/netif/ppp/ppp_opts.h | 8 -
net/ip/lwip_base/include/netif/ppp/pppcrypt.h | 8 -
net/ip/lwip_base/include/netif/ppp/pppdebug.h | 8 -
net/ip/lwip_base/include/netif/ppp/pppoe.h | 8 -
net/ip/lwip_base/include/netif/ppp/pppol2tp.h | 8 -
net/ip/lwip_base/include/netif/ppp/pppos.h | 8 -
net/ip/lwip_base/include/netif/ppp/upap.h | 8 -
net/ip/lwip_base/include/netif/ppp/vj.h | 8 -
net/ip/lwip_base/include/posix/errno.h | 33 +
net/ip/lwip_base/src/Filelists.mk | 10 +-
net/ip/lwip_base/src/api/api_lib.c | 69 +-
net/ip/lwip_base/src/api/api_msg.c | 127 +-
net/ip/lwip_base/src/api/err.c | 40 +
net/ip/lwip_base/src/api/netdb.c | 10 +-
net/ip/lwip_base/src/api/netifapi.c | 14 +-
net/ip/lwip_base/src/api/sockets.c | 204 +--
net/ip/lwip_base/src/api/tcpip.c | 3 +-
net/ip/lwip_base/src/apps/httpd/fsdata.h | 8 -
net/ip/lwip_base/src/apps/httpd/httpd.c | 180 +--
net/ip/lwip_base/src/apps/httpd/httpd_structs.h | 8 -
net/ip/lwip_base/src/apps/lwiperf/lwiperf.c | 16 +-
net/ip/lwip_base/src/apps/mdns/mdns.c | 161 +--
net/ip/lwip_base/src/apps/mqtt/mqtt.c | 1341 ++++++++++++++++++
net/ip/lwip_base/src/apps/netbiosns/netbiosns.c | 5 +-
net/ip/lwip_base/src/apps/snmp/snmp_asn1.c | 8 +-
net/ip/lwip_base/src/apps/snmp/snmp_core.c | 84 +-
net/ip/lwip_base/src/apps/snmp/snmp_mib2_ip.c | 12 +-
net/ip/lwip_base/src/apps/snmp/snmp_mib2_tcp.c | 6 +-
net/ip/lwip_base/src/apps/snmp/snmp_msg.c | 11 +-
net/ip/lwip_base/src/apps/snmp/snmp_netconn.c | 5 +-
net/ip/lwip_base/src/apps/snmp/snmp_raw.c | 2 +-
.../lwip_base/src/apps/snmp/snmp_threadsync.c | 1 +
net/ip/lwip_base/src/apps/snmp/snmp_traps.c | 9 +-
net/ip/lwip_base/src/apps/snmp/snmpv3_priv.h | 8 -
net/ip/lwip_base/src/apps/sntp/sntp.c | 9 +-
net/ip/lwip_base/src/apps/tftp/tftp_server.c | 417 ++++++
net/ip/lwip_base/src/core/def.c | 177 ++-
net/ip/lwip_base/src/core/dns.c | 239 +++-
net/ip/lwip_base/src/core/inet_chksum.c | 15 +-
net/ip/lwip_base/src/core/init.c | 12 +-
net/ip/lwip_base/src/core/ipv4/autoip.c | 16 +-
net/ip/lwip_base/src/core/ipv4/dhcp.c | 114 +-
net/ip/lwip_base/src/core/ipv4/etharp.c | 69 +-
net/ip/lwip_base/src/core/ipv4/icmp.c | 14 +-
net/ip/lwip_base/src/core/ipv4/igmp.c | 75 +-
net/ip/lwip_base/src/core/ipv4/ip4.c | 57 +-
net/ip/lwip_base/src/core/ipv4/ip4_addr.c | 10 +-
net/ip/lwip_base/src/core/ipv4/ip4_frag.c | 88 +-
net/ip/lwip_base/src/core/ipv6/ethip6.c | 42 +-
net/ip/lwip_base/src/core/ipv6/ip6.c | 62 +-
net/ip/lwip_base/src/core/ipv6/ip6_addr.c | 10 +-
net/ip/lwip_base/src/core/ipv6/ip6_frag.c | 49 +-
net/ip/lwip_base/src/core/ipv6/mld6.c | 7 +-
net/ip/lwip_base/src/core/ipv6/nd6.c | 355 +++--
net/ip/lwip_base/src/core/mem.c | 8 +-
net/ip/lwip_base/src/core/memp.c | 25 +-
net/ip/lwip_base/src/core/netif.c | 127 +-
net/ip/lwip_base/src/core/pbuf.c | 91 +-
net/ip/lwip_base/src/core/raw.c | 51 +-
net/ip/lwip_base/src/core/stats.c | 6 +-
net/ip/lwip_base/src/core/sys.c | 38 +
net/ip/lwip_base/src/core/tcp.c | 149 +-
net/ip/lwip_base/src/core/tcp_in.c | 88 +-
net/ip/lwip_base/src/core/tcp_out.c | 195 ++-
net/ip/lwip_base/src/core/timeouts.c | 4 +-
net/ip/lwip_base/src/core/udp.c | 72 +-
net/ip/lwip_base/src/netif/ethernet.c | 20 +-
net/ip/lwip_base/src/netif/lowpan6.c | 103 +-
net/ip/lwip_base/src/netif/ppp/auth.c | 10 +-
net/ip/lwip_base/src/netif/ppp/ipcp.c | 120 +-
net/ip/lwip_base/src/netif/ppp/ipv6cp.c | 4 +-
net/ip/lwip_base/src/netif/ppp/multilink.c | 4 +-
net/ip/lwip_base/src/netif/ppp/ppp.c | 19 +-
net/ip/lwip_base/src/netif/ppp/pppapi.c | 5 +
net/ip/lwip_base/src/netif/ppp/pppoe.c | 19 +-
net/ip/lwip_base/src/netif/ppp/pppol2tp.c | 9 +-
net/ip/lwip_base/src/netif/ppp/pppos.c | 40 +-
net/ip/lwip_base/src/netif/ppp/utils.c | 4 +-
net/ip/lwip_base/src/netif/ppp/vj.c | 62 +-
net/ip/lwip_base/src/netif/slipif.c | 2 +-
net/ip/lwip_base/test/fuzz/Makefile | 53 +
net/ip/lwip_base/test/fuzz/README | 34 +
net/ip/lwip_base/test/fuzz/config.h | 0
net/ip/lwip_base/test/fuzz/fuzz.c | 136 ++
.../lwip_base/test/fuzz/inputs/arp/arp_req.bin | Bin 0 -> 42 bytes
.../test/fuzz/inputs/icmp/icmp_ping.bin | Bin 0 -> 98 bytes
.../fuzz/inputs/ipv6/neighbor_solicitation.bin | Bin 0 -> 86 bytes
.../test/fuzz/inputs/ipv6/router_adv.bin | Bin 0 -> 118 bytes
.../lwip_base/test/fuzz/inputs/tcp/tcp_syn.bin | Bin 0 -> 74 bytes
.../test/fuzz/inputs/udp/udp_port_5000.bin | Bin 0 -> 50 bytes
net/ip/lwip_base/test/fuzz/lwipopts.h | 68 +
net/ip/lwip_base/test/fuzz/output_to_pcap.sh | 31 +
net/ip/lwip_base/test/unit/core/test_mem.h | 8 -
net/ip/lwip_base/test/unit/core/test_pbuf.h | 8 -
net/ip/lwip_base/test/unit/dhcp/test_dhcp.c | 113 +-
net/ip/lwip_base/test/unit/dhcp/test_dhcp.h | 8 -
net/ip/lwip_base/test/unit/etharp/test_etharp.h | 8 -
net/ip/lwip_base/test/unit/lwip_check.h | 8 -
net/ip/lwip_base/test/unit/lwipopts.h | 8 -
net/ip/lwip_base/test/unit/mdns/test_mdns.c | 71 +-
net/ip/lwip_base/test/unit/mdns/test_mdns.h | 8 -
net/ip/lwip_base/test/unit/tcp/tcp_helper.c | 23 +-
net/ip/lwip_base/test/unit/tcp/tcp_helper.h | 8 -
net/ip/lwip_base/test/unit/tcp/test_tcp.c | 18 +-
net/ip/lwip_base/test/unit/tcp/test_tcp.h | 8 -
net/ip/lwip_base/test/unit/tcp/test_tcp_oos.h | 8 -
net/ip/lwip_base/test/unit/udp/test_udp.h | 8 -
net/ip/mn_socket/include/mn_socket/mn_socket.h | 7 +
net/ip/mn_socket/src/mn_socket.c | 16 +
net/ip/native_sockets/src/native_itf.c | 5 +-
net/ip/pkg.yml | 7 +
net/ip/src/ip_init.c | 5 +
net/ip/src/ip_priv.h | 3 +
net/ip/src/lwip_cli.c | 140 ++
net/ip/src/lwip_if.c | 17 +-
net/ip/src/lwip_socket.c | 179 ++-
net/ip/syscfg.yml | 26 +
net/nimble/host/src/ble_att_clt.c | 2 +-
net/nimble/host/test/src/ble_gatt_disc_s_test.c | 2 +
net/nimble/host/test/src/ble_hs_test_util.c | 35 +
net/nimble/host/test/src/ble_hs_test_util.h | 6 +
net/nimble/transport/uart/src/ble_hci_uart.c | 12 +-
sys/console/full/include/console/console.h | 2 +-
sys/console/full/src/cons_fmt.c | 40 +-
sys/console/minimal/include/console/console.h | 5 +-
sys/console/stub/include/console/console.h | 5 +-
261 files changed, 10406 insertions(+), 3803 deletions(-)
----------------------------------------------------------------------
[19/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-728;
support native arch armv7.
Posted by ja...@apache.org.
MYNEWT-728; support native arch armv7.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/6d3edb39
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/6d3edb39
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/6d3edb39
Branch: refs/heads/bluetooth5
Commit: 6d3edb39595ad958b04a24e21d854429857bea84
Parents: 31d00cb
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Apr 19 15:30:36 2017 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Apr 19 15:30:36 2017 -0700
----------------------------------------------------------------------
compiler/sim-armv7/compiler.yml | 41 ++
compiler/sim-armv7/pkg.yml | 28 ++
.../os/include/os/arch/sim-armv7/os/os_arch.h | 82 ++++
kernel/os/src/arch/sim-armv7/os_arch_sim.c | 457 +++++++++++++++++++
.../os/src/arch/sim-armv7/os_arch_stack_frame.s | 47 ++
kernel/os/src/arch/sim-armv7/os_fault.c | 39 ++
6 files changed, 694 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d3edb39/compiler/sim-armv7/compiler.yml
----------------------------------------------------------------------
diff --git a/compiler/sim-armv7/compiler.yml b/compiler/sim-armv7/compiler.yml
new file mode 100644
index 0000000..79a710f
--- /dev/null
+++ b/compiler/sim-armv7/compiler.yml
@@ -0,0 +1,41 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Default.
+compiler.path.cc: "gcc"
+compiler.path.cpp: "g++"
+compiler.path.as: "gcc"
+compiler.path.archive: "ar"
+compiler.path.objdump: "objdump"
+compiler.path.objsize: "size"
+compiler.path.objcopy: "objcopy"
+compiler.flags.base: >
+ -Wall -Werror -ggdb -DARCH_sim
+compiler.ld.resolve_circular_deps: true
+
+compiler.flags.default: [compiler.flags.base, -O1]
+compiler.flags.debug: [compiler.flags.base, -O0]
+compiler.as.flags: [-x, assembler-with-cpp]
+compiler.ld.mapfile: false
+compiler.ld.binfile: false
+
+# Linux.
+compiler.flags.base.LINUX: >
+ -DMN_LINUX
+compiler.ld.flags.LINUX: -lutil
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d3edb39/compiler/sim-armv7/pkg.yml
----------------------------------------------------------------------
diff --git a/compiler/sim-armv7/pkg.yml b/compiler/sim-armv7/pkg.yml
new file mode 100644
index 0000000..d5a7ec7
--- /dev/null
+++ b/compiler/sim-armv7/pkg.yml
@@ -0,0 +1,28 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+pkg.name: compiler/sim-armv7
+pkg.type: compiler
+pkg.description: Compiler definition for native gcc compiler.
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
+pkg.keywords:
+ - sim
+ - compiler
+ - gcc
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d3edb39/kernel/os/include/os/arch/sim-armv7/os/os_arch.h
----------------------------------------------------------------------
diff --git a/kernel/os/include/os/arch/sim-armv7/os/os_arch.h b/kernel/os/include/os/arch/sim-armv7/os/os_arch.h
new file mode 100644
index 0000000..80f886f
--- /dev/null
+++ b/kernel/os/include/os/arch/sim-armv7/os/os_arch.h
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef _OS_ARCH_SIM_H
+#define _OS_ARCH_SIM_H
+
+#include <mcu/mcu_sim.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct os_task;
+
+/* CPU status register */
+typedef unsigned int os_sr_t;
+/* Stack type, aligned to a 32-bit word. */
+#define OS_STACK_PATTERN (0xdeadbeef)
+
+typedef unsigned int os_stack_t;
+#define OS_ALIGNMENT (4)
+#define OS_STACK_ALIGNMENT (16)
+
+/*
+ * Stack sizes for common OS tasks
+ */
+#define OS_SANITY_STACK_SIZE (1024)
+#define OS_IDLE_STACK_SIZE (1024)
+
+/*
+ * The 'sim' architecture-specific code does not have as much control on
+ * stack usage as the real embedded architectures.
+ *
+ * For e.g. the space occupied by the signal handler frame on the task
+ * stack is entirely dependent on the host OS.
+ *
+ * Deal with this by scaling the stack size by a factor of 16. The scaling
+ * factor can be arbitrarily large because the stacks are allocated from
+ * BSS and thus don't add to either the executable size or resident
+ * memory.
+ */
+#define OS_STACK_ALIGN(__nmemb) \
+ (OS_ALIGN(((__nmemb) * 16), OS_STACK_ALIGNMENT))
+
+/* Enter a critical section, save processor state, and block interrupts */
+#define OS_ENTER_CRITICAL(__os_sr) (__os_sr = os_arch_save_sr())
+/* Exit a critical section, restore processor state and unblock interrupts */
+#define OS_EXIT_CRITICAL(__os_sr) (os_arch_restore_sr(__os_sr))
+#define OS_ASSERT_CRITICAL() (assert(os_arch_in_critical()))
+
+void _Die(char *file, int line);
+
+os_stack_t *os_arch_task_stack_init(struct os_task *, os_stack_t *, int);
+void os_arch_ctx_sw(struct os_task *);
+os_sr_t os_arch_save_sr(void);
+void os_arch_restore_sr(os_sr_t sr);
+int os_arch_in_critical(void);
+os_error_t os_arch_os_init(void);
+void os_arch_os_stop(void);
+os_error_t os_arch_os_start(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OS_ARCH_SIM_H */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d3edb39/kernel/os/src/arch/sim-armv7/os_arch_sim.c
----------------------------------------------------------------------
diff --git a/kernel/os/src/arch/sim-armv7/os_arch_sim.c b/kernel/os/src/arch/sim-armv7/os_arch_sim.c
new file mode 100644
index 0000000..67d1a6e
--- /dev/null
+++ b/kernel/os/src/arch/sim-armv7/os_arch_sim.c
@@ -0,0 +1,457 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "os/os.h"
+#include "os_priv.h"
+
+#include <hal/hal_bsp.h>
+
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <sys/time.h>
+#include <assert.h>
+
+struct stack_frame {
+ int sf_mainsp; /* stack on which main() is executing */
+ sigjmp_buf sf_jb;
+ struct os_task *sf_task;
+};
+
+/*
+ * Assert that 'sf_mainsp' and 'sf_jb' are at the specific offsets where
+ * os_arch_frame_init() expects them to be.
+ */
+CTASSERT(offsetof(struct stack_frame, sf_mainsp) == 0);
+CTASSERT(offsetof(struct stack_frame, sf_jb) == 8);
+
+extern void os_arch_frame_init(struct stack_frame *sf);
+
+#define sim_setjmp(__jb) sigsetjmp(__jb, 0)
+#define sim_longjmp(__jb, __ret) siglongjmp(__jb, __ret)
+
+#define OS_USEC_PER_TICK (1000000 / OS_TICKS_PER_SEC)
+
+static pid_t mypid;
+static sigset_t allsigs, nosigs;
+static void timer_handler(int sig);
+
+static bool suspended; /* process is blocked in sigsuspend() */
+static sigset_t suspsigs; /* signals delivered in sigsuspend() */
+
+/*
+ * Called from 'os_arch_frame_init()' when setjmp returns indirectly via
+ * longjmp. The return value of setjmp is passed to this function as 'rc'.
+ */
+void
+os_arch_task_start(struct stack_frame *sf, int rc)
+{
+ struct os_task *task;
+
+ /*
+ * Interrupts are disabled when a task starts executing. This happens in
+ * two different ways:
+ * - via os_arch_os_start() for the first task.
+ * - via os_sched() for all other tasks.
+ *
+ * Enable interrupts before starting the task.
+ */
+ OS_EXIT_CRITICAL(0);
+
+ task = sf->sf_task;
+ task->t_func(task->t_arg);
+
+ /* This should never return */
+ assert(0);
+}
+
+os_stack_t *
+os_arch_task_stack_init(struct os_task *t, os_stack_t *stack_top, int size)
+{
+ struct stack_frame *sf;
+
+ sf = (struct stack_frame *) ((uint8_t *) stack_top - sizeof(*sf));
+ sf->sf_task = t;
+
+ os_arch_frame_init(sf);
+
+ return ((os_stack_t *)sf);
+}
+
+void
+os_arch_ctx_sw(struct os_task *next_t)
+{
+ /*
+ * gdb will stop execution of the program on most signals (e.g. SIGUSR1)
+ * whereas it passes SIGURG to the process without any special settings.
+ */
+ kill(mypid, SIGURG);
+}
+
+static void
+ctxsw_handler(int sig)
+{
+ struct os_task *t, *next_t;
+ struct stack_frame *sf;
+ int rc;
+
+ OS_ASSERT_CRITICAL();
+
+ /*
+ * Just record that this handler was called when the process was blocked.
+ * The handler will be called after sigsuspend() returns in the correct
+ * order.
+ */
+ if (suspended) {
+ sigaddset(&suspsigs, sig);
+ return;
+ }
+
+ t = os_sched_get_current_task();
+ next_t = os_sched_next_task();
+ if (t == next_t) {
+ /*
+ * Context switch not needed - just return.
+ */
+ return;
+ }
+
+ if (t) {
+ sf = (struct stack_frame *) t->t_stackptr;
+
+ rc = sim_setjmp(sf->sf_jb);
+ if (rc != 0) {
+ OS_ASSERT_CRITICAL();
+ return;
+ }
+ }
+
+ os_sched_ctx_sw_hook(next_t);
+
+ os_sched_set_current_task(next_t);
+
+ sf = (struct stack_frame *) next_t->t_stackptr;
+ sim_longjmp(sf->sf_jb, 1);
+}
+
+/*
+ * Disable signals and enter a critical section.
+ *
+ * Returns 1 if signals were already blocked and 0 otherwise.
+ */
+os_sr_t
+os_arch_save_sr(void)
+{
+ int error;
+ sigset_t omask;
+
+ error = sigprocmask(SIG_BLOCK, &allsigs, &omask);
+ assert(error == 0);
+
+ /*
+ * If any one of the signals in 'allsigs' is present in 'omask' then
+ * we are already inside a critical section.
+ */
+ return (sigismember(&omask, SIGALRM));
+}
+
+void
+os_arch_restore_sr(os_sr_t osr)
+{
+ int error;
+
+ OS_ASSERT_CRITICAL();
+ assert(osr == 0 || osr == 1);
+
+ if (osr == 1) {
+ /* Exiting a nested critical section */
+ return;
+ }
+
+ error = sigprocmask(SIG_UNBLOCK, &allsigs, NULL);
+ assert(error == 0);
+}
+
+int
+os_arch_in_critical(void)
+{
+ int error;
+ sigset_t omask;
+
+ error = sigprocmask(SIG_SETMASK, NULL, &omask);
+ assert(error == 0);
+
+ /*
+ * If any one of the signals in 'allsigs' is present in 'omask' then
+ * we are already inside a critical section.
+ */
+ return (sigismember(&omask, SIGALRM));
+}
+
+static struct {
+ int num;
+ void (*handler)(int sig);
+} signals[] = {
+ { SIGALRM, timer_handler },
+ { SIGURG, ctxsw_handler },
+};
+
+#define NUMSIGS (sizeof(signals)/sizeof(signals[0]))
+
+void
+os_tick_idle(os_time_t ticks)
+{
+ int i, rc, sig;
+ struct itimerval it;
+ void (*handler)(int sig);
+
+ OS_ASSERT_CRITICAL();
+
+ if (ticks > 0) {
+ /*
+ * Enter tickless regime and set the timer to fire after 'ticks'
+ * worth of time has elapsed.
+ */
+ it.it_value.tv_sec = ticks / OS_TICKS_PER_SEC;
+ it.it_value.tv_usec = (ticks % OS_TICKS_PER_SEC) * OS_USEC_PER_TICK;
+ it.it_interval.tv_sec = 0;
+ it.it_interval.tv_usec = OS_USEC_PER_TICK;
+ rc = setitimer(ITIMER_REAL, &it, NULL);
+ assert(rc == 0);
+ }
+
+ suspended = true;
+ sigemptyset(&suspsigs);
+ sigsuspend(&nosigs); /* Wait for a signal to wake us up */
+ suspended = false;
+
+ /*
+ * Call handlers for signals delivered to the process during sigsuspend().
+ * The SIGALRM handler is called before any other handlers to ensure that
+ * OS time is always correct.
+ */
+ if (sigismember(&suspsigs, SIGALRM)) {
+ timer_handler(SIGALRM);
+ }
+ for (i = 0; i < NUMSIGS; i++) {
+ sig = signals[i].num;
+ handler = signals[i].handler;
+ if (sig != SIGALRM && sigismember(&suspsigs, sig)) {
+ handler(sig);
+ }
+ }
+
+ if (ticks > 0) {
+ /*
+ * Enable the periodic timer interrupt.
+ */
+ it.it_value.tv_sec = 0;
+ it.it_value.tv_usec = OS_USEC_PER_TICK;
+ it.it_interval.tv_sec = 0;
+ it.it_interval.tv_usec = OS_USEC_PER_TICK;
+ rc = setitimer(ITIMER_REAL, &it, NULL);
+ assert(rc == 0);
+ }
+}
+
+static void
+signals_init(void)
+{
+ int i, error;
+ struct sigaction sa;
+
+ sigemptyset(&nosigs);
+ sigemptyset(&allsigs);
+ for (i = 0; i < NUMSIGS; i++) {
+ sigaddset(&allsigs, signals[i].num);
+ }
+
+ for (i = 0; i < NUMSIGS; i++) {
+ memset(&sa, 0, sizeof sa);
+ sa.sa_handler = signals[i].handler;
+ sa.sa_mask = allsigs;
+ sa.sa_flags = SA_RESTART;
+ error = sigaction(signals[i].num, &sa, NULL);
+ assert(error == 0);
+ }
+
+ /*
+ * We use SIGALRM as a proxy for 'allsigs' to check if we are inside
+ * a critical section (for e.g. see os_arch_in_critical()). Make sure
+ * that SIGALRM is indeed present in 'allsigs'.
+ */
+ assert(sigismember(&allsigs, SIGALRM));
+}
+
+static void
+signals_cleanup(void)
+{
+ int i, error;
+ struct sigaction sa;
+
+ for (i = 0; i < NUMSIGS; i++) {
+ memset(&sa, 0, sizeof sa);
+ sa.sa_handler = SIG_DFL;
+ error = sigaction(signals[i].num, &sa, NULL);
+ assert(error == 0);
+ }
+}
+
+static void
+timer_handler(int sig)
+{
+ struct timeval time_now, time_diff;
+ int ticks;
+
+ static struct timeval time_last;
+ static int time_inited;
+
+ OS_ASSERT_CRITICAL();
+
+ /*
+ * Just record that this handler was called when the process was blocked.
+ * The handler will be called after sigsuspend() returns in the proper
+ * order.
+ */
+ if (suspended) {
+ sigaddset(&suspsigs, sig);
+ return;
+ }
+
+ if (!time_inited) {
+ gettimeofday(&time_last, NULL);
+ time_inited = 1;
+ }
+
+ gettimeofday(&time_now, NULL);
+ if (timercmp(&time_now, &time_last, <)) {
+ /*
+ * System time going backwards.
+ */
+ time_last = time_now;
+ } else {
+ timersub(&time_now, &time_last, &time_diff);
+
+ ticks = time_diff.tv_sec * OS_TICKS_PER_SEC;
+ ticks += time_diff.tv_usec / OS_USEC_PER_TICK;
+
+ /*
+ * Update 'time_last' but account for the remainder usecs that did not
+ * contribute towards whole 'ticks'.
+ */
+ time_diff.tv_sec = 0;
+ time_diff.tv_usec %= OS_USEC_PER_TICK;
+ timersub(&time_now, &time_diff, &time_last);
+
+ os_time_advance(ticks);
+ }
+}
+
+static void
+start_timer(void)
+{
+ struct itimerval it;
+ int rc;
+
+ memset(&it, 0, sizeof(it));
+ it.it_value.tv_sec = 0;
+ it.it_value.tv_usec = OS_USEC_PER_TICK;
+ it.it_interval.tv_sec = 0;
+ it.it_interval.tv_usec = OS_USEC_PER_TICK;
+
+ rc = setitimer(ITIMER_REAL, &it, NULL);
+ assert(rc == 0);
+}
+
+static void
+stop_timer(void)
+{
+ struct itimerval it;
+ int rc;
+
+ memset(&it, 0, sizeof(it));
+
+ rc = setitimer(ITIMER_REAL, &it, NULL);
+ assert(rc == 0);
+}
+
+os_error_t
+os_arch_os_init(void)
+{
+ mypid = getpid();
+ g_current_task = NULL;
+
+ STAILQ_INIT(&g_os_task_list);
+ TAILQ_INIT(&g_os_run_list);
+ TAILQ_INIT(&g_os_sleep_list);
+
+ /*
+ * Setup all interrupt handlers.
+ *
+ * This must be done early because task initialization uses critical
+ * sections which function correctly only when 'allsigs' is initialized.
+ */
+ signals_init();
+
+ os_init_idle_task();
+
+ return OS_OK;
+}
+
+os_error_t
+os_arch_os_start(void)
+{
+ struct stack_frame *sf;
+ struct os_task *t;
+ os_sr_t sr;
+
+ /*
+ * Disable interrupts before enabling any interrupt sources. Pending
+ * interrupts will be recognized when the first task starts executing.
+ */
+ OS_ENTER_CRITICAL(sr);
+ assert(sr == 0);
+
+ /* Enable the interrupt sources */
+ start_timer();
+
+ t = os_sched_next_task();
+ os_sched_set_current_task(t);
+
+ g_os_started = 1;
+
+ sf = (struct stack_frame *) t->t_stackptr;
+ sim_longjmp(sf->sf_jb, 1);
+
+ return 0;
+}
+
+/**
+ * Stops the tick timer and clears the "started" flag. This function is only
+ * implemented for sim.
+ */
+void
+os_arch_os_stop(void)
+{
+ stop_timer();
+ signals_cleanup();
+ g_os_started = 0;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d3edb39/kernel/os/src/arch/sim-armv7/os_arch_stack_frame.s
----------------------------------------------------------------------
diff --git a/kernel/os/src/arch/sim-armv7/os_arch_stack_frame.s b/kernel/os/src/arch/sim-armv7/os_arch_stack_frame.s
new file mode 100644
index 0000000..460d54a
--- /dev/null
+++ b/kernel/os/src/arch/sim-armv7/os_arch_stack_frame.s
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#define sigsetjmp __sigsetjmp
+
+ .text
+ .p2align 4, 0x90 /* align on 16-byte boundary and fill with NOPs */
+
+ .globl os_arch_frame_init
+ /*
+ * void os_arch_frame_init(struct stack_frame *sf)
+ */
+os_arch_frame_init:
+ mov r1, sp
+ mov sp, r0 /* stack for the task starts from sf */
+ sub sp, sp, #20
+ str r1, [sp, #12]
+ str lr, [sp, #16] /* Store LR there */
+ str r0, [sp, #4] /* Store sf pointer to stack */
+ add r0, r0, #8 /* $r0 = sf->sf_jb */
+ mov r1, #0
+ bl __sigsetjmp
+ cmp r0, #0 /* If $r0 == 0 then return */
+ beq end
+ mov r1, r0
+ ldr r0, [sp, #4]
+ bl os_arch_task_start
+end:
+ ldr r1, [sp, #16] /* return $sp for the callee */
+ ldr sp, [sp, #12]
+ mov pc, r1
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d3edb39/kernel/os/src/arch/sim-armv7/os_fault.c
----------------------------------------------------------------------
diff --git a/kernel/os/src/arch/sim-armv7/os_fault.c b/kernel/os/src/arch/sim-armv7/os_fault.c
new file mode 100644
index 0000000..964202e
--- /dev/null
+++ b/kernel/os/src/arch/sim-armv7/os_fault.c
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "os/os.h"
+#include "os_priv.h"
+
+void
+__assert_func(const char *file, int line, const char *func, const char *e)
+{
+ char msg[256];
+
+ if (file) {
+ snprintf(msg, sizeof(msg), "assert @ %s:%d\n", file, line);
+ } else {
+ snprintf(msg, sizeof(msg), "assert @ %p\n",
+ __builtin_return_address(0));
+ }
+ write(1, msg, strlen(msg));
+ _exit(1);
+}
[42/50] [abbrv] incubator-mynewt-core git commit: apps/bleprph:
disable console input to save flash
Posted by ja...@apache.org.
apps/bleprph: disable console input to save flash
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/27ff3195
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/27ff3195
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/27ff3195
Branch: refs/heads/bluetooth5
Commit: 27ff31954fe450ae2d0d2282db7c0492995b277a
Parents: 6f73953
Author: Micha\u0142 Narajowski <mi...@codecoup.pl>
Authored: Thu Mar 23 13:40:04 2017 +0100
Committer: Micha\u0142 Narajowski <mi...@codecoup.pl>
Committed: Tue Apr 25 17:49:15 2017 -0700
----------------------------------------------------------------------
apps/bleprph/syscfg.yml | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27ff3195/apps/bleprph/syscfg.yml
----------------------------------------------------------------------
diff --git a/apps/bleprph/syscfg.yml b/apps/bleprph/syscfg.yml
index 9bc5db5..d9f69bb 100644
--- a/apps/bleprph/syscfg.yml
+++ b/apps/bleprph/syscfg.yml
@@ -21,6 +21,7 @@
syscfg.vals:
# Use INFO log level to reduce code size. DEBUG is too large for nRF51.
LOG_LEVEL: 1
+ CONSOLE_INPUT: 0
# Disable central and observer roles.
BLE_ROLE_BROADCASTER: 1
[47/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-696 NMP
datetime: always put usecs in rsp.
Posted by ja...@apache.org.
MYNEWT-696 NMP datetime: always put usecs in rsp.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/6ac1b82e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/6ac1b82e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/6ac1b82e
Branch: refs/heads/bluetooth5
Commit: 6ac1b82ef24fc45adb742e4fa872204faa4ea410
Parents: 5ec317d
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Apr 25 18:27:52 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Apr 25 18:27:52 2017 -0700
----------------------------------------------------------------------
time/datetime/src/datetime.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6ac1b82e/time/datetime/src/datetime.c
----------------------------------------------------------------------
diff --git a/time/datetime/src/datetime.c b/time/datetime/src/datetime.c
index 229866a..31a3641 100644
--- a/time/datetime/src/datetime.c
+++ b/time/datetime/src/datetime.c
@@ -379,23 +379,14 @@ datetime_format(const struct os_timeval *tv, const struct os_timezone *tz,
cp = ostr;
rlen = olen;
- rc = snprintf(cp, rlen, "%04d-%02d-%02dT%02d:%02d:%02d",
- ct.year, ct.mon, ct.day, ct.hour, ct.min, ct.sec);
+ rc = snprintf(cp, rlen, "%04d-%02d-%02dT%02d:%02d:%02d.%06d",
+ ct.year, ct.mon, ct.day, ct.hour, ct.min, ct.sec, ct.usec);
cp += rc;
rlen -= rc;
if (rc < 0 || rlen <= 0) {
goto err;
}
- if (ct.usec != 0) {
- rc = snprintf(cp, rlen, ".%06d", ct.usec);
- cp += rc;
- rlen -= rc;
- if (rc < 0 || rlen <= 0) {
- goto err;
- }
- }
-
if (tz != NULL) {
minswest = tz->tz_minuteswest;
if (tz->tz_dsttime) {
[49/50] [abbrv] incubator-mynewt-core git commit: This closes #242.
Posted by ja...@apache.org.
This closes #242.
Merge branch 'ble400' of https://github.com/utzig/incubator-mynewt-core
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/02fd7c76
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/02fd7c76
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/02fd7c76
Branch: refs/heads/bluetooth5
Commit: 02fd7c764dc11eb8ac21bc70633f4f9f3a1ea828
Parents: 7a1e0a8 323f784
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Apr 26 10:53:40 2017 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Apr 26 10:53:40 2017 -0700
----------------------------------------------------------------------
hw/bsp/ble400/ble400.cfg | 22 ++
hw/bsp/ble400/ble400_debug.cmd | 22 ++
hw/bsp/ble400/ble400_debug.sh | 38 +++
hw/bsp/ble400/ble400_download.cmd | 22 ++
hw/bsp/ble400/ble400_download.sh | 42 +++
hw/bsp/ble400/ble400_no_boot.ld | 179 ++++++++++++
hw/bsp/ble400/boot-nrf51xxac.ld | 25 ++
hw/bsp/ble400/bsp.yml | 64 +++++
hw/bsp/ble400/include/bsp/boards.h | 19 ++
hw/bsp/ble400/include/bsp/bsp.h | 53 ++++
hw/bsp/ble400/include/bsp/cmsis_nvic.h | 30 ++
hw/bsp/ble400/nrf51xxac.ld | 25 ++
hw/bsp/ble400/pkg.yml | 90 ++++++
hw/bsp/ble400/split-ble400.ld | 185 ++++++++++++
.../src/arch/cortex_m0/gcc_startup_nrf51.s | 283 +++++++++++++++++++
.../arch/cortex_m0/gcc_startup_nrf51_split.s | 185 ++++++++++++
hw/bsp/ble400/src/hal_bsp.c | 189 +++++++++++++
hw/bsp/ble400/src/sbrk.c | 57 ++++
hw/bsp/ble400/syscfg.yml | 97 +++++++
19 files changed, 1627 insertions(+)
----------------------------------------------------------------------
[41/50] [abbrv] incubator-mynewt-core git commit: nrf52dk bsp -
Delete empty file.
Posted by ja...@apache.org.
nrf52dk bsp - Delete empty file.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/5ec317d4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/5ec317d4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/5ec317d4
Branch: refs/heads/bluetooth5
Commit: 5ec317d4553d2990a0ed2f2addb3fe0b73744bd4
Parents: b16eed6
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Apr 24 19:04:55 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Apr 24 19:20:58 2017 -0700
----------------------------------------------------------------------
hw/bsp/nrf52dk/include/bsp/boards.h | 19 -------------------
1 file changed, 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5ec317d4/hw/bsp/nrf52dk/include/bsp/boards.h
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52dk/include/bsp/boards.h b/hw/bsp/nrf52dk/include/bsp/boards.h
deleted file mode 100644
index 560c31f..0000000
--- a/hw/bsp/nrf52dk/include/bsp/boards.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
[23/50] [abbrv] incubator-mynewt-core git commit: Merge branch
'console-num-chars' of https://github.com/ccollins476ad/incubator-mynewt-core
Posted by ja...@apache.org.
Merge branch 'console-num-chars' of https://github.com/ccollins476ad/incubator-mynewt-core
This closes #240. This closes #239.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/fd7bf2bf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/fd7bf2bf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/fd7bf2bf
Branch: refs/heads/bluetooth5
Commit: fd7bf2bf59e0dba634b12acf6fde576cbb26c9d0
Parents: b83face 80fb08c
Author: aditihilbert <ad...@runtime.io>
Authored: Wed Apr 19 18:06:04 2017 -0700
Committer: aditihilbert <ad...@runtime.io>
Committed: Wed Apr 19 18:06:04 2017 -0700
----------------------------------------------------------------------
sys/console/full/include/console/console.h | 2 +-
sys/console/full/src/cons_fmt.c | 40 +++++++++++++++++++---
sys/console/minimal/include/console/console.h | 5 +--
sys/console/stub/include/console/console.h | 5 +--
4 files changed, 42 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
[34/50] [abbrv] incubator-mynewt-core git commit: drivers/rtt: add
SEGGER RTT package
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d36cccb2/hw/drivers/rtt/src/SEGGER_RTT_printf.c
----------------------------------------------------------------------
diff --git a/hw/drivers/rtt/src/SEGGER_RTT_printf.c b/hw/drivers/rtt/src/SEGGER_RTT_printf.c
new file mode 100644
index 0000000..995a883
--- /dev/null
+++ b/hw/drivers/rtt/src/SEGGER_RTT_printf.c
@@ -0,0 +1,511 @@
+/*********************************************************************
+* SEGGER MICROCONTROLLER GmbH & Co. KG *
+* Solutions for real time microcontroller applications *
+**********************************************************************
+* *
+* (c) 2014 - 2016 SEGGER Microcontroller GmbH & Co. KG *
+* *
+* www.segger.com Support: support@segger.com *
+* *
+**********************************************************************
+* *
+* SEGGER RTT * Real Time Transfer for embedded targets *
+* *
+**********************************************************************
+* *
+* All rights reserved. *
+* *
+* SEGGER strongly recommends to not make any changes *
+* to or modify the source code of this software in order to stay *
+* compatible with the RTT protocol and J-Link. *
+* *
+* Redistribution and use in source and binary forms, with or *
+* without modification, are permitted provided that the following *
+* conditions are met: *
+* *
+* o Redistributions of source code must retain the above copyright *
+* notice, this list of conditions and the following disclaimer. *
+* *
+* o Redistributions in binary form 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. *
+* *
+* o Neither the name of SEGGER Microcontroller GmbH & Co. KG *
+* nor the names of its contributors may be used to endorse or *
+* promote products derived from this software without specific *
+* prior written permission. *
+* *
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
+* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
+* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
+* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller 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. *
+* *
+**********************************************************************
+---------------------------END-OF-HEADER------------------------------
+File : SEGGER_RTT_printf.c
+Purpose : Replacement for printf to write formatted data via RTT
+Revision: $Rev: 4351 $
+----------------------------------------------------------------------
+*/
+#include "rtt/SEGGER_RTT.h"
+#include "rtt/SEGGER_RTT_Conf.h"
+
+/*********************************************************************
+*
+* Defines, configurable
+*
+**********************************************************************
+*/
+
+#ifndef SEGGER_RTT_PRINTF_BUFFER_SIZE
+ #define SEGGER_RTT_PRINTF_BUFFER_SIZE (64)
+#endif
+
+#include <stdlib.h>
+#include <stdarg.h>
+
+
+#define FORMAT_FLAG_LEFT_JUSTIFY (1u << 0)
+#define FORMAT_FLAG_PAD_ZERO (1u << 1)
+#define FORMAT_FLAG_PRINT_SIGN (1u << 2)
+#define FORMAT_FLAG_ALTERNATE (1u << 3)
+
+/*********************************************************************
+*
+* Types
+*
+**********************************************************************
+*/
+
+typedef struct {
+ char* pBuffer;
+ unsigned BufferSize;
+ unsigned Cnt;
+
+ int ReturnValue;
+
+ unsigned RTTBufferIndex;
+} SEGGER_RTT_PRINTF_DESC;
+
+/*********************************************************************
+*
+* Function prototypes
+*
+**********************************************************************
+*/
+int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList);
+
+/*********************************************************************
+*
+* Static code
+*
+**********************************************************************
+*/
+/*********************************************************************
+*
+* _StoreChar
+*/
+static void _StoreChar(SEGGER_RTT_PRINTF_DESC * p, char c) {
+ unsigned Cnt;
+
+ Cnt = p->Cnt;
+ if ((Cnt + 1u) <= p->BufferSize) {
+ *(p->pBuffer + Cnt) = c;
+ p->Cnt = Cnt + 1u;
+ p->ReturnValue++;
+ }
+ //
+ // Write part of string, when the buffer is full
+ //
+ if (p->Cnt == p->BufferSize) {
+ if (SEGGER_RTT_Write(p->RTTBufferIndex, p->pBuffer, p->Cnt) != p->Cnt) {
+ p->ReturnValue = -1;
+ } else {
+ p->Cnt = 0u;
+ }
+ }
+}
+
+/*********************************************************************
+*
+* _PrintUnsigned
+*/
+static void _PrintUnsigned(SEGGER_RTT_PRINTF_DESC * pBufferDesc, unsigned v, unsigned Base, unsigned NumDigits, unsigned FieldWidth, unsigned FormatFlags) {
+ static const char _aV2C[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+ unsigned Div;
+ unsigned Digit;
+ unsigned Number;
+ unsigned Width;
+ char c;
+
+ Number = v;
+ Digit = 1u;
+ //
+ // Get actual field width
+ //
+ Width = 1u;
+ while (Number >= Base) {
+ Number = (Number / Base);
+ Width++;
+ }
+ if (NumDigits > Width) {
+ Width = NumDigits;
+ }
+ //
+ // Print leading chars if necessary
+ //
+ if ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0u) {
+ if (FieldWidth != 0u) {
+ if (((FormatFlags & FORMAT_FLAG_PAD_ZERO) == FORMAT_FLAG_PAD_ZERO) && (NumDigits == 0u)) {
+ c = '0';
+ } else {
+ c = ' ';
+ }
+ while ((FieldWidth != 0u) && (Width < FieldWidth)) {
+ FieldWidth--;
+ _StoreChar(pBufferDesc, c);
+ if (pBufferDesc->ReturnValue < 0) {
+ break;
+ }
+ }
+ }
+ }
+ if (pBufferDesc->ReturnValue >= 0) {
+ //
+ // Compute Digit.
+ // Loop until Digit has the value of the highest digit required.
+ // Example: If the output is 345 (Base 10), loop 2 times until Digit is 100.
+ //
+ while (1) {
+ if (NumDigits > 1u) { // User specified a min number of digits to print? => Make sure we loop at least that often, before checking anything else (> 1 check avoids problems with NumDigits being signed / unsigned)
+ NumDigits--;
+ } else {
+ Div = v / Digit;
+ if (Div < Base) { // Is our divider big enough to extract the highest digit from value? => Done
+ break;
+ }
+ }
+ Digit *= Base;
+ }
+ //
+ // Output digits
+ //
+ do {
+ Div = v / Digit;
+ v -= Div * Digit;
+ _StoreChar(pBufferDesc, _aV2C[Div]);
+ if (pBufferDesc->ReturnValue < 0) {
+ break;
+ }
+ Digit /= Base;
+ } while (Digit);
+ //
+ // Print trailing spaces if necessary
+ //
+ if ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == FORMAT_FLAG_LEFT_JUSTIFY) {
+ if (FieldWidth != 0u) {
+ while ((FieldWidth != 0u) && (Width < FieldWidth)) {
+ FieldWidth--;
+ _StoreChar(pBufferDesc, ' ');
+ if (pBufferDesc->ReturnValue < 0) {
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+
+/*********************************************************************
+*
+* _PrintInt
+*/
+static void _PrintInt(SEGGER_RTT_PRINTF_DESC * pBufferDesc, int v, unsigned Base, unsigned NumDigits, unsigned FieldWidth, unsigned FormatFlags) {
+ unsigned Width;
+ int Number;
+
+ Number = (v < 0) ? -v : v;
+
+ //
+ // Get actual field width
+ //
+ Width = 1u;
+ while (Number >= (int)Base) {
+ Number = (Number / (int)Base);
+ Width++;
+ }
+ if (NumDigits > Width) {
+ Width = NumDigits;
+ }
+ if ((FieldWidth > 0u) && ((v < 0) || ((FormatFlags & FORMAT_FLAG_PRINT_SIGN) == FORMAT_FLAG_PRINT_SIGN))) {
+ FieldWidth--;
+ }
+
+ //
+ // Print leading spaces if necessary
+ //
+ if ((((FormatFlags & FORMAT_FLAG_PAD_ZERO) == 0u) || (NumDigits != 0u)) && ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0u)) {
+ if (FieldWidth != 0u) {
+ while ((FieldWidth != 0u) && (Width < FieldWidth)) {
+ FieldWidth--;
+ _StoreChar(pBufferDesc, ' ');
+ if (pBufferDesc->ReturnValue < 0) {
+ break;
+ }
+ }
+ }
+ }
+ //
+ // Print sign if necessary
+ //
+ if (pBufferDesc->ReturnValue >= 0) {
+ if (v < 0) {
+ v = -v;
+ _StoreChar(pBufferDesc, '-');
+ } else if ((FormatFlags & FORMAT_FLAG_PRINT_SIGN) == FORMAT_FLAG_PRINT_SIGN) {
+ _StoreChar(pBufferDesc, '+');
+ } else {
+
+ }
+ if (pBufferDesc->ReturnValue >= 0) {
+ //
+ // Print leading zeros if necessary
+ //
+ if (((FormatFlags & FORMAT_FLAG_PAD_ZERO) == FORMAT_FLAG_PAD_ZERO) && ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0u) && (NumDigits == 0u)) {
+ if (FieldWidth != 0u) {
+ while ((FieldWidth != 0u) && (Width < FieldWidth)) {
+ FieldWidth--;
+ _StoreChar(pBufferDesc, '0');
+ if (pBufferDesc->ReturnValue < 0) {
+ break;
+ }
+ }
+ }
+ }
+ if (pBufferDesc->ReturnValue >= 0) {
+ //
+ // Print number without sign
+ //
+ _PrintUnsigned(pBufferDesc, (unsigned)v, Base, NumDigits, FieldWidth, FormatFlags);
+ }
+ }
+ }
+}
+
+/*********************************************************************
+*
+* Public code
+*
+**********************************************************************
+*/
+/*********************************************************************
+*
+* SEGGER_RTT_vprintf
+*
+* Function description
+* Stores a formatted string in SEGGER RTT control block.
+* This data is read by the host.
+*
+* Parameters
+* BufferIndex Index of "Up"-buffer to be used. (e.g. 0 for "Terminal")
+* sFormat Pointer to format string
+* pParamList Pointer to the list of arguments for the format string
+*
+* Return values
+* >= 0: Number of bytes which have been stored in the "Up"-buffer.
+* < 0: Error
+*/
+int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList) {
+ char c;
+ SEGGER_RTT_PRINTF_DESC BufferDesc;
+ int v;
+ unsigned NumDigits;
+ unsigned FormatFlags;
+ unsigned FieldWidth;
+ char acBuffer[SEGGER_RTT_PRINTF_BUFFER_SIZE];
+
+ BufferDesc.pBuffer = acBuffer;
+ BufferDesc.BufferSize = SEGGER_RTT_PRINTF_BUFFER_SIZE;
+ BufferDesc.Cnt = 0u;
+ BufferDesc.RTTBufferIndex = BufferIndex;
+ BufferDesc.ReturnValue = 0;
+
+ do {
+ c = *sFormat;
+ sFormat++;
+ if (c == 0u) {
+ break;
+ }
+ if (c == '%') {
+ //
+ // Filter out flags
+ //
+ FormatFlags = 0u;
+ v = 1;
+ do {
+ c = *sFormat;
+ switch (c) {
+ case '-': FormatFlags |= FORMAT_FLAG_LEFT_JUSTIFY; sFormat++; break;
+ case '0': FormatFlags |= FORMAT_FLAG_PAD_ZERO; sFormat++; break;
+ case '+': FormatFlags |= FORMAT_FLAG_PRINT_SIGN; sFormat++; break;
+ case '#': FormatFlags |= FORMAT_FLAG_ALTERNATE; sFormat++; break;
+ default: v = 0; break;
+ }
+ } while (v);
+ //
+ // filter out field with
+ //
+ FieldWidth = 0u;
+ do {
+ c = *sFormat;
+ if ((c < '0') || (c > '9')) {
+ break;
+ }
+ sFormat++;
+ FieldWidth = (FieldWidth * 10u) + ((unsigned)c - '0');
+ } while (1);
+
+ //
+ // Filter out precision (number of digits to display)
+ //
+ NumDigits = 0u;
+ c = *sFormat;
+ if (c == '.') {
+ sFormat++;
+ do {
+ c = *sFormat;
+ if ((c < '0') || (c > '9')) {
+ break;
+ }
+ sFormat++;
+ NumDigits = NumDigits * 10u + ((unsigned)c - '0');
+ } while (1);
+ }
+ //
+ // Filter out length modifier
+ //
+ c = *sFormat;
+ do {
+ if ((c == 'l') || (c == 'h')) {
+ sFormat++;
+ c = *sFormat;
+ } else {
+ break;
+ }
+ } while (1);
+ //
+ // Handle specifiers
+ //
+ switch (c) {
+ case 'c': {
+ char c0;
+ v = va_arg(*pParamList, int);
+ c0 = (char)v;
+ _StoreChar(&BufferDesc, c0);
+ break;
+ }
+ case 'd':
+ v = va_arg(*pParamList, int);
+ _PrintInt(&BufferDesc, v, 10u, NumDigits, FieldWidth, FormatFlags);
+ break;
+ case 'u':
+ v = va_arg(*pParamList, int);
+ _PrintUnsigned(&BufferDesc, (unsigned)v, 10u, NumDigits, FieldWidth, FormatFlags);
+ break;
+ case 'x':
+ case 'X':
+ v = va_arg(*pParamList, int);
+ _PrintUnsigned(&BufferDesc, (unsigned)v, 16u, NumDigits, FieldWidth, FormatFlags);
+ break;
+ case 's':
+ {
+ const char * s = va_arg(*pParamList, const char *);
+ do {
+ c = *s;
+ s++;
+ if (c == '\0') {
+ break;
+ }
+ _StoreChar(&BufferDesc, c);
+ } while (BufferDesc.ReturnValue >= 0);
+ }
+ break;
+ case 'p':
+ v = va_arg(*pParamList, int);
+ _PrintUnsigned(&BufferDesc, (unsigned)v, 16u, 8u, 8u, 0u);
+ break;
+ case '%':
+ _StoreChar(&BufferDesc, '%');
+ break;
+ default:
+ break;
+ }
+ sFormat++;
+ } else {
+ _StoreChar(&BufferDesc, c);
+ }
+ } while (BufferDesc.ReturnValue >= 0);
+
+ if (BufferDesc.ReturnValue > 0) {
+ //
+ // Write remaining data, if any
+ //
+ if (BufferDesc.Cnt != 0u) {
+ SEGGER_RTT_Write(BufferIndex, acBuffer, BufferDesc.Cnt);
+ }
+ BufferDesc.ReturnValue += (int)BufferDesc.Cnt;
+ }
+ return BufferDesc.ReturnValue;
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_printf
+*
+* Function description
+* Stores a formatted string in SEGGER RTT control block.
+* This data is read by the host.
+*
+* Parameters
+* BufferIndex Index of "Up"-buffer to be used. (e.g. 0 for "Terminal")
+* sFormat Pointer to format string, followed by the arguments for conversion
+*
+* Return values
+* >= 0: Number of bytes which have been stored in the "Up"-buffer.
+* < 0: Error
+*
+* Notes
+* (1) Conversion specifications have following syntax:
+* %[flags][FieldWidth][.Precision]ConversionSpecifier
+* (2) Supported flags:
+* -: Left justify within the field width
+* +: Always print sign extension for signed conversions
+* 0: Pad with 0 instead of spaces. Ignored when using '-'-flag or precision
+* Supported conversion specifiers:
+* c: Print the argument as one char
+* d: Print the argument as a signed integer
+* u: Print the argument as an unsigned integer
+* x: Print the argument as an hexadecimal integer
+* s: Print the string pointed to by the argument
+* p: Print the argument as an 8-digit hexadecimal integer. (Argument shall be a pointer to void.)
+*/
+int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...) {
+ int r;
+ va_list ParamList;
+
+ va_start(ParamList, sFormat);
+ r = SEGGER_RTT_vprintf(BufferIndex, sFormat, &ParamList);
+ va_end(ParamList);
+ return r;
+}
+/*************************** End of file ****************************/
[21/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-734
console_printf() return # printed chrs.
Posted by ja...@apache.org.
MYNEWT-734 console_printf() return # printed chrs.
The *printf family of functions do this. It is useful for aligning text.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/80fb08ca
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/80fb08ca
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/80fb08ca
Branch: refs/heads/bluetooth5
Commit: 80fb08cac5ce1d56c7662b3e549acea6264b47f1
Parents: 31d00cb
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Apr 19 16:20:33 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Apr 19 16:34:01 2017 -0700
----------------------------------------------------------------------
sys/console/full/include/console/console.h | 2 +-
sys/console/full/src/cons_fmt.c | 40 +++++++++++++++++++---
sys/console/minimal/include/console/console.h | 5 +--
sys/console/stub/include/console/console.h | 5 +--
4 files changed, 42 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/80fb08ca/sys/console/full/include/console/console.h
----------------------------------------------------------------------
diff --git a/sys/console/full/include/console/console.h b/sys/console/full/include/console/console.h
index 054b997..c7ae04c 100644
--- a/sys/console/full/include/console/console.h
+++ b/sys/console/full/include/console/console.h
@@ -34,7 +34,7 @@ int console_read(char *str, int cnt, int *newline);
void console_blocking_mode(void);
void console_echo(int on);
-void console_printf(const char *fmt, ...)
+int console_printf(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));;
extern int console_is_midline;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/80fb08ca/sys/console/full/src/cons_fmt.c
----------------------------------------------------------------------
diff --git a/sys/console/full/src/cons_fmt.c b/sys/console/full/src/cons_fmt.c
index 83c9ca0..1a3c72e 100644
--- a/sys/console/full/src/cons_fmt.c
+++ b/sys/console/full/src/cons_fmt.c
@@ -38,43 +38,73 @@ static const FILE console_file = {
.vmt = &console_file_ops
};
-void
+/**
+ * Prints the specified format string to the console.
+ *
+ * @return The number of characters that would have been
+ * printed if the console buffer were
+ * unlimited. This return value is analogous
+ * to that of snprintf.
+ */
+int
console_printf(const char *fmt, ...)
{
va_list args;
+ int num_chars;
+
+ num_chars = 0;
+
if (console_get_ticks()) {
/* Prefix each line with a timestamp. */
if (!console_is_midline) {
- fprintf((FILE *)&console_file, "%lu:", (unsigned long)os_time_get());
+ num_chars += fprintf((FILE *)&console_file, "%lu:",
+ (unsigned long)os_time_get());
}
}
va_start(args, fmt);
- vfprintf((FILE *)&console_file, fmt, args);
+ num_chars += vfprintf((FILE *)&console_file, fmt, args);
va_end(args);
+
+ return num_chars;
}
#else
-void
+/**
+ * Prints the specified format string to the console.
+ *
+ * @return The number of characters that would have been
+ * printed if the console buffer were
+ * unlimited. This return value is analogous
+ * to that of snprintf.
+ */
+int
console_printf(const char *fmt, ...)
{
va_list args;
char buf[CONS_OUTPUT_MAX_LINE];
+ int num_chars;
int len;
+
if (console_get_ticks()) {
/* Prefix each line with a timestamp. */
if (!console_is_midline) {
- len = snprintf(buf, sizeof(buf), "%lu:", (unsigned long)os_time_get());
+ len = snprintf(buf, sizeof(buf), "%lu:",
+ (unsigned long)os_time_get());
+ num_chars += len;
console_write(buf, len);
}
}
va_start(args, fmt);
len = vsnprintf(buf, sizeof(buf), fmt, args);
+ num_chars += len;
if (len >= sizeof(buf)) {
len = sizeof(buf) - 1;
}
console_write(buf, len);
va_end(args);
+
+ return num_chars;
}
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/80fb08ca/sys/console/minimal/include/console/console.h
----------------------------------------------------------------------
diff --git a/sys/console/minimal/include/console/console.h b/sys/console/minimal/include/console/console.h
index 384b6a9..61f6534 100644
--- a/sys/console/minimal/include/console/console.h
+++ b/sys/console/minimal/include/console/console.h
@@ -46,11 +46,12 @@ console_echo(int on)
{
}
-static void console_printf(const char *fmt, ...)
+static int console_printf(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));;
-static void inline
+static int inline
console_printf(const char *fmt, ...)
{
+ return 0;
}
#define console_is_midline 0
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/80fb08ca/sys/console/stub/include/console/console.h
----------------------------------------------------------------------
diff --git a/sys/console/stub/include/console/console.h b/sys/console/stub/include/console/console.h
index ca7a1b9..3c83b9d 100644
--- a/sys/console/stub/include/console/console.h
+++ b/sys/console/stub/include/console/console.h
@@ -56,12 +56,13 @@ console_write(const char *str, int cnt)
{
}
-static void inline console_printf(const char *fmt, ...)
+static int inline console_printf(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));
-static void inline
+static int inline
console_printf(const char *fmt, ...)
{
+ return 0;
}
static void inline
[30/50] [abbrv] incubator-mynewt-core git commit: nimble/transport;
MYNEWT-737: Make ble_hci_uart_tx_char more efficient
Posted by ja...@apache.org.
nimble/transport; MYNEWT-737: Make ble_hci_uart_tx_char more efficient
Modified the code in ble_hci_uart_tx_char to be faster. This
added a bit more code (should not have increased ram usage) and
should in general be faster than the old method and should also
free the mbufs slightly faster (each one is freed as it is
used).
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/be6ce3cc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/be6ce3cc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/be6ce3cc
Branch: refs/heads/bluetooth5
Commit: be6ce3cc261f0fedee0807ce85aae0b287d13dd2
Parents: 271ab1b
Author: William San Filippo <wi...@runtime.io>
Authored: Thu Apr 20 19:36:37 2017 -0700
Committer: William San Filippo <wi...@runtime.io>
Committed: Thu Apr 20 19:36:37 2017 -0700
----------------------------------------------------------------------
net/nimble/transport/uart/src/ble_hci_uart.c | 65 +++++++++++++++++++----
1 file changed, 54 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/be6ce3cc/net/nimble/transport/uart/src/ble_hci_uart.c
----------------------------------------------------------------------
diff --git a/net/nimble/transport/uart/src/ble_hci_uart.c b/net/nimble/transport/uart/src/ble_hci_uart.c
index 9de4ad7..a4c1855 100755
--- a/net/nimble/transport/uart/src/ble_hci_uart.c
+++ b/net/nimble/transport/uart/src/ble_hci_uart.c
@@ -125,6 +125,16 @@ struct ble_hci_uart_pkt {
uint8_t type;
};
+/**
+ * Structure for transmitting ACL packets over UART
+ *
+ */
+struct ble_hci_uart_h4_acl_tx
+{
+ uint8_t *dptr;
+ struct os_mbuf *tx_acl;
+};
+
static struct {
/*** State of data received over UART. */
uint8_t rx_type; /* Pending packet type. 0 means nothing pending */
@@ -135,9 +145,10 @@ static struct {
/*** State of data transmitted over UART. */
uint8_t tx_type; /* Pending packet type. 0 means nothing pending */
+ uint16_t rem_tx_len; /* Used for acl tx only currently */
union {
struct ble_hci_uart_cmd tx_cmd;
- struct os_mbuf *tx_acl;
+ struct ble_hci_uart_h4_acl_tx tx_pkt;
};
STAILQ_HEAD(, ble_hci_uart_pkt) tx_pkts; /* Packet queue to send to UART */
} ble_hci_uart_state;
@@ -170,6 +181,12 @@ ble_hci_uart_acl_tx(struct os_mbuf *om)
struct ble_hci_uart_pkt *pkt;
os_sr_t sr;
+ /* If this packet is zero length, just free it */
+ if (OS_MBUF_PKTLEN(om) == 0) {
+ os_mbuf_free_chain(om);
+ return 0;
+ }
+
pkt = os_memblock_get(&ble_hci_uart_pkt_pool);
if (pkt == NULL) {
os_mbuf_free_chain(om);
@@ -220,6 +237,7 @@ static int
ble_hci_uart_tx_pkt_type(void)
{
struct ble_hci_uart_pkt *pkt;
+ struct os_mbuf *om;
os_sr_t sr;
int rc;
@@ -255,7 +273,12 @@ ble_hci_uart_tx_pkt_type(void)
case BLE_HCI_UART_H4_ACL:
ble_hci_uart_state.tx_type = BLE_HCI_UART_H4_ACL;
- ble_hci_uart_state.tx_acl = pkt->data;
+ om = (struct os_mbuf *)pkt->data;
+ /* NOTE: first mbuf must have non-zero length */
+ os_mbuf_trim_front(om);
+ ble_hci_uart_state.tx_pkt.tx_acl = om;
+ ble_hci_uart_state.tx_pkt.dptr = om->om_data;
+ ble_hci_uart_state.rem_tx_len = OS_MBUF_PKTLEN(om);
break;
default:
@@ -276,7 +299,8 @@ static int
ble_hci_uart_tx_char(void *arg)
{
uint8_t u8;
- int rc = -1;
+ int rc;
+ struct os_mbuf *om;
switch (ble_hci_uart_state.tx_type) {
case BLE_HCI_UART_H4_NONE: /* No pending packet, pick one from the queue */
@@ -297,17 +321,36 @@ ble_hci_uart_tx_char(void *arg)
/* Copy the first unsent byte from the tx buffer and remove it from the
* source.
*/
- os_mbuf_copydata(ble_hci_uart_state.tx_acl, 0, 1, &u8);
- os_mbuf_adj(ble_hci_uart_state.tx_acl, 1);
-
- /* Free the tx buffer if this is the last byte to send. */
- if (OS_MBUF_PKTLEN(ble_hci_uart_state.tx_acl) == 0) {
- os_mbuf_free_chain(ble_hci_uart_state.tx_acl);
+ u8 = ble_hci_uart_state.tx_pkt.dptr[0];
+ --ble_hci_uart_state.rem_tx_len;
+ if (ble_hci_uart_state.rem_tx_len == 0) {
+ os_mbuf_free_chain(ble_hci_uart_state.tx_pkt.tx_acl);
ble_hci_uart_state.tx_type = BLE_HCI_UART_H4_NONE;
+ } else {
+ om = ble_hci_uart_state.tx_pkt.tx_acl;
+ --om->om_len;
+ if (om->om_len == 0) {
+ /* Remove and free any zero mbufs */
+ while ((om != NULL) && (om->om_len == 0)) {
+ ble_hci_uart_state.tx_pkt.tx_acl = SLIST_NEXT(om, om_next);
+ os_mbuf_free(om);
+ om = ble_hci_uart_state.tx_pkt.tx_acl;
+ }
+ /* NOTE: om should never be NULL! What to do? */
+ if (om == NULL) {
+ ble_hci_uart_state.tx_type = BLE_HCI_UART_H4_NONE;
+ } else {
+ ble_hci_uart_state.tx_pkt.dptr = om->om_data;
+ }
+ } else {
+ ble_hci_uart_state.tx_pkt.dptr++;
+ }
}
-
rc = u8;
break;
+ default:
+ rc = -1;
+ break;
}
return rc;
@@ -931,7 +974,7 @@ ble_hci_trans_reset(void)
ble_hci_uart_free_pkt(ble_hci_uart_state.tx_type,
ble_hci_uart_state.tx_cmd.data,
- ble_hci_uart_state.tx_acl);
+ ble_hci_uart_state.tx_pkt.tx_acl);
ble_hci_uart_state.tx_type = BLE_HCI_UART_H4_NONE;
while ((pkt = STAILQ_FIRST(&ble_hci_uart_state.tx_pkts)) != NULL) {
[37/50] [abbrv] incubator-mynewt-core git commit: This closes #244.
Posted by ja...@apache.org.
This closes #244.
Merge branch 'dev_20170423' of https://github.com/wesley-wu/incubator-mynewt-core
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/ce47d845
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/ce47d845
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/ce47d845
Branch: refs/heads/bluetooth5
Commit: ce47d8450b153a2ac062534a7857b26192032f8a
Parents: 271ab1b cabdff9
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Apr 24 17:04:43 2017 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Apr 24 17:04:43 2017 -0700
----------------------------------------------------------------------
hw/mcu/stm/stm32f4xx/src/hal_flash.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
[10/50] [abbrv] incubator-mynewt-core git commit: hw/bsp: MYNEWT-730
Add BSP for Ruuvi tag
Posted by ja...@apache.org.
hw/bsp: MYNEWT-730 Add BSP for Ruuvi tag
Add BSP for Ruuvi tag revision B3/B4. Not sure if this same BSP
will work on other Ruuvi Tag B revisions. Note that the UART
only uses tx/rx and goes to test points on the board (the
test points are TP10 and TP11).
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/f4e2b349
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f4e2b349
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f4e2b349
Branch: refs/heads/bluetooth5
Commit: f4e2b34905df1960f436145dd7346b17516edd4c
Parents: 813463e
Author: William San Filippo <wi...@runtime.io>
Authored: Tue Apr 18 16:36:28 2017 -0700
Committer: William San Filippo <wi...@runtime.io>
Committed: Tue Apr 18 16:36:28 2017 -0700
----------------------------------------------------------------------
hw/bsp/ruuvi_tag_revb2/boot-nrf52xxaa.ld | 25 ++
hw/bsp/ruuvi_tag_revb2/bsp.yml | 64 ++++
hw/bsp/ruuvi_tag_revb2/include/bsp/boards.h | 19 ++
hw/bsp/ruuvi_tag_revb2/include/bsp/bsp.h | 73 +++++
hw/bsp/ruuvi_tag_revb2/include/bsp/cmsis_nvic.h | 29 ++
hw/bsp/ruuvi_tag_revb2/nrf52dk_debug.cmd | 22 ++
hw/bsp/ruuvi_tag_revb2/nrf52dk_debug.sh | 46 +++
hw/bsp/ruuvi_tag_revb2/nrf52dk_download.cmd | 22 ++
hw/bsp/ruuvi_tag_revb2/nrf52dk_download.sh | 40 +++
hw/bsp/ruuvi_tag_revb2/nrf52dk_no_boot.ld | 191 ++++++++++++
hw/bsp/ruuvi_tag_revb2/nrf52xxaa.ld | 25 ++
hw/bsp/ruuvi_tag_revb2/pkg.yml | 97 ++++++
hw/bsp/ruuvi_tag_revb2/split-nrf52dk.ld | 208 +++++++++++++
.../src/arch/cortex_m4/gcc_startup_nrf52.s | 301 ++++++++++++++++++
.../arch/cortex_m4/gcc_startup_nrf52_split.s | 166 ++++++++++
hw/bsp/ruuvi_tag_revb2/src/hal_bsp.c | 303 +++++++++++++++++++
hw/bsp/ruuvi_tag_revb2/src/sbrk.c | 59 ++++
hw/bsp/ruuvi_tag_revb2/syscfg.yml | 95 ++++++
18 files changed, 1785 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4e2b349/hw/bsp/ruuvi_tag_revb2/boot-nrf52xxaa.ld
----------------------------------------------------------------------
diff --git a/hw/bsp/ruuvi_tag_revb2/boot-nrf52xxaa.ld b/hw/bsp/ruuvi_tag_revb2/boot-nrf52xxaa.ld
new file mode 100755
index 0000000..d1f1b99
--- /dev/null
+++ b/hw/bsp/ruuvi_tag_revb2/boot-nrf52xxaa.ld
@@ -0,0 +1,25 @@
+/* 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.
+ */
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x4000
+ RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000
+}
+
+/* The bootloader does not contain an image header */
+_imghdr_size = 0x0;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4e2b349/hw/bsp/ruuvi_tag_revb2/bsp.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/ruuvi_tag_revb2/bsp.yml b/hw/bsp/ruuvi_tag_revb2/bsp.yml
new file mode 100644
index 0000000..918392c
--- /dev/null
+++ b/hw/bsp/ruuvi_tag_revb2/bsp.yml
@@ -0,0 +1,64 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+bsp.arch: cortex_m4
+bsp.compiler: compiler/arm-none-eabi-m4
+bsp.linkerscript:
+ - "hw/bsp/ruuvi_tag_revb2/nrf52xxaa.ld"
+ - "hw/mcu/nordic/nrf52xxx/nrf52.ld"
+bsp.linkerscript.BOOT_LOADER.OVERWRITE:
+ - "hw/bsp/ruuvi_tag_revb2/boot-nrf52xxaa.ld"
+ - "hw/mcu/nordic/nrf52xxx/nrf52.ld"
+bsp.part2linkerscript: "hw/bsp/ruuvi_tag_revb2/split-nrf52dk.ld"
+bsp.downloadscript: "hw/bsp/ruuvi_tag_revb2/nrf52dk_download.sh"
+bsp.debugscript: "hw/bsp/ruuvi_tag_revb2/nrf52dk_debug.sh"
+bsp.downloadscript.WINDOWS.OVERWRITE: "hw/bsp/ruuvi_tag_revb2/nrf52dk_download.cmd"
+bsp.debugscript.WINDOWS.OVERWRITE: "hw/bsp/ruuvi_tag_revb2/nrf52dk_debug.cmd"
+
+bsp.flash_map:
+ areas:
+ # System areas.
+ FLASH_AREA_BOOTLOADER:
+ device: 0
+ offset: 0x00000000
+ size: 16kB
+ FLASH_AREA_IMAGE_0:
+ device: 0
+ offset: 0x00008000
+ size: 232kB
+ FLASH_AREA_IMAGE_1:
+ device: 0
+ offset: 0x00042000
+ size: 232kB
+ FLASH_AREA_IMAGE_SCRATCH:
+ device: 0
+ offset: 0x0007c000
+ size: 4kB
+
+ # User areas.
+ FLASH_AREA_REBOOT_LOG:
+ user_id: 0
+ device: 0
+ offset: 0x00004000
+ size: 16kB
+ FLASH_AREA_NFFS:
+ user_id: 1
+ device: 0
+ offset: 0x0007d000
+ size: 12kB
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4e2b349/hw/bsp/ruuvi_tag_revb2/include/bsp/boards.h
----------------------------------------------------------------------
diff --git a/hw/bsp/ruuvi_tag_revb2/include/bsp/boards.h b/hw/bsp/ruuvi_tag_revb2/include/bsp/boards.h
new file mode 100644
index 0000000..560c31f
--- /dev/null
+++ b/hw/bsp/ruuvi_tag_revb2/include/bsp/boards.h
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4e2b349/hw/bsp/ruuvi_tag_revb2/include/bsp/bsp.h
----------------------------------------------------------------------
diff --git a/hw/bsp/ruuvi_tag_revb2/include/bsp/bsp.h b/hw/bsp/ruuvi_tag_revb2/include/bsp/bsp.h
new file mode 100644
index 0000000..e43ad7f
--- /dev/null
+++ b/hw/bsp/ruuvi_tag_revb2/include/bsp/bsp.h
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BSP_H
+#define H_BSP_H
+
+#include <inttypes.h>
+
+#include <syscfg/syscfg.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Define special stackos sections */
+#define sec_data_core __attribute__((section(".data.core")))
+#define sec_bss_core __attribute__((section(".bss.core")))
+#define sec_bss_nz_core __attribute__((section(".bss.core.nz")))
+
+/* More convenient section placement macros. */
+#define bssnz_t sec_bss_nz_core
+
+extern uint8_t _ram_start;
+#define RAM_SIZE 0x10000
+
+/* IRQ */
+#define ACC_INT1 (2)
+#define ACC_INT2 (6)
+
+/* SPI CS */
+#define SPI_HUMI_CS (3)
+#define SPI_ACC_CS (8)
+
+/* LED pins */
+#define LED_1 (17)
+#define LED_2 (19)
+#define LED_BLINK_PIN (LED_1)
+
+/* UART info */
+#define CONSOLE_UART "uart0"
+
+#if MYNEWT_VAL(BOOT_SERIAL)
+#define BOOT_SERIAL_DETECT_PIN 13 /* Button 1 */
+#define BOOT_SERIAL_DETECT_PIN_CFG HAL_GPIO_PULL_UP
+#define BOOT_SERIAL_DETECT_PIN_VAL 0
+
+#define BOOT_SERIAL_REPORT_PIN LED_BLINK_PIN
+#define BOOT_SERIAL_REPORT_FREQ (MYNEWT_VAL(OS_CPUTIME_FREQ) / 4)
+#endif
+
+#define NFFS_AREA_MAX (8)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* H_BSP_H */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4e2b349/hw/bsp/ruuvi_tag_revb2/include/bsp/cmsis_nvic.h
----------------------------------------------------------------------
diff --git a/hw/bsp/ruuvi_tag_revb2/include/bsp/cmsis_nvic.h b/hw/bsp/ruuvi_tag_revb2/include/bsp/cmsis_nvic.h
new file mode 100644
index 0000000..856f7d0
--- /dev/null
+++ b/hw/bsp/ruuvi_tag_revb2/include/bsp/cmsis_nvic.h
@@ -0,0 +1,29 @@
+/* mbed Microcontroller Library - cmsis_nvic
+ * Copyright (c) 2009-2011 ARM Limited. All rights reserved.
+ *
+ * CMSIS-style functionality to support dynamic vectors
+ */
+
+#ifndef MBED_CMSIS_NVIC_H
+#define MBED_CMSIS_NVIC_H
+
+#include <stdint.h>
+
+#define NVIC_NUM_VECTORS (16 + 38) // CORE + MCU Peripherals
+#define NVIC_USER_IRQ_OFFSET 16
+
+#include "nrf52.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void NVIC_Relocate(void);
+void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector);
+uint32_t NVIC_GetVector(IRQn_Type IRQn);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4e2b349/hw/bsp/ruuvi_tag_revb2/nrf52dk_debug.cmd
----------------------------------------------------------------------
diff --git a/hw/bsp/ruuvi_tag_revb2/nrf52dk_debug.cmd b/hw/bsp/ruuvi_tag_revb2/nrf52dk_debug.cmd
new file mode 100755
index 0000000..96f0b26
--- /dev/null
+++ b/hw/bsp/ruuvi_tag_revb2/nrf52dk_debug.cmd
@@ -0,0 +1,22 @@
+@rem
+@rem Licensed to the Apache Software Foundation (ASF) under one
+@rem or more contributor license agreements. See the NOTICE file
+@rem distributed with this work for additional information
+@rem regarding copyright ownership. The ASF licenses this file
+@rem to you under the Apache License, Version 2.0 (the
+@rem "License"); you may not use this file except in compliance
+@rem with the License. You may obtain a copy of the License at
+@rem
+@rem http://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing,
+@rem software distributed under the License is distributed on an
+@rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@rem KIND, either express or implied. See the License for the
+@rem specific language governing permissions and limitations
+@rem under the License.
+@rem
+
+@rem Execute a shell with a script of the same name and .sh extension
+
+@bash "%~dp0%~n0.sh"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4e2b349/hw/bsp/ruuvi_tag_revb2/nrf52dk_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/ruuvi_tag_revb2/nrf52dk_debug.sh b/hw/bsp/ruuvi_tag_revb2/nrf52dk_debug.sh
new file mode 100755
index 0000000..17b980d
--- /dev/null
+++ b/hw/bsp/ruuvi_tag_revb2/nrf52dk_debug.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Called with following variables set:
+# - CORE_PATH is absolute path to @apache-mynewt-core
+# - BSP_PATH is absolute path to hw/bsp/bsp_name
+# - BIN_BASENAME is the path to prefix to target binary,
+# .elf appended to name is the ELF file
+# - FEATURES holds the target features string
+# - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
+# - RESET set if target should be reset when attaching
+# - NO_GDB set if we should not start gdb to debug
+#
+
+. $CORE_PATH/hw/scripts/jlink.sh
+
+FILE_NAME=$BIN_BASENAME.elf
+
+if [ $# -gt 2 ]; then
+ SPLIT_ELF_NAME=$3.elf
+ # TODO -- this magic number 0x42000 is the location of the second image
+ # slot. we should either get this from a flash map file or somehow learn
+ # this from the image itself
+ EXTRA_GDB_CMDS="add-symbol-file $SPLIT_ELF_NAME 0x8000 -readnow"
+fi
+
+JLINK_DEV="nRF52"
+
+jlink_debug
+
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4e2b349/hw/bsp/ruuvi_tag_revb2/nrf52dk_download.cmd
----------------------------------------------------------------------
diff --git a/hw/bsp/ruuvi_tag_revb2/nrf52dk_download.cmd b/hw/bsp/ruuvi_tag_revb2/nrf52dk_download.cmd
new file mode 100755
index 0000000..96f0b26
--- /dev/null
+++ b/hw/bsp/ruuvi_tag_revb2/nrf52dk_download.cmd
@@ -0,0 +1,22 @@
+@rem
+@rem Licensed to the Apache Software Foundation (ASF) under one
+@rem or more contributor license agreements. See the NOTICE file
+@rem distributed with this work for additional information
+@rem regarding copyright ownership. The ASF licenses this file
+@rem to you under the Apache License, Version 2.0 (the
+@rem "License"); you may not use this file except in compliance
+@rem with the License. You may obtain a copy of the License at
+@rem
+@rem http://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing,
+@rem software distributed under the License is distributed on an
+@rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@rem KIND, either express or implied. See the License for the
+@rem specific language governing permissions and limitations
+@rem under the License.
+@rem
+
+@rem Execute a shell with a script of the same name and .sh extension
+
+@bash "%~dp0%~n0.sh"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4e2b349/hw/bsp/ruuvi_tag_revb2/nrf52dk_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/ruuvi_tag_revb2/nrf52dk_download.sh b/hw/bsp/ruuvi_tag_revb2/nrf52dk_download.sh
new file mode 100755
index 0000000..08d45b4
--- /dev/null
+++ b/hw/bsp/ruuvi_tag_revb2/nrf52dk_download.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Called with following variables set:
+# - CORE_PATH is absolute path to @apache-mynewt-core
+# - BSP_PATH is absolute path to hw/bsp/bsp_name
+# - BIN_BASENAME is the path to prefix to target binary,
+# .elf appended to name is the ELF file
+# - IMAGE_SLOT is the image slot to download to (for non-mfg-image, non-boot)
+# - FEATURES holds the target features string
+# - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
+# - MFG_IMAGE is "1" if this is a manufacturing image
+# - FLASH_OFFSET contains the flash offset to download to
+# - BOOT_LOADER is set if downloading a bootloader
+
+. $CORE_PATH/hw/scripts/jlink.sh
+
+if [ "$MFG_IMAGE" ]; then
+ FLASH_OFFSET=0x0
+fi
+
+JLINK_DEV="nRF52"
+
+common_file_to_load
+jlink_load
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4e2b349/hw/bsp/ruuvi_tag_revb2/nrf52dk_no_boot.ld
----------------------------------------------------------------------
diff --git a/hw/bsp/ruuvi_tag_revb2/nrf52dk_no_boot.ld b/hw/bsp/ruuvi_tag_revb2/nrf52dk_no_boot.ld
new file mode 100755
index 0000000..e2fb5a8
--- /dev/null
+++ b/hw/bsp/ruuvi_tag_revb2/nrf52dk_no_boot.ld
@@ -0,0 +1,191 @@
+/* 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")
+
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x80000
+ RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000
+}
+
+/* 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__
+ * __HeapBase
+ * __HeapLimit
+ * __StackLimit
+ * __StackTop
+ * __stack
+ * __bssnz_start__
+ * __bssnz_end__
+ */
+ENTRY(Reset_Handler)
+
+SECTIONS
+{
+ .text :
+ {
+ __isr_vector_start = .;
+ KEEP(*(.isr_vector))
+ __isr_vector_end = .;
+ *(.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 = .;
+
+ .vector_relocation :
+ {
+ . = ALIGN(4);
+ __vector_tbl_reloc__ = .;
+ . = . + (__isr_vector_end - __isr_vector_start);
+ . = ALIGN(4);
+ } > RAM
+
+ .data : AT (__etext)
+ {
+ __data_start__ = .;
+ *(vtable)
+ *(.data*)
+
+ . = ALIGN(4);
+ /* preinit data */
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ *(.preinit_array)
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+
+ . = ALIGN(4);
+ /* init data */
+ PROVIDE_HIDDEN (__init_array_start = .);
+ *(SORT(.init_array.*))
+ *(.init_array)
+ PROVIDE_HIDDEN (__init_array_end = .);
+
+
+ . = ALIGN(4);
+ /* finit data */
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ *(SORT(.fini_array.*))
+ *(.fini_array)
+ PROVIDE_HIDDEN (__fini_array_end = .);
+
+ *(.jcr)
+ . = ALIGN(4);
+ /* All data end */
+ __data_end__ = .;
+ } > RAM
+
+ /* Non-zeroed BSS. This section is similar to BSS, with the following
+ * caveat:
+ * 1. It does not get zeroed at init-time.
+ */
+ .bssnz :
+ {
+ . = ALIGN(4);
+ __bssnz_start__ = .;
+ *(.bss.core.nz*)
+ . = ALIGN(4);
+ __bssnz_end__ = .;
+ } > RAM
+
+ .bss :
+ {
+ . = ALIGN(4);
+ __bss_start__ = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4);
+ __bss_end__ = .;
+ } > RAM
+
+ /* Heap starts after BSS */
+ __HeapBase = .;
+
+ /* .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);
+
+ /* Top of head is the bottom of the stack */
+ __HeapLimit = __StackLimit;
+
+ /* Check if data + heap + stack exceeds RAM limit */
+ ASSERT(__HeapBase <= __HeapLimit, "region RAM overflowed with stack")
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4e2b349/hw/bsp/ruuvi_tag_revb2/nrf52xxaa.ld
----------------------------------------------------------------------
diff --git a/hw/bsp/ruuvi_tag_revb2/nrf52xxaa.ld b/hw/bsp/ruuvi_tag_revb2/nrf52xxaa.ld
new file mode 100755
index 0000000..9433e37
--- /dev/null
+++ b/hw/bsp/ruuvi_tag_revb2/nrf52xxaa.ld
@@ -0,0 +1,25 @@
+/* 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.
+ */
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x00008000, LENGTH = 0x3a000
+ RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000
+}
+
+/* This linker script is used for images and thus contains an image header */
+_imghdr_size = 0x20;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4e2b349/hw/bsp/ruuvi_tag_revb2/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/ruuvi_tag_revb2/pkg.yml b/hw/bsp/ruuvi_tag_revb2/pkg.yml
new file mode 100644
index 0000000..7bd4489
--- /dev/null
+++ b/hw/bsp/ruuvi_tag_revb2/pkg.yml
@@ -0,0 +1,97 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+pkg.name: hw/bsp/ruuvi_tag_revb
+pkg.type: bsp
+pkg.description: BSP definition for the Ruuvi Tag rev B (B3 and B4).
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
+pkg.keywords:
+ - ruuvi
+ - ruuvi_tag
+ - nrf52
+ - nrf52dk
+
+pkg.cflags:
+ # Nordic SDK files require these defines.
+ - '-DADC_ENABLED=0'
+ - '-DCLOCK_ENABLED=1'
+ - '-DCOMP_ENABLED=1'
+ - '-DEGU_ENABLED=0'
+ - '-DGPIOTE_ENABLED=1'
+ - '-DI2S_ENABLED=1'
+ - '-DLPCOMP_ENABLED=1'
+ - '-DNRF52'
+ - '-DPDM_ENABLED=0'
+ - '-DPERIPHERAL_RESOURCE_SHARING_ENABLED=1'
+ - '-DPWM0_ENABLED=1'
+ - '-DPWM1_ENABLED=0'
+ - '-DPWM2_ENABLED=0'
+ - '-DQDEC_ENABLED=1'
+ - '-DRNG_ENABLED=1'
+ - '-DRTC0_ENABLED=0'
+ - '-DRTC1_ENABLED=0'
+ - '-DRTC2_ENABLED=0'
+ - '-DSAADC_ENABLED=1'
+ - '-DSPI_MASTER_0_ENABLE=1'
+ - '-DSPI0_CONFIG_MISO_PIN=28'
+ - '-DSPI0_CONFIG_MOSI_PIN=25'
+ - '-DSPI0_CONFIG_SCK_PIN=29'
+ - '-DSPI0_ENABLED=1'
+ - '-DSPI0_USE_EASY_DMA=1'
+ - '-DSPI1_ENABLED=0'
+ - '-DSPI2_ENABLED=0'
+ - '-DSPIS0_CONFIG_MISO_PIN=28'
+ - '-DSPIS0_CONFIG_MOSI_PIN=25'
+ - '-DSPIS0_CONFIG_SCK_PIN=29'
+ - '-DSPIS0_ENABLED=1'
+ - '-DSPIS1_CONFIG_MISO_PIN=4'
+ - '-DSPIS1_CONFIG_MOSI_PIN=3'
+ - '-DSPIS1_CONFIG_SCK_PIN=2'
+ - '-DSPIS1_ENABLED=0'
+ - '-DSPIS2_ENABLED=0'
+ - '-DTIMER0_ENABLED=1'
+ - '-DTIMER1_ENABLED=0'
+ - '-DTIMER2_ENABLED=0'
+ - '-DTIMER3_ENABLED=0'
+ - '-DTIMER4_ENABLED=0'
+ - '-DTWI0_CONFIG_SCL=27'
+ - '-DTWI0_CONFIG_SDA=26'
+ - '-DTWI0_ENABLED=1'
+ - '-DTWI1_ENABLED=1'
+ - '-DTWIS0_ENABLED=1'
+ - '-DTWIS1_ENABLED=0'
+ - '-DUART0_ENABLED=1'
+ - '-DWDT_ENABLED=1'
+
+pkg.cflags.HARDFLOAT:
+ - -mfloat-abi=hard -mfpu=fpv4-sp-d16
+
+pkg.deps:
+ - hw/mcu/nordic/nrf52xxx
+ - libc/baselibc
+
+pkg.deps.BLE_DEVICE:
+ - hw/drivers/nimble/nrf52
+
+pkg.deps.UART_0:
+ - hw/drivers/uart/uart_hal
+
+pkg.deps.UART_1:
+ - hw/drivers/uart/uart_bitbang
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4e2b349/hw/bsp/ruuvi_tag_revb2/split-nrf52dk.ld
----------------------------------------------------------------------
diff --git a/hw/bsp/ruuvi_tag_revb2/split-nrf52dk.ld b/hw/bsp/ruuvi_tag_revb2/split-nrf52dk.ld
new file mode 100755
index 0000000..f4ffe5a
--- /dev/null
+++ b/hw/bsp/ruuvi_tag_revb2/split-nrf52dk.ld
@@ -0,0 +1,208 @@
+/* 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")
+
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x00042000, LENGTH = 0x3a000
+ RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000
+}
+
+/* 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__
+ * __HeapBase
+ * __HeapLimit
+ * __StackLimit
+ * __StackTop
+ * __stack
+ * __bssnz_start__
+ * __bssnz_end__
+ */
+ENTRY(Reset_Handler_split)
+
+SECTIONS
+{
+ .imghdr (NOLOAD):
+ {
+ . = . + 0x20;
+ } > FLASH
+
+ .text :
+ {
+ __split_isr_vector_start = .;
+ KEEP(*(.isr_vector_split))
+ __split_isr_vector_end = .;
+ *(.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 : ALIGN(4)
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > 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 = .;
+
+ /* save RAM used by the split image. This assumes that
+ * the loader uses all the RAM up to its HeapBase */
+ .loader_ram_contents :
+ {
+ _loader_ram_start = .;
+
+ /* this symbol comes from the loader linker */
+ . = . + (ABSOLUTE(__HeapBase_loader) - _loader_ram_start);
+ _loader_ram_end = .;
+ } > RAM
+
+ .data :
+ {
+ __data_start__ = .;
+ *(.data*)
+
+ . = ALIGN(4);
+ /* preinit data */
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ *(.preinit_array)
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+
+ . = ALIGN(4);
+ /* init data */
+ PROVIDE_HIDDEN (__init_array_start = .);
+ *(SORT(.init_array.*))
+ *(.init_array)
+ PROVIDE_HIDDEN (__init_array_end = .);
+
+ . = ALIGN(4);
+ /* finit data */
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ *(SORT(.fini_array.*))
+ *(.fini_array)
+ PROVIDE_HIDDEN (__fini_array_end = .);
+
+ *(.jcr)
+ . = ALIGN(4);
+ /* All data end */
+ __data_end__ = .;
+ } > RAM AT > FLASH
+
+ /* Non-zeroed BSS. This section is similar to BSS, with the following two
+ * caveats:
+ * 1. It does not get zeroed at init-time.
+ * 2. You cannot use it as source memory for EasyDMA.
+ *
+ * This section exists because of a hardware defect; see errata 33 and 34
+ * in nrf52 errata sheet.
+ */
+ .bssnz :
+ {
+ . = ALIGN(4);
+ __bssnz_start__ = .;
+ *(.bss.core.nz*)
+ . = ALIGN(4);
+ __bssnz_end__ = .;
+ } > RAM
+
+ .bss :
+ {
+ . = ALIGN(4);
+ __bss_start__ = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4);
+ __bss_end__ = .;
+ } > RAM
+
+ /* Heap starts after BSS */
+ __HeapBase = .;
+
+ /* .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
+
+ _ram_start = ORIGIN(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);
+
+ /* Top of head is the bottom of the stack */
+ __HeapLimit = __StackLimit;
+
+ /* Check if data + heap + stack exceeds RAM limit */
+ ASSERT(__HeapBase <= __HeapLimit, "region RAM overflowed with stack")
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4e2b349/hw/bsp/ruuvi_tag_revb2/src/arch/cortex_m4/gcc_startup_nrf52.s
----------------------------------------------------------------------
diff --git a/hw/bsp/ruuvi_tag_revb2/src/arch/cortex_m4/gcc_startup_nrf52.s b/hw/bsp/ruuvi_tag_revb2/src/arch/cortex_m4/gcc_startup_nrf52.s
new file mode 100755
index 0000000..8ce6ee5
--- /dev/null
+++ b/hw/bsp/ruuvi_tag_revb2/src/arch/cortex_m4/gcc_startup_nrf52.s
@@ -0,0 +1,301 @@
+/*
+Copyright (c) 2015, 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:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form 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.
+
+* 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.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
+*/
+
+/*
+NOTE: Template files (including this one) are application specific and therefore
+expected to be copied into the application project folder prior to its use!
+*/
+
+ .syntax unified
+ .arch armv7-m
+
+ .section .stack
+ .align 3
+ .equ Stack_Size, 432
+ .globl __StackTop
+ .globl __StackLimit
+__StackLimit:
+ .space Stack_Size
+ .size __StackLimit, . - __StackLimit
+__StackTop:
+ .size __StackTop, . - __StackTop
+
+ .section .heap
+ .align 3
+#ifdef __HEAP_SIZE
+ .equ Heap_Size, __HEAP_SIZE
+#else
+ .equ Heap_Size, 0
+#endif
+ .globl __HeapBase
+ .globl __HeapLimit
+__HeapBase:
+ .if Heap_Size
+ .space Heap_Size
+ .endif
+ .size __HeapBase, . - __HeapBase
+__HeapLimit:
+ .size __HeapLimit, . - __HeapLimit
+
+ .section .isr_vector
+ .align 2
+ .globl __isr_vector
+__isr_vector:
+ .long __StackTop /* Top of Stack */
+ .long Reset_Handler /* Reset Handler */
+ .long NMI_Handler /* NMI Handler */
+ .long HardFault_Handler /* Hard Fault Handler */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long SVC_Handler /* SVCall Handler */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long PendSV_Handler /* PendSV Handler */
+ .long SysTick_Handler /* SysTick Handler */
+
+ /* External Interrupts */
+ .long POWER_CLOCK_IRQHandler
+ .long RADIO_IRQHandler
+ .long UARTE0_UART0_IRQHandler
+ .long SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler
+ .long SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler
+ .long NFCT_IRQHandler
+ .long GPIOTE_IRQHandler
+ .long SAADC_IRQHandler
+ .long TIMER0_IRQHandler
+ .long TIMER1_IRQHandler
+ .long TIMER2_IRQHandler
+ .long RTC0_IRQHandler
+ .long TEMP_IRQHandler
+ .long RNG_IRQHandler
+ .long ECB_IRQHandler
+ .long CCM_AAR_IRQHandler
+ .long WDT_IRQHandler
+ .long RTC1_IRQHandler
+ .long QDEC_IRQHandler
+ .long COMP_LPCOMP_IRQHandler
+ .long SWI0_EGU0_IRQHandler
+ .long SWI1_EGU1_IRQHandler
+ .long SWI2_EGU2_IRQHandler
+ .long SWI3_EGU3_IRQHandler
+ .long SWI4_EGU4_IRQHandler
+ .long SWI5_EGU5_IRQHandler
+ .long TIMER3_IRQHandler
+ .long TIMER4_IRQHandler
+ .long PWM0_IRQHandler
+ .long PDM_IRQHandler
+ .long 0 /*Reserved */
+ .long 0 /*Reserved */
+ .long MWU_IRQHandler
+ .long PWM1_IRQHandler
+ .long PWM2_IRQHandler
+ .long SPIM2_SPIS2_SPI2_IRQHandler
+ .long RTC2_IRQHandler
+ .long I2S_IRQHandler
+
+ .size __isr_vector, . - __isr_vector
+
+/* Reset Handler */
+
+ .text
+ .thumb
+ .thumb_func
+ .align 1
+ .globl Reset_Handler
+ .type Reset_Handler, %function
+Reset_Handler:
+ .fnstart
+
+ /* Clear BSS */
+ mov r0, #0
+ ldr r2, =__bss_start__
+ ldr r3, =__bss_end__
+.bss_zero_loop:
+ cmp r2, r3
+ itt lt
+ strlt r0, [r2], #4
+ blt .bss_zero_loop
+
+
+/* Loop to copy data from read only memory to RAM. The ranges
+ * of copy from/to are specified by following symbols evaluated in
+ * linker script.
+ * __etext: End of code section, i.e., begin of data sections to copy from.
+ * __data_start__/__data_end__: RAM address range that data should be
+ * copied to. Both must be aligned to 4 bytes boundary. */
+ ldr r1, =__etext
+ ldr r2, =__data_start__
+ ldr r3, =__data_end__
+
+ subs r3, r2
+ ble .LC0
+
+.LC1:
+ subs r3, 4
+ ldr r0, [r1,r3]
+ str r0, [r2,r3]
+ bgt .LC1
+
+.LC0:
+
+ LDR R0, =__HeapBase
+ LDR R1, =__HeapLimit
+ BL _sbrkInit
+
+ LDR R0, =SystemInit
+ BLX R0
+
+ BL hal_system_init
+
+ LDR R0, =_start
+ BX R0
+
+ .pool
+ .cantunwind
+ .fnend
+ .size Reset_Handler,.-Reset_Handler
+
+ .section ".text"
+
+
+/* Dummy Exception Handlers (infinite loops which can be modified) */
+
+ .weak NMI_Handler
+ .type NMI_Handler, %function
+NMI_Handler:
+ B .
+ .size NMI_Handler, . - NMI_Handler
+
+
+ .weak HardFault_Handler
+ .type HardFault_Handler, %function
+HardFault_Handler:
+ B .
+ .size HardFault_Handler, . - HardFault_Handler
+
+
+ .weak MemoryManagement_Handler
+ .type MemoryManagement_Handler, %function
+MemoryManagement_Handler:
+ B .
+ .size MemoryManagement_Handler, . - MemoryManagement_Handler
+
+
+ .weak BusFault_Handler
+ .type BusFault_Handler, %function
+BusFault_Handler:
+ B .
+ .size BusFault_Handler, . - BusFault_Handler
+
+
+ .weak UsageFault_Handler
+ .type UsageFault_Handler, %function
+UsageFault_Handler:
+ B .
+ .size UsageFault_Handler, . - UsageFault_Handler
+
+
+ .weak SVC_Handler
+ .type SVC_Handler, %function
+SVC_Handler:
+ B .
+ .size SVC_Handler, . - SVC_Handler
+
+
+ .weak PendSV_Handler
+ .type PendSV_Handler, %function
+PendSV_Handler:
+ B .
+ .size PendSV_Handler, . - PendSV_Handler
+
+
+ .weak SysTick_Handler
+ .type SysTick_Handler, %function
+SysTick_Handler:
+ B .
+ .size SysTick_Handler, . - SysTick_Handler
+
+
+/* IRQ Handlers */
+
+ .globl Default_Handler
+ .type Default_Handler, %function
+Default_Handler:
+ B .
+ .size Default_Handler, . - Default_Handler
+
+ .macro IRQ handler
+ .weak \handler
+ .set \handler, Default_Handler
+ .endm
+
+ IRQ POWER_CLOCK_IRQHandler
+ IRQ RADIO_IRQHandler
+ IRQ UARTE0_UART0_IRQHandler
+ IRQ SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler
+ IRQ SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler
+ IRQ NFCT_IRQHandler
+ IRQ GPIOTE_IRQHandler
+ IRQ SAADC_IRQHandler
+ IRQ TIMER0_IRQHandler
+ IRQ TIMER1_IRQHandler
+ IRQ TIMER2_IRQHandler
+ IRQ RTC0_IRQHandler
+ IRQ TEMP_IRQHandler
+ IRQ RNG_IRQHandler
+ IRQ ECB_IRQHandler
+ IRQ CCM_AAR_IRQHandler
+ IRQ WDT_IRQHandler
+ IRQ RTC1_IRQHandler
+ IRQ QDEC_IRQHandler
+ IRQ COMP_LPCOMP_IRQHandler
+ IRQ SWI0_EGU0_IRQHandler
+ IRQ SWI1_EGU1_IRQHandler
+ IRQ SWI2_EGU2_IRQHandler
+ IRQ SWI3_EGU3_IRQHandler
+ IRQ SWI4_EGU4_IRQHandler
+ IRQ SWI5_EGU5_IRQHandler
+ IRQ TIMER3_IRQHandler
+ IRQ TIMER4_IRQHandler
+ IRQ PWM0_IRQHandler
+ IRQ PDM_IRQHandler
+ IRQ MWU_IRQHandler
+ IRQ PWM1_IRQHandler
+ IRQ PWM2_IRQHandler
+ IRQ SPIM2_SPIS2_SPI2_IRQHandler
+ IRQ RTC2_IRQHandler
+ IRQ I2S_IRQHandler
+
+ .end
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4e2b349/hw/bsp/ruuvi_tag_revb2/src/arch/cortex_m4/gcc_startup_nrf52_split.s
----------------------------------------------------------------------
diff --git a/hw/bsp/ruuvi_tag_revb2/src/arch/cortex_m4/gcc_startup_nrf52_split.s b/hw/bsp/ruuvi_tag_revb2/src/arch/cortex_m4/gcc_startup_nrf52_split.s
new file mode 100755
index 0000000..044aa17
--- /dev/null
+++ b/hw/bsp/ruuvi_tag_revb2/src/arch/cortex_m4/gcc_startup_nrf52_split.s
@@ -0,0 +1,166 @@
+/*
+Copyright (c) 2015, 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:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form 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.
+
+* 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.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
+*/
+
+/*
+NOTE: Template files (including this one) are application specific and therefore
+expected to be copied into the application project folder prior to its use!
+*/
+
+ .syntax unified
+ .arch armv7-m
+ .section .stack
+ .align 3
+ .equ Stack_Size, 432
+ .globl __StackTop
+ .globl __StackLimit
+__StackLimit:
+ .space Stack_Size
+ .size __StackLimit, . - __StackLimit
+__StackTop:
+ .size __StackTop, . - __StackTop
+
+ .section .heap
+ .align 3
+#ifdef __HEAP_SIZE
+ .equ Heap_Size, __HEAP_SIZE
+#else
+ .equ Heap_Size, 0
+#endif
+ .globl __HeapBase
+ .globl __HeapLimit
+__HeapBase:
+ .if Heap_Size
+ .space Heap_Size
+ .endif
+ .size __HeapBase, . - __HeapBase
+__HeapLimit:
+ .size __HeapLimit, . - __HeapLimit
+
+ .section .isr_vector_split
+ .align 2
+ .globl __isr_vector_split
+__isr_vector_split:
+ .long __StackTop /* Top of Stack */
+ .long Reset_Handler_split /* Reset Handler */
+
+ .size __isr_vector_split, . - __isr_vector_split
+
+/* Reset Handler */
+
+ .text
+ .thumb
+ .thumb_func
+ .align 1
+ .globl Reset_Handler_split
+ .type Reset_Handler_split, %function
+Reset_Handler_split:
+ .fnstart
+
+ /* Clear CPU state before proceeding */
+ mov r0, #0
+ msr control, r0
+ msr primask, r0
+ /* Clear BSS */
+ ldr r2, =__bss_start__
+ ldr r3, =__bss_end__
+.bss_zero_loop:
+ cmp r2, r3
+ itt lt
+ strlt r0, [r2], #4
+ blt .bss_zero_loop
+
+
+/* Loop to copy data from read only memory to RAM. The ranges
+ * of copy from/to are specified by following symbols evaluated in
+ * linker script.
+ * __etext: End of code section, i.e., begin of data sections to copy from.
+ * __data_start__/__data_end__: RAM address range that data should be
+ * copied to. Both must be aligned to 4 bytes boundary. */
+
+ ldr r1, =__etext
+ ldr r2, =__data_start__
+ ldr r3, =__data_end__
+
+ subs r3, r2
+ ble .LC0
+
+.LC1:
+ subs r3, 4
+ ldr r0, [r1,r3]
+ str r0, [r2,r3]
+ bgt .LC1
+
+.LC0:
+ ldr r1, =__etext_loader
+ ldr r2, =__data_start___loader
+ ldr r3, =__data_end___loader
+
+ subs r3, r2
+ ble .LC2
+
+.LC3:
+ subs r3, 4
+ ldr r0, [r1,r3]
+ str r0, [r2,r3]
+ bgt .LC3
+.LC2:
+
+ subs r0, r0
+ ldr r2, =__bss_start___loader
+ ldr r3, =__bss_end___loader
+
+ subs r3, r2
+ ble .LC4
+
+.LC5:
+ subs r3, 4
+ str r0, [r2,r3]
+ bgt .LC5
+.LC4:
+
+ LDR R0, =__HeapBase
+ LDR R1, =__HeapLimit
+ BL _sbrkInit
+
+ LDR R0, =SystemInit
+ BLX R0
+
+ BL hal_system_init
+
+ LDR R0, =_start_split
+ BX R0
+
+ .pool
+ .cantunwind
+ .fnend
+ .size Reset_Handler_split,.-Reset_Handler_split
+
+ .section ".text"
+ .end
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4e2b349/hw/bsp/ruuvi_tag_revb2/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/ruuvi_tag_revb2/src/hal_bsp.c b/hw/bsp/ruuvi_tag_revb2/src/hal_bsp.c
new file mode 100644
index 0000000..ab960ce
--- /dev/null
+++ b/hw/bsp/ruuvi_tag_revb2/src/hal_bsp.c
@@ -0,0 +1,303 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+#include <assert.h>
+#include <nrf52.h>
+#include "os/os_cputime.h"
+#include "syscfg/syscfg.h"
+#include "sysflash/sysflash.h"
+#include "flash_map/flash_map.h"
+#include "hal/hal_bsp.h"
+#include "hal/hal_flash.h"
+#include "hal/hal_spi.h"
+#include "hal/hal_watchdog.h"
+#include "hal/hal_i2c.h"
+#include "mcu/nrf52_hal.h"
+#if MYNEWT_VAL(UART_0) || MYNEWT_VAL(UART_1)
+#include "uart/uart.h"
+#endif
+#if MYNEWT_VAL(UART_0)
+#include "uart_hal/uart_hal.h"
+#endif
+#if MYNEWT_VAL(UART_1)
+#include "uart_bitbang/uart_bitbang.h"
+#endif
+#include "os/os_dev.h"
+#include "bsp.h"
+#if MYNEWT_VAL(LSM303DLHC_PRESENT)
+#include <lsm303dlhc/lsm303dlhc.h>
+static struct lsm303dlhc lsm303dlhc;
+#endif
+#if MYNEWT_VAL(BNO055_PRESENT)
+#include <bno055/bno055.h>
+#endif
+#if MYNEWT_VAL(TSL2561_PRESENT)
+#include <tsl2561/tsl2561.h>
+#endif
+#if MYNEWT_VAL(TCS34725_PRESENT)
+#include <tcs34725/tcs34725.h>
+#endif
+
+#if MYNEWT_VAL(LSM303DLHC_PRESENT)
+static struct lsm303dlhc lsm303dlhc;
+#endif
+
+#if MYNEWT_VAL(BNO055_PRESENT)
+static struct bno055 bno055;
+#endif
+
+#if MYNEWT_VAL(TSL2561_PRESENT)
+static struct tsl2561 tsl2561;
+#endif
+
+#if MYNEWT_VAL(TCS34725_PRESENT)
+static struct tcs34725 tcs34725;
+#endif
+
+#if MYNEWT_VAL(UART_0)
+static struct uart_dev os_bsp_uart0;
+static const struct nrf52_uart_cfg os_bsp_uart0_cfg = {
+ .suc_pin_tx = MYNEWT_VAL(UART_0_PIN_TX),
+ .suc_pin_rx = MYNEWT_VAL(UART_0_PIN_RX),
+ .suc_pin_rts = MYNEWT_VAL(UART_0_PIN_RTS),
+ .suc_pin_cts = MYNEWT_VAL(UART_0_PIN_CTS),
+};
+#endif
+
+#if MYNEWT_VAL(UART_1)
+static struct uart_dev os_bsp_bitbang_uart1;
+static const struct uart_bitbang_conf os_bsp_uart1_cfg = {
+ .ubc_txpin = MYNEWT_VAL(UART_1_PIN_TX),
+ .ubc_rxpin = MYNEWT_VAL(UART_1_PIN_RX),
+ .ubc_cputimer_freq = MYNEWT_VAL(OS_CPUTIME_FREQ),
+};
+#endif
+
+#if MYNEWT_VAL(SPI_0_MASTER)
+/*
+ * NOTE: Our HAL expects that the SS pin, if used, is treated as a gpio line
+ * and is handled outside the SPI routines.
+ */
+static const struct nrf52_hal_spi_cfg os_bsp_spi0m_cfg = {
+ .sck_pin = 29,
+ .mosi_pin = 25,
+ .miso_pin = 28,
+};
+#endif
+
+#if MYNEWT_VAL(SPI_0_SLAVE)
+static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {
+ .sck_pin = 29,
+ .mosi_pin = 25,
+ .miso_pin = 28,
+ .ss_pin = 22,
+};
+#endif
+
+#if MYNEWT_VAL(I2C_0)
+static const struct nrf52_hal_i2c_cfg hal_i2c_cfg = {
+ .scl_pin = 27,
+ .sda_pin = 26,
+ .i2c_frequency = 100 /* 100 kHz */
+};
+#endif
+
+/*
+ * What memory to include in coredump.
+ */
+static const struct hal_bsp_mem_dump dump_cfg[] = {
+ [0] = {
+ .hbmd_start = &_ram_start,
+ .hbmd_size = RAM_SIZE
+ }
+};
+
+const struct hal_flash *
+hal_bsp_flash_dev(uint8_t id)
+{
+ /*
+ * Internal flash mapped to id 0.
+ */
+ if (id != 0) {
+ return NULL;
+ }
+ return &nrf52k_flash_dev;
+}
+
+const struct hal_bsp_mem_dump *
+hal_bsp_core_dump(int *area_cnt)
+{
+ *area_cnt = sizeof(dump_cfg) / sizeof(dump_cfg[0]);
+ return dump_cfg;
+}
+
+int
+hal_bsp_power_state(int state)
+{
+ return (0);
+}
+
+/**
+ * Returns the configured priority for the given interrupt. If no priority
+ * configured, return the priority passed in
+ *
+ * @param irq_num
+ * @param pri
+ *
+ * @return uint32_t
+ */
+uint32_t
+hal_bsp_get_nvic_priority(int irq_num, uint32_t pri)
+{
+ uint32_t cfg_pri;
+
+ switch (irq_num) {
+ /* Radio gets highest priority */
+ case RADIO_IRQn:
+ cfg_pri = 0;
+ break;
+ default:
+ cfg_pri = pri;
+ }
+ return cfg_pri;
+}
+
+#if MYNEWT_VAL(LSM303DLHC_PRESENT) || MYNEWT_VAL(BNO055_PRESENT)
+static int
+slinky_accel_init(struct os_dev *dev, void *arg)
+{
+ return (0);
+}
+#endif
+
+#if MYNEWT_VAL(TSL2561_PRESENT)
+static int
+slinky_light_init(struct os_dev *dev, void *arg)
+{
+ return (0);
+}
+#endif
+
+#if MYNEWT_VAL(TCS34725_PRESENT)
+static int
+slinky_color_init(struct os_dev *dev, void *arg)
+{
+ return (0);
+}
+#endif
+
+static void
+sensor_dev_create(void)
+{
+ int rc;
+
+ (void)rc;
+#if MYNEWT_VAL(LSM303DLHC_PRESENT)
+ rc = os_dev_create((struct os_dev *) &lsm303dlhc, "accel0",
+ OS_DEV_INIT_PRIMARY, 0, slinky_accel_init, NULL);
+ assert(rc == 0);
+#endif
+
+#if MYNEWT_VAL(BNO055_PRESENT)
+ rc = os_dev_create((struct os_dev *) &bno055, "accel1",
+ OS_DEV_INIT_PRIMARY, 0, slinky_accel_init, NULL);
+ assert(rc == 0);
+#endif
+
+#if MYNEWT_VAL(TSL2561_PRESENT)
+ rc = os_dev_create((struct os_dev *) &tsl2561, "light0",
+ OS_DEV_INIT_PRIMARY, 0, slinky_light_init, NULL);
+ assert(rc == 0);
+#endif
+
+#if MYNEWT_VAL(TCS34725_PRESENT)
+ rc = os_dev_create((struct os_dev *) &tcs34725, "color0",
+ OS_DEV_INIT_PRIMARY, 0, slinky_color_init, NULL);
+ assert(rc == 0);
+#endif
+
+}
+
+void
+hal_bsp_init(void)
+{
+ int rc;
+
+ (void)rc;
+#if MYNEWT_VAL(TIMER_0)
+ rc = hal_timer_init(0, NULL);
+ assert(rc == 0);
+#endif
+#if MYNEWT_VAL(TIMER_1)
+ rc = hal_timer_init(1, NULL);
+ assert(rc == 0);
+#endif
+#if MYNEWT_VAL(TIMER_2)
+ rc = hal_timer_init(2, NULL);
+ assert(rc == 0);
+#endif
+#if MYNEWT_VAL(TIMER_3)
+ rc = hal_timer_init(3, NULL);
+ assert(rc == 0);
+#endif
+#if MYNEWT_VAL(TIMER_4)
+ rc = hal_timer_init(4, NULL);
+ assert(rc == 0);
+#endif
+#if MYNEWT_VAL(TIMER_5)
+ rc = hal_timer_init(5, NULL);
+ assert(rc == 0);
+#endif
+
+#if (MYNEWT_VAL(OS_CPUTIME_TIMER_NUM) >= 0)
+ rc = os_cputime_init(MYNEWT_VAL(OS_CPUTIME_FREQ));
+ assert(rc == 0);
+#endif
+
+#if MYNEWT_VAL(I2C_0)
+ rc = hal_i2c_init(0, (void *)&hal_i2c_cfg);
+ assert(rc == 0);
+#endif
+
+#if MYNEWT_VAL(SPI_0_MASTER)
+ rc = hal_spi_init(0, (void *)&os_bsp_spi0m_cfg, HAL_SPI_TYPE_MASTER);
+ assert(rc == 0);
+#endif
+
+#if MYNEWT_VAL(SPI_0_SLAVE)
+ rc = hal_spi_init(0, (void *)&os_bsp_spi0s_cfg, HAL_SPI_TYPE_SLAVE);
+ assert(rc == 0);
+#endif
+
+#if MYNEWT_VAL(UART_0)
+ rc = os_dev_create((struct os_dev *) &os_bsp_uart0, "uart0",
+ OS_DEV_INIT_PRIMARY, 0, uart_hal_init, (void *)&os_bsp_uart0_cfg);
+ assert(rc == 0);
+#endif
+
+#if MYNEWT_VAL(UART_1)
+ rc = os_dev_create((struct os_dev *) &os_bsp_bitbang_uart1, "uart1",
+ OS_DEV_INIT_PRIMARY, 0, uart_bitbang_init, (void *)&os_bsp_uart1_cfg);
+ assert(rc == 0);
+#endif
+
+ sensor_dev_create();
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4e2b349/hw/bsp/ruuvi_tag_revb2/src/sbrk.c
----------------------------------------------------------------------
diff --git a/hw/bsp/ruuvi_tag_revb2/src/sbrk.c b/hw/bsp/ruuvi_tag_revb2/src/sbrk.c
new file mode 100644
index 0000000..5df43c9
--- /dev/null
+++ b/hw/bsp/ruuvi_tag_revb2/src/sbrk.c
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <hal/hal_bsp.h>
+
+/* put these in the data section so they are not cleared by _start */
+static char *sbrkBase __attribute__ ((section (".data")));
+static char *sbrkLimit __attribute__ ((section (".data")));
+static char *brk __attribute__ ((section (".data")));
+
+void
+_sbrkInit(char *base, char *limit) {
+ sbrkBase = base;
+ sbrkLimit = limit;
+ brk = base;
+}
+
+void *
+_sbrk(int incr)
+{
+ void *prev_brk;
+
+ if (incr < 0) {
+ /* Returning memory to the heap. */
+ incr = -incr;
+ if (brk - incr < sbrkBase) {
+ prev_brk = (void *)-1;
+ } else {
+ prev_brk = brk;
+ brk -= incr;
+ }
+ } else {
+ /* Allocating memory from the heap. */
+ if (sbrkLimit - brk >= incr) {
+ prev_brk = brk;
+ brk += incr;
+ } else {
+ prev_brk = (void *)-1;
+ }
+ }
+
+ return prev_brk;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4e2b349/hw/bsp/ruuvi_tag_revb2/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/ruuvi_tag_revb2/syscfg.yml b/hw/bsp/ruuvi_tag_revb2/syscfg.yml
new file mode 100644
index 0000000..5c019a6
--- /dev/null
+++ b/hw/bsp/ruuvi_tag_revb2/syscfg.yml
@@ -0,0 +1,95 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Package: hw/bsp/nrf52dk
+
+syscfg.defs:
+ BSP_NRF52:
+ description: 'Set to indicate that BSP has NRF52'
+ value: 1
+
+ XTAL_32768:
+ description: 'External 32k oscillator available.'
+ value: 1
+
+ UART_0:
+ description: 'Whether to enable UART0'
+ value: 1
+ UART_0_PIN_TX:
+ description: 'TX pin for UART0'
+ value: 4
+ UART_0_PIN_RX:
+ description: 'RX pin for UART0'
+ value: 5
+ UART_0_PIN_RTS:
+ description: 'RTS pin for UART0'
+ value: -1
+ UART_0_PIN_CTS:
+ description: 'CTS pin for UART0'
+ value: -1
+
+ UART_1:
+ description: 'Whether to enable bitbanger UART1'
+ value: 0
+ UART_1_PIN_TX:
+ description: 'TX pin for UART1'
+ value: -1
+ UART_1_PIN_RX:
+ description: 'RX pin for UART1'
+ value: -1
+
+ SPI_0_MASTER:
+ description: 'SPI 0 master'
+ value: 0
+ restrictions:
+ - "!SPI_0_SLAVE"
+ SPI_0_SLAVE:
+ description: 'SPI 0 slave'
+ value: 0
+ restrictions:
+ - "!SPI_0_MASTER"
+
+ TIMER_0:
+ description: 'NRF52 Timer 0'
+ value: 1
+ TIMER_1:
+ description: 'NRF52 Timer 1'
+ value: 0
+ TIMER_2:
+ description: 'NRF52 Timer 2'
+ value: 0
+ TIMER_3:
+ description: 'NRF52 Timer 3'
+ value: 0
+ TIMER_4:
+ description: 'NRF52 Timer 4'
+ value: 0
+ TIMER_5:
+ description: 'NRF52 RTC 0'
+ value: 0
+
+ I2C_0:
+ description: 'NRF52 I2C (TWI) interface 0'
+ value: '0'
+
+syscfg.vals:
+ CONFIG_FCB_FLASH_AREA: FLASH_AREA_NFFS
+ REBOOT_LOG_FLASH_AREA: FLASH_AREA_REBOOT_LOG
+ NFFS_FLASH_AREA: FLASH_AREA_NFFS
+ COREDUMP_FLASH_AREA: FLASH_AREA_IMAGE_1
+ MCU_DCDC_ENABLED: 1
[17/50] [abbrv] incubator-mynewt-core git commit: This closes #237.
Posted by ja...@apache.org.
This closes #237.
Merge remote-tracking branch 'simonratner/MYNEWT-732'
* simonratner/MYNEWT-732:
MYNEWT-732: Fix ble_gattc_disc_svc_by_uuid
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/43e3f723
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/43e3f723
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/43e3f723
Branch: refs/heads/bluetooth5
Commit: 43e3f72351dc632731138ef297dae386c7e96e62
Parents: a1e5c12 1ae1757
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Apr 19 12:00:16 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Apr 19 12:00:16 2017 -0700
----------------------------------------------------------------------
net/nimble/host/src/ble_att_clt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
[22/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-735
tinyprintf: negative field width spec.
Posted by ja...@apache.org.
MYNEWT-735 tinyprintf: negative field width spec.
>From the printf(3) man page on my OS X:
`-' A negative field width flag; the converted value is to
be left adjusted on the field boundary. Except for n
conversions, the converted value is padded on the right
with blanks, rather than on the left with blanks or
zeros. A - overrides a 0 if both are given.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/b83face5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/b83face5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/b83face5
Branch: refs/heads/bluetooth5
Commit: b83face5dfb740328c79081424fd2abdd9ca8d1d
Parents: 31d00cb
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Apr 19 16:30:27 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Apr 19 16:39:14 2017 -0700
----------------------------------------------------------------------
libc/baselibc/src/tinyprintf.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b83face5/libc/baselibc/src/tinyprintf.c
----------------------------------------------------------------------
diff --git a/libc/baselibc/src/tinyprintf.c b/libc/baselibc/src/tinyprintf.c
index 7719d80..11bcf63 100644
--- a/libc/baselibc/src/tinyprintf.c
+++ b/libc/baselibc/src/tinyprintf.c
@@ -70,6 +70,7 @@ struct param {
char sign:1; /**< The sign to display (if any) */
char alt:1; /**< alternate form */
char uc:1; /**< Upper case (for base16 only) */
+ char left:1; /**< Force text to left (padding on right) */
char base; /**< number base (e.g.: 8, 10, 16) */
char *bf; /**< Buffer to output */
};
@@ -155,8 +156,8 @@ static unsigned putchw(FILE *putp, struct param *p)
else if (p->alt && p->base == 8)
n--;
- /* Fill with space, before alternate or sign */
- if (!p->lz) {
+ /* Unless left-aligned, fill with space, before alternate or sign */
+ if (!p->lz && !p->left) {
while (n-- > 0)
written += putf(putp, ' ');
}
@@ -183,6 +184,12 @@ static unsigned putchw(FILE *putp, struct param *p)
bf = p->bf;
while ((ch = *bf++))
written += putf(putp, ch);
+
+ /* If left-aligned, pad the end with spaces. */
+ if (p->left) {
+ while (n-- > 0)
+ written += putf(putp, ' ');
+ }
return written;
}
@@ -246,17 +253,24 @@ size_t tfp_format(FILE *putp, const char *fmt, va_list va)
p.alt = 0;
p.width = 0;
p.sign = 0;
+ p.left = 0;
lng = 0;
/* Flags */
while ((ch = *(fmt++))) {
switch (ch) {
case '0':
- p.lz = 1;
+ if (!p.left) {
+ p.lz = 1;
+ }
continue;
case '#':
p.alt = 1;
continue;
+ case '-':
+ p.left = 1;
+ p.lz = 0;
+ continue;
default:
break;
}
[05/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-729
SensorAPI: Send sensor data over OIC
Posted by ja...@apache.org.
MYNEWT-729 SensorAPI: Send sensor data over OIC
- use valid URIs as per spec
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/54533236
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/54533236
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/54533236
Branch: refs/heads/bluetooth5
Commit: 5453323642458eccb8691f450302220d76d6f93d
Parents: 2300485
Author: Vipul Rahane <vi...@apache.org>
Authored: Fri Apr 14 11:37:55 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Mon Apr 17 16:14:20 2017 -0700
----------------------------------------------------------------------
hw/sensor/src/sensor_oic.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/54533236/hw/sensor/src/sensor_oic.c
----------------------------------------------------------------------
diff --git a/hw/sensor/src/sensor_oic.c b/hw/sensor/src/sensor_oic.c
index ab296a7..27edafd 100644
--- a/hw/sensor/src/sensor_oic.c
+++ b/hw/sensor/src/sensor_oic.c
@@ -44,6 +44,8 @@
#include <oic/oc_ri.h>
#include <oic/oc_api.h>
+static const char g_s_oic_dn[] = "x.mynewt.sensors.r.";
+
static int
sensor_oic_encode(struct sensor* sensor, void *arg, void *databuf)
{
@@ -456,19 +458,13 @@ sensor_oic_get_data(oc_request_t *request, oc_interface_mask_t interface)
int rc;
struct sensor *sensor;
struct sensor_listener listener;
- char *devname;
+ char devname[COAP_MAX_URI] = {0};
char *typename;
sensor_type_t type;
- const char s[2] = "/";
- char tmpstr[COAP_MAX_URI];
- memcpy(tmpstr, (char *)&(request->resource->uri.os_str[1]),
+ memcpy(devname, (char *)&(request->resource->uri.os_str[1]),
request->resource->uri.os_sz - 1);
- /* Parse the sensor device name from the uri */
- devname = strtok(tmpstr, s);
- typename = strtok(NULL, s);
-
/* Look up sensor by name */
sensor = sensor_mgr_find_next_bydevname(devname, NULL);
if (!sensor) {
@@ -476,6 +472,11 @@ sensor_oic_get_data(oc_request_t *request, oc_interface_mask_t interface)
goto err;
}
+ if (memcmp(g_s_oic_dn, request->resource->types.oa_arr.s,
+ sizeof(g_s_oic_dn) - 1)) {
+ goto err;
+ }
+
oc_rep_start_root_object();
switch (interface) {
@@ -485,6 +486,8 @@ sensor_oic_get_data(oc_request_t *request, oc_interface_mask_t interface)
/* Register a listener and then trigger/read a bunch of samples */
memset(&listener, 0, sizeof(listener));
+ typename =
+ &(request->resource->types.oa_arr.s[sizeof(g_s_oic_dn) - 1]);
rc = sensor_typename_to_type(typename, &type, sensor);
if (rc) {
/* Type either not supported by sensor or not found */
@@ -561,15 +564,13 @@ sensor_oic_init(void)
}
memset(tmpstr, 0, sizeof(tmpstr));
- snprintf(tmpstr, sizeof(tmpstr), "/%s/%s",
- sensor->s_dev->od_name, typename);
+ snprintf(tmpstr, sizeof(tmpstr), "/%s", sensor->s_dev->od_name);
+
res = oc_new_resource(tmpstr, 1, 0);
memset(tmpstr, 0, sizeof(tmpstr));
- snprintf(tmpstr, sizeof(tmpstr), "sensors.r.%s", sensor->s_dev->od_name);
-
+ snprintf(tmpstr, sizeof(tmpstr), "x.mynewt.sensors.r.%s", typename);
oc_resource_bind_resource_type(res, tmpstr);
-
oc_resource_bind_resource_interface(res, OC_IF_R);
oc_resource_set_default_interface(res, OC_IF_R);
[08/50] [abbrv] incubator-mynewt-core git commit: This closes #234.
Posted by ja...@apache.org.
This closes #234.
Merge branch 'sensy' of https://github.com/vrahane/incubator-mynewt-core
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/3bd1a0d0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/3bd1a0d0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/3bd1a0d0
Branch: refs/heads/bluetooth5
Commit: 3bd1a0d095a93c594bc27d9c9ed32742601d5f01
Parents: f5c02fe e301553
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Apr 17 16:38:25 2017 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Apr 17 16:38:25 2017 -0700
----------------------------------------------------------------------
apps/sensors_test/pkg.yml | 16 +-
apps/sensors_test/src/bleprph.h | 59 ++
apps/sensors_test/src/gatt_svr.c | 313 ++++++++++
apps/sensors_test/src/main.c | 338 ++++++++++-
apps/sensors_test/src/misc.c | 43 ++
apps/sensors_test/syscfg.yml | 30 +-
.../sensors/bno055/include/bno055/bno055.h | 33 --
hw/drivers/sensors/bno055/src/bno055_priv.h | 34 ++
hw/sensor/include/sensor/quat.h | 3 +-
hw/sensor/include/sensor/sensor.h | 4 +
hw/sensor/pkg.yml | 10 +
hw/sensor/src/sensor_oic.c | 587 +++++++++++++++++++
hw/sensor/syscfg.yml | 6 +
13 files changed, 1405 insertions(+), 71 deletions(-)
----------------------------------------------------------------------
[40/50] [abbrv] incubator-mynewt-core git commit: Misc: Add some
required includes to .h files.
Posted by ja...@apache.org.
Misc: Add some required includes to .h files.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/b16eed63
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/b16eed63
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/b16eed63
Branch: refs/heads/bluetooth5
Commit: b16eed6379619272d4ec0dee5dc0f86ee8b64607
Parents: 843e03d
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Apr 24 19:04:21 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Apr 24 19:20:57 2017 -0700
----------------------------------------------------------------------
hw/hal/include/hal/hal_timer.h | 3 +++
kernel/os/include/os/os.h | 5 +++--
sys/stats/full/include/stats/stats.h | 1 +
3 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b16eed63/hw/hal/include/hal/hal_timer.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_timer.h b/hw/hal/include/hal/hal_timer.h
index a2f717a..1937130 100644
--- a/hw/hal/include/hal/hal_timer.h
+++ b/hw/hal/include/hal/hal_timer.h
@@ -20,6 +20,9 @@
#ifndef H_HAL_TIMER_
#define H_HAL_TIMER_
+#include <inttypes.h>
+#include "os/queue.h"
+
#ifdef __cplusplus
extern "C" {
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b16eed63/kernel/os/include/os/os.h
----------------------------------------------------------------------
diff --git a/kernel/os/include/os/os.h b/kernel/os/include/os/os.h
index c8734d4..e37b913 100644
--- a/kernel/os/include/os/os.h
+++ b/kernel/os/include/os/os.h
@@ -72,10 +72,10 @@ enum os_error {
OS_TIMEOUT = 6,
OS_ERR_IN_ISR = 7, /* Function cannot be called from ISR */
OS_ERR_PRIV = 8, /* Privileged access error */
- OS_NOT_STARTED = 9, /* Operating must be started to call this function, but isn't */
+ OS_NOT_STARTED = 9, /* OS must be started to call this function, but isn't */
OS_ENOENT = 10, /* No such thing */
OS_EBUSY = 11, /* Resource busy */
- OS_ERROR = 12, /* Generic Error */
+ OS_ERROR = 12, /* Generic Error */
};
#define OS_WAIT_FOREVER (-1)
@@ -96,6 +96,7 @@ void os_init_idle_task(void);
#include "os/endian.h"
#include "os/os_arch.h"
#include "os/os_callout.h"
+#include "os/os_cputime.h"
#include "os/os_dev.h"
#include "os/os_eventq.h"
#include "os/os_heap.h"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b16eed63/sys/stats/full/include/stats/stats.h
----------------------------------------------------------------------
diff --git a/sys/stats/full/include/stats/stats.h b/sys/stats/full/include/stats/stats.h
index 1f381f1..5de0142 100644
--- a/sys/stats/full/include/stats/stats.h
+++ b/sys/stats/full/include/stats/stats.h
@@ -19,6 +19,7 @@
#ifndef __UTIL_STATS_H__
#define __UTIL_STATS_H__
+#include <stddef.h>
#include <stdint.h>
#include "syscfg/syscfg.h"
#include "os/queue.h"
[31/50] [abbrv] incubator-mynewt-core git commit: stm32f4xx,
erase flash should wait for complete
Posted by ja...@apache.org.
stm32f4xx, erase flash should wait for complete
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/cabdff91
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/cabdff91
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/cabdff91
Branch: refs/heads/bluetooth5
Commit: cabdff917d4494d6bce6aabdace0533a44b3b2c8
Parents: 271ab1b
Author: wesley <we...@wolinke.com>
Authored: Sun Apr 23 12:39:55 2017 +0800
Committer: wesley <we...@wolinke.com>
Committed: Sun Apr 23 12:39:55 2017 +0800
----------------------------------------------------------------------
hw/mcu/stm/stm32f4xx/src/hal_flash.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cabdff91/hw/mcu/stm/stm32f4xx/src/hal_flash.c
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/src/hal_flash.c b/hw/mcu/stm/stm32f4xx/src/hal_flash.c
index bc36a3b..2b18772 100644
--- a/hw/mcu/stm/stm32f4xx/src/hal_flash.c
+++ b/hw/mcu/stm/stm32f4xx/src/hal_flash.c
@@ -106,7 +106,16 @@ stm32f4_flash_write(const struct hal_flash *dev, uint32_t address,
static void
stm32f4_flash_erase_sector_id(int sector_id)
{
- FLASH_Erase_Sector(sector_id, FLASH_VOLTAGE_RANGE_1);
+ FLASH_EraseInitTypeDef eraseinit;
+ uint32_t SectorError;
+
+ eraseinit.TypeErase = FLASH_TYPEERASE_SECTORS;
+ eraseinit.Banks = 0;
+ eraseinit.Sector = sector_id;
+ eraseinit.NbSectors = 1;
+ eraseinit.VoltageRange = FLASH_VOLTAGE_RANGE_1;
+
+ HAL_FLASHEx_Erase(&eraseinit, &SectorError);
}
static int
[20/50] [abbrv] incubator-mynewt-core git commit: hw/mcu/native;
remove dependency on compiler/sim; bsp already has it.
Posted by ja...@apache.org.
hw/mcu/native; remove dependency on compiler/sim; bsp already has it.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/1b5f14c6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/1b5f14c6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/1b5f14c6
Branch: refs/heads/bluetooth5
Commit: 1b5f14c6fc906ae48e502ceb59108fb19c879812
Parents: 6d3edb3
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Apr 19 15:34:15 2017 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Apr 19 15:34:15 2017 -0700
----------------------------------------------------------------------
hw/mcu/native/pkg.yml | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1b5f14c6/hw/mcu/native/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/mcu/native/pkg.yml b/hw/mcu/native/pkg.yml
index 79df5a7..f8309f7 100644
--- a/hw/mcu/native/pkg.yml
+++ b/hw/mcu/native/pkg.yml
@@ -27,7 +27,6 @@ pkg.keywords:
pkg.deps:
- hw/hal
- - compiler/sim
pkg.req_apis:
- console
[33/50] [abbrv] incubator-mynewt-core git commit: kernel/os: Add
os_eventq_get_no_wait function
Posted by ja...@apache.org.
kernel/os: Add os_eventq_get_no_wait function
This function is needed in interrupt context for quick queue
polls.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/10d350c5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/10d350c5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/10d350c5
Branch: refs/heads/bluetooth5
Commit: 10d350c5ebb751a371fae7c0d2c73a80af4c2d45
Parents: 271ab1b
Author: Micha\u0142 Narajowski <mi...@codecoup.pl>
Authored: Fri Jan 27 16:01:20 2017 +0100
Committer: Micha\u0142 Narajowski <mi...@codecoup.pl>
Committed: Mon Apr 24 09:27:37 2017 -0700
----------------------------------------------------------------------
kernel/os/include/os/os_eventq.h | 1 +
kernel/os/src/os_eventq.c | 14 ++++++++++++++
2 files changed, 15 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/10d350c5/kernel/os/include/os/os_eventq.h
----------------------------------------------------------------------
diff --git a/kernel/os/include/os/os_eventq.h b/kernel/os/include/os/os_eventq.h
index 2ae779c..812d822 100644
--- a/kernel/os/include/os/os_eventq.h
+++ b/kernel/os/include/os/os_eventq.h
@@ -49,6 +49,7 @@ struct os_eventq {
void os_eventq_init(struct os_eventq *);
int os_eventq_inited(const struct os_eventq *evq);
void os_eventq_put(struct os_eventq *, struct os_event *);
+struct os_event *os_eventq_get_no_wait(struct os_eventq *evq);
struct os_event *os_eventq_get(struct os_eventq *);
void os_eventq_run(struct os_eventq *evq);
struct os_event *os_eventq_poll(struct os_eventq **, int, os_time_t);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/10d350c5/kernel/os/src/os_eventq.c
----------------------------------------------------------------------
diff --git a/kernel/os/src/os_eventq.c b/kernel/os/src/os_eventq.c
index 626d560..ed9aa37 100644
--- a/kernel/os/src/os_eventq.c
+++ b/kernel/os/src/os_eventq.c
@@ -96,6 +96,20 @@ os_eventq_put(struct os_eventq *evq, struct os_event *ev)
}
}
+struct os_event *
+os_eventq_get_no_wait(struct os_eventq *evq)
+{
+ struct os_event *ev;
+
+ ev = STAILQ_FIRST(&evq->evq_list);
+ if (ev) {
+ STAILQ_REMOVE(&evq->evq_list, ev, os_event, ev_next);
+ ev->ev_queued = 0;
+ }
+
+ return ev;
+}
+
/**
* Pull a single item from an event queue. This function blocks until there
* is an item on the event queue to read.
[03/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-729
SensorAPI: Send sensor data over OIC
Posted by ja...@apache.org.
MYNEWT-729 SensorAPI: Send sensor data over OIC
- Add timestamp in oic sensor payload
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/a6b41a55
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/a6b41a55
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/a6b41a55
Branch: refs/heads/bluetooth5
Commit: a6b41a554c4dc5855658b8cca4698ae2576af0cd
Parents: ecf3a28
Author: Vipul Rahane <vi...@apache.org>
Authored: Fri Apr 7 17:06:00 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Mon Apr 17 16:14:20 2017 -0700
----------------------------------------------------------------------
apps/sensors_test/src/bleprph.h | 59 ++++++++++++++++++++++++++++++++++++
hw/sensor/src/sensor_oic.c | 6 +++-
2 files changed, 64 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a6b41a55/apps/sensors_test/src/bleprph.h
----------------------------------------------------------------------
diff --git a/apps/sensors_test/src/bleprph.h b/apps/sensors_test/src/bleprph.h
new file mode 100644
index 0000000..2e3f024
--- /dev/null
+++ b/apps/sensors_test/src/bleprph.h
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLEPRPH_
+#define H_BLEPRPH_
+
+#include "log/log.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ble_hs_cfg;
+struct ble_gatt_register_ctxt;
+
+extern struct log bleprph_log;
+
+/* bleprph uses the first "peruser" log module. */
+#define BLEPRPH_LOG_MODULE (LOG_MODULE_PERUSER + 0)
+
+/* Convenience macro for logging to the bleprph module. */
+#define BLEPRPH_LOG(lvl, ...) \
+ LOG_ ## lvl(&bleprph_log, BLEPRPH_LOG_MODULE, __VA_ARGS__)
+
+/** GATT server. */
+#define GATT_SVR_SVC_ALERT_UUID 0x1811
+#define GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID 0x2A47
+#define GATT_SVR_CHR_NEW_ALERT 0x2A46
+#define GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID 0x2A48
+#define GATT_SVR_CHR_UNR_ALERT_STAT_UUID 0x2A45
+#define GATT_SVR_CHR_ALERT_NOT_CTRL_PT 0x2A44
+
+void gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg);
+int gatt_svr_init(void);
+
+/** Misc. */
+void print_bytes(const uint8_t *bytes, int len);
+void print_addr(const void *addr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a6b41a55/hw/sensor/src/sensor_oic.c
----------------------------------------------------------------------
diff --git a/hw/sensor/src/sensor_oic.c b/hw/sensor/src/sensor_oic.c
index ea86122..b30f417 100644
--- a/hw/sensor/src/sensor_oic.c
+++ b/hw/sensor/src/sensor_oic.c
@@ -252,7 +252,7 @@ sensor_oic_encode(struct sensor* sensor, void *arg, void *databuf)
}
if (((struct sensor_color_data *)(databuf))->scd_cratio_is_valid) {
oc_rep_set_double(root, cratio,
- ((struct sensor_color_data *)(databuf))->scd_cratio_is_valid);
+ ((struct sensor_color_data *)(databuf))->scd_cratio);
} else {
goto err;
}
@@ -280,6 +280,10 @@ sensor_oic_encode(struct sensor* sensor, void *arg, void *databuf)
goto err;
}
+ oc_rep_set_uint(root, ts_secs, (long int)sensor->s_sts.st_ostv.tv_sec);
+ oc_rep_set_int(root, ts_usecs, (int)sensor->s_sts.st_ostv.tv_usec);
+ oc_rep_set_uint(root, ts_cputime, (unsigned int)sensor->s_sts.st_cputime);
+
return 0;
err:
return rc;
[09/50] [abbrv] incubator-mynewt-core git commit: No Ticket:
Redefining user defined sensor types
Posted by ja...@apache.org.
No Ticket: Redefining user defined sensor types
- It was correct before. It was changed to accomodate more sensors but
there was discontinuation in the types.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/813463ed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/813463ed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/813463ed
Branch: refs/heads/bluetooth5
Commit: 813463edfaa10383a35798ead25ac2708a69608f
Parents: 3bd1a0d
Author: Vipul Rahane <vi...@apache.org>
Authored: Tue Apr 18 11:42:02 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Tue Apr 18 11:47:55 2017 -0700
----------------------------------------------------------------------
hw/sensor/include/sensor/sensor.h | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/813463ed/hw/sensor/include/sensor/sensor.h
----------------------------------------------------------------------
diff --git a/hw/sensor/include/sensor/sensor.h b/hw/sensor/include/sensor/sensor.h
index fb5bf2d..b792685 100644
--- a/hw/sensor/include/sensor/sensor.h
+++ b/hw/sensor/include/sensor/sensor.h
@@ -68,17 +68,28 @@ typedef enum {
/* Weight Supported */
SENSOR_TYPE_WEIGHT = (1 << 11),
/* Linear Accelerometer (Without Gravity) */
- SENSOR_TYPE_LINEAR_ACCEL = (1 << 26),
+ SENSOR_TYPE_LINEAR_ACCEL = (1 << 12),
/* Gravity Sensor */
- SENSOR_TYPE_GRAVITY = (1 << 27),
+ SENSOR_TYPE_GRAVITY = (1 << 13),
/* Euler Orientation Sensor */
- SENSOR_TYPE_EULER = (1 << 28),
+ SENSOR_TYPE_EULER = (1 << 14),
/* Color Sensor */
- SENSOR_TYPE_COLOR = (1 << 29),
+ SENSOR_TYPE_COLOR = (1 << 15),
+
+ /* Standard sensor types to be defined here */
+
/* User defined sensor type 1 */
- SENSOR_TYPE_USER_DEFINED_1 = (1 << 30),
+ SENSOR_TYPE_USER_DEFINED_1 = (1 << 26),
/* User defined sensor type 2 */
- SENSOR_TYPE_USER_DEFINED_2 = (1 << 31),
+ SENSOR_TYPE_USER_DEFINED_2 = (1 << 27),
+ /* User defined sensor type 3 */
+ SENSOR_TYPE_USER_DEFINED_3 = (1 << 28),
+ /* User defined sensor type 4 */
+ SENSOR_TYPE_USER_DEFINED_4 = (1 << 29),
+ /* User defined sensor type 5 */
+ SENSOR_TYPE_USER_DEFINED_5 = (1 << 30),
+ /* User defined sensor type 6 */
+ SENSOR_TYPE_USER_DEFINED_6 = (1 << 31),
/* A selector, describes all sensors */
SENSOR_TYPE_ALL = 0xFFFFFFFF
} sensor_type_t;
[13/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-732: Fix
ble_gattc_disc_svc_by_uuid
Posted by ja...@apache.org.
MYNEWT-732: Fix ble_gattc_disc_svc_by_uuid
Broken in a refactor in 191acab73c9c77c157a806d8871b653f3c64cbc9.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/1ae17576
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/1ae17576
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/1ae17576
Branch: refs/heads/bluetooth5
Commit: 1ae17576b9d9c48c659397afd03d053a8b896a00
Parents: 73c8953
Author: Simon Ratner <si...@probablyprime.net>
Authored: Wed Apr 19 10:48:34 2017 -0700
Committer: Simon Ratner <si...@probablyprime.net>
Committed: Wed Apr 19 10:51:34 2017 -0700
----------------------------------------------------------------------
net/nimble/host/src/ble_att_clt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1ae17576/net/nimble/host/src/ble_att_clt.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_clt.c b/net/nimble/host/src/ble_att_clt.c
index 9ff9b53..23e140d 100644
--- a/net/nimble/host/src/ble_att_clt.c
+++ b/net/nimble/host/src/ble_att_clt.c
@@ -295,7 +295,7 @@ ble_att_clt_tx_find_type_value(uint16_t conn_handle, uint16_t start_handle,
return BLE_HS_EINVAL;
}
- req = ble_att_cmd_get(BLE_ATT_OP_FIND_INFO_REQ, sizeof(*req) + value_len,
+ req = ble_att_cmd_get(BLE_ATT_OP_FIND_TYPE_VALUE_REQ, sizeof(*req) + value_len,
&txom);
if (req == NULL) {
return BLE_HS_ENOMEM;
[35/50] [abbrv] incubator-mynewt-core git commit: drivers/rtt: add
SEGGER RTT package
Posted by ja...@apache.org.
drivers/rtt: add SEGGER RTT package
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/d36cccb2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/d36cccb2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/d36cccb2
Branch: refs/heads/bluetooth5
Commit: d36cccb2d7cb278b27dc6476e6cd6720f6459f86
Parents: 10d350c
Author: Micha\u0142 Narajowski <mi...@codecoup.pl>
Authored: Mon Feb 20 14:07:00 2017 +0100
Committer: Micha\u0142 Narajowski <mi...@codecoup.pl>
Committed: Mon Apr 24 09:27:37 2017 -0700
----------------------------------------------------------------------
hw/drivers/rtt/include/rtt/SEGGER_RTT.h | 244 ++++
hw/drivers/rtt/include/rtt/SEGGER_RTT_Conf.h | 265 ++++
hw/drivers/rtt/pkg.yml | 28 +
hw/drivers/rtt/src/SEGGER_RTT.c | 1462 +++++++++++++++++++++
hw/drivers/rtt/src/SEGGER_RTT_printf.c | 511 +++++++
5 files changed, 2510 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d36cccb2/hw/drivers/rtt/include/rtt/SEGGER_RTT.h
----------------------------------------------------------------------
diff --git a/hw/drivers/rtt/include/rtt/SEGGER_RTT.h b/hw/drivers/rtt/include/rtt/SEGGER_RTT.h
new file mode 100644
index 0000000..b4417a0
--- /dev/null
+++ b/hw/drivers/rtt/include/rtt/SEGGER_RTT.h
@@ -0,0 +1,244 @@
+/*********************************************************************
+* SEGGER MICROCONTROLLER GmbH & Co. KG *
+* Solutions for real time microcontroller applications *
+**********************************************************************
+* *
+* (c) 2014 - 2016 SEGGER Microcontroller GmbH & Co. KG *
+* *
+* www.segger.com Support: support@segger.com *
+* *
+**********************************************************************
+* *
+* SEGGER RTT * Real Time Transfer for embedded targets *
+* *
+**********************************************************************
+* *
+* All rights reserved. *
+* *
+* SEGGER strongly recommends to not make any changes *
+* to or modify the source code of this software in order to stay *
+* compatible with the RTT protocol and J-Link. *
+* *
+* Redistribution and use in source and binary forms, with or *
+* without modification, are permitted provided that the following *
+* conditions are met: *
+* *
+* o Redistributions of source code must retain the above copyright *
+* notice, this list of conditions and the following disclaimer. *
+* *
+* o Redistributions in binary form 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. *
+* *
+* o Neither the name of SEGGER Microcontroller GmbH & Co. KG *
+* nor the names of its contributors may be used to endorse or *
+* promote products derived from this software without specific *
+* prior written permission. *
+* *
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
+* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
+* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
+* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller 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. *
+* *
+**********************************************************************
+---------------------------END-OF-HEADER------------------------------
+File : SEGGER_RTT.h
+Purpose : Implementation of SEGGER real-time transfer which allows
+ real-time communication on targets which support debugger
+ memory accesses while the CPU is running.
+Revision: $Rev: 4351 $
+----------------------------------------------------------------------
+*/
+
+#ifndef SEGGER_RTT_H
+#define SEGGER_RTT_H
+
+#include "rtt/SEGGER_RTT_Conf.h"
+
+/*********************************************************************
+*
+* Defines, fixed
+*
+**********************************************************************
+*/
+
+/*********************************************************************
+*
+* Types
+*
+**********************************************************************
+*/
+
+//
+// Description for a circular buffer (also called "ring buffer")
+// which is used as up-buffer (T->H)
+//
+typedef struct {
+ const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
+ char* pBuffer; // Pointer to start of buffer
+ unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
+ unsigned WrOff; // Position of next item to be written by either target.
+ volatile unsigned RdOff; // Position of next item to be read by host. Must be volatile since it may be modified by host.
+ unsigned Flags; // Contains configuration flags
+} SEGGER_RTT_BUFFER_UP;
+
+//
+// Description for a circular buffer (also called "ring buffer")
+// which is used as down-buffer (H->T)
+//
+typedef struct {
+ const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
+ char* pBuffer; // Pointer to start of buffer
+ unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
+ volatile unsigned WrOff; // Position of next item to be written by host. Must be volatile since it may be modified by host.
+ unsigned RdOff; // Position of next item to be read by target (down-buffer).
+ unsigned Flags; // Contains configuration flags
+} SEGGER_RTT_BUFFER_DOWN;
+
+//
+// RTT control block which describes the number of buffers available
+// as well as the configuration for each buffer
+//
+//
+typedef struct {
+ char acID[16]; // Initialized to "SEGGER RTT"
+ int MaxNumUpBuffers; // Initialized to SEGGER_RTT_MAX_NUM_UP_BUFFERS (type. 2)
+ int MaxNumDownBuffers; // Initialized to SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (type. 2)
+ SEGGER_RTT_BUFFER_UP aUp[SEGGER_RTT_MAX_NUM_UP_BUFFERS]; // Up buffers, transferring information up from target via debug probe to host
+ SEGGER_RTT_BUFFER_DOWN aDown[SEGGER_RTT_MAX_NUM_DOWN_BUFFERS]; // Down buffers, transferring information down from host via debug probe to target
+} SEGGER_RTT_CB;
+
+/*********************************************************************
+*
+* Global data
+*
+**********************************************************************
+*/
+extern SEGGER_RTT_CB _SEGGER_RTT;
+
+/*********************************************************************
+*
+* RTT API functions
+*
+**********************************************************************
+*/
+#ifdef __cplusplus
+ extern "C" {
+#endif
+int SEGGER_RTT_AllocDownBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
+int SEGGER_RTT_AllocUpBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
+int SEGGER_RTT_ConfigUpBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
+int SEGGER_RTT_ConfigDownBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
+int SEGGER_RTT_GetKey (void);
+unsigned SEGGER_RTT_HasData (unsigned BufferIndex);
+int SEGGER_RTT_HasKey (void);
+void SEGGER_RTT_Init (void);
+unsigned SEGGER_RTT_Read (unsigned BufferIndex, void* pBuffer, unsigned BufferSize);
+unsigned SEGGER_RTT_ReadNoLock (unsigned BufferIndex, void* pData, unsigned BufferSize);
+int SEGGER_RTT_SetNameDownBuffer (unsigned BufferIndex, const char* sName);
+int SEGGER_RTT_SetNameUpBuffer (unsigned BufferIndex, const char* sName);
+int SEGGER_RTT_SetFlagsDownBuffer (unsigned BufferIndex, unsigned Flags);
+int SEGGER_RTT_SetFlagsUpBuffer (unsigned BufferIndex, unsigned Flags);
+int SEGGER_RTT_WaitKey (void);
+unsigned SEGGER_RTT_Write (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
+unsigned SEGGER_RTT_WriteNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
+unsigned SEGGER_RTT_WriteSkipNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
+unsigned SEGGER_RTT_WriteString (unsigned BufferIndex, const char* s);
+void SEGGER_RTT_WriteWithOverwriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
+//
+// Function macro for performance optimization
+//
+#define SEGGER_RTT_HASDATA(n) (_SEGGER_RTT.aDown[n].WrOff - _SEGGER_RTT.aDown[n].RdOff)
+
+/*********************************************************************
+*
+* RTT "Terminal" API functions
+*
+**********************************************************************
+*/
+int 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, ...);
+#ifdef __cplusplus
+ }
+#endif
+
+/*********************************************************************
+*
+* Defines
+*
+**********************************************************************
+*/
+
+//
+// Operating modes. Define behavior if buffer is full (not enough space for entire message)
+//
+#define SEGGER_RTT_MODE_NO_BLOCK_SKIP (0U) // Skip. Do not block, output nothing. (Default)
+#define SEGGER_RTT_MODE_NO_BLOCK_TRIM (1U) // Trim: Do not block, output as much as fits.
+#define SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL (2U) // Block: Wait until there is space in the buffer.
+#define SEGGER_RTT_MODE_MASK (3U)
+
+//
+// Control sequences, based on ANSI.
+// Can be used to control color, and clear the screen
+//
+#define RTT_CTRL_RESET "[0m" // Reset to default colors
+#define RTT_CTRL_CLEAR "[2J" // Clear screen, reposition cursor to top left
+
+#define RTT_CTRL_TEXT_BLACK "[2;30m"
+#define RTT_CTRL_TEXT_RED "[2;31m"
+#define RTT_CTRL_TEXT_GREEN "[2;32m"
+#define RTT_CTRL_TEXT_YELLOW "[2;33m"
+#define RTT_CTRL_TEXT_BLUE "[2;34m"
+#define RTT_CTRL_TEXT_MAGENTA "[2;35m"
+#define RTT_CTRL_TEXT_CYAN "[2;36m"
+#define RTT_CTRL_TEXT_WHITE "[2;37m"
+
+#define RTT_CTRL_TEXT_BRIGHT_BLACK "[1;30m"
+#define RTT_CTRL_TEXT_BRIGHT_RED "[1;31m"
+#define RTT_CTRL_TEXT_BRIGHT_GREEN "[1;32m"
+#define RTT_CTRL_TEXT_BRIGHT_YELLOW "[1;33m"
+#define RTT_CTRL_TEXT_BRIGHT_BLUE "[1;34m"
+#define RTT_CTRL_TEXT_BRIGHT_MAGENTA "[1;35m"
+#define RTT_CTRL_TEXT_BRIGHT_CYAN "[1;36m"
+#define RTT_CTRL_TEXT_BRIGHT_WHITE "[1;37m"
+
+#define RTT_CTRL_BG_BLACK "[24;40m"
+#define RTT_CTRL_BG_RED "[24;41m"
+#define RTT_CTRL_BG_GREEN "[24;42m"
+#define RTT_CTRL_BG_YELLOW "[24;43m"
+#define RTT_CTRL_BG_BLUE "[24;44m"
+#define RTT_CTRL_BG_MAGENTA "[24;45m"
+#define RTT_CTRL_BG_CYAN "[24;46m"
+#define RTT_CTRL_BG_WHITE "[24;47m"
+
+#define RTT_CTRL_BG_BRIGHT_BLACK "[4;40m"
+#define RTT_CTRL_BG_BRIGHT_RED "[4;41m"
+#define RTT_CTRL_BG_BRIGHT_GREEN "[4;42m"
+#define RTT_CTRL_BG_BRIGHT_YELLOW "[4;43m"
+#define RTT_CTRL_BG_BRIGHT_BLUE "[4;44m"
+#define RTT_CTRL_BG_BRIGHT_MAGENTA "[4;45m"
+#define RTT_CTRL_BG_BRIGHT_CYAN "[4;46m"
+#define RTT_CTRL_BG_BRIGHT_WHITE "[4;47m"
+
+
+#endif
+
+/*************************** End of file ****************************/
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d36cccb2/hw/drivers/rtt/include/rtt/SEGGER_RTT_Conf.h
----------------------------------------------------------------------
diff --git a/hw/drivers/rtt/include/rtt/SEGGER_RTT_Conf.h b/hw/drivers/rtt/include/rtt/SEGGER_RTT_Conf.h
new file mode 100644
index 0000000..6a7a3ae
--- /dev/null
+++ b/hw/drivers/rtt/include/rtt/SEGGER_RTT_Conf.h
@@ -0,0 +1,265 @@
+/*********************************************************************
+* SEGGER MICROCONTROLLER GmbH & Co. KG *
+* Solutions for real time microcontroller applications *
+**********************************************************************
+* *
+* (c) 2014 - 2016 SEGGER Microcontroller GmbH & Co. KG *
+* *
+* www.segger.com Support: support@segger.com *
+* *
+**********************************************************************
+* *
+* SEGGER RTT * Real Time Transfer for embedded targets *
+* *
+**********************************************************************
+* *
+* All rights reserved. *
+* *
+* SEGGER strongly recommends to not make any changes *
+* to or modify the source code of this software in order to stay *
+* compatible with the RTT protocol and J-Link. *
+* *
+* Redistribution and use in source and binary forms, with or *
+* without modification, are permitted provided that the following *
+* conditions are met: *
+* *
+* o Redistributions of source code must retain the above copyright *
+* notice, this list of conditions and the following disclaimer. *
+* *
+* o Redistributions in binary form 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. *
+* *
+* o Neither the name of SEGGER Microcontroller GmbH & Co. KG *
+* nor the names of its contributors may be used to endorse or *
+* promote products derived from this software without specific *
+* prior written permission. *
+* *
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
+* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
+* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
+* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller 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. *
+* *
+**********************************************************************
+---------------------------END-OF-HEADER------------------------------
+File : SEGGER_RTT_Conf.h
+Purpose : Implementation of SEGGER real-time transfer (RTT) which
+ allows real-time communication on targets which support
+ debugger memory accesses while the CPU is running.
+Revision: $Rev: 4351 $
+----------------------------------------------------------------------
+*/
+
+#ifndef SEGGER_RTT_CONF_H
+#define SEGGER_RTT_CONF_H
+
+#ifdef __IAR_SYSTEMS_ICC__
+ #include <intrinsics.h>
+#endif
+
+/*********************************************************************
+*
+* Defines, configurable
+*
+**********************************************************************
+*/
+
+#define SEGGER_RTT_MAX_NUM_UP_BUFFERS (3) // Max. number of up-buffers (T->H) available on this target (Default: 3)
+#define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (3) // Max. number of down-buffers (H->T) available on this target (Default: 3)
+
+#define BUFFER_SIZE_UP (1024) // 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 (64u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64)
+
+#define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP // Mode for pre-initialized terminal channel (buffer 0)
+
+//
+// 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.
+//
+// SEGGER_RTT_MAX_INTERRUPT_PRIORITY can be used in the sample lock routines on Cortex-M3/4.
+// Make sure to mask all interrupts which can send RTT data, i.e. generate SystemView events, or cause task switches.
+// When high-priority interrupts must not be masked while sending RTT data, SEGGER_RTT_MAX_INTERRUPT_PRIORITY needs to be adjusted accordingly.
+// (Higher priority = lower priority number)
+// Default value for embOS: 128u
+// Default configuration in FreeRTOS: configMAX_SYSCALL_INTERRUPT_PRIORITY: ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+// In case of doubt mask all interrupts: 1 << (8 - BASEPRI_PRIO_BITS) i.e. 1 << 5 when 3 bits are implemented in NVIC
+// or define SEGGER_RTT_LOCK() to completely disable interrupts.
+//
+
+#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20)
+
+/*********************************************************************
+*
+* RTT lock configuration for SEGGER Embedded Studio,
+* Rowley CrossStudio and GCC
+*/
+#if (defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__)
+ #ifdef __ARM_ARCH_6M__
+ #define SEGGER_RTT_LOCK() { \
+ unsigned int LockState; \
+ __asm volatile ("mrs %0, primask \n\t" \
+ "mov r1, $1 \n\t" \
+ "msr primask, r1 \n\t" \
+ : "=r" (LockState) \
+ : \
+ : "r1" \
+ );
+
+ #define SEGGER_RTT_UNLOCK() __asm volatile ("msr primask, %0 \n\t" \
+ : \
+ : "r" (LockState) \
+ : \
+ ); \
+ }
+
+ #elif (defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__))
+ #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
+ #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
+ #endif
+ #define SEGGER_RTT_LOCK() { \
+ unsigned int LockState; \
+ __asm volatile ("mrs %0, basepri \n\t" \
+ "mov r1, %1 \n\t" \
+ "msr basepri, r1 \n\t" \
+ : "=r" (LockState) \
+ : "i"(SEGGER_RTT_MAX_INTERRUPT_PRIORITY) \
+ : "r1" \
+ );
+
+ #define SEGGER_RTT_UNLOCK() __asm volatile ("msr basepri, %0 \n\t" \
+ : \
+ : "r" (LockState) \
+ : \
+ ); \
+ }
+
+ #elif defined(__ARM_ARCH_7A__)
+ #define SEGGER_RTT_LOCK() { \
+ unsigned int LockState; \
+ __asm volatile ("mrs r1, CPSR \n\t" \
+ "mov %0, r1 \n\t" \
+ "orr r1, r1, #0xC0 \n\t" \
+ "msr CPSR_c, r1 \n\t" \
+ : "=r" (LockState) \
+ : \
+ : "r1" \
+ );
+
+ #define SEGGER_RTT_UNLOCK() __asm volatile ("mov r0, %0 \n\t" \
+ "mrs r1, CPSR \n\t" \
+ "bic r1, r1, #0xC0 \n\t" \
+ "and r0, r0, #0xC0 \n\t" \
+ "orr r1, r1, r0 \n\t" \
+ "msr CPSR_c, r1 \n\t" \
+ : \
+ : "r" (LockState) \
+ : "r0", "r1" \
+ ); \
+ }
+#else
+ #define SEGGER_RTT_LOCK()
+ #define SEGGER_RTT_UNLOCK()
+ #endif
+#endif
+
+/*********************************************************************
+*
+* RTT lock configuration for IAR EWARM
+*/
+#ifdef __ICCARM__
+ #if (defined (__ARM6M__) && (__CORE__ == __ARM6M__))
+ #define SEGGER_RTT_LOCK() { \
+ unsigned int LockState; \
+ LockState = __get_PRIMASK(); \
+ __set_PRIMASK(1);
+
+ #define SEGGER_RTT_UNLOCK() __set_PRIMASK(LockState); \
+ }
+ #elif ((defined (__ARM7EM__) && (__CORE__ == __ARM7EM__)) || (defined (__ARM7M__) && (__CORE__ == __ARM7M__)))
+ #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
+ #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
+ #endif
+ #define SEGGER_RTT_LOCK() { \
+ unsigned int LockState; \
+ LockState = __get_BASEPRI(); \
+ __set_BASEPRI(SEGGER_RTT_MAX_INTERRUPT_PRIORITY);
+
+ #define SEGGER_RTT_UNLOCK() __set_BASEPRI(LockState); \
+ }
+ #endif
+#endif
+
+/*********************************************************************
+*
+* RTT lock configuration for IAR RX
+*/
+#ifdef __ICCRX__
+ #define SEGGER_RTT_LOCK() { \
+ unsigned long LockState; \
+ LockState = __get_interrupt_state(); \
+ __disable_interrupt();
+
+ #define SEGGER_RTT_UNLOCK() __set_interrupt_state(LockState); \
+ }
+#endif
+
+/*********************************************************************
+*
+* RTT lock configuration for KEIL ARM
+*/
+#ifdef __CC_ARM
+ #if (defined __TARGET_ARCH_6S_M)
+ #define SEGGER_RTT_LOCK() { \
+ unsigned int LockState; \
+ register unsigned char PRIMASK __asm( "primask"); \
+ LockState = PRIMASK; \
+ PRIMASK = 1u; \
+ __schedule_barrier();
+
+ #define SEGGER_RTT_UNLOCK() PRIMASK = LockState; \
+ __schedule_barrier(); \
+ }
+ #elif (defined(__TARGET_ARCH_7_M) || defined(__TARGET_ARCH_7E_M))
+ #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
+ #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
+ #endif
+ #define SEGGER_RTT_LOCK() { \
+ unsigned int LockState; \
+ register unsigned char BASEPRI __asm( "basepri"); \
+ LockState = BASEPRI; \
+ BASEPRI = SEGGER_RTT_MAX_INTERRUPT_PRIORITY; \
+ __schedule_barrier();
+
+ #define SEGGER_RTT_UNLOCK() BASEPRI = LockState; \
+ __schedule_barrier(); \
+ }
+ #endif
+#endif
+
+/*********************************************************************
+*
+* RTT lock configuration fallback
+*/
+#ifndef SEGGER_RTT_LOCK
+ #define SEGGER_RTT_LOCK() // Lock RTT (nestable) (i.e. disable interrupts)
+#endif
+
+#ifndef SEGGER_RTT_UNLOCK
+ #define SEGGER_RTT_UNLOCK() // Unlock RTT (nestable) (i.e. enable previous interrupt lock state)
+#endif
+
+#endif
+/*************************** End of file ****************************/
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d36cccb2/hw/drivers/rtt/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/drivers/rtt/pkg.yml b/hw/drivers/rtt/pkg.yml
new file mode 100644
index 0000000..43dfe4a
--- /dev/null
+++ b/hw/drivers/rtt/pkg.yml
@@ -0,0 +1,28 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+pkg.name: hw/drivers/rtt
+pkg.description: Segger RTT driver
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
+pkg.keywords:
+pkg.deps:
+pkg.req_apis:
+pkg.init:
+ rtt_pkg_init: 19
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d36cccb2/hw/drivers/rtt/src/SEGGER_RTT.c
----------------------------------------------------------------------
diff --git a/hw/drivers/rtt/src/SEGGER_RTT.c b/hw/drivers/rtt/src/SEGGER_RTT.c
new file mode 100644
index 0000000..4e5aeec
--- /dev/null
+++ b/hw/drivers/rtt/src/SEGGER_RTT.c
@@ -0,0 +1,1462 @@
+/*********************************************************************
+* SEGGER MICROCONTROLLER GmbH & Co. KG *
+* Solutions for real time microcontroller applications *
+**********************************************************************
+* *
+* (c) 2014 - 2016 SEGGER Microcontroller GmbH & Co. KG *
+* *
+* www.segger.com Support: support@segger.com *
+* *
+**********************************************************************
+* *
+* SEGGER RTT * Real Time Transfer for embedded targets *
+* *
+**********************************************************************
+* *
+* All rights reserved. *
+* *
+* SEGGER strongly recommends to not make any changes *
+* to or modify the source code of this software in order to stay *
+* compatible with the RTT protocol and J-Link. *
+* *
+* Redistribution and use in source and binary forms, with or *
+* without modification, are permitted provided that the following *
+* conditions are met: *
+* *
+* o Redistributions of source code must retain the above copyright *
+* notice, this list of conditions and the following disclaimer. *
+* *
+* o Redistributions in binary form 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. *
+* *
+* o Neither the name of SEGGER Microcontroller GmbH & Co. KG *
+* nor the names of its contributors may be used to endorse or *
+* promote products derived from this software without specific *
+* prior written permission. *
+* *
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
+* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
+* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
+* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller 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. *
+* *
+**********************************************************************
+---------------------------END-OF-HEADER------------------------------
+File : SEGGER_RTT.c
+Purpose : Implementation of SEGGER real-time transfer (RTT) which
+ allows real-time communication on targets which support
+ debugger memory accesses while the CPU is running.
+Revision: $Rev: 4351 $
+
+Additional information:
+ Type "int" is assumed to be 32-bits in size
+ H->T Host to target communication
+ T->H Target to host communication
+
+ RTT channel 0 is always present and reserved for Terminal usage.
+ Name is fixed to "Terminal"
+
+ Effective buffer size: SizeOfBuffer - 1
+
+ WrOff == RdOff: Buffer is empty
+ WrOff == (RdOff - 1): Buffer is full
+ WrOff > RdOff: Free space includes wrap-around
+ WrOff < RdOff: Used space includes wrap-around
+ (WrOff == (SizeOfBuffer - 1)) && (RdOff == 0):
+ Buffer full and wrap-around after next byte
+
+
+----------------------------------------------------------------------
+*/
+
+#include "rtt/SEGGER_RTT.h"
+#include "sysinit/sysinit.h"
+
+#include <string.h> // for memcpy
+
+/*********************************************************************
+*
+* Configuration, default values
+*
+**********************************************************************
+*/
+
+#ifndef BUFFER_SIZE_UP
+ #define BUFFER_SIZE_UP 1024 // Size of the buffer for terminal output of target, up to host
+#endif
+
+#ifndef BUFFER_SIZE_DOWN
+ #define BUFFER_SIZE_DOWN 16 // Size of the buffer for terminal input to target from host (Usually keyboard input)
+#endif
+
+#ifndef SEGGER_RTT_MAX_NUM_UP_BUFFERS
+ #define SEGGER_RTT_MAX_NUM_UP_BUFFERS 2 // Number of up-buffers (T->H) available on this target
+#endif
+
+#ifndef SEGGER_RTT_MAX_NUM_DOWN_BUFFERS
+ #define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS 2 // Number of down-buffers (H->T) available on this target
+#endif
+
+#ifndef SEGGER_RTT_BUFFER_SECTION
+ #if defined(SEGGER_RTT_SECTION)
+ #define SEGGER_RTT_BUFFER_SECTION SEGGER_RTT_SECTION
+ #endif
+#endif
+
+#ifndef SEGGER_RTT_ALIGNMENT
+ #define SEGGER_RTT_ALIGNMENT 0
+#endif
+
+#ifndef SEGGER_RTT_BUFFER_ALIGNMENT
+ #define SEGGER_RTT_BUFFER_ALIGNMENT 0
+#endif
+
+#ifndef SEGGER_RTT_MODE_DEFAULT
+ #define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP
+#endif
+
+#ifndef SEGGER_RTT_LOCK
+ #define SEGGER_RTT_LOCK()
+#endif
+
+#ifndef SEGGER_RTT_UNLOCK
+ #define SEGGER_RTT_UNLOCK()
+#endif
+
+#ifndef STRLEN
+ #define STRLEN(a) strlen((a))
+#endif
+
+#ifndef MEMCPY
+ #define MEMCPY(pDest, pSrc, NumBytes) memcpy((pDest), (pSrc), (NumBytes))
+#endif
+
+#ifndef MIN
+ #define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#ifndef MAX
+ #define MAX(a, b) (((a) > (b)) ? (a) : (b))
+#endif
+//
+// For some environments, NULL may not be defined until certain headers are included
+//
+#ifndef NULL
+ #define NULL 0
+#endif
+
+/*********************************************************************
+*
+* Defines, fixed
+*
+**********************************************************************
+*/
+#if (defined __ICCARM__) || (defined __ICCRX__)
+ #define RTT_PRAGMA(P) _Pragma(#P)
+#endif
+
+#if SEGGER_RTT_ALIGNMENT || SEGGER_RTT_BUFFER_ALIGNMENT
+ #if (defined __GNUC__)
+ #define SEGGER_RTT_ALIGN(Var, Alignment) Var __attribute__ ((aligned (Alignment)))
+ #elif (defined __ICCARM__) || (defined __ICCRX__)
+ #define PRAGMA(A) _Pragma(#A)
+#define SEGGER_RTT_ALIGN(Var, Alignment) RTT_PRAGMA(data_alignment=Alignment) \
+ Var
+ #elif (defined __CC_ARM__)
+ #define SEGGER_RTT_ALIGN(Var, Alignment) Var __attribute__ ((aligned (Alignment)))
+ #else
+ #error "Alignment not supported for this compiler."
+ #endif
+#else
+ #define SEGGER_RTT_ALIGN(Var, Alignment) Var
+#endif
+
+#if defined(SEGGER_RTT_SECTION) || defined (SEGGER_RTT_BUFFER_SECTION)
+ #if (defined __GNUC__)
+ #define SEGGER_RTT_PUT_SECTION(Var, Section) __attribute__ ((section (Section))) Var
+ #elif (defined __ICCARM__) || (defined __ICCRX__)
+#define SEGGER_RTT_PUT_SECTION(Var, Section) RTT_PRAGMA(location=Section) \
+ Var
+ #elif (defined __CC_ARM__)
+ #define SEGGER_RTT_PUT_SECTION(Var, Section) __attribute__ ((section (Section), zero_init)) Var
+ #else
+ #error "Section placement not supported for this compiler."
+ #endif
+#else
+ #define SEGGER_RTT_PUT_SECTION(Var, Section) Var
+#endif
+
+
+#if SEGGER_RTT_ALIGNMENT
+ #define SEGGER_RTT_CB_ALIGN(Var) SEGGER_RTT_ALIGN(Var, SEGGER_RTT_ALIGNMENT)
+#else
+ #define SEGGER_RTT_CB_ALIGN(Var) Var
+#endif
+
+#if SEGGER_RTT_BUFFER_ALIGNMENT
+ #define SEGGER_RTT_BUFFER_ALIGN(Var) SEGGER_RTT_ALIGN(Var, SEGGER_RTT_BUFFER_ALIGNMENT)
+#else
+ #define SEGGER_RTT_BUFFER_ALIGN(Var) Var
+#endif
+
+
+#if defined(SEGGER_RTT_SECTION)
+ #define SEGGER_RTT_PUT_CB_SECTION(Var) SEGGER_RTT_PUT_SECTION(Var, SEGGER_RTT_SECTION)
+#else
+ #define SEGGER_RTT_PUT_CB_SECTION(Var) Var
+#endif
+
+#if defined(SEGGER_RTT_BUFFER_SECTION)
+ #define SEGGER_RTT_PUT_BUFFER_SECTION(Var) SEGGER_RTT_PUT_SECTION(Var, SEGGER_RTT_BUFFER_SECTION)
+#else
+ #define SEGGER_RTT_PUT_BUFFER_SECTION(Var) Var
+#endif
+
+/*********************************************************************
+*
+* Static const data
+*
+**********************************************************************
+*/
+
+static unsigned char _aTerminalId[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+
+/*********************************************************************
+*
+* Static data
+*
+**********************************************************************
+*/
+//
+// RTT Control Block and allocate buffers for channel 0
+//
+SEGGER_RTT_PUT_CB_SECTION(SEGGER_RTT_CB_ALIGN(SEGGER_RTT_CB _SEGGER_RTT));
+
+SEGGER_RTT_PUT_BUFFER_SECTION(SEGGER_RTT_BUFFER_ALIGN(static char _acUpBuffer [BUFFER_SIZE_UP]));
+SEGGER_RTT_PUT_BUFFER_SECTION(SEGGER_RTT_BUFFER_ALIGN(static char _acDownBuffer[BUFFER_SIZE_DOWN]));
+
+static char _ActiveTerminal;
+
+/*********************************************************************
+*
+* Static functions
+*
+**********************************************************************
+*/
+
+/*********************************************************************
+*
+* _DoInit()
+*
+* Function description
+* Initializes the control block an buffers.
+* May only be called via INIT() to avoid overriding settings.
+*
+*/
+#define INIT() do { \
+ if (_SEGGER_RTT.acID[0] == '\0') { _DoInit(); } \
+ } while (0)
+static void _DoInit(void) {
+ SEGGER_RTT_CB* p;
+ //
+ // Initialize control block
+ //
+ p = &_SEGGER_RTT;
+ p->MaxNumUpBuffers = SEGGER_RTT_MAX_NUM_UP_BUFFERS;
+ p->MaxNumDownBuffers = SEGGER_RTT_MAX_NUM_DOWN_BUFFERS;
+ //
+ // Initialize up buffer 0
+ //
+ p->aUp[0].sName = "Terminal";
+ p->aUp[0].pBuffer = _acUpBuffer;
+ p->aUp[0].SizeOfBuffer = sizeof(_acUpBuffer);
+ p->aUp[0].RdOff = 0u;
+ p->aUp[0].WrOff = 0u;
+ p->aUp[0].Flags = SEGGER_RTT_MODE_DEFAULT;
+ //
+ // Initialize down buffer 0
+ //
+ p->aDown[0].sName = "Terminal";
+ p->aDown[0].pBuffer = _acDownBuffer;
+ p->aDown[0].SizeOfBuffer = sizeof(_acDownBuffer);
+ p->aDown[0].RdOff = 0u;
+ p->aDown[0].WrOff = 0u;
+ p->aDown[0].Flags = SEGGER_RTT_MODE_DEFAULT;
+ //
+ // Finish initialization of the control block.
+ // Copy Id string in three steps to make sure "SEGGER RTT" is not found
+ // in initializer memory (usually flash) by J-Link
+ //
+ strcpy(&p->acID[7], "RTT");
+ strcpy(&p->acID[0], "SEGGER");
+ p->acID[6] = ' ';
+}
+
+/*********************************************************************
+*
+* _WriteBlocking()
+*
+* Function description
+* Stores a specified number of characters in SEGGER RTT ring buffer
+* and updates the associated write pointer which is periodically
+* read by the host.
+* The caller is responsible for managing the write chunk sizes as
+* _WriteBlocking() will block until all data has been posted successfully.
+*
+* Parameters
+* pRing Ring buffer to post to.
+* pBuffer Pointer to character array. Does not need to point to a \0 terminated string.
+* NumBytes Number of bytes to be stored in the SEGGER RTT control block.
+*
+* Return value
+* >= 0 - Number of bytes written into buffer.
+*/
+static unsigned _WriteBlocking(SEGGER_RTT_BUFFER_UP* pRing, const char* pBuffer, unsigned NumBytes) {
+ unsigned NumBytesToWrite;
+ unsigned NumBytesWritten;
+ unsigned RdOff;
+ unsigned WrOff;
+ //
+ // Write data to buffer and handle wrap-around if necessary
+ //
+ NumBytesWritten = 0u;
+ WrOff = pRing->WrOff;
+ do {
+ RdOff = pRing->RdOff; // May be changed by host (debug probe) in the meantime
+ if (RdOff > WrOff) {
+ NumBytesToWrite = RdOff - WrOff - 1u;
+ } else {
+ NumBytesToWrite = pRing->SizeOfBuffer - (WrOff - RdOff + 1u);
+ }
+ NumBytesToWrite = MIN(NumBytesToWrite, (pRing->SizeOfBuffer - WrOff)); // Number of bytes that can be written until buffer wrap-around
+ NumBytesToWrite = MIN(NumBytesToWrite, NumBytes);
+ memcpy(pRing->pBuffer + WrOff, pBuffer, NumBytesToWrite);
+ NumBytesWritten += NumBytesToWrite;
+ pBuffer += NumBytesToWrite;
+ NumBytes -= NumBytesToWrite;
+ WrOff += NumBytesToWrite;
+ if (WrOff == pRing->SizeOfBuffer) {
+ WrOff = 0u;
+ }
+ pRing->WrOff = WrOff;
+ } while (NumBytes);
+ //
+ return NumBytesWritten;
+}
+
+/*********************************************************************
+*
+* _WriteNoCheck()
+*
+* Function description
+* Stores a specified number of characters in SEGGER RTT ring buffer
+* and updates the associated write pointer which is periodically
+* read by the host.
+* It is callers responsibility to make sure data actually fits in buffer.
+*
+* Parameters
+* pRing Ring buffer to post to.
+* pBuffer Pointer to character array. Does not need to point to a \0 terminated string.
+* NumBytes Number of bytes to be stored in the SEGGER RTT control block.
+*
+* Notes
+* (1) If there might not be enough space in the "Up"-buffer, call _WriteBlocking
+*/
+static void _WriteNoCheck(SEGGER_RTT_BUFFER_UP* pRing, const char* pData, unsigned NumBytes) {
+ unsigned NumBytesAtOnce;
+ unsigned WrOff;
+ unsigned Rem;
+
+ WrOff = pRing->WrOff;
+ Rem = pRing->SizeOfBuffer - WrOff;
+ if (Rem > NumBytes) {
+ //
+ // All data fits before wrap around
+ //
+ memcpy(pRing->pBuffer + WrOff, pData, NumBytes);
+ pRing->WrOff = WrOff + NumBytes;
+ } else {
+ //
+ // We reach the end of the buffer, so need to wrap around
+ //
+ NumBytesAtOnce = Rem;
+ memcpy(pRing->pBuffer + WrOff, pData, NumBytesAtOnce);
+ NumBytesAtOnce = NumBytes - Rem;
+ memcpy(pRing->pBuffer, pData + Rem, NumBytesAtOnce);
+ pRing->WrOff = NumBytesAtOnce;
+ }
+}
+
+/*********************************************************************
+*
+* _PostTerminalSwitch()
+*
+* Function description
+* Switch terminal to the given terminal ID. It is the caller's
+* responsibility to ensure the terminal ID is correct and there is
+* enough space in the buffer for this to complete successfully.
+*
+* Parameters
+* pRing Ring buffer to post to.
+* TerminalId Terminal ID to switch to.
+*/
+static void _PostTerminalSwitch(SEGGER_RTT_BUFFER_UP* pRing, unsigned char TerminalId) {
+ char ac[2];
+
+ ac[0] = 0xFFu;
+ ac[1] = _aTerminalId[TerminalId]; // Caller made already sure that TerminalId does not exceed our terminal limit
+ _WriteBlocking(pRing, ac, 2u);
+}
+
+/*********************************************************************
+*
+* _GetAvailWriteSpace()
+*
+* Function description
+* Returns the number of bytes that can be written to the ring
+* buffer without blocking.
+*
+* Parameters
+* pRing Ring buffer to check.
+*
+* Return value
+* Number of bytes that are free in the buffer.
+*/
+static unsigned _GetAvailWriteSpace(SEGGER_RTT_BUFFER_UP* pRing) {
+ unsigned RdOff;
+ unsigned WrOff;
+ unsigned r;
+ //
+ // Avoid warnings regarding volatile access order. It's not a problem
+ // in this case, but dampen compiler enthusiasm.
+ //
+ RdOff = pRing->RdOff;
+ WrOff = pRing->WrOff;
+ if (RdOff <= WrOff) {
+ r = pRing->SizeOfBuffer - 1u - WrOff + RdOff;
+ } else {
+ r = RdOff - WrOff - 1u;
+ }
+ return r;
+}
+
+/*********************************************************************
+*
+* Public code
+*
+**********************************************************************
+*/
+/*********************************************************************
+*
+* SEGGER_RTT_ReadNoLock()
+*
+* Function description
+* Reads characters from SEGGER real-time-terminal control block
+* which have been previously stored by the host.
+* Do not lock against interrupts and multiple access.
+*
+* Parameters
+* BufferIndex Index of Down-buffer to be used (e.g. 0 for "Terminal").
+* pBuffer Pointer to buffer provided by target application, to copy characters from RTT-down-buffer to.
+* BufferSize Size of the target application buffer.
+*
+* Return value
+* Number of bytes that have been read.
+*/
+unsigned SEGGER_RTT_ReadNoLock(unsigned BufferIndex, void* pData, unsigned BufferSize) {
+ unsigned NumBytesRem;
+ unsigned NumBytesRead;
+ unsigned RdOff;
+ unsigned WrOff;
+ unsigned char* pBuffer;
+ SEGGER_RTT_BUFFER_DOWN* pRing;
+ //
+ INIT();
+ pRing = &_SEGGER_RTT.aDown[BufferIndex];
+ pBuffer = (unsigned char*)pData;
+ RdOff = pRing->RdOff;
+ WrOff = pRing->WrOff;
+ NumBytesRead = 0u;
+ //
+ // Read from current read position to wrap-around of buffer, first
+ //
+ if (RdOff > WrOff) {
+ NumBytesRem = pRing->SizeOfBuffer - RdOff;
+ NumBytesRem = MIN(NumBytesRem, BufferSize);
+ memcpy(pBuffer, pRing->pBuffer + RdOff, NumBytesRem);
+ NumBytesRead += NumBytesRem;
+ pBuffer += NumBytesRem;
+ BufferSize -= NumBytesRem;
+ RdOff += NumBytesRem;
+ //
+ // Handle wrap-around of buffer
+ //
+ if (RdOff == pRing->SizeOfBuffer) {
+ RdOff = 0u;
+ }
+ }
+ //
+ // Read remaining items of buffer
+ //
+ NumBytesRem = WrOff - RdOff;
+ NumBytesRem = MIN(NumBytesRem, BufferSize);
+ if (NumBytesRem > 0u) {
+ memcpy(pBuffer, pRing->pBuffer + RdOff, NumBytesRem);
+ NumBytesRead += NumBytesRem;
+ pBuffer += NumBytesRem;
+ BufferSize -= NumBytesRem;
+ RdOff += NumBytesRem;
+ }
+ if (NumBytesRead) {
+ pRing->RdOff = RdOff;
+ }
+ //
+ return NumBytesRead;
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_Read
+*
+* Function description
+* Reads characters from SEGGER real-time-terminal control block
+* which have been previously stored by the host.
+*
+* Parameters
+* BufferIndex Index of Down-buffer to be used (e.g. 0 for "Terminal").
+* pBuffer Pointer to buffer provided by target application, to copy characters from RTT-down-buffer to.
+* BufferSize Size of the target application buffer.
+*
+* Return value
+* Number of bytes that have been read.
+*/
+unsigned SEGGER_RTT_Read(unsigned BufferIndex, void* pBuffer, unsigned BufferSize) {
+ unsigned NumBytesRead;
+ //
+ SEGGER_RTT_LOCK();
+ //
+ // Call the non-locking read function
+ //
+ NumBytesRead = SEGGER_RTT_ReadNoLock(BufferIndex, pBuffer, BufferSize);
+ //
+ // Finish up.
+ //
+ SEGGER_RTT_UNLOCK();
+ //
+ return NumBytesRead;
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_WriteWithOverwriteNoLock
+*
+* Function description
+* Stores a specified number of characters in SEGGER RTT
+* control block.
+* SEGGER_RTT_WriteWithOverwriteNoLock does not lock the application
+* and overwrites data if the data does not fit into the buffer.
+*
+* Parameters
+* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal").
+* pBuffer Pointer to character array. Does not need to point to a \0 terminated string.
+* NumBytes Number of bytes to be stored in the SEGGER RTT control block.
+*
+* Notes
+* (1) If there is not enough space in the "Up"-buffer, data is overwritten.
+* (2) For performance reasons this function does not call Init()
+* and may only be called after RTT has been initialized.
+* Either by calling SEGGER_RTT_Init() or calling another RTT API function first.
+* (3) Do not use SEGGER_RTT_WriteWithOverwriteNoLock if a J-Link
+* connection reads RTT data.
+*/
+void SEGGER_RTT_WriteWithOverwriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes) {
+ const char* pData;
+ SEGGER_RTT_BUFFER_UP* pRing;
+ unsigned Avail;
+
+ pData = (const char *)pBuffer;
+ //
+ // Get "to-host" ring buffer and copy some elements into local variables.
+ //
+ pRing = &_SEGGER_RTT.aUp[BufferIndex];
+ //
+ // Check if we will overwrite data and need to adjust the RdOff.
+ //
+ if (pRing->WrOff == pRing->RdOff) {
+ Avail = pRing->SizeOfBuffer - 1u;
+ } else if ( pRing->WrOff < pRing->RdOff) {
+ Avail = pRing->RdOff - pRing->WrOff - 1u;
+ } else {
+ Avail = pRing->RdOff - pRing->WrOff - 1u + pRing->SizeOfBuffer;
+ }
+ if (NumBytes > Avail) {
+ pRing->RdOff += (NumBytes - Avail);
+ while (pRing->RdOff >= pRing->SizeOfBuffer) {
+ pRing->RdOff -= pRing->SizeOfBuffer;
+ }
+ }
+ //
+ // Write all data, no need to check the RdOff, but possibly handle multiple wrap-arounds
+ //
+ Avail = pRing->SizeOfBuffer - pRing->WrOff;
+ do {
+ if (Avail > NumBytes) {
+ //
+ // Last round
+ //
+#if 1 // memcpy() is good for large amounts of data, but the overhead is too big for small amounts. Use a simple byte loop instead.
+ char* pDst;
+ pDst = pRing->pBuffer + pRing->WrOff;
+ pRing->WrOff += NumBytes;
+ do {
+ *pDst++ = *pData++;
+ } while (--NumBytes);
+#else
+ memcpy(pRing->pBuffer + WrOff, pData, NumBytes);
+ pRing->WrOff += NumBytes;
+#endif
+ break; //Alternatively: NumBytes = 0;
+ } else {
+ //
+ // Wrap-around necessary, write until wrap-around and reset WrOff
+ //
+ memcpy(pRing->pBuffer + pRing->WrOff, pData, Avail);
+ pData += Avail;
+ pRing->WrOff = 0;
+ NumBytes -= Avail;
+ Avail = (pRing->SizeOfBuffer - 1);
+ }
+ } while (NumBytes);
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_WriteSkipNoLock
+*
+* Function description
+* Stores a specified number of characters in SEGGER RTT
+* control block which is then read by the host.
+* SEGGER_RTT_WriteSkipNoLock does not lock the application and
+* skips all data, if the data does not fit into the buffer.
+*
+* Parameters
+* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal").
+* pBuffer Pointer to character array. Does not need to point to a \0 terminated string.
+* NumBytes Number of bytes to be stored in the SEGGER RTT control block.
+*
+* Return value
+* Number of bytes which have been stored in the "Up"-buffer.
+*
+* Notes
+* (1) If there is not enough space in the "Up"-buffer, all data is dropped.
+* (2) For performance reasons this function does not call Init()
+* and may only be called after RTT has been initialized.
+* Either by calling SEGGER_RTT_Init() or calling another RTT API function first.
+*/
+unsigned SEGGER_RTT_WriteSkipNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes) {
+ const char* pData;
+ SEGGER_RTT_BUFFER_UP* pRing;
+ unsigned Avail;
+ unsigned RdOff;
+ unsigned WrOff;
+ unsigned Rem;
+
+ pData = (const char *)pBuffer;
+ //
+ // Get "to-host" ring buffer and copy some elements into local variables.
+ //
+ pRing = &_SEGGER_RTT.aUp[BufferIndex];
+ RdOff = pRing->RdOff;
+ WrOff = pRing->WrOff;
+ //
+ // Handle the most common cases fastest.
+ // Which is:
+ // RdOff <= WrOff -> Space until wrap around is free.
+ // AND
+ // WrOff + NumBytes < SizeOfBuffer -> No Wrap around necessary.
+ //
+ // OR
+ //
+ // RdOff > WrOff -> Space until RdOff - 1 is free.
+ // AND
+ // WrOff + NumBytes < RdOff -> Data fits into buffer
+ //
+ if (RdOff <= WrOff) {
+ //
+ // Get space until WrOff will be at wrap around.
+ //
+ Avail = pRing->SizeOfBuffer - 1u - WrOff ;
+ if (Avail >= NumBytes) {
+#if 1 // memcpy() is good for large amounts of data, but the overhead is too big for small amounts. Use a simple byte loop instead.
+ char* pDst;
+ pDst = pRing->pBuffer + WrOff;
+ WrOff += NumBytes;
+ do {
+ *pDst++ = *pData++;
+ } while (--NumBytes);
+ pRing->WrOff = WrOff + NumBytes;
+#else
+ memcpy(pRing->pBuffer + WrOff, pData, NumBytes);
+ pRing->WrOff = WrOff + NumBytes;
+#endif
+ return 1;
+ }
+ //
+ // If data did not fit into space until wrap around calculate complete space in buffer.
+ //
+ Avail += RdOff;
+ //
+ // If there is still no space for the whole of this output, don't bother.
+ //
+ if (Avail >= NumBytes) {
+ //
+ // OK, we have enough space in buffer. Copy in one or 2 chunks
+ //
+ Rem = pRing->SizeOfBuffer - WrOff; // Space until end of buffer
+ if (Rem > NumBytes) {
+ memcpy(pRing->pBuffer + WrOff, pData, NumBytes);
+ pRing->WrOff = WrOff + NumBytes;
+ } else {
+ //
+ // We reach the end of the buffer, so need to wrap around
+ //
+ memcpy(pRing->pBuffer + WrOff, pData, Rem);
+ memcpy(pRing->pBuffer, pData + Rem, NumBytes - Rem);
+ pRing->WrOff = NumBytes - Rem;
+ }
+ return 1;
+ }
+ } else {
+ Avail = RdOff - WrOff - 1u;
+ if (Avail >= NumBytes) {
+ memcpy(pRing->pBuffer + WrOff, pData, NumBytes);
+ pRing->WrOff = WrOff + NumBytes;
+ return 1;
+ }
+ }
+ //
+ // If we reach this point no data has been written
+ //
+ return 0;
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_WriteNoLock
+*
+* Function description
+* Stores a specified number of characters in SEGGER RTT
+* control block which is then read by the host.
+* SEGGER_RTT_WriteNoLock does not lock the application.
+*
+* Parameters
+* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal").
+* pBuffer Pointer to character array. Does not need to point to a \0 terminated string.
+* NumBytes Number of bytes to be stored in the SEGGER RTT control block.
+*
+* Return value
+* Number of bytes which have been stored in the "Up"-buffer.
+*
+* Notes
+* (1) If there is not enough space in the "Up"-buffer, remaining characters of pBuffer are dropped.
+* (2) For performance reasons this function does not call Init()
+* and may only be called after RTT has been initialized.
+* Either by calling SEGGER_RTT_Init() or calling another RTT API function first.
+*/
+unsigned SEGGER_RTT_WriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes) {
+ unsigned Status;
+ unsigned Avail;
+ const char* pData;
+ SEGGER_RTT_BUFFER_UP* pRing;
+
+ pData = (const char *)pBuffer;
+ //
+ // Get "to-host" ring buffer.
+ //
+ pRing = &_SEGGER_RTT.aUp[BufferIndex];
+ //
+ // How we output depends upon the mode...
+ //
+ switch (pRing->Flags) {
+ case SEGGER_RTT_MODE_NO_BLOCK_SKIP:
+ //
+ // If we are in skip mode and there is no space for the whole
+ // of this output, don't bother.
+ //
+ Avail = _GetAvailWriteSpace(pRing);
+ if (Avail < NumBytes) {
+ Status = 0u;
+ } else {
+ Status = NumBytes;
+ _WriteNoCheck(pRing, pData, NumBytes);
+ }
+ break;
+ case SEGGER_RTT_MODE_NO_BLOCK_TRIM:
+ //
+ // If we are in trim mode, trim to what we can output without blocking.
+ //
+ Avail = _GetAvailWriteSpace(pRing);
+ Status = Avail < NumBytes ? Avail : NumBytes;
+ _WriteNoCheck(pRing, pData, Status);
+ break;
+ case SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL:
+ //
+ // If we are in blocking mode, output everything.
+ //
+ Status = _WriteBlocking(pRing, pData, NumBytes);
+ break;
+ default:
+ Status = 0u;
+ break;
+ }
+ //
+ // Finish up.
+ //
+ return Status;
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_Write
+*
+* Function description
+* Stores a specified number of characters in SEGGER RTT
+* control block which is then read by the host.
+*
+* Parameters
+* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal").
+* pBuffer Pointer to character array. Does not need to point to a \0 terminated string.
+* NumBytes Number of bytes to be stored in the SEGGER RTT control block.
+*
+* Return value
+* Number of bytes which have been stored in the "Up"-buffer.
+*
+* Notes
+* (1) If there is not enough space in the "Up"-buffer, remaining characters of pBuffer are dropped.
+*/
+unsigned SEGGER_RTT_Write(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes) {
+ unsigned Status;
+ //
+ INIT();
+ SEGGER_RTT_LOCK();
+ //
+ // Call the non-locking write function
+ //
+ Status = SEGGER_RTT_WriteNoLock(BufferIndex, pBuffer, NumBytes);
+ //
+ // Finish up.
+ //
+ SEGGER_RTT_UNLOCK();
+ //
+ return Status;
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_WriteString
+*
+* Function description
+* Stores string in SEGGER RTT control block.
+* This data is read by the host.
+*
+* Parameters
+* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal").
+* s Pointer to string.
+*
+* Return value
+* Number of bytes which have been stored in the "Up"-buffer.
+*
+* Notes
+* (1) If there is not enough space in the "Up"-buffer, depending on configuration,
+* remaining characters may be dropped or RTT module waits until there is more space in the buffer.
+* (2) String passed to this function has to be \0 terminated
+* (3) \0 termination character is *not* stored in RTT buffer
+*/
+unsigned SEGGER_RTT_WriteString(unsigned BufferIndex, const char* s) {
+ unsigned Len;
+
+ Len = STRLEN(s);
+ return SEGGER_RTT_Write(BufferIndex, s, Len);
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_GetKey
+*
+* Function description
+* Reads one character from the SEGGER RTT buffer.
+* Host has previously stored data there.
+*
+* Return value
+* < 0 - No character available (buffer empty).
+* >= 0 - Character which has been read. (Possible values: 0 - 255)
+*
+* Notes
+* (1) This function is only specified for accesses to RTT buffer 0.
+*/
+int SEGGER_RTT_GetKey(void) {
+ char c;
+ int r;
+
+ r = (int)SEGGER_RTT_Read(0u, &c, 1u);
+ if (r == 1) {
+ r = (int)(unsigned char)c;
+ } else {
+ r = -1;
+ }
+ return r;
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_WaitKey
+*
+* Function description
+* Waits until at least one character is avaible in the SEGGER RTT buffer.
+* Once a character is available, it is read and this function returns.
+*
+* Return value
+* >=0 - Character which has been read.
+*
+* Notes
+* (1) This function is only specified for accesses to RTT buffer 0
+* (2) This function is blocking if no character is present in RTT buffer
+*/
+int SEGGER_RTT_WaitKey(void) {
+ int r;
+
+ do {
+ r = SEGGER_RTT_GetKey();
+ } while (r < 0);
+ return r;
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_HasKey
+*
+* Function description
+* Checks if at least one character for reading is available in the SEGGER RTT buffer.
+*
+* Return value
+* == 0 - No characters are available to read.
+* == 1 - At least one character is available.
+*
+* Notes
+* (1) This function is only specified for accesses to RTT buffer 0
+*/
+int SEGGER_RTT_HasKey(void) {
+ unsigned RdOff;
+ int r;
+
+ INIT();
+ RdOff = _SEGGER_RTT.aDown[0].RdOff;
+ if (RdOff != _SEGGER_RTT.aDown[0].WrOff) {
+ r = 1;
+ } else {
+ r = 0;
+ }
+ return r;
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_HasData
+*
+* Function description
+* Check if there is data from the host in the given buffer.
+*
+* Return value:
+* ==0: No data
+* !=0: Data in buffer
+*
+*/
+unsigned SEGGER_RTT_HasData(unsigned BufferIndex) {
+ SEGGER_RTT_BUFFER_DOWN* pRing;
+ unsigned v;
+
+ pRing = &_SEGGER_RTT.aDown[BufferIndex];
+ v = pRing->WrOff;
+ return v - pRing->RdOff;
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_AllocDownBuffer
+*
+* Function description
+* Run-time configuration of the next down-buffer (H->T).
+* The next buffer, which is not used yet is configured.
+* This includes: Buffer address, size, name, flags, ...
+*
+* Parameters
+* sName Pointer to a constant name string.
+* pBuffer Pointer to a buffer to be used.
+* BufferSize Size of the buffer.
+* Flags Operating modes. Define behavior if buffer is full (not enough space for entire message).
+*
+* Return value
+* >= 0 - O.K. Buffer Index
+* < 0 - Error
+*/
+int SEGGER_RTT_AllocDownBuffer(const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags) {
+ int BufferIndex;
+
+ INIT();
+ SEGGER_RTT_LOCK();
+ BufferIndex = 0;
+ do {
+ if (_SEGGER_RTT.aDown[BufferIndex].pBuffer == NULL) {
+ break;
+ }
+ BufferIndex++;
+ } while (BufferIndex < _SEGGER_RTT.MaxNumDownBuffers);
+ if (BufferIndex < _SEGGER_RTT.MaxNumDownBuffers) {
+ _SEGGER_RTT.aDown[BufferIndex].sName = sName;
+ _SEGGER_RTT.aDown[BufferIndex].pBuffer = (char*)pBuffer;
+ _SEGGER_RTT.aDown[BufferIndex].SizeOfBuffer = BufferSize;
+ _SEGGER_RTT.aDown[BufferIndex].RdOff = 0u;
+ _SEGGER_RTT.aDown[BufferIndex].WrOff = 0u;
+ _SEGGER_RTT.aDown[BufferIndex].Flags = Flags;
+ } else {
+ BufferIndex = -1;
+ }
+ SEGGER_RTT_UNLOCK();
+ return BufferIndex;
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_AllocUpBuffer
+*
+* Function description
+* Run-time configuration of the next up-buffer (T->H).
+* The next buffer, which is not used yet is configured.
+* This includes: Buffer address, size, name, flags, ...
+*
+* Parameters
+* sName Pointer to a constant name string.
+* pBuffer Pointer to a buffer to be used.
+* BufferSize Size of the buffer.
+* Flags Operating modes. Define behavior if buffer is full (not enough space for entire message).
+*
+* Return value
+* >= 0 - O.K. Buffer Index
+* < 0 - Error
+*/
+int SEGGER_RTT_AllocUpBuffer(const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags) {
+ int BufferIndex;
+
+ INIT();
+ SEGGER_RTT_LOCK();
+ BufferIndex = 0;
+ do {
+ if (_SEGGER_RTT.aUp[BufferIndex].pBuffer == NULL) {
+ break;
+ }
+ BufferIndex++;
+ } while (BufferIndex < _SEGGER_RTT.MaxNumUpBuffers);
+ if (BufferIndex < _SEGGER_RTT.MaxNumUpBuffers) {
+ _SEGGER_RTT.aUp[BufferIndex].sName = sName;
+ _SEGGER_RTT.aUp[BufferIndex].pBuffer = (char*)pBuffer;
+ _SEGGER_RTT.aUp[BufferIndex].SizeOfBuffer = BufferSize;
+ _SEGGER_RTT.aUp[BufferIndex].RdOff = 0u;
+ _SEGGER_RTT.aUp[BufferIndex].WrOff = 0u;
+ _SEGGER_RTT.aUp[BufferIndex].Flags = Flags;
+ } else {
+ BufferIndex = -1;
+ }
+ SEGGER_RTT_UNLOCK();
+ return BufferIndex;
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_ConfigUpBuffer
+*
+* Function description
+* Run-time configuration of a specific up-buffer (T->H).
+* Buffer to be configured is specified by index.
+* This includes: Buffer address, size, name, flags, ...
+*
+* Parameters
+* BufferIndex Index of the buffer to configure.
+* sName Pointer to a constant name string.
+* pBuffer Pointer to a buffer to be used.
+* BufferSize Size of the buffer.
+* Flags Operating modes. Define behavior if buffer is full (not enough space for entire message).
+*
+* Return value
+* >= 0 - O.K.
+* < 0 - Error
+*
+* Additional information
+* Buffer 0 is configured on compile-time.
+* May only be called once per buffer.
+* Buffer name and flags can be reconfigured using the appropriate functions.
+*/
+int SEGGER_RTT_ConfigUpBuffer(unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags) {
+ int r;
+
+ INIT();
+ if (BufferIndex < (unsigned)_SEGGER_RTT.MaxNumUpBuffers) {
+ SEGGER_RTT_LOCK();
+ if (BufferIndex > 0u) {
+ _SEGGER_RTT.aUp[BufferIndex].sName = sName;
+ _SEGGER_RTT.aUp[BufferIndex].pBuffer = (char*)pBuffer;
+ _SEGGER_RTT.aUp[BufferIndex].SizeOfBuffer = BufferSize;
+ _SEGGER_RTT.aUp[BufferIndex].RdOff = 0u;
+ _SEGGER_RTT.aUp[BufferIndex].WrOff = 0u;
+ }
+ _SEGGER_RTT.aUp[BufferIndex].Flags = Flags;
+ SEGGER_RTT_UNLOCK();
+ r = 0;
+ } else {
+ r = -1;
+ }
+ return r;
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_ConfigDownBuffer
+*
+* Function description
+* Run-time configuration of a specific down-buffer (H->T).
+* Buffer to be configured is specified by index.
+* This includes: Buffer address, size, name, flags, ...
+*
+* Parameters
+* BufferIndex Index of the buffer to configure.
+* sName Pointer to a constant name string.
+* pBuffer Pointer to a buffer to be used.
+* BufferSize Size of the buffer.
+* Flags Operating modes. Define behavior if buffer is full (not enough space for entire message).
+*
+* Return value
+* >= 0 O.K.
+* < 0 Error
+*
+* Additional information
+* Buffer 0 is configured on compile-time.
+* May only be called once per buffer.
+* Buffer name and flags can be reconfigured using the appropriate functions.
+*/
+int SEGGER_RTT_ConfigDownBuffer(unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags) {
+ int r;
+
+ INIT();
+ if (BufferIndex < (unsigned)_SEGGER_RTT.MaxNumDownBuffers) {
+ SEGGER_RTT_LOCK();
+ if (BufferIndex > 0u) {
+ _SEGGER_RTT.aDown[BufferIndex].sName = sName;
+ _SEGGER_RTT.aDown[BufferIndex].pBuffer = (char*)pBuffer;
+ _SEGGER_RTT.aDown[BufferIndex].SizeOfBuffer = BufferSize;
+ _SEGGER_RTT.aDown[BufferIndex].RdOff = 0u;
+ _SEGGER_RTT.aDown[BufferIndex].WrOff = 0u;
+ }
+ _SEGGER_RTT.aDown[BufferIndex].Flags = Flags;
+ SEGGER_RTT_UNLOCK();
+ r = 0;
+ } else {
+ r = -1;
+ }
+ return r;
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_SetNameUpBuffer
+*
+* Function description
+* Run-time configuration of a specific up-buffer name (T->H).
+* Buffer to be configured is specified by index.
+*
+* Parameters
+* BufferIndex Index of the buffer to renamed.
+* sName Pointer to a constant name string.
+*
+* Return value
+* >= 0 O.K.
+* < 0 Error
+*/
+int SEGGER_RTT_SetNameUpBuffer(unsigned BufferIndex, const char* sName) {
+ int r;
+
+ INIT();
+ if (BufferIndex < (unsigned)_SEGGER_RTT.MaxNumUpBuffers) {
+ SEGGER_RTT_LOCK();
+ _SEGGER_RTT.aUp[BufferIndex].sName = sName;
+ SEGGER_RTT_UNLOCK();
+ r = 0;
+ } else {
+ r = -1;
+ }
+ return r;
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_SetNameDownBuffer
+*
+* Function description
+* Run-time configuration of a specific Down-buffer name (T->H).
+* Buffer to be configured is specified by index.
+*
+* Parameters
+* BufferIndex Index of the buffer to renamed.
+* sName Pointer to a constant name string.
+*
+* Return value
+* >= 0 O.K.
+* < 0 Error
+*/
+int SEGGER_RTT_SetNameDownBuffer(unsigned BufferIndex, const char* sName) {
+ int r;
+
+ INIT();
+ if (BufferIndex < (unsigned)_SEGGER_RTT.MaxNumDownBuffers) {
+ SEGGER_RTT_LOCK();
+ _SEGGER_RTT.aDown[BufferIndex].sName = sName;
+ SEGGER_RTT_UNLOCK();
+ r = 0;
+ } else {
+ r = -1;
+ }
+ return r;
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_SetFlagsUpBuffer
+*
+* Function description
+* Run-time configuration of specific up-buffer flags (T->H).
+* Buffer to be configured is specified by index.
+*
+* Parameters
+* BufferIndex Index of the buffer.
+* Flags Flags to set for the buffer.
+*
+* Return value
+* >= 0 O.K.
+* < 0 Error
+*/
+int SEGGER_RTT_SetFlagsUpBuffer(unsigned BufferIndex, unsigned Flags) {
+ int r;
+
+ INIT();
+ if (BufferIndex < (unsigned)_SEGGER_RTT.MaxNumUpBuffers) {
+ SEGGER_RTT_LOCK();
+ _SEGGER_RTT.aUp[BufferIndex].Flags = Flags;
+ SEGGER_RTT_UNLOCK();
+ r = 0;
+ } else {
+ r = -1;
+ }
+ return r;
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_SetFlagsDownBuffer
+*
+* Function description
+* Run-time configuration of specific Down-buffer flags (T->H).
+* Buffer to be configured is specified by index.
+*
+* Parameters
+* BufferIndex Index of the buffer to renamed.
+* Flags Flags to set for the buffer.
+*
+* Return value
+* >= 0 O.K.
+* < 0 Error
+*/
+int SEGGER_RTT_SetFlagsDownBuffer(unsigned BufferIndex, unsigned Flags) {
+ int r;
+
+ INIT();
+ if (BufferIndex < (unsigned)_SEGGER_RTT.MaxNumDownBuffers) {
+ SEGGER_RTT_LOCK();
+ _SEGGER_RTT.aDown[BufferIndex].Flags = Flags;
+ SEGGER_RTT_UNLOCK();
+ r = 0;
+ } else {
+ r = -1;
+ }
+ return r;
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_Init
+*
+* Function description
+* Initializes the RTT Control Block.
+* Should be used in RAM targets, at start of the application.
+*
+*/
+void SEGGER_RTT_Init (void) {
+ _DoInit();
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_SetTerminal
+*
+* Function description
+* Sets the terminal to be used for output on channel 0.
+*
+* Parameters
+* TerminalId Index of the terminal.
+*
+* Return value
+* >= 0 O.K.
+* < 0 Error (e.g. if RTT is configured for non-blocking mode and there was no space in the buffer to set the new terminal Id)
+*/
+int SEGGER_RTT_SetTerminal (char TerminalId) {
+ char ac[2];
+ SEGGER_RTT_BUFFER_UP* pRing;
+ unsigned Avail;
+ int r;
+ //
+ INIT();
+ //
+ r = 0;
+ ac[0] = 0xFFU;
+ if ((unsigned char)TerminalId < (unsigned char)sizeof(_aTerminalId)) { // We only support a certain number of channels
+ ac[1] = _aTerminalId[(unsigned char)TerminalId];
+ pRing = &_SEGGER_RTT.aUp[0]; // Buffer 0 is always reserved for terminal I/O, so we can use index 0 here, fixed
+ SEGGER_RTT_LOCK(); // Lock to make sure that no other task is writing into buffer, while we are and number of free bytes in buffer does not change downwards after checking and before writing
+ if ((pRing->Flags & SEGGER_RTT_MODE_MASK) == SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL) {
+ _ActiveTerminal = TerminalId;
+ _WriteBlocking(pRing, ac, 2u);
+ } else { // Skipping mode or trim mode? => We cannot trim this command so handling is the same for both modes
+ Avail = _GetAvailWriteSpace(pRing);
+ if (Avail >= 2) {
+ _ActiveTerminal = TerminalId; // Only change active terminal in case of success
+ _WriteNoCheck(pRing, ac, 2u);
+ } else {
+ r = -1;
+ }
+ }
+ SEGGER_RTT_UNLOCK();
+ } else {
+ r = -1;
+ }
+ return r;
+}
+
+/*********************************************************************
+*
+* SEGGER_RTT_TerminalOut
+*
+* Function description
+* Writes a string to the given terminal
+* without changing the terminal for channel 0.
+*
+* Parameters
+* TerminalId Index of the terminal.
+* s String to be printed on the terminal.
+*
+* Return value
+* >= 0 - Number of bytes written.
+* < 0 - Error.
+*
+*/
+int SEGGER_RTT_TerminalOut (char TerminalId, const char* s) {
+ int Status;
+ unsigned FragLen;
+ unsigned Avail;
+ SEGGER_RTT_BUFFER_UP* pRing;
+ //
+ INIT();
+ //
+ // Validate terminal ID.
+ //
+ if (TerminalId < (char)sizeof(_aTerminalId)) { // We only support a certain number of channels
+ //
+ // Get "to-host" ring buffer.
+ //
+ pRing = &_SEGGER_RTT.aUp[0];
+ //
+ // Need to be able to change terminal, write data, change back.
+ // Compute the fixed and variable sizes.
+ //
+ FragLen = strlen(s);
+ //
+ // How we output depends upon the mode...
+ //
+ SEGGER_RTT_LOCK();
+ Avail = _GetAvailWriteSpace(pRing);
+ switch (pRing->Flags & SEGGER_RTT_MODE_MASK) {
+ case SEGGER_RTT_MODE_NO_BLOCK_SKIP:
+ //
+ // If we are in skip mode and there is no space for the whole
+ // of this output, don't bother switching terminals at all.
+ //
+ if (Avail < (FragLen + 4u)) {
+ Status = 0;
+ } else {
+ _PostTerminalSwitch(pRing, TerminalId);
+ Status = (int)_WriteBlocking(pRing, s, FragLen);
+ _PostTerminalSwitch(pRing, _ActiveTerminal);
+ }
+ break;
+ case SEGGER_RTT_MODE_NO_BLOCK_TRIM:
+ //
+ // If we are in trim mode and there is not enough space for everything,
+ // trim the output but always include the terminal switch. If no room
+ // for terminal switch, skip that totally.
+ //
+ if (Avail < 4u) {
+ Status = -1;
+ } else {
+ _PostTerminalSwitch(pRing, TerminalId);
+ Status = (int)_WriteBlocking(pRing, s, (FragLen < (Avail - 4u)) ? FragLen : (Avail - 4u));
+ _PostTerminalSwitch(pRing, _ActiveTerminal);
+ }
+ break;
+ case SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL:
+ //
+ // If we are in blocking mode, output everything.
+ //
+ _PostTerminalSwitch(pRing, TerminalId);
+ Status = (int)_WriteBlocking(pRing, s, FragLen);
+ _PostTerminalSwitch(pRing, _ActiveTerminal);
+ break;
+ default:
+ Status = -1;
+ break;
+ }
+ //
+ // Finish up.
+ //
+ SEGGER_RTT_UNLOCK();
+ } else {
+ Status = -1;
+ }
+ return Status;
+}
+
+
+void
+rtt_pkg_init(void)
+{
+ /* Ensure this function only gets called by sysinit. */
+ SYSINIT_ASSERT_ACTIVE();
+ SEGGER_RTT_Init();
+}
+
+/*************************** End of file ****************************/