Skip to content

Commit ed4febe

Browse files
authored
Merge pull request #4209 from ARMmbed/release-candidate
Release candidate for mbed-os-5.4.4
2 parents 42be5c0 + 9ce6141 commit ed4febe

File tree

96 files changed

+1480
-418
lines changed

Some content is hidden

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

96 files changed

+1480
-418
lines changed

drivers/CAN.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ CAN::CAN(PinName rd, PinName td) : _can(), _irq() {
2727
// No lock needed in constructor
2828

2929
for (int i = 0; i < sizeof _irq / sizeof _irq[0]; i++) {
30-
_irq[i].attach(donothing);
30+
_irq[i] = callback(donothing);
3131
}
3232

3333
can_init(&_can, rd, td);
@@ -104,10 +104,10 @@ int CAN::filter(unsigned int id, unsigned int mask, CANFormat format, int handle
104104
void CAN::attach(Callback<void()> func, IrqType type) {
105105
lock();
106106
if (func) {
107-
_irq[(CanIrqType)type].attach(func);
107+
_irq[(CanIrqType)type] = func;
108108
can_irq_set(&_can, (CanIrqType)type, 1);
109109
} else {
110-
_irq[(CanIrqType)type].attach(donothing);
110+
_irq[(CanIrqType)type] = callback(donothing);
111111
can_irq_set(&_can, (CanIrqType)type, 0);
112112
}
113113
unlock();

events/equeue/equeue_mbed.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@ static void equeue_tick_init() {
4242
"The equeue_timer buffer must fit the class Timer");
4343
MBED_STATIC_ASSERT(sizeof(equeue_ticker) >= sizeof(Ticker),
4444
"The equeue_ticker buffer must fit the class Ticker");
45-
new (equeue_timer) Timer;
46-
new (equeue_ticker) Ticker;
45+
Timer *timer = new (equeue_timer) Timer;
46+
Ticker *ticker = new (equeue_ticker) Ticker;
4747

4848
equeue_minutes = 0;
49-
reinterpret_cast<Timer*>(equeue_timer)->start();
50-
reinterpret_cast<Ticker*>(equeue_ticker)
51-
->attach_us(equeue_tick_update, 1000 << 16);
49+
timer->start();
50+
ticker->attach_us(equeue_tick_update, 1000 << 16);
5251

5352
equeue_tick_inited = true;
5453
}

mbed.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
#ifndef MBED_H
1717
#define MBED_H
1818

19-
#define MBED_LIBRARY_VERSION 140
19+
#define MBED_LIBRARY_VERSION 141
2020

2121
#if MBED_CONF_RTOS_PRESENT
2222
// RTOS present, this is valid only for mbed OS 5
2323
#define MBED_MAJOR_VERSION 5
2424
#define MBED_MINOR_VERSION 4
25-
#define MBED_PATCH_VERSION 3
25+
#define MBED_PATCH_VERSION 4
2626

2727
#else
2828
// mbed 2

platform/mbed_board.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,25 @@ void mbed_error_printf(const char* format, ...) {
7575

7676
void mbed_error_vfprintf(const char * format, va_list arg) {
7777
#if DEVICE_SERIAL
78-
79-
#if MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES
80-
char stdio_out_prev;
81-
#endif
82-
78+
#define ERROR_BUF_SIZE (128)
8379
core_util_critical_section_enter();
84-
char buffer[128];
85-
int size = vsprintf(buffer, format, arg);
80+
char buffer[ERROR_BUF_SIZE];
81+
int size = vsnprintf(buffer, ERROR_BUF_SIZE, format, arg);
8682
if (size > 0) {
8783
if (!stdio_uart_inited) {
8884
serial_init(&stdio_uart, STDIO_UART_TX, STDIO_UART_RX);
8985
}
9086
#if MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES
91-
for (unsigned int i = 0; i < size; i++) {
87+
char stdio_out_prev = '\0';
88+
for (int i = 0; i < size; i++) {
9289
if (buffer[i] == '\n' && stdio_out_prev != '\r') {
9390
serial_putc(&stdio_uart, '\r');
9491
}
9592
serial_putc(&stdio_uart, buffer[i]);
9693
stdio_out_prev = buffer[i];
9794
}
9895
#else
99-
for (unsigned int i = 0; i < size; i++) {
96+
for (int i = 0; i < size; i++) {
10097
serial_putc(&stdio_uart, buffer[i]);
10198
}
10299
#endif

platform/mbed_retarget.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ static void init_serial() {
120120
#endif
121121
}
122122

123+
#if MBED_CONF_FILESYSTEM_PRESENT
123124
static inline int openmode_to_posix(int openmode) {
124125
int posix = openmode;
125126
#ifdef __ARMCC_VERSION
@@ -154,6 +155,7 @@ static inline int openmode_to_posix(int openmode) {
154155
#endif
155156
return posix;
156157
}
158+
#endif
157159

158160
extern "C" WEAK void mbed_sdk_init(void);
159161
extern "C" WEAK void mbed_sdk_init(void) {

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K66F/device/TOOLCHAIN_ARM_STD/MK66FN2M0xxx18.sct

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@
4747
*/
4848
#define __ram_vector_table__ 1
4949

50-
/* Heap 1/4 of ram and stack 1/8 */
51-
#define __stack_size__ 0x8000
52-
#define __heap_size__ 0x10000
53-
5450
#if (defined(__ram_vector_table__))
5551
#define __ram_vector_table_size__ 0x00000400
5652
#else

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K82F/device/TOOLCHAIN_ARM_STD/MK82FN256xxx15.sct

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@
4949
*/
5050

5151
#define __ram_vector_table__ 1
52-
53-
/* Heap 1/4 of ram and stack 1/8 */
54-
#define __stack_size__ 0x8000
55-
#define __heap_size__ 0x10000
5652

5753
#if (defined(__ram_vector_table__))
5854
#define __ram_vector_table_size__ 0x000003C0

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL27Z/device/TOOLCHAIN_ARM_STD/MKL27Z64xxx4.sct

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@
5050
*/
5151
#define __ram_vector_table__ 1
5252

53-
/* Heap 1/4 of ram and stack 1/8 */
54-
#define __stack_size__ 0x800
55-
#define __heap_size__ 0x1000
56-
5753
#if (defined(__ram_vector_table__))
5854
#define __ram_vector_table_size__ 0x00000200
5955
#else

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL43Z/device/TOOLCHAIN_ARM_STD/MKL43Z256xxx4.sct

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@
4747
*/
4848
#define __ram_vector_table__ 1
4949

50-
/* Heap 1/4 of ram and stack 1/8 */
51-
#define __stack_size__ 0x1000
52-
#define __heap_size__ 0x2800
53-
5450
#if (defined(__ram_vector_table__))
5551
#define __ram_vector_table_size__ 0x00000200
5652
#else

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL82Z/device/TOOLCHAIN_ARM_STD/MKL82Z128xxx7.sct

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@
5050
*/
5151
#define __ram_vector_table__ 1
5252

53-
/* Heap 1/4 of ram and stack 1/8 */
54-
#define __stack_size__ 0x3000
55-
#define __heap_size__ 0x6000
56-
5753
#if (defined(__ram_vector_table__))
5854
#define __ram_vector_table_size__ 0x00000140
5955
#else

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW24D/device/TOOLCHAIN_ARM_STD/MKW24D512xxx5.sct

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@
4545
*/
4646
#define __ram_vector_table__ 1
4747

48-
/* Heap 1/4 of ram and stack 1/8 */
49-
#define __stack_size__ 0x2000
50-
#define __heap_size__ 0x4000
51-
5248
#if (defined(__ram_vector_table__))
5349
#define __ram_vector_table_size__ 0x00000400
5450
#else

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW41Z/device/TOOLCHAIN_ARM_STD/MKW41Z512xxx4.sct

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@
4545
*/
4646
#define __ram_vector_table__ 1
4747

48-
/* Heap 1/4 of ram and stack 1/8 */
49-
#define __stack_size__ 0x4000
50-
#define __heap_size__ 0x8000
51-
5248
#if (defined(__ram_vector_table__))
5349
#define __ram_vector_table_size__ 0x00000200
5450
#else

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K22F/TARGET_MCU_K22F512/device/TOOLCHAIN_ARM_STD/MK22FN512xxx12.sct

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@
5151
*/
5252
#define __ram_vector_table__ 1
5353

54-
/* Heap 1/4 of ram and stack 1/8 */
55-
#define __stack_size__ 0x4000
56-
#define __heap_size__ 0x8000
57-
5854
#if (defined(__ram_vector_table__))
5955
#define __ram_vector_table_size__ 0x00000400
6056
#else

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/TOOLCHAIN_ARM_STD/MK64FN1M0xxx12.sct

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@
5050
*/
5151
#define __ram_vector_table__ 1
5252

53-
/* Heap 1/4 of ram and stack 1/8 */
54-
#define __stack_size__ 0x8000
55-
#define __heap_size__ 0x10000
56-
5753
#if (defined(__ram_vector_table__))
5854
#define __ram_vector_table_size__ 0x00000400
5955
#else

targets/TARGET_Maxim/TARGET_MAX32630/sleep.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@
3434
#include "sleep_api.h"
3535
#include "lp.h"
3636

37-
void sleep(void)
37+
void hal_sleep(void)
3838
{
3939
LP_EnterLP2();
4040
}
4141

4242
// Low-power stop mode
43-
void deepsleep(void)
43+
void hal_deepsleep(void)
4444
{
45-
sleep();
45+
hal_sleep();
4646
}

targets/TARGET_NORDIC/TARGET_NRF5/us_ticker.c

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "nrf_drv_common.h"
4343
#include "nrf_drv_config.h"
4444
#include "lp_ticker_api.h"
45+
#include "mbed_critical.h"
4546

4647

4748
//------------------------------------------------------------------------------
@@ -52,12 +53,25 @@
5253
bool m_common_rtc_enabled = false;
5354
uint32_t volatile m_common_rtc_overflows = 0;
5455

56+
__STATIC_INLINE void rtc_ovf_event_check(void)
57+
{
58+
if (nrf_rtc_event_pending(COMMON_RTC_INSTANCE, NRF_RTC_EVENT_OVERFLOW)) {
59+
nrf_rtc_event_clear(COMMON_RTC_INSTANCE, NRF_RTC_EVENT_OVERFLOW);
60+
// Don't disable this event. It shall occur periodically.
61+
62+
++m_common_rtc_overflows;
63+
}
64+
}
65+
5566
#if defined(TARGET_MCU_NRF51822)
5667
void common_rtc_irq_handler(void)
5768
#else
5869
void COMMON_RTC_IRQ_HANDLER(void)
5970
#endif
6071
{
72+
73+
rtc_ovf_event_check();
74+
6175
if (nrf_rtc_event_pending(COMMON_RTC_INSTANCE, US_TICKER_EVENT)) {
6276
us_ticker_irq_handler();
6377
}
@@ -69,12 +83,6 @@ void COMMON_RTC_IRQ_HANDLER(void)
6983
}
7084
#endif
7185

72-
if (nrf_rtc_event_pending(COMMON_RTC_INSTANCE, NRF_RTC_EVENT_OVERFLOW)) {
73-
nrf_rtc_event_clear(COMMON_RTC_INSTANCE, NRF_RTC_EVENT_OVERFLOW);
74-
// Don't disable this event. It shall occur periodically.
75-
76-
++m_common_rtc_overflows;
77-
}
7886
}
7987

8088
#if (defined (__ICCARM__)) && defined(TARGET_MCU_NRF51822)//IAR
@@ -142,13 +150,37 @@ void common_rtc_init(void)
142150
m_common_rtc_enabled = true;
143151
}
144152

153+
__STATIC_INLINE void rtc_ovf_event_safe_check(void)
154+
{
155+
core_util_critical_section_enter();
156+
157+
rtc_ovf_event_check();
158+
159+
core_util_critical_section_exit();
160+
}
161+
162+
145163
uint32_t common_rtc_32bit_ticks_get(void)
146164
{
147-
uint32_t ticks = nrf_rtc_counter_get(COMMON_RTC_INSTANCE);
148-
// The counter used for time measurements is less than 32 bit wide,
149-
// so its value is complemented with the number of registered overflows
150-
// of the counter.
151-
ticks += (m_common_rtc_overflows << RTC_COUNTER_BITS);
165+
uint32_t ticks;
166+
uint32_t prev_overflows;
167+
168+
do {
169+
prev_overflows = m_common_rtc_overflows;
170+
171+
ticks = nrf_rtc_counter_get(COMMON_RTC_INSTANCE);
172+
// The counter used for time measurements is less than 32 bit wide,
173+
// so its value is complemented with the number of registered overflows
174+
// of the counter.
175+
ticks += (m_common_rtc_overflows << RTC_COUNTER_BITS);
176+
177+
// Check in case that OVF occurred during execution of a RTC handler (apply if call was from RTC handler)
178+
// m_common_rtc_overflows might been updated in this call.
179+
rtc_ovf_event_safe_check();
180+
181+
// If call was made from a low priority level m_common_rtc_overflows might have been updated in RTC handler.
182+
} while (m_common_rtc_overflows != prev_overflows);
183+
152184
return ticks;
153185
}
154186

@@ -185,6 +217,8 @@ void common_rtc_set_interrupt(uint32_t us_timestamp, uint32_t cc_channel,
185217
uint32_t compare_value =
186218
(uint32_t)CEIL_DIV((timestamp64) * RTC_INPUT_FREQ, 1000000);
187219

220+
221+
core_util_critical_section_enter();
188222
// The COMPARE event occurs when the value in compare register is N and
189223
// the counter value changes from N-1 to N. Therefore, the minimal safe
190224
// difference between the compare value to be set and the current counter
@@ -197,6 +231,8 @@ void common_rtc_set_interrupt(uint32_t us_timestamp, uint32_t cc_channel,
197231

198232
nrf_rtc_cc_set(COMMON_RTC_INSTANCE, cc_channel, RTC_WRAP(compare_value));
199233
nrf_rtc_event_enable(COMMON_RTC_INSTANCE, int_mask);
234+
235+
core_util_critical_section_exit();
200236
}
201237
//------------------------------------------------------------------------------
202238

0 commit comments

Comments
 (0)