Skip to content

Commit

Permalink
Merge pull request ARMmbed#36 from yennster/try
Browse files Browse the repository at this point in the history
Latest Mbed OS
  • Loading branch information
Jenny Plunkett authored Jul 24, 2018
2 parents fb0b758 + 61f425f commit 1850508
Show file tree
Hide file tree
Showing 1,118 changed files with 439,834 additions and 22,646 deletions.
4 changes: 4 additions & 0 deletions .astyleignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ features/filesystem/fat/ChaN
features/frameworks
features/FEATURE_BLE/targets
features/unsupported/
features/FEATURE_COMMON_PAL/
hal/storage_abstraction
FEATURE_NANOSTACK/coap-service
FEATURE_NANOSTACK/sal-stack-nanostack
rtos/TARGET_CORTEX/rtx5
targets
tools
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ matrix:
- env:
- NAME=astyle
install:
- wget https://downloads.sourceforge.net/project/astyle/astyle/astyle%203.1/astyle_3.1_linux.tar.gz;
mkdir -p BUILD && tar xf astyle_3.1_linux.tar.gz -C BUILD;
- curl -L0 http://mbed-os.s3-eu-west-1.amazonaws.com/builds/deps/astyle_3.1_linux.tar.gz --output astyle.tar.gz;
mkdir -p BUILD && tar xf astyle.tar.gz -C BUILD;
pushd BUILD/astyle/build/gcc;
make;
export PATH=$PWD/bin:$PATH;
Expand Down
25 changes: 0 additions & 25 deletions LICENSE-BSD-3-Clause

This file was deleted.

38 changes: 25 additions & 13 deletions TESTS/mbed_drivers/lp_timer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ extern uint32_t SystemCoreClock;
#define DELTA_MS(delay_ms) (1 + ((delay_ms) * US_PER_MSEC / 20 / US_PER_MSEC))
#define DELTA_S(delay_ms) (0.000500f + (((float)(delay_ms)) / MSEC_PER_SEC / 20))

void busy_wait_us(int us)
{
const ticker_data_t *const ticker = get_us_ticker_data();
uint32_t start = ticker_read(ticker);
while ((ticker_read(ticker) - start) < (uint32_t)us);
}

void busy_wait_ms(int ms)
{
busy_wait_us(ms * US_PER_MSEC);
}

/* This test verifies if low power timer is stopped after
* creation.
*
Expand All @@ -74,7 +86,7 @@ void test_lptimer_creation()

/* Wait 10 ms.
* After that operation timer read routines should still return 0. */
wait_ms(10);
busy_wait_ms(10);

/* Check results. */
TEST_ASSERT_EQUAL_FLOAT(0, lp_timer.read());
Expand Down Expand Up @@ -102,7 +114,7 @@ void test_lptimer_time_accumulation()
lp_timer.start();

/* Wait 10 ms. */
wait_ms(10);
busy_wait_ms(10);

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

/* ------ */

/* Start the timer. */
lp_timer.start();

/* Wait 20 ms. */
wait_ms(20);
busy_wait_ms(20);

/* Stop the timer. */
lp_timer.stop();
Expand All @@ -145,7 +157,7 @@ void test_lptimer_time_accumulation()
lp_timer.start();

/* Wait 30 ms. */
wait_ms(30);
busy_wait_ms(30);

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

/* ------ */

/* Start the timer. */
lp_timer.start();

/* Wait 1 sec. */
wait_ms(1000);
busy_wait_ms(1000);

/* Stop the timer. */
lp_timer.stop();
Expand Down Expand Up @@ -196,7 +208,7 @@ void test_lptimer_reset()
lp_timer.start();

/* Wait 10 ms. */
wait_ms(10);
busy_wait_ms(10);

/* Stop the timer. */
lp_timer.stop();
Expand All @@ -214,7 +226,7 @@ void test_lptimer_reset()
lp_timer.start();

/* Wait 20 ms. */
wait_ms(20);
busy_wait_ms(20);

/* Stop the timer. */
lp_timer.stop();
Expand All @@ -241,13 +253,13 @@ void test_lptimer_start_started_timer()
lp_timer.start();

/* Wait 10 ms. */
wait_ms(10);
busy_wait_ms(10);

/* Now start timer again. */
lp_timer.start();

/* Wait 20 ms. */
wait_ms(20);
busy_wait_ms(20);

/* Stop the timer. */
lp_timer.stop();
Expand All @@ -274,7 +286,7 @@ void test_lptimer_float_operator()
lp_timer.start();

