Skip to content

Commit 4fa2b21

Browse files
author
Jenny Plunkett
authored
Merge pull request ARMmbed#9 from yennster/uart-new
Added peripherals & updated Mbed OS
2 parents 674fabb + 420bec9 commit 4fa2b21

File tree

639 files changed

+16990
-5516
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

639 files changed

+16990
-5516
lines changed

.astyleignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@ BUILD
22
cmsis
33
features/cryptocell
44
features/mbedtls
5-
features/FEATURE_LWIP/lwip
5+
features/lwipstack/lwip
66
rtos/TARGET_CORTEX/rtx4
77
features/filesystem/littlefs/littlefs
88
features/filesystem/fat/ChaN
99
features/frameworks
1010
features/FEATURE_BLE/targets
11-
features/FEATURE_LWIP/lwip-interface/lwip
1211
features/unsupported/
13-
features/FEATURE_COMMON_PAL/
14-
FEATURE_NANOSTACK/coap-service
15-
FEATURE_NANOSTACK/sal-stack-nanostack
1612
rtos/TARGET_CORTEX/rtx5
1713
targets
1814
tools

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ before_install:
3030
# Setup ppa to make sure arm-none-eabi-gcc is correct version
3131
- sudo add-apt-repository -y ppa:team-gcc-arm-embedded/ppa
3232
- sudo add-apt-repository -y ppa:deadsnakes/ppa
33+
# Fix for "The following signatures were invalid: KEYEXPIRED 1515625755" failed". See https://github.com/travis-ci/travis-ci/issues/9037
34+
- sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
3335
# Loop until update succeeds (timeouts can occur)
3436
- travis_retry $(! sudo apt-get update 2>&1 |grep Failed)
3537

@@ -160,7 +162,7 @@ matrix:
160162
- python tools/make.py -t GCC_ARM -m K64F --source=. --build=BUILD/K64F/GCC_ARM -j0
161163
# Check that example compiles without rtos
162164
- sed -n '/``` cpp/,/```/{/```$/Q;/```/d;p;}' $EVENTS/README.md > main.cpp
163-
- rm -r rtos features/cellular features/netsocket features/nanostack features/frameworks/greentea-client features/frameworks/utest features/frameworks/unity BUILD
165+
- rm -r rtos features/cellular features/netsocket features/nanostack features/lwipstack features/frameworks/greentea-client features/frameworks/utest features/frameworks/unity BUILD
164166
- python tools/make.py -t GCC_ARM -m DISCO_F401VC --source=. --build=BUILD/DISCO_F401VC/GCC_ARM -j0
165167
# Run local equeue tests
166168
- make -C $EVENTS/equeue test

TESTS/mbed_hal/sleep/main.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@
2828

2929
#define US_PER_S 1000000
3030

31+
/* Flush serial buffer before deep sleep
32+
*
33+
* Since deepsleep() may shut down the UART peripheral, we wait for some time
34+
* to allow for hardware serial buffers to completely flush.
35+
*
36+
* Take NUMAKER_PFM_NUC472 as an example:
37+
* Its UART peripheral has 16-byte Tx FIFO. With baud rate set to 9600, flush
38+
* Tx FIFO would take: 16 * 8 * 1000 / 9600 = 13.3 (ms). So set wait time to
39+
* 20ms here for safe.
40+
*
41+
* This should be replaced with a better function that checks if the
42+
* hardware buffers are empty. However, such an API does not exist now,
43+
* so we'll use the wait_ms() function for now.
44+
*/
45+
#define SERIAL_FLUSH_TIME_MS 20
46+
3147
using namespace utest::v1;
3248

3349
/* The following ticker frequencies are possible:
@@ -167,7 +183,7 @@ void deepsleep_lpticker_test()
167183
/* Give some time Green Tea to finish UART transmission before entering
168184
* deep-sleep mode.
169185
*/
170-
wait_ms(10);
186+
wait_ms(SERIAL_FLUSH_TIME_MS);
171187

172188
TEST_ASSERT_TRUE_MESSAGE(sleep_manager_can_deep_sleep(), "deep sleep should not be locked");
173189

