Skip to content

Commit bf6e647

Browse files
committed
Adapt to be used as Mbed library
1 parent d446005 commit bf6e647

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

cores/arduino/Arduino.h

+14-5
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,28 @@
2020
#ifndef Arduino_h
2121
#define Arduino_h
2222

23-
// TEMP: include proper CMSIS
24-
inline void NVIC_SystemReset() {}
25-
26-
#ifdef __cplusplus
23+
#if defined(__cplusplus)
24+
#if !defined(ARDUINO_AS_MBED_LIBRARY)
2725
#define PinMode MbedPinMode
26+
#endif
2827
#include "mbed.h"
2928
#undef PinMode
3029
#endif
3130

31+
#if defined(ARDUINO_AS_MBED_LIBRARY)
32+
#define PinMode ArduinoPinMode
33+
#endif
34+
3235
#include "api/ArduinoAPI.h"
3336

34-
#ifdef __cplusplus
37+
#if defined(ARDUINO_AS_MBED_LIBRARY)
38+
#undef PinMode
39+
#endif
40+
41+
#if defined(__cplusplus)
42+
#if !defined(ARDUINO_AS_MBED_LIBRARY)
3543
using namespace arduino;
44+
#endif
3645
extern "C"{
3746
#endif
3847

cores/arduino/Serial.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
#include "api/HardwareSerial.h"
21
#include "api/RingBuffer.h"
3-
#include "mbed/drivers/Serial.h"
4-
#include "mbed/rtos/Thread.h"
5-
#include "mbed/events/EventQueue.h"
2+
#include "Arduino.h"
63

74
#ifdef __cplusplus
85

@@ -35,7 +32,7 @@ class UART : public HardwareSerial {
3532
};
3633
}
3734

38-
extern UART UART1;
35+
extern arduino::UART UART1;
3936

4037
#endif
4138
#endif

cores/arduino/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ int main(void)
3939

4040
for (;;) {
4141
loop();
42-
if (serialEventRun) serialEventRun();
42+
if (arduino::serialEventRun) arduino::serialEventRun();
4343
}
4444

4545
return 0;

0 commit comments

Comments
 (0)