/* Wait 10 ms. */
wait_ms(10);
busy_wait_ms(10);

/* Stop the timer. */
lp_timer.stop();
Expand Down Expand Up @@ -302,7 +314,7 @@ void test_lptimer_time_measurement()
lp_timer.start();

/* Wait <wait_val_us> us. */
wait_us(wait_val_us);
busy_wait_us(wait_val_us);

/* Stop the timer. */
lp_timer.stop();
Expand Down
43 changes: 34 additions & 9 deletions TESTS/mbed_hal/common_tickers/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
#include "hal/us_ticker_api.h"
#include "hal/lp_ticker_api.h"

#ifdef __cplusplus
extern "C" {
#endif
#include "os_tick.h"
#ifdef __cplusplus
}
#endif // __cplusplus

#if !DEVICE_USTICKER
#error [NOT_SUPPORTED] test not supported
#endif
Expand All @@ -29,8 +37,10 @@
#define TICKER_INT_VAL 500
#define TICKER_DELTA 10

#define LP_TICKER_OVERFLOW_DELTA 0 // this will allow to detect that ticker counter rollovers to 0
#define US_TICKER_OVERFLOW_DELTA 50
#define LP_TICKER_OVERFLOW_DELTA1 0 // this will allow to detect that ticker counter rollovers to 0
#define LP_TICKER_OVERFLOW_DELTA2 0
#define US_TICKER_OVERFLOW_DELTA1 50
#define US_TICKER_OVERFLOW_DELTA2 60

#define TICKER_100_TICKS 100

Expand All @@ -48,10 +58,22 @@ using namespace utest::v1;
volatile int intFlag = 0;
const ticker_interface_t* intf;
ticker_irq_handler_type prev_irq_handler;
unsigned int ticker_overflow_delta;
/* Some targets might fail overflow test uncertainly due to getting trapped in busy
* intf->read() loop. In the loop, some ticker values wouldn't get caught in time
* because of:
* 1. Lower CPU clock
* 2. Compiled code with worse performance
* 3. Interrupt at that time
*
* We fix it by checking small ticker value range rather than one exact ticker point
* in near overflow check.
*/
unsigned int ticker_overflow_delta1;
unsigned int ticker_overflow_delta2;

/* Auxiliary function to count ticker ticks elapsed during execution of N cycles of empty while loop.
* Parameter <step> is used to disable compiler optimisation. */
MBED_NOINLINE
uint32_t count_ticks(uint32_t cycles, uint32_t step)
{
register uint32_t reg_cycles = cycles;
Expand Down Expand Up @@ -117,7 +139,7 @@ void ticker_event_handler_stub(const ticker_data_t * const ticker)
}

/* Indicate that ISR has been executed in interrupt context. */
if (IsIrqMode()) {
if (core_util_is_isr_active()) {
intFlag++;
}
}
Expand Down Expand Up @@ -292,12 +314,13 @@ void ticker_overflow_test(void)
intFlag = 0;

