Skip to content

Commit 9c59d9a

Browse files
author
Cruz Monrreal
authored
Merge pull request #7864 from deepikabhavnani/remove_mbed_h
Add required header file and namespace element instead add all.
2 parents 140f3e2 + 1d23843 commit 9c59d9a

File tree

11 files changed

+55
-32
lines changed

11 files changed

+55
-32
lines changed

events/EventQueue.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
* limitations under the License.
1515
*/
1616
#include "events/EventQueue.h"
17-
1817
#include "events/mbed_events.h"
19-
#include "mbed.h"
2018

19+
using mbed::Callback;
20+
21+
namespace events {
2122

2223
EventQueue::EventQueue(unsigned event_size, unsigned char *event_pointer)
2324
{
@@ -77,3 +78,4 @@ void EventQueue::chain(EventQueue *target)
7778
equeue_chain(&_equeue, 0);
7879
}
7980
}
81+
}

events/equeue/equeue_mbed.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@
2121
#if defined(EQUEUE_PLATFORM_MBED)
2222

2323
#include <stdbool.h>
24-
#include "mbed.h"
24+
#include <string.h>
25+
#include "platform/mbed_critical.h"
26+
#include "drivers/Timer.h"
27+
#include "drivers/Ticker.h"
28+
#include "drivers/Timeout.h"
29+
#include "drivers/LowPowerTimeout.h"
30+
#include "drivers/LowPowerTicker.h"
31+
#include "drivers/LowPowerTimer.h"
32+
33+
using namespace mbed;
2534

