Skip to content

Commit

Permalink
Merge pull request #2590 from ARMmbed/release
Browse files Browse the repository at this point in the history
Release mbed-os-5.1.3 and mbed lib v125
  • Loading branch information
sg- authored Sep 1, 2016
2 parents d220204 + 5e38a9c commit bdab10d
Show file tree
Hide file tree
Showing 270 changed files with 30,063 additions and 2,409 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mbed OS accelerates the process of creating a connected product by providing a p

Our current release series is mbed OS 5.1:

- [Release Note](https://docs.mbed.com/docs/mbed-os-release-notes/en/latest/5_1/release)
- [Release Note](https://docs.mbed.com/docs/mbed-os-release-notes/en/latest/5_1/release/)

## Getting Started for Developers

Expand All @@ -20,4 +20,4 @@ We have a getting started guide for developers using mbed OS in applications:

We have a getting started guide for contributors working on mbed OS:

- Have a look in the docs directory
- Have a look in the docs directory
132 changes: 132 additions & 0 deletions TESTS/mbed_drivers/lp_timeout/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/* mbed Microcontroller Library
* Copyright (c) 2016 ARM Limited
*
* Licensed 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.
*/

#if !DEVICE_LOWPOWERTIMER
#error [NOT_SUPPORTED] Low power timer not supported for this target
#endif

#include "utest/utest.h"
#include "unity/unity.h"
#include "greentea-client/test_env.h"

#include "mbed.h"
#include "us_ticker_api.h"

using namespace utest::v1;

volatile static bool complete;
static LowPowerTimeout lpt;

/* Timeouts are quite arbitrary due to large number of boards with varying level of accuracy */
#define LONG_TIMEOUT (100000)
#define SHORT_TIMEOUT (600)

void cb_done() {
complete = true;
}

#if DEVICE_SLEEP
void lp_timeout_1s_deepsleep(void)
{
complete = false;

timestamp_t start = us_ticker_read();
lpt.attach(&cb_done, 1);
deepsleep();
while (!complete);
timestamp_t end = us_ticker_read();

/* It takes longer to wake up from deep sleep */
TEST_ASSERT_UINT32_WITHIN(LONG_TIMEOUT, 1000000, end - start);
TEST_ASSERT_TRUE(complete);
}

void lp_timeout_1s_sleep(void)
{
complete = false;

timestamp_t start = us_ticker_read();
lpt.attach(&cb_done, 1);
sleep();
while (!complete);
timestamp_t end = us_ticker_read();

TEST_ASSERT_UINT32_WITHIN(LONG_TIMEOUT, 1000000, end - start);
TEST_ASSERT_TRUE(complete);
}
#endif /* DEVICE_SLEEP */

void lp_timeout_us(uint32_t delay_us, uint32_t tolerance)
{
complete = false;

timestamp_t start = us_ticker_read();
lpt.attach_us(&cb_done, delay_us);
while (!complete);
timestamp_t end = us_ticker_read();

/* Using RTC which is less accurate */
TEST_ASSERT_UINT32_WITHIN(tolerance, delay_us, end - start);
TEST_ASSERT_TRUE(complete);
}

void lp_timeout_5s(void)
{
lp_timeout_us(5000000, LONG_TIMEOUT);
}

void lp_timeout_1s(void)
{
lp_timeout_us(1000000, LONG_TIMEOUT);
}

void lp_timeout_1ms(void)
{
lp_timeout_us(1000, SHORT_TIMEOUT);
}

void lp_timeout_500us(void)
{
lp_timeout_us(500, SHORT_TIMEOUT);

}

status_t greentea_failure_handler(const Case *const source, const failure_t reason) {
greentea_case_failure_abort_handler(source, reason);
return STATUS_CONTINUE;
}

Case cases[] = {
Case("500us LowPowerTimeout", lp_timeout_500us, greentea_failure_handler),
Case("1ms LowPowerTimeout", lp_timeout_1ms, greentea_failure_handler),
Case("1sec LowPowerTimeout", lp_timeout_1s, greentea_failure_handler),
Case("5sec LowPowerTimeout", lp_timeout_5s, greentea_failure_handler),
#if DEVICE_SLEEP
Case("1sec LowPowerTimeout from sleep", lp_timeout_1s_sleep, greentea_failure_handler),
Case("1sec LowPowerTimeout from deepsleep", lp_timeout_1s_deepsleep, greentea_failure_handler),
#endif /* DEVICE_SLEEP */
};

status_t greentea_test_setup(const size_t number_of_cases) {
GREENTEA_SETUP(20, "default_auto");
return greentea_test_setup_handler(number_of_cases);
}

Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);

int main() {
Harness::run(specification);
}
148 changes: 148 additions & 0 deletions TESTS/mbed_hal/lp_ticker/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/* mbed Microcontroller Library
* Copyright (c) 2016 ARM Limited
*
* Licensed 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.
*/

#if !DEVICE_LOWPOWERTIMER
#error [NOT_SUPPORTED] Low power timer not supported for this target
#endif

#include "utest/utest.h"
#include "unity/unity.h"
#include "greentea-client/test_env.h"

#include "mbed.h"
#include "us_ticker_api.h"
#include "lp_ticker_api.h"

using namespace utest::v1;

volatile static bool complete;
static ticker_event_t delay_event;
static const ticker_data_t *lp_ticker_data = get_lp_ticker_data();


/* Timeouts are quite arbitrary due to large number of boards with varying level of accuracy */
#define LONG_TIMEOUT (100000)
#define SHORT_TIMEOUT (600)

void cb_done(uint32_t id) {
complete = true;
}

void lp_ticker_delay_us(uint32_t delay_us, uint32_t tolerance)
{
complete = false;
uint32_t delay_ts;

ticker_set_handler(lp_ticker_data, cb_done);
ticker_remove_event(lp_ticker_data, &delay_event);
delay_ts = lp_ticker_read() + delay_us;

timestamp_t start = us_ticker_read();
ticker_insert_event(lp_ticker_data, &delay_event, delay_ts, (uint32_t)&delay_event);
while (!complete);
timestamp_t end = us_ticker_read();

TEST_ASSERT_UINT32_WITHIN(tolerance, delay_us, end - start);
TEST_ASSERT_TRUE(complete);
}

#if DEVICE_SLEEP
void lp_ticker_1s_deepsleep()
{
complete = false;
uint32_t delay_ts;

ticker_set_handler(lp_ticker_data, cb_done);
ticker_remove_event(lp_ticker_data, &delay_event);
delay_ts = lp_ticker_read() + 1000000;

timestamp_t start = us_ticker_read();
ticker_insert_event(lp_ticker_data, &delay_event, delay_ts, (uint32_t)&delay_event);
deepsleep();
while (!complete);
timestamp_t end = us_ticker_read();

TEST_ASSERT_UINT32_WITHIN(LONG_TIMEOUT, 1000000, end - start);
TEST_ASSERT_TRUE(complete);
}

void lp_ticker_1s_sleep()
{
complete = false;
uint32_t delay_ts;

ticker_set_handler(lp_ticker_data, cb_done);
ticker_remove_event(lp_ticker_data, &delay_event);
delay_ts = lp_ticker_read() + 1000000;

timestamp_t start = us_ticker_read();
ticker_insert_event(lp_ticker_data, &delay_event, delay_ts, (uint32_t)&delay_event);
sleep();
while (!complete);
timestamp_t end = us_ticker_read();

TEST_ASSERT_UINT32_WITHIN(LONG_TIMEOUT, 1000000, end - start);
TEST_ASSERT_TRUE(complete);
}
#endif /* DEVICE_SLEEP */

void lp_ticker_500us(void)
{
lp_ticker_delay_us(500, SHORT_TIMEOUT);
}

void lp_ticker_1ms(void)
{
lp_ticker_delay_us(1000, SHORT_TIMEOUT);
}

void lp_ticker_1s(void)
{
lp_ticker_delay_us(1000000, LONG_TIMEOUT);
}

void lp_ticker_5s(void)
{
lp_ticker_delay_us(5000000, LONG_TIMEOUT);
}

status_t greentea_failure_handler(const Case *const source, const failure_t reason) {
greentea_case_failure_abort_handler(source, reason);
return STATUS_CONTINUE;
}

Case cases[] = {
Case("500us lp_ticker", lp_ticker_500us, greentea_failure_handler),
Case("1ms lp_ticker", lp_ticker_1ms, greentea_failure_handler),
Case("1s lp_ticker", lp_ticker_1s, greentea_failure_handler),
Case("5s lp_ticker", lp_ticker_5s, greentea_failure_handler),
#if DEVICE_SLEEP
Case("1s lp_ticker sleep", lp_ticker_1s_sleep, greentea_failure_handler),
Case("1s lp_ticker deepsleep", lp_ticker_1s_deepsleep, greentea_failure_handler),
#endif /* DEVICE_SLEEP */
};

status_t greentea_test_setup(const size_t number_of_cases) {
GREENTEA_SETUP(20, "default_auto");
lp_ticker_data->interface->init();
return greentea_test_setup_handler(number_of_cases);
}

Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);