@@ -202,7 +218,7 @@ void deepsleep_high_speed_clocks_turned_off_test()
202218
/* Give some time Green Tea to finish UART transmission before entering
203219
* deep-sleep mode.
204220
*/
205-
wait_ms(10);
221+
wait_ms(SERIAL_FLUSH_TIME_MS);
206222

207223
TEST_ASSERT_TRUE_MESSAGE(sleep_manager_can_deep_sleep(), "deep sleep should not be locked");
208224

TESTS/mbed_platform/error_handling/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ void test_error_context_capture()
132132
TEST_ASSERT_EQUAL_UINT((uint32_t)current_thread->thread_addr, error_ctx.thread_entry_address);
133133
TEST_ASSERT_EQUAL_UINT((uint32_t)current_thread->stack_size, error_ctx.thread_stack_size);
134134
TEST_ASSERT_EQUAL_UINT((uint32_t)current_thread->stack_mem, error_ctx.thread_stack_mem);
135-
#ifdef MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED
135+
#if MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED
136136
TEST_ASSERT_EQUAL_STRING(MBED_FILENAME, error_ctx.error_filename);
137137
#endif
138138
}
139139

140-
#ifndef MBED_CONF_ERROR_HIST_DISABLED
140+
#if MBED_CONF_PLATFORM_ERROR_HIST_ENABLED
141141
/** Test error logging functionality
142142
*/
143143
void test_error_logging()
@@ -261,7 +261,7 @@ void test_error_hook()
261261
TEST_ASSERT(sem_status > 0);
262262
}
263263

264-
#ifdef MBED_TEST_SIM_BLOCKDEVICE
264+
#if MBED_CONF_PLATFORM_ERROR_HIST_ENABLED && defined(MBED_TEST_SIM_BLOCKDEVICE)
265265