2635
// Ticker operations
2736
#if MBED_CONF_RTOS_PRESENT
@@ -33,6 +42,7 @@ unsigned equeue_tick() {
3342
#else
3443

3544
#if MBED_CONF_EVENTS_USE_LOWPOWER_TIMER_TICKER
45+
3646
#define ALIAS_TIMER LowPowerTimer
3747
#define ALIAS_TICKER LowPowerTicker
3848
#define ALIAS_TIMEOUT LowPowerTimeout

events/mbed_shared_queues.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
*/
1616

1717
#include "events/mbed_shared_queues.h"
18-
#include "mbed.h"
18+
19+
#ifdef MBED_CONF_RTOS_PRESENT
20+
#include "rtos/Thread.h"
21+
using rtos::Thread;
22+
#endif
1923

2024
using namespace events;
2125

platform/ATCmdParser.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
#include "ATCmdParser.h"
2222
#include "mbed_poll.h"
2323
#include "mbed_debug.h"
24+
#include <stdio.h>
25+
#include <stdlib.h>
26+
#include <string.h>
2427

2528
#ifdef LF
2629
#undef LF
@@ -36,6 +39,8 @@
3639
#define CR 13
3740
#endif
3841

42+
namespace mbed {
43+
3944
// getc/putc handling with timeouts
4045
int ATCmdParser::putc(char c)
4146
{
@@ -102,7 +107,7 @@ int ATCmdParser::read(char *data, int size)
102107

103108

104109
// printf/scanf handling
105-
int ATCmdParser::vprintf(const char *format, va_list args)
110+
int ATCmdParser::vprintf(const char *format, std::va_list args)
106111
{
107112

108113
if (vsprintf(_buffer, format, args) < 0) {
@@ -118,7 +123,7 @@ int ATCmdParser::vprintf(const char *format, va_list args)
118123
return i;
119124
}
120125

121-
int ATCmdParser::vscanf(const char *format, va_list args)
126+
int ATCmdParser::vscanf(const char *format, std::va_list args)
122127
{
123128
// Since format is const, we need to copy it into our buffer to
124129
// add the line's null terminator and clobber value-matches with asterisks.
@@ -181,7 +186,7 @@ int ATCmdParser::vscanf(const char *format, va_list args)
181186

182187

183188
// Command parsing with line handling
184-
bool ATCmdParser::vsend(const char *command, va_list args)
189+
bool ATCmdParser::vsend(const char *command, std::va_list args)
185190
{
186191
// Create and send command
187192
if (vsprintf(_buffer, command, args) < 0) {
@@ -205,7 +210,7 @@ bool ATCmdParser::vsend(const char *command, va_list args)
205210
return true;
206211
}
207212

208-
bool ATCmdParser::vrecv(const char *response, va_list args)
213+
bool ATCmdParser::vrecv(const char *response, std::va_list args)
209214
{
210215
restart:
211216
_aborted = false;
@@ -331,7 +336,7 @@ bool ATCmdParser::vrecv(const char *response, va_list args)
331336
// Mapping to vararg functions
332337
int ATCmdParser::printf(const char *format, ...)
333338
{
334-
va_list args;
339+
std::va_list args;
335340
va_start(args, format);
336341
int res = vprintf(format, args);
337342
va_end(args);
@@ -340,7 +345,7 @@ int ATCmdParser::printf(const char *format, ...)
340345

341346
int ATCmdParser::scanf(const char *format, ...)
342347
{
343-
va_list args;
348+
std::va_list args;
344349
va_start(args, format);
345350
int res = vscanf(format, args);
346351
va_end(args);
@@ -349,7 +354,7 @@ int ATCmdParser::scanf(const char *format, ...)
349354

350355
bool ATCmdParser::send(const char *command, ...)
351356
{
352-
va_list args;
357+
std::va_list args;
353358
va_start(args, command);
354359
bool res = vsend(command, args);
355360
va_end(args);
@@ -358,7 +363,7 @@ bool ATCmdParser::send(const char *command, ...)
358363

359364
bool ATCmdParser::recv(const char *response, ...)
360365
{
361-
va_list args;
366+
std::va_list args;
362367
va_start(args, response);
363368
bool res = vrecv(response, args);
364369
va_end(args);
@@ -431,4 +436,5 @@ bool ATCmdParser::process_oob()
431436
}
432437
}
433438

439+
}
434440

platform/ATCmdParser.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
#ifndef MBED_ATCMDPARSER_H
2121
#define MBED_ATCMDPARSER_H
2222

23-
#include "mbed.h"
2423
#include <cstdarg>
2524
#include "Callback.h"
25+
#include "NonCopyable.h"
26+
#include "FileHandle.h"
2627

2728
namespace mbed {
2829

@@ -202,7 +203,7 @@ class ATCmdParser : private NonCopyable<ATCmdParser> {
202203
*/
203204
bool send(const char *command, ...) MBED_PRINTF_METHOD(1, 2);
204205

205-
bool vsend(const char *command, va_list args);
206+
bool vsend(const char *command, std::va_list args);
206207

207208
/**
208209
* Receive an AT response
@@ -220,7 +221,7 @@ class ATCmdParser : private NonCopyable<ATCmdParser> {
220221
*/
221222
bool recv(const char *response, ...) MBED_SCANF_METHOD(1, 2);
222223

223-
bool vrecv(const char *response, va_list args);
224+
bool vrecv(const char *response, std::va_list args);
224225

225226
/**
226227
* Write a single byte to the underlying stream
@@ -265,7 +266,7 @@ class ATCmdParser : private NonCopyable<ATCmdParser> {
265266
*/
266267
int printf(const char *format, ...) MBED_PRINTF_METHOD(1, 2);
267268

268-
int vprintf(const char *format, va_list args);
269+
int vprintf(const char *format, std::va_list args);
269270

270271
/**
271272
* Direct scanf on underlying stream
@@ -277,7 +278,7 @@ class ATCmdParser : private NonCopyable<ATCmdParser> {
277278
*/
278279
int scanf(const char *format, ...) MBED_SCANF_METHOD(1, 2);
279280

280-
int vscanf(const char *format, va_list args);
281+
int vscanf(const char *format, std::va_list args);
281282

282283
/**
283284
* Attach a callback for out-of-band data

platform/FileSystemHandle.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
#include "mbed.h"
1817
#include "FileSystemHandle.h"
1918
#include <errno.h>
2019

20+
namespace mbed {
2121
int FileSystemHandle::open(DirHandle **dir, const char *path)
2222
{
2323
return -ENOSYS;
@@ -47,3 +47,4 @@ int FileSystemHandle::statvfs(const char *path, struct statvfs *buf)
4747
{
4848
return -ENOSYS;
4949
}
50+
}

platform/mbed_wait_api_rtos.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#include "platform/mbed_wait_api.h"
2222
#include "hal/us_ticker_api.h"
23-
#include "rtos/rtos.h"
23+
#include "rtos/ThisThread.h"
2424
#include "platform/mbed_critical.h"
2525
#include "platform/mbed_power_mgmt.h"
2626

rtos/Kernel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
* SOFTWARE.
2121
*/
2222

23+
#include "cmsis_os2.h"
2324
#include "rtos/Kernel.h"
24-
25-
#include "mbed.h"
2625
#include "rtos/rtos_idle.h"
2726
#include "rtos/rtos_handlers.h"
27+
#include "platform/mbed_critical.h"
2828

2929
namespace rtos {
3030

rtos/RtosTimer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
* SOFTWARE.
2121
*/
2222
#include "rtos/RtosTimer.h"
23+
#include "platform/Callback.h"
24+
#include "platform/mbed_error.h"
25+
#include "platform/mbed_assert.h"
2326

2427
#include <string.h>
2528

26-
#include "mbed.h"
27-
#include "platform/mbed_error.h"
28-
2929
namespace rtos {
3030

3131
void RtosTimer::constructor(mbed::Callback<void()> func, os_timer_type type) {
@@ -34,7 +34,7 @@ void RtosTimer::constructor(mbed::Callback<void()> func, os_timer_type type) {
3434
osTimerAttr_t attr = { 0 };
3535
attr.cb_mem = &_obj_mem;
3636
attr.cb_size = sizeof(_obj_mem);
37-
_id = osTimerNew((void (*)(void *))Callback<void()>::thunk, type, &_function, &attr);
37+
_id = osTimerNew((void (*)(void *))mbed::Callback<void()>::thunk, type, &_function, &attr);
3838
MBED_ASSERT(_id);
3939
}
4040

rtos/ThisThread.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
#define __STDC_LIMIT_MACROS
2424
#include "rtos/ThisThread.h"
2525

26-
#include "mbed.h"
26+
#include "rtos/Kernel.h"
2727
#include "rtos/rtos_idle.h"
28-
#include "mbed_assert.h"
28+
#include "platform/mbed_assert.h"
2929

3030
namespace rtos {
3131

rtos/Thread.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121
*/
2222
#include "rtos/Thread.h"
2323
#include "rtos/ThisThread.h"
24-
25-
#include "mbed.h"
2624
#include "rtos/rtos_idle.h"
2725
#include "rtos/rtos_handlers.h"
28-
#include "mbed_assert.h"
26+
#include "platform/mbed_assert.h"
27+
#include "platform/mbed_error.h"
2928

3029
#define ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos))
3130
MBED_STATIC_ASSERT(ALIGN_UP(0, 8) == 0, "ALIGN_UP macro error");
@@ -68,7 +67,7 @@ void Thread::constructor(osPriority priority,
6867
constructor(MBED_TZ_DEFAULT_ACCESS, priority, stack_size, stack_mem, name);
6968
}
7069

71-
void Thread::constructor(Callback<void()> task,
70+
void Thread::constructor(mbed::Callback<void()> task,
7271
osPriority priority, uint32_t stack_size, unsigned char *stack_mem, const char *name)
7372
{
7473
constructor(MBED_TZ_DEFAULT_ACCESS, priority, stack_size, stack_mem, name);
@@ -87,7 +86,7 @@ void Thread::constructor(Callback<void()> task,
8786
}
8887
}
8988

90-
osStatus Thread::start(Callback<void()> task)
89+
osStatus Thread::start(mbed::Callback<void()> task)
9190
{
9291
_mutex.lock();
9392

0 commit comments

Comments
 (0)