int main() {
Harness::run(specification);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,16 @@

#define TRACE_GROUP "mClt"

#ifdef MBED_CONF_MBED_CLIENT_EVENT_LOOP_SIZE
#define MBED_CLIENT_EVENT_LOOP_SIZE MBED_CONF_MBED_CLIENT_EVENT_LOOP_SIZE
#else
#define MBED_CLIENT_EVENT_LOOP_SIZE 1024
#endif

int8_t M2MConnectionHandlerPimpl::_tasklet_id = -1;

static MemoryPool<M2MConnectionHandlerPimpl::TaskIdentifier, MBED_CLIENT_EVENT_LOOP_SIZE/64> memory_pool;

extern "C" void connection_tasklet_event_handler(arm_event_s *event)
{
tr_debug("M2MConnectionHandlerPimpl::connection_tasklet_event_handler");
Expand Down Expand Up @@ -74,7 +82,7 @@ extern "C" void connection_tasklet_event_handler(arm_event_s *event)
break;
}
if (task_id) {
free(task_id);
memory_pool.free(task_id);
}
}

Expand Down Expand Up @@ -103,7 +111,7 @@ M2MConnectionHandlerPimpl::M2MConnectionHandlerPimpl(M2MConnectionHandler* base,
_address._address = _address_buffer;

if (_network_stack != M2MInterface::LwIP_IPv4) {
error("ConnectionHandler: Unsupported network stack, only IPv4 is currently supported");
tr_error("ConnectionHandler: Unsupported network stack, only IPv4 is currently supported");
}
_running = true;
tr_debug("M2MConnectionHandlerPimpl::M2MConnectionHandlerPimpl() - Initializing thread");
Expand All @@ -117,6 +125,10 @@ M2MConnectionHandlerPimpl::M2MConnectionHandlerPimpl(M2MConnectionHandler* base,
M2MConnectionHandlerPimpl::~M2MConnectionHandlerPimpl()
{
tr_debug("M2MConnectionHandlerPimpl::~M2MConnectionHandlerPimpl()");
if(_socket_address) {
delete _socket_address;
_socket_address = NULL;
}
if (_socket) {
delete _socket;
_socket = 0;
Expand Down Expand Up @@ -145,7 +157,7 @@ bool M2MConnectionHandlerPimpl::resolve_server_address(const String& server_addr
_server_port = server_port;
_server_type = server_type;
_server_address = server_address;
TaskIdentifier* task = (TaskIdentifier*)malloc(sizeof(TaskIdentifier));
TaskIdentifier* task = memory_pool.alloc();
if (!task) {
return false;
}
Expand All @@ -163,6 +175,10 @@ bool M2MConnectionHandlerPimpl::resolve_server_address(const String& server_addr
void M2MConnectionHandlerPimpl::dns_handler()
{
tr_debug("M2MConnectionHandlerPimpl::dns_handler()");
if(_socket_address) {
delete _socket_address;
_socket_address = NULL;
}
_socket_address = new SocketAddress(_net_iface,_server_address.c_str(), _server_port);
if(*_socket_address) {
_address._address = (void*)_socket_address->get_ip_address();
Expand Down Expand Up @@ -248,7 +264,7 @@ bool M2MConnectionHandlerPimpl::send_data(uint8_t *data,
return false;
}

TaskIdentifier* task = (TaskIdentifier*)malloc(sizeof(TaskIdentifier));
TaskIdentifier* task = memory_pool.alloc();
if (!task) {
free(buffer);
return false;
Expand Down Expand Up @@ -310,9 +326,7 @@ int8_t M2MConnectionHandlerPimpl::connection_tasklet_handler()

void M2MConnectionHandlerPimpl::socket_event()
{
tr_debug("M2MConnectionHandlerPimpl::socket_event()");

TaskIdentifier* task = (TaskIdentifier*)malloc(sizeof(TaskIdentifier));
TaskIdentifier* task = memory_pool.alloc();
if (!task) {
_observer.socket_error(M2MConnectionHandler::SOCKET_READ_ERROR, true);
return;
Expand Down
Loading

0 comments on commit bdab10d

Please sign in to comment.