Skip to content

Commit

Permalink
Merge pull request #4209 from ARMmbed/release-candidate
Browse files Browse the repository at this point in the history
Release candidate for mbed-os-5.4.4
  • Loading branch information
0xc0170 committed Apr 27, 2017
2 parents 42be5c0 + 9ce6141 commit ed4febe
Show file tree
Hide file tree
Showing 96 changed files with 1,480 additions and 418 deletions.
6 changes: 3 additions & 3 deletions drivers/CAN.cpp
Expand Up @@ -27,7 +27,7 @@ CAN::CAN(PinName rd, PinName td) : _can(), _irq() {
// No lock needed in constructor

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

can_init(&_can, rd, td);
Expand Down Expand Up @@ -104,10 +104,10 @@ int CAN::filter(unsigned int id, unsigned int mask, CANFormat format, int handle
void CAN::attach(Callback<void()> func, IrqType type) {
lock();
if (func) {
_irq[(CanIrqType)type].attach(func);
_irq[(CanIrqType)type] = func;
can_irq_set(&_can, (CanIrqType)type, 1);
} else {
_irq[(CanIrqType)type].attach(donothing);
_irq[(CanIrqType)type] = callback(donothing);
can_irq_set(&_can, (CanIrqType)type, 0);
}
unlock();
Expand Down
9 changes: 4 additions & 5 deletions events/equeue/equeue_mbed.cpp
Expand Up @@ -42,13 +42,12 @@ static void equeue_tick_init() {
"The equeue_timer buffer must fit the class Timer");
MBED_STATIC_ASSERT(sizeof(equeue_ticker) >= sizeof(Ticker),
"The equeue_ticker buffer must fit the class Ticker");
new (equeue_timer) Timer;
new (equeue_ticker) Ticker;
Timer *timer = new (equeue_timer) Timer;
Ticker *ticker = new (equeue_ticker) Ticker;

equeue_minutes = 0;
reinterpret_cast<Timer*>(equeue_timer)->start();
reinterpret_cast<Ticker*>(equeue_ticker)
->attach_us(equeue_tick_update, 1000 << 16);
timer->start();
ticker->attach_us(equeue_tick_update, 1000 << 16);

equeue_tick_inited = true;
}
Expand Down
4 changes: 2 additions & 2 deletions mbed.h
Expand Up @@ -16,13 +16,13 @@
#ifndef MBED_H
#define MBED_H

#define MBED_LIBRARY_VERSION 140
#define MBED_LIBRARY_VERSION 141

#if MBED_CONF_RTOS_PRESENT
// RTOS present, this is valid only for mbed OS 5
#define MBED_MAJOR_VERSION 5
#define MBED_MINOR_VERSION 4
#define MBED_PATCH_VERSION 3
#define MBED_PATCH_VERSION 4

#else
// mbed 2
Expand Down
15 changes: 6 additions & 9 deletions platform/mbed_board.c
Expand Up @@ -75,28 +75,25 @@ void mbed_error_printf(const char* format, ...) {

void mbed_error_vfprintf(const char * format, va_list arg) {
#if DEVICE_SERIAL

#if MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES
char stdio_out_prev;
#endif

#define ERROR_BUF_SIZE (128)
core_util_critical_section_enter();
char buffer[128];
int size = vsprintf(buffer, format, arg);
char buffer[ERROR_BUF_SIZE];
int size = vsnprintf(buffer, ERROR_BUF_SIZE, format, arg);
if (size > 0) {
if (!stdio_uart_inited) {
serial_init(&stdio_uart, STDIO_UART_TX, STDIO_UART_RX);
}
#if MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES
for (unsigned int i = 0; i < size; i++) {
char stdio_out_prev = '\0';
for (int i = 0; i < size; i++) {
if (buffer[i] == '\n' && stdio_out_prev != '\r') {
serial_putc(&stdio_uart, '\r');
}
serial_putc(&stdio_uart, buffer[i]);
stdio_out_prev = buffer[i];
}
#else
for (unsigned int i = 0; i < size; i++) {
for (int i = 0; i < size; i++) {
serial_putc(&stdio_uart, buffer[i]);
}
#endif
Expand Down
2 changes: 2 additions & 0 deletions platform/mbed_retarget.cpp
Expand Up @@ -120,6 +120,7 @@ static void init_serial() {
#endif
}

#if MBED_CONF_FILESYSTEM_PRESENT
static inline int openmode_to_posix(int openmode) {
int posix = openmode;
#ifdef __ARMCC_VERSION
Expand Down Expand Up @@ -154,6 +155,7 @@ static inline int openmode_to_posix(int openmode) {
#endif
return posix;
}
#endif

extern "C" WEAK void mbed_sdk_init(void);
extern "C" WEAK void mbed_sdk_init(void) {
Expand Down
Expand Up @@ -47,10 +47,6 @@
*/
#define __ram_vector_table__ 1

/* Heap 1/4 of ram and stack 1/8 */
#define __stack_size__ 0x8000
#define __heap_size__ 0x10000

#if (defined(__ram_vector_table__))
#define __ram_vector_table_size__ 0x00000400
#else
Expand Down
Expand Up @@ -49,10 +49,6 @@
*/

#define __ram_vector_table__ 1

/* Heap 1/4 of ram and stack 1/8 */
#define __stack_size__ 0x8000
#define __heap_size__ 0x10000

#if (defined(__ram_vector_table__))
#define __ram_vector_table_size__ 0x000003C0
Expand Down
Expand Up @@ -50,10 +50,6 @@
*/
#define __ram_vector_table__ 1

/* Heap 1/4 of ram and stack 1/8 */
#define __stack_size__ 0x800
#define __heap_size__ 0x1000

#if (defined(__ram_vector_table__))
#define __ram_vector_table_size__ 0x00000200
#else
Expand Down
Expand Up @@ -47,10 +47,6 @@
*/
#define __ram_vector_table__ 1

/* Heap 1/4 of ram and stack 1/8 */
#define __stack_size__ 0x1000
#define __heap_size__ 0x2800

#if (defined(__ram_vector_table__))
#define __ram_vector_table_size__ 0x00000200
#else
Expand Down
Expand Up @@ -50,10 +50,6 @@
*/
#define __ram_vector_table__ 1

/* Heap 1/4 of ram and stack 1/8 */
#define __stack_size__ 0x3000
#define __heap_size__ 0x6000

#if (defined(__ram_vector_table__))
#define __ram_vector_table_size__ 0x00000140
#else
Expand Down
Expand Up @@ -45,10 +45,6 @@
*/
#define __ram_vector_table__ 1

/* Heap 1/4 of ram and stack 1/8 */
#define __stack_size__ 0x2000
#define __heap_size__ 0x4000

#if (defined(__ram_vector_table__))
#define __ram_vector_table_size__ 0x00000400
#else
Expand Down
Expand Up @@ -45,10 +45,6 @@
*/
#define __ram_vector_table__ 1

/* Heap 1/4 of ram and stack 1/8 */
#define __stack_size__ 0x4000
#define __heap_size__ 0x8000

#if (defined(__ram_vector_table__))
#define __ram_vector_table_size__ 0x00000200
#else
Expand Down
Expand Up @@ -51,10 +51,6 @@
*/
#define __ram_vector_table__ 1

/* Heap 1/4 of ram and stack 1/8 */
#define __stack_size__ 0x4000
#define __heap_size__ 0x8000

#if (defined(__ram_vector_table__))
#define __ram_vector_table_size__ 0x00000400
#else
Expand Down
Expand Up @@ -50,10 +50,6 @@
*/
#define __ram_vector_table__ 1

/* Heap 1/4 of ram and stack 1/8 */
#define __stack_size__ 0x8000
#define __heap_size__ 0x10000

#if (defined(__ram_vector_table__))
#define __ram_vector_table_size__ 0x00000400
#else
Expand Down
6 changes: 3 additions & 3 deletions targets/TARGET_Maxim/TARGET_MAX32630/sleep.c
Expand Up @@ -34,13 +34,13 @@
#include "sleep_api.h"
#include "lp.h"

void sleep(void)
void hal_sleep(void)
{
LP_EnterLP2();
}

// Low-power stop mode
void deepsleep(void)
void hal_deepsleep(void)
{
sleep();
hal_sleep();
}
58 changes: 47 additions & 11 deletions targets/TARGET_NORDIC/TARGET_NRF5/us_ticker.c
Expand Up @@ -42,6 +42,7 @@
#include "nrf_drv_common.h"
#include "nrf_drv_config.h"
#include "lp_ticker_api.h"
#include "mbed_critical.h"


//------------------------------------------------------------------------------
Expand All @@ -52,12 +53,25 @@
bool m_common_rtc_enabled = false;
uint32_t volatile m_common_rtc_overflows = 0;

__STATIC_INLINE void rtc_ovf_event_check(void)
{
if (nrf_rtc_event_pending(COMMON_RTC_INSTANCE, NRF_RTC_EVENT_OVERFLOW)) {
nrf_rtc_event_clear(COMMON_RTC_INSTANCE, NRF_RTC_EVENT_OVERFLOW);
// Don't disable this event. It shall occur periodically.

++m_common_rtc_overflows;
}
}

#if defined(TARGET_MCU_NRF51822)
void common_rtc_irq_handler(void)
#else
void COMMON_RTC_IRQ_HANDLER(void)
#endif
{

rtc_ovf_event_check();

if (nrf_rtc_event_pending(COMMON_RTC_INSTANCE, US_TICKER_EVENT)) {
us_ticker_irq_handler();
}
Expand All @@ -69,12 +83,6 @@ void COMMON_RTC_IRQ_HANDLER(void)
}
#endif

if (nrf_rtc_event_pending(COMMON_RTC_INSTANCE, NRF_RTC_EVENT_OVERFLOW)) {
nrf_rtc_event_clear(COMMON_RTC_INSTANCE, NRF_RTC_EVENT_OVERFLOW);
// Don't disable this event. It shall occur periodically.

++m_common_rtc_overflows;
}
}

#if (defined (__ICCARM__)) && defined(TARGET_MCU_NRF51822)//IAR
Expand Down Expand Up @@ -142,13 +150,37 @@ void common_rtc_init(void)
m_common_rtc_enabled = true;
}

__STATIC_INLINE void rtc_ovf_event_safe_check(void)
{
core_util_critical_section_enter();

rtc_ovf_event_check();

core_util_critical_section_exit();
}


uint32_t common_rtc_32bit_ticks_get(void)
{
uint32_t ticks = nrf_rtc_counter_get(COMMON_RTC_INSTANCE);
// The counter used for time measurements is less than 32 bit wide,
// so its value is complemented with the number of registered overflows
// of the counter.
ticks += (m_common_rtc_overflows << RTC_COUNTER_BITS);
uint32_t ticks;
uint32_t prev_overflows;

do {
prev_overflows = m_common_rtc_overflows;

ticks = nrf_rtc_counter_get(COMMON_RTC_INSTANCE);
// The counter used for time measurements is less than 32 bit wide,
// so its value is complemented with the number of registered overflows
// of the counter.
ticks += (m_common_rtc_overflows << RTC_COUNTER_BITS);

// Check in case that OVF occurred during execution of a RTC handler (apply if call was from RTC handler)
// m_common_rtc_overflows might been updated in this call.
rtc_ovf_event_safe_check();

// If call was made from a low priority level m_common_rtc_overflows might have been updated in RTC handler.
} while (m_common_rtc_overflows != prev_overflows);

return ticks;
}

Expand Down Expand Up @@ -185,6 +217,8 @@ void common_rtc_set_interrupt(uint32_t us_timestamp, uint32_t cc_channel,
uint32_t compare_value =
(uint32_t)CEIL_DIV((timestamp64) * RTC_INPUT_FREQ, 1000000);


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

nrf_rtc_cc_set(COMMON_RTC_INSTANCE, cc_channel, RTC_WRAP(compare_value));
nrf_rtc_event_enable(COMMON_RTC_INSTANCE, int_mask);

core_util_critical_section_exit();
}
//------------------------------------------------------------------------------

Expand Down

0 comments on commit ed4febe

Please sign in to comment.