Skip to content

Commit 50bd61a

Browse files
authored
Merge pull request #7518 from ARMmbed/release-candidate
Release candidate for mbed-os-5.9.3
2 parents 62f8b92 + 627be9b commit 50bd61a

File tree

350 files changed

+16357
-14929
lines changed

Some content is hidden

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

350 files changed

+16357
-14929
lines changed

.astyleignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ features/FEATURE_BLE/targets
1111
features/FEATURE_LWIP/lwip-interface/lwip
1212
features/unsupported/
1313
features/FEATURE_COMMON_PAL/
14+
hal/storage_abstraction
1415
FEATURE_NANOSTACK/coap-service
1516
FEATURE_NANOSTACK/sal-stack-nanostack
1617
rtos/TARGET_CORTEX/rtx5

TESTS/mbed_drivers/lp_timer/main.cpp

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ extern uint32_t SystemCoreClock;
5555
#define DELTA_MS(delay_ms) (1 + ((delay_ms) * US_PER_MSEC / 20 / US_PER_MSEC))
5656
#define DELTA_S(delay_ms) (0.000500f + (((float)(delay_ms)) / MSEC_PER_SEC / 20))
5757

58+
void busy_wait_us(int us)
59+
{
60+
const ticker_data_t *const ticker = get_us_ticker_data();
61+
uint32_t start = ticker_read(ticker);
62+
while ((ticker_read(ticker) - start) < (uint32_t)us);
63+
}
64+
65+
void busy_wait_ms(int ms)
66+
{
67+
busy_wait_us(ms * US_PER_MSEC);
68+
}
69+
5870
/* This test verifies if low power timer is stopped after
5971
* creation.
6072
*
@@ -74,7 +86,7 @@ void test_lptimer_creation()
7486

7587
/* Wait 10 ms.
7688
* After that operation timer read routines should still return 0. */
77-
wait_ms(10);
89+
busy_wait_ms(10);
7890

7991
/* Check results. */
8092
TEST_ASSERT_EQUAL_FLOAT(0, lp_timer.read());
@@ -102,7 +114,7 @@ void test_lptimer_time_accumulation()
102114
lp_timer.start();
103115

104116
/* Wait 10 ms. */
105-
wait_ms(10);
117+
busy_wait_ms(10);
106118

107119
/* Stop the timer. */
108120
lp_timer.stop();
@@ -116,15 +128,15 @@ void test_lptimer_time_accumulation()
116128
/* Wait 50 ms - this is done to show that time elapsed when
117129
* the timer is stopped does not have influence on the
118130
* timer counted time. */
119-
wait_ms(50);
131+
busy_wait_ms(50);
120132

121133
/* ------ */
122134

123135
/* Start the timer. */
124136
lp_timer.start();
125137

126138
/* Wait 20 ms. */
127-
wait_ms(20);
139+
busy_wait_ms(20);
128140

129141
/* Stop the timer. */
130142
lp_timer.stop();
@@ -145,7 +157,7 @@ void test_lptimer_time_accumulation()
145157
lp_timer.start();
146158

147159
/* Wait 30 ms. */
148-
wait_ms(30);
160+
busy_wait_ms(30);
149161

150162
/* Stop the timer. */
151163
lp_timer.stop();
@@ -159,15 +171,15 @@ void test_lptimer_time_accumulation()
159171
/* Wait 50 ms - this is done to show that time elapsed when
160172
* the timer is stopped does not have influence on the
161173
* timer time. */
162-
wait_ms(50);
174+
busy_wait_ms(50);
163175

164176
/* ------ */
165177

166178
/* Start the timer. */
167179
lp_timer.start();
168180

169181
/* Wait 1 sec. */
170-
wait_ms(1000);
182+
busy_wait_ms(1000);
171183

172184
/* Stop the timer. */
173185
lp_timer.stop();
@@ -196,7 +208,7 @@ void test_lptimer_reset()
196208
lp_timer.start();
197209

198210
/* Wait 10 ms. */
199-
wait_ms(10);
211+
busy_wait_ms(10);
200212

201213
/* Stop the timer. */
202214
lp_timer.stop();
@@ -214,7 +226,7 @@ void test_lptimer_reset()
214226
lp_timer.start();
215227

216228
/* Wait 20 ms. */
217-
wait_ms(20);
229+
busy_wait_ms(20);
218230

