Skip to content

Commit 3176fc7

Browse files
authored
mbed-ce@master + fixes + gcc 11 support (ARMmbed#135)
* Fix rtos::Mutex stub, add trylock() method * LowPowerTicker - Add ::attach(...) method + call callback * mbed_power_management - rename sleep --> mbed_sleep to avoid conflicts Fixes conflicts w/ unistd.h and boost::ut * GCC 11/C++ 20 - Remove deprecated type_traits * GCC 11/C++ 20 - Remove redundant templating of methods * Warning - pragma ignore invalid-noreturn for unit tests * Fix astyle errors * Fix missing mbed_sleep() calls
1 parent eda766e commit 3176fc7

File tree

12 files changed

+33
-25
lines changed

12 files changed

+33
-25
lines changed

cmsis/device/rtos/source/mbed_rtx_idle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ extern "C" {
148148
// critical section to complete sleep with locked deepsleep
149149
core_util_critical_section_enter();
150150
sleep_manager_lock_deep_sleep();
151-
sleep();
151+
mbed_sleep();
152152
sleep_manager_unlock_deep_sleep();
153153
core_util_critical_section_exit();
154154
}

connectivity/FEATURE_BLE/include/ble/gatt/GattCharacteristic.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,7 +1915,7 @@ class ReadOnlyGattCharacteristic : public GattCharacteristic {
19151915
* attribute value that equals sizeof(T). For a variable length alternative,
19161916
* use GattCharacteristic directly.
19171917
*/
1918-
ReadOnlyGattCharacteristic<T>(
1918+
ReadOnlyGattCharacteristic(
19191919
const UUID &uuid,
19201920
T *valuePtr,
19211921
uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
@@ -1958,7 +1958,7 @@ class WriteOnlyGattCharacteristic : public GattCharacteristic {
19581958
* attribute value with maximum size equal to sizeof(T). For a fixed length
19591959
* alternative, use GattCharacteristic directly.
19601960
*/
1961-
WriteOnlyGattCharacteristic<T>(
1961+
WriteOnlyGattCharacteristic(
19621962
const UUID &uuid,
19631963
T *valuePtr,
19641964
uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
@@ -2000,7 +2000,7 @@ class ReadWriteGattCharacteristic : public GattCharacteristic {
20002000
* attribute value with maximum size equal to sizeof(T). For a fixed length
20012001
* alternative, use GattCharacteristic directly.
20022002
*/
2003-
ReadWriteGattCharacteristic<T>(
2003+
ReadWriteGattCharacteristic(
20042004
const UUID &uuid,
20052005
T *valuePtr,
20062006
uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
@@ -2043,7 +2043,7 @@ class WriteOnlyArrayGattCharacteristic : public GattCharacteristic {
20432043
* attribute value with maximum size equal to sizeof(T) * NUM_ELEMENTS.
20442044
* For a fixed length alternative, use GattCharacteristic directly.
20452045
*/
2046-
WriteOnlyArrayGattCharacteristic<T, NUM_ELEMENTS>(
2046+
WriteOnlyArrayGattCharacteristic(
20472047
const UUID &uuid,
20482048
T valuePtr[NUM_ELEMENTS],
20492049
uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
@@ -2087,7 +2087,7 @@ class ReadOnlyArrayGattCharacteristic : public GattCharacteristic {
20872087
* attribute value that equals sizeof(T) * NUM_ELEMENTS. For a variable
20882088
* length alternative, use GattCharacteristic directly.
20892089
*/
2090-
ReadOnlyArrayGattCharacteristic<T, NUM_ELEMENTS>(
2090+
ReadOnlyArrayGattCharacteristic(
20912091
const UUID &uuid,
20922092
T valuePtr[NUM_ELEMENTS],
20932093
uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
@@ -2132,7 +2132,7 @@ class ReadWriteArrayGattCharacteristic : public GattCharacteristic {
21322132
* attribute value with maximum size equal to sizeof(T) * NUM_ELEMENTS.
21332133
* For a fixed length alternative, use GattCharacteristic directly.
21342134
*/
2135-
ReadWriteArrayGattCharacteristic<T, NUM_ELEMENTS>(
2135+
ReadWriteArrayGattCharacteristic(
21362136
const UUID &uuid,
21372137
T valuePtr[NUM_ELEMENTS],
21382138
uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,

drivers/tests/UNITTESTS/doubles/drivers/LowPowerTicker.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#ifndef MBED_LOWPOWERTICKER_H
1818
#define MBED_LOWPOWERTICKER_H
1919

20+
#include <chrono>
21+
2022
#include "hal/ticker_api.h"
2123
#include "Callback.h"
2224

@@ -28,21 +30,23 @@ namespace mbed {
2830
class LowPowerTicker {
2931

3032
public:
31-
LowPowerTicker()
32-
{
33-
}
33+
LowPowerTicker() = default;
34+
35+
virtual ~LowPowerTicker() = default;
3436

35-
virtual ~LowPowerTicker()
37+
void attach(Callback<void()> func, std::chrono::microseconds t)
3638
{
39+
func();
3740
}
3841

3942
void attach_us(Callback<void()> func, us_timestamp_t t)
4043
{
41-
44+
func();
4245
}
46+
4347
void detach()
4448
{
45-
49+
// nothing to do
4650
}
4751
};
4852

events/source/equeue_mbed.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ bool equeue_sema_wait(equeue_sema_t *s, int ms)
218218

219219
core_util_critical_section_enter();
220220
while (!*s && ms != 0) {
221-
sleep();
221+
mbed_sleep();
222222
core_util_critical_section_exit();
223223
__ISB();
224224
core_util_critical_section_enter();

hal/tests/TESTS/mbed_hal/lp_ticker/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void lp_ticker_deepsleep_test()
142142
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep_test_check());
143143

144144
while (!intFlag) {
145-
sleep();
145+
mbed_sleep();
146146
}
147147

148148
TEST_ASSERT_EQUAL(1, intFlag);

hal/tests/TESTS/mbed_hal/rtc/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void rtc_sleep_test_support(bool deepsleep_mode)
8080
TEST_ASSERT(sleep_manager_can_deep_sleep_test_check() == deepsleep_mode);
8181

8282
while (!expired) {
83-
sleep();
83+
mbed_sleep();
8484
}
8585

8686
const auto stop = RealTimeClock::now();

hal/tests/TESTS/mbed_hal/sleep/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void sleep_usticker_test()
7979

8080
us_ticker_set_interrupt(next_match_timestamp);
8181

82-
sleep();
82+
mbed_sleep();
8383

8484
const unsigned int wakeup_timestamp = us_ticker_read();
8585

@@ -130,7 +130,7 @@ void deepsleep_lpticker_test()
130130
Since this interrupt wakes-up the board from the sleep we need to go to sleep after CMPOK is handled. */
131131
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep_test_check());
132132

133-
sleep();
133+
mbed_sleep();
134134

135135
/* On some targets like STM family boards with LPTIM enabled an interrupt is triggered on counter rollover.
136136
We need special handling for cases when next_match_timestamp < start_timestamp (interrupt is to be fired after rollover).
@@ -140,7 +140,7 @@ void deepsleep_lpticker_test()
140140
if ((next_match_timestamp < start_timestamp) && lp_ticker_read() < next_match_timestamp) {
141141
lp_ticker_set_interrupt(next_match_timestamp);
142142
wait_ns(200000);
143-
sleep();
143+
mbed_sleep();
144144
}
145145
#endif
146146

@@ -182,7 +182,7 @@ void deepsleep_high_speed_clocks_turned_off_test()
182182

183183
const unsigned int us_ticks_before_sleep = us_ticker_read();
184184

185-
sleep();
185+
mbed_sleep();
186186

187187
const unsigned int us_ticks_after_sleep = us_ticker_read();
188188
const unsigned int lp_ticks_after_sleep = lp_ticker_read();

platform/cxxsupport/mstd_type_traits

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ using std::is_trivial;
210210
using std::is_trivially_copyable;
211211
using std::is_standard_layout;
212212
using std::is_pod;
213-
using std::is_literal_type;
214213
using std::is_empty;
215214
using std::is_polymorphic;
216215
using std::is_abstract;
@@ -274,8 +273,6 @@ using std::decay;
274273
using std::decay_t;
275274
using std::common_type;
276275
using std::common_type_t;
277-
using std::result_of;
278-
using std::result_of_t;
279276

280277
/* C++20 remove_cvref */
281278
template <typename T>

platform/include/platform/mbed_power_mgmt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ void sleep_manager_sleep_auto(void);
192192
* Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
193193
* able to access the LocalFileSystem
194194
*/
195-
static inline void sleep(void)
195+
static inline void mbed_sleep(void)
196196
{
197197
#if DEVICE_SLEEP
198198
#if (MBED_CONF_RTOS_PRESENT == 0) || (DEVICE_SYSTICK_CLK_OFF_DURING_SLEEP == 0) || defined(MBED_TICKLESS)

platform/source/mbed_os_timer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ void do_sleep_operation(OpT &op)
170170
// we go round to set the timer again.
171171
if (op.sleep_prepared()) {
172172
// Enter HAL sleep (normal or deep)
173-
sleep();
173+
mbed_sleep();
174174
}
175175
}
176176

platform/tests/UNITTESTS/doubles/mbed_assert_stub.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <stdio.h>
2121
#include <stdbool.h>
2222

23+
#pragma GCC diagnostic ignored "-Winvalid-noreturn"
24+
2325
bool mbed_assert_throw_errors = false;
2426

2527
extern "C" void mbed_assert_internal(const char *expr, const char *file, int line)

rtos/tests/UNITTESTS/doubles/Mutex_stub.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,8 @@ osStatus rtos::Mutex::unlock()
3636
{
3737
return osOK;
3838
}
39+
40+
bool rtos::Mutex::trylock()
41+
{
42+
return true;
43+
}

0 commit comments

Comments
 (0)