266266
// test configuration
267267
#ifndef MBED_TEST_FILESYSTEM
@@ -351,12 +351,12 @@ Case cases[] = {
351351
Case("Test error context capture", test_error_context_capture),
352352
#endif //MBED_CONF_RTOS_PRESENT
353353
Case("Test error hook", test_error_hook),
354-
#ifndef MBED_CONF_ERROR_HIST_DISABLED
354+
#if MBED_CONF_PLATFORM_ERROR_HIST_ENABLED
355355
Case("Test error logging", test_error_logging),
356356
#if MBED_CONF_RTOS_PRESENT
357357
Case("Test error handling multi-threaded", test_error_logging_multithread),
358358
#endif //MBED_CONF_RTOS_PRESENT
359-
#ifdef MBED_TEST_SIM_BLOCKDEVICE
359+
#if MBED_CONF_PLATFORM_ERROR_HIST_ENABLED && defined(MBED_TEST_SIM_BLOCKDEVICE)
360360
Case("Test error save log", test_save_error_log),
361361
#endif //MBED_TEST_SIM_BLOCKDEVICE
362362
#endif //MBED_CONF_ERROR_HIST_DISABLED
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2018, ARM Limited, All Rights Reserved
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
* not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#include "mbed.h"
19+
#include "greentea-client/test_env.h"
20+
#include "unity.h"
21+
#include "utest.h"
22+
#include "dns_tests.h"
23+
24+
using namespace utest::v1;
25+
26+
namespace {
27+
int result_ok;
28+
int result_no_mem;
29+
int result_dns_failure;
30+
int result_exp_timeout;
31+
}
32+
33+
void ASYNCHRONOUS_DNS()
34+
{
35+
do_asynchronous_gethostbyname(dns_test_hosts, 1, &result_ok, &result_no_mem, &result_dns_failure, &result_exp_timeout);
36+
37+
TEST_ASSERT(result_ok == 1);
38+
TEST_ASSERT(result_no_mem == 0);
39+
TEST_ASSERT(result_dns_failure == 0);
40+
TEST_ASSERT(result_exp_timeout == 0);
41+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright (c) 2018, ARM Limited, All Rights Reserved
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
* not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#include "mbed.h"
19+
#include "greentea-client/test_env.h"
20+
#include "unity.h"
21+
#include "utest.h"
22+
#include "dns_tests.h"
23+
24+
using namespace utest::v1;
25+
26+
namespace {
27+
int ticker_us = 0;
28+
}
29+
30+
static void test_dns_query_ticker(void)
31+
{
32+
ticker_us += 100;
33+
}
34+
35+
void ASYNCHRONOUS_DNS_CACHE()
36+
{
37+
rtos::Semaphore semaphore;
38+
dns_application_data data;
39+
data.semaphore = &semaphore;
40+
41+
Ticker ticker;
42+
ticker.attach_us(&test_dns_query_ticker, 100);
43+
44+
for (unsigned int i = 0; i < 5; i++) {
45+
int started_us = ticker_us;
46+
47+
nsapi_error_t err = get_interface()->gethostbyname_async(dns_test_hosts[0],
48+
mbed::Callback<void(nsapi_error_t, SocketAddress *)>(hostbyname_cb, (void *) &data));
49+
TEST_ASSERT(err >= 0);
50+
51+
semaphore.wait();
52+
53+
TEST_ASSERT(data.result == NSAPI_ERROR_OK);
54+
TEST_ASSERT(strlen(data.addr.get_ip_address()) > 1);
55+
56+
int delay_ms = (ticker_us - started_us) / 1000;
57+
58+
static int delay_first = delay_ms / 2;
59+
// Check that cached accesses are at least twice as fast as the first one
60+
TEST_ASSERT_FALSE(i != 0 && delay_ms > delay_first);
61+
62+
printf("DNS: query \"%s\" => \"%s\", time %i ms\n",
63+
dns_test_hosts[0], data.addr.get_ip_address(), delay_ms);
64+
}
65+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright (c) 2018, ARM Limited, All Rights Reserved
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
* not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#include "mbed.h"
19+
#include "greentea-client/test_env.h"
20+
#include "unity.h"
21+
#include "utest.h"
22+
#include "dns_tests.h"
23+
24+
using namespace utest::v1;
25+
26+
void ASYNCHRONOUS_DNS_CANCEL()
27+
{
28+
rtos::Semaphore semaphore;
29+
dns_application_data *data = new dns_application_data[MBED_CONF_APP_DNS_TEST_HOSTS_NUM];
30+
31+
int count = 0;
32+
33+
for (unsigned int i = 0; i < MBED_CONF_APP_DNS_TEST_HOSTS_NUM; i++) {
34+
data[i].value_set = false;
35+
data[i].semaphore = &semaphore;
36+
data[i].req_result = get_interface()->gethostbyname_async(dns_test_hosts[i],
37+
mbed::Callback<void(nsapi_error_t, SocketAddress *)>(hostbyname_cb, (void *) &data[i]));
38+
TEST_ASSERT(data[i].req_result >= 0 || data[i].req_result == NSAPI_ERROR_NO_MEMORY);
39+
40+
if (data[i].req_result >= 0) {
41+
// Callback will be called
42+
count++;
43+
} else {
44+
// No memory to initiate DNS query, callback will not be called
45+
data[i].result = NSAPI_ERROR_NO_MEMORY;
46+
data[i].value_set = true;
47+
}
48+
}
49+
50+
for (unsigned int i = 0; i < MBED_CONF_APP_DNS_TEST_HOSTS_NUM; i++) {
51+
if (data[i].req_result > 0) {
52+
if (get_interface()->gethostbyname_async_cancel(data[i].req_result) == NSAPI_ERROR_OK) {
53+
count--;
54+
}
55+
}
56+
}
57+
58+
// Wait for callback(s) to complete
59+
for (int i = 0; i < count; i++) {
60+
semaphore.wait();
61+
}
62+
63+
for (unsigned int i = 0; i < MBED_CONF_APP_DNS_TEST_HOSTS_NUM; i++) {
64+
if (!data[i].value_set) {
65+
printf("DNS: query \"%s\" => cancel\n", dns_test_hosts[i]);
66+
continue;
67+
}
68+
TEST_ASSERT(data[i].result == NSAPI_ERROR_OK || data[i].result == NSAPI_ERROR_NO_MEMORY || data[i].result == NSAPI_ERROR_DNS_FAILURE || data[i].result == NSAPI_ERROR_TIMEOUT);
69+
if (data[i].result == NSAPI_ERROR_OK) {
70+
printf("DNS: query \"%s\" => \"%s\"\n",
71+
dns_test_hosts[i], data[i].addr.get_ip_address());
72+
} else if (data[i].result == NSAPI_ERROR_DNS_FAILURE) {
73+
printf("DNS: query \"%s\" => DNS failure\n", dns_test_hosts[i]);
74+
} else if (data[i].result == NSAPI_ERROR_TIMEOUT) {
75+
printf("DNS: query \"%s\" => timeout\n", dns_test_hosts[i]);
76+
} else if (data[i].result == NSAPI_ERROR_NO_MEMORY) {
77+
printf("DNS: query \"%s\" => no memory\n", dns_test_hosts[i]);
78+
}
79+
}
80+
81+
delete[] data;
82+
83+
wait(5.0);
84+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Copyright (c) 2018, ARM Limited, All Rights Reserved
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
* not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#include "mbed.h"
19+
#include "greentea-client/test_env.h"
20+
#include "unity.h"
21+
#include "utest.h"
22+
#include "dns_tests.h"
23+
24+
#include "nsapi_dns.h"
25+
26+
using namespace utest::v1;
27+
28+
namespace {
29+
int result_ok;
30+
int result_no_mem;
31+
int result_dns_failure;
32+
int result_exp_timeout;
33+
34+
const int EXTERNAL_THREAD_SIZE = 2048;
35+
const int EVENT_QUEUE_SIZE = 10;
36+
37+
events::EventQueue *event_queue;
38+
}
39+
40+
static nsapi_error_t event_queue_call(int delay, mbed::Callback<void()> func)
41+
{
42+
if (delay) {
43+
if (event_queue->call_in(delay, func) == 0) {
44+
return NSAPI_ERROR_NO_MEMORY;
45+
}
46+
} else {
47+
if (event_queue->call(func) == 0) {
48+
return NSAPI_ERROR_NO_MEMORY;
49+
}
50+
}
51+
return NSAPI_ERROR_OK;
52+
}
53+
54+
void ASYNCHRONOUS_DNS_EXTERNAL_EVENT_QUEUE()
55+
{
56+
// Ensures that cache does not contain entries
57+
do_asynchronous_gethostbyname(dns_test_hosts, MBED_CONF_NSAPI_DNS_CACHE_SIZE, &result_ok, &result_no_mem,
58+
&result_dns_failure, &result_exp_timeout);
59+
60+
TEST_ASSERT(result_ok == MBED_CONF_NSAPI_DNS_CACHE_SIZE);
61+
TEST_ASSERT(result_no_mem == 0);
62+
TEST_ASSERT(result_dns_failure == 0);
63+
TEST_ASSERT(result_exp_timeout == 0);
64+
65+
// Dispatch event queue
66+
Thread eventThread(osPriorityNormal, EXTERNAL_THREAD_SIZE);
67+
EventQueue queue(EVENT_QUEUE_SIZE * EVENTS_EVENT_SIZE);
68+
eventThread.start(callback(&queue, &EventQueue::dispatch_forever));
69+
event_queue = &queue;
70+
71+
nsapi_dns_call_in_set(event_queue_call);
72+
73+
do_asynchronous_gethostbyname(dns_test_hosts_second, MBED_CONF_APP_DNS_SIMULT_QUERIES + 1, &result_ok, &result_no_mem,
74+
&result_dns_failure, &result_exp_timeout);
75+
76+
TEST_ASSERT(result_ok == MBED_CONF_APP_DNS_SIMULT_QUERIES);
77+
TEST_ASSERT(result_no_mem == 1); // last query fails for no memory as expected
78+
TEST_ASSERT(result_dns_failure == 0);
79+
TEST_ASSERT(result_exp_timeout == 0);
80+
81+
// Give event queue time to finalise before destructors
82+
wait(2.0);
83+
84+
nsapi_dns_call_in_set(0);
85+
}

0 commit comments

Comments
 (0)