/* Wait for max count. */
while (intf->read() != (max_count - ticker_overflow_delta)) {
while (intf->read() >= (max_count - ticker_overflow_delta2) &&
intf->read() <= (max_count - ticker_overflow_delta1)) {
/* Just wait. */
}

/* Now we are near/at the overflow point. Detect rollover. */
while (intf->read() > ticker_overflow_delta);
while (intf->read() > ticker_overflow_delta1);

const uint32_t after_overflow = intf->read();

Expand All @@ -309,7 +332,7 @@ void ticker_overflow_test(void)
const uint32_t next_after_overflow = intf->read();

/* Check that after the overflow ticker continue count. */
TEST_ASSERT(after_overflow <= ticker_overflow_delta);
TEST_ASSERT(after_overflow <= ticker_overflow_delta1);
TEST_ASSERT(next_after_overflow >= TICKER_100_TICKS);
TEST_ASSERT_EQUAL(0, intFlag);

Expand Down Expand Up @@ -464,7 +487,8 @@ utest::v1::status_t us_ticker_setup(const Case *const source, const size_t index

prev_irq_handler = set_us_ticker_irq_handler(ticker_event_handler_stub);

ticker_overflow_delta = US_TICKER_OVERFLOW_DELTA;
ticker_overflow_delta1 = US_TICKER_OVERFLOW_DELTA1;
ticker_overflow_delta2 = US_TICKER_OVERFLOW_DELTA2;

return greentea_case_setup_handler(source, index_of_case);
}
Expand Down Expand Up @@ -492,7 +516,8 @@ utest::v1::status_t lp_ticker_setup(const Case *const source, const size_t index

prev_irq_handler = set_lp_ticker_irq_handler(ticker_event_handler_stub);

ticker_overflow_delta = LP_TICKER_OVERFLOW_DELTA;
ticker_overflow_delta1 = LP_TICKER_OVERFLOW_DELTA1;
ticker_overflow_delta2 = LP_TICKER_OVERFLOW_DELTA2;

return greentea_case_setup_handler(source, index_of_case);
}
Expand Down
38 changes: 30 additions & 8 deletions TESTS/mbed_hal/lp_ticker/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,38 @@ using namespace utest::v1;

volatile int intFlag = 0;

#define US_PER_MS 1000

#define TICKER_GLITCH_TEST_TICKS 1000

#define TICKER_INT_VAL 500
#define TICKER_DELTA 10

#define LP_TICKER_OV_LIMIT 4000

/* Flush serial buffer before deep sleep
*
* Since deepsleep() may shut down the UART peripheral, we wait for some time
* to allow for hardware serial buffers to completely flush.
*
* Take NUMAKER_PFM_NUC472 as an example:
* Its UART peripheral has 16-byte Tx FIFO. With baud rate set to 9600, flush
* Tx FIFO would take: 16 * 8 * 1000 / 9600 = 13.3 (ms). So set wait time to
* 20ms here for safe.
*
* This should be replaced with a better function that checks if the
* hardware buffers are empty. However, such an API does not exist now,
* so we'll use the busy_wait_ms() function for now.
*/
#define SERIAL_FLUSH_TIME_MS 20

void busy_wait_ms(int ms)
{
const ticker_data_t *const ticker = get_us_ticker_data();
uint32_t start = ticker_read(ticker);
while ((ticker_read(ticker) - start) < (uint32_t)(ms * US_PER_MS));
}

/* Since according to the ticker requirements min acceptable counter size is
* - 12 bits for low power timer - max count = 4095,
* then all test cases must be executed in this time windows.
Expand Down Expand Up @@ -63,7 +88,7 @@ void overflow_protect()
void ticker_event_handler_stub(const ticker_data_t * const ticker)
{
/* Indicate that ISR has been executed in interrupt context. */
if (IsIrqMode()) {
if (core_util_is_isr_active()) {
intFlag++;
}

Expand All @@ -72,11 +97,6 @@ void ticker_event_handler_stub(const ticker_data_t * const ticker)
lp_ticker_disable_interrupt();
}

void wait_cycles(volatile unsigned int cycles)
{
while (cycles--);
}

/* Test that the ticker has the correct frequency and number of bits. */
void lp_ticker_info_test()
{
Expand All @@ -97,8 +117,10 @@ void lp_ticker_deepsleep_test()

lp_ticker_init();

/* Wait for green tea UART transmission before entering deep-sleep mode. */
wait_cycles(400000);
/* Give some time Green Tea to finish UART transmission before entering
* deep-sleep mode.
*/
busy_wait_ms(SERIAL_FLUSH_TIME_MS);

overflow_protect();

Expand Down
1 change: 1 addition & 0 deletions TESTS/mbed_platform/stats_sys/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ void test_sys_info()
mbed_stats_sys_t stats;
mbed_stats_sys_get(&stats);

TEST_ASSERT_NOT_EQUAL(0, stats.os_version);
#if defined(__CORTEX_M)
TEST_ASSERT_NOT_EQUAL(0, stats.cpu_id);
#endif
Expand Down
4 changes: 4 additions & 0 deletions TESTS/mbedmicro-rtos-mbed/basic/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@

using utest::v1::Case;

#if defined(__CORTEX_M23) || defined(__CORTEX_M33)
#define TEST_STACK_SIZE 512
#else
#define TEST_STACK_SIZE 256
#endif
#define ONE_MILLI_SEC 1000

volatile uint32_t elapsed_time_ms = 0;
Expand Down
4 changes: 4 additions & 0 deletions TESTS/mbedmicro-rtos-mbed/event_flags/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ using utest::v1::Case;
#error [NOT_SUPPORTED] test not supported
#endif

#if defined(__CORTEX_M23) || defined(__CORTEX_M33)
#define THREAD_STACK_SIZE 512
#else
#define THREAD_STACK_SIZE 320 /* 512B stack on GCC_ARM compiler cause out of memory on some 16kB RAM boards e.g. NUCLEO_F070RB */
#endif

#define MAX_FLAG_POS 30
#define PROHIBITED_FLAG_POS 31
Expand Down
Loading

0 comments on commit 1850508

Please sign in to comment.