219231
/* Stop the timer. */
220232
lp_timer.stop();
@@ -241,13 +253,13 @@ void test_lptimer_start_started_timer()
241253
lp_timer.start();
242254

243255
/* Wait 10 ms. */
244-
wait_ms(10);
256+
busy_wait_ms(10);
245257

246258
/* Now start timer again. */
247259
lp_timer.start();
248260

249261
/* Wait 20 ms. */
250-
wait_ms(20);
262+
busy_wait_ms(20);
251263

252264
/* Stop the timer. */
253265
lp_timer.stop();
@@ -274,7 +286,7 @@ void test_lptimer_float_operator()
274286
lp_timer.start();
275287

276288
/* Wait 10 ms. */
277-
wait_ms(10);
289+
busy_wait_ms(10);
278290

279291
/* Stop the timer. */
280292
lp_timer.stop();
@@ -302,7 +314,7 @@ void test_lptimer_time_measurement()
302314
lp_timer.start();
303315

304316
/* Wait <wait_val_us> us. */
305-
wait_us(wait_val_us);
317+
busy_wait_us(wait_val_us);
306318

307319
/* Stop the timer. */
308320
lp_timer.stop();

TESTS/mbed_hal/common_tickers/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ unsigned int ticker_overflow_delta;
5252

5353
/* Auxiliary function to count ticker ticks elapsed during execution of N cycles of empty while loop.
5454
* Parameter <step> is used to disable compiler optimisation. */
55+
MBED_NOINLINE
5556
uint32_t count_ticks(uint32_t cycles, uint32_t step)
5657
{
5758
register uint32_t reg_cycles = cycles;

TESTS/mbed_hal/lp_ticker/main.cpp

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,38 @@ using namespace utest::v1;
2929

3030
volatile int intFlag = 0;
3131

32+
#define US_PER_MS 1000
33+
3234
#define TICKER_GLITCH_TEST_TICKS 1000
3335

3436
#define TICKER_INT_VAL 500
3537
#define TICKER_DELTA 10
3638

3739
#define LP_TICKER_OV_LIMIT 4000
3840

41+
/* Flush serial buffer before deep sleep
42+
*
43+
* Since deepsleep() may shut down the UART peripheral, we wait for some time
44+
* to allow for hardware serial buffers to completely flush.
45+
*
46+
* Take NUMAKER_PFM_NUC472 as an example:
47+
* Its UART peripheral has 16-byte Tx FIFO. With baud rate set to 9600, flush
48+
* Tx FIFO would take: 16 * 8 * 1000 / 9600 = 13.3 (ms). So set wait time to
49+
* 20ms here for safe.
50+
*
51+
* This should be replaced with a better function that checks if the
52+
* hardware buffers are empty. However, such an API does not exist now,
53+
* so we'll use the busy_wait_ms() function for now.
54+
*/
55+
#define SERIAL_FLUSH_TIME_MS 20
56+
57+
void busy_wait_ms(int ms)
58+
{
59+
const ticker_data_t *const ticker = get_us_ticker_data();
60+
uint32_t start = ticker_read(ticker);
61+
while ((ticker_read(ticker) - start) < (uint32_t)(ms * US_PER_MS));
62+
}
63+
3964
/* Since according to the ticker requirements min acceptable counter size is
4065
* - 12 bits for low power timer - max count = 4095,
4166
* then all test cases must be executed in this time windows.
@@ -72,11 +97,6 @@ void ticker_event_handler_stub(const ticker_data_t * const ticker)
7297
lp_ticker_disable_interrupt();
7398
}
7499

75-
void wait_cycles(volatile unsigned int cycles)
76-
{
77-
while (cycles--);
78-
}
79-
80100
/* Test that the ticker has the correct frequency and number of bits. */
81101
void lp_ticker_info_test()
82102
{
@@ -97,8 +117,10 @@ void lp_ticker_deepsleep_test()
97117

98118
lp_ticker_init();
99119

100-
/* Wait for green tea UART transmission before entering deep-sleep mode. */
101-
wait_cycles(400000);
120+
/* Give some time Green Tea to finish UART transmission before entering
121+
* deep-sleep mode.
122+
*/
123+
busy_wait_ms(SERIAL_FLUSH_TIME_MS);
102124

103125
overflow_protect();
104126

TESTS/mbed_platform/stats_sys/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ void test_sys_info()
3232
mbed_stats_sys_t stats;
3333
mbed_stats_sys_get(&stats);
3434

35+
TEST_ASSERT_NOT_EQUAL(0, stats.os_version);
3536
#if defined(__CORTEX_M)
3637
TEST_ASSERT_NOT_EQUAL(0, stats.cpu_id);
3738
#endif
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2018-2018 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#include "greentea-client/test_env.h"
17+
#include "utest/utest.h"
18+
#include "unity/unity.h"
19+
20+
#include "rtos/Kernel.h"
21+
#include "mbed.h"
22+
23+
24+
using utest::v1::Case;
25+
26+
#define TEST_REPEAT_COUNT 1000
27+
#define NUM_WAIT_TICKS 1000
28+
29+
// all in [us]
30+
#define ONE_SECOND 1000000
31+
#define SMALL_DELTA 1500 // 0.15%
32+
#define BIG_DELTA 15000 // 1.5%
33+
34+
/** Test if kernel ticker frequency is 1kHz
35+
36+
Given a RTOS kernel ticker
37+
When check it frequency
38+
Then the the frequency is 1kHz
39+
*/
40+
void test_frequency()
41+
{
42+
uint32_t freq = osKernelGetTickFreq();
43+
TEST_ASSERT_EQUAL_UINT32_MESSAGE(1000, freq, "Expected SysTick frequency is 1kHz");
44+
}
45+
46+
/** Test if kernel ticker increments by one
47+
48+
Given a RTOS kernel ticker
49+
When perform subsequent calls of @a rtos::Kernel::get_ms_count
50+
Then subsequent reads should not differ by more than one
51+
*/
52+
void test_increment(void)
53+
{
54+
for (uint32_t i = 0; i < TEST_REPEAT_COUNT; i++) {
55+
const uint64_t start = rtos::Kernel::get_ms_count();
56+
while (true) {
57+
uint64_t diff = rtos::Kernel::get_ms_count() - start;
58+
if (diff != 0) {
59+
TEST_ASSERT_EQUAL_UINT64(1, diff);
60+
break;
61+
}
62+
}
63+
}
64+
}
65+
66+
/** Test if kernel ticker interval is 1ms
67+
68+
Given a RTOS kernel ticker
69+
When perform subsequent calls of @a rtos::Kernel::get_ms_count
70+
Then the ticker interval should be 1ms
71+
*/
72+
void test_interval()
73+
{
74+
uint64_t start, stop;
75+
Timer timer;
76+
77+
start = rtos::Kernel::get_ms_count();
78+
// wait for tick
79+
do {
80+
stop = rtos::Kernel::get_ms_count();
81+
} while ((stop - start) == 0);
82+
timer.start();
83+
start = stop;
84+
85+
// wait for NUM_WAIT_TICKS ticks
86+
do {
87+
stop = rtos::Kernel::get_ms_count();
88+
} while ((stop - start) != NUM_WAIT_TICKS);
89+
timer.stop();
90+
TEST_ASSERT_EQUAL_UINT64(NUM_WAIT_TICKS, (stop - start));
91+
92+
#if defined(NO_SYSTICK) || defined(MBED_TICKLESS)
93+
// On targets with NO_SYSTICK/MBED_TICKLESS enabled, systick is emulated by lp_ticker what makes it less accurate
94+
// for more details https://os.mbed.com/docs/latest/reference/tickless.html
95+
TEST_ASSERT_UINT64_WITHIN(BIG_DELTA, ONE_SECOND, timer.read_high_resolution_us());
96+
#else
97+
TEST_ASSERT_UINT64_WITHIN(SMALL_DELTA, ONE_SECOND, timer.read_high_resolution_us());
98+
#endif
99+
}
100+
101+
// Test cases
102+
Case cases[] = {
103+
Case("Test kernel ticker frequency", test_frequency),
104+
Case("Test if kernel ticker increments by one", test_increment),
105+
Case("Test if kernel ticker interval is 1ms", test_interval)
106+
};
107+
108+
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
109+
{
110+
GREENTEA_SETUP(10, "timing_drift_auto");
111+
return utest::v1::greentea_test_setup_handler(number_of_cases);
112+
}
113+
114+
utest::v1::Specification specification(greentea_test_setup, cases);
115+
116+
int main()
117+
{
118+
return !utest::v1::Harness::run(specification);
119+
}

0 commit comments

Comments
 (0)