Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/arduino compatibility regression #1283

Merged
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e9507e8
re-instate 0.6.0 arduino constants. moves the new 0.6.1 arduino defi…
m-mcgowan Mar 27, 2017
8ed1df0
remove `PARTICLE_NO_ARDUINO_COMPATIBILITY`. The alternative is to in…
m-mcgowan Mar 27, 2017
c67b3d3
makes pgmspace defines conditional to avoid duplicate definitions
m-mcgowan Mar 27, 2017
40264bc
adds demarkation for functions already defined by particle as templat…
m-mcgowan Mar 27, 2017
c57c10c
removes documentation for arduino compatibility switch
m-mcgowan Mar 27, 2017
52b4f34
PARTICLE_ARDUINO_COMPATIBILTY -> PARTICLE_WIRING_ARDUINO_COMPATIBILTY
m-mcgowan Mar 28, 2017
fa3e755
when the full arduino API is used, the few progmem related symbols fr…
m-mcgowan Mar 28, 2017
b860e10
ensures that SPISettings (a new Arduino API) is only available when A…
m-mcgowan Mar 29, 2017
5f1bfcd
remove “active_object.h” from application headers since this stops th…
m-mcgowan Mar 31, 2017
47289ed
ensure the ISR queue is available to non-threading platforms too
m-mcgowan Mar 31, 2017
6331ec6
rename SPISettings because it’s ambiguous.
m-mcgowan Apr 1, 2017
48a841e
fix IDE rename typo
m-mcgowan Apr 3, 2017
1292314
makes the arduino compatibility symbols always defined. Adds a test f…
m-mcgowan Apr 3, 2017
fe2fb7b
update CHANGELOG.md (v0.6.2-rc.1) [ci skip]
technobly Apr 4, 2017
d0ab86f
missing change - sourcetree doesn’t always fully refresh the workspac…
m-mcgowan Apr 4, 2017
35d1f41
allow Arduino.h to be included after Particle.h. ensure min/max/cons…
m-mcgowan Apr 4, 2017
ad5a10c
adds support for `__FlashStringHelper` in the String class.
m-mcgowan Apr 4, 2017
5830bf5
adds `Wire.setClock()` for arduino compatibility
m-mcgowan Apr 4, 2017
040b516
adds a stub for `SPI.usingInterrupt()` for arduino compatibility
m-mcgowan Apr 4, 2017
4643b43
bool `Serial` test
m-mcgowan Apr 4, 2017
c3fe44e
adds tests for other public arduino APIs
m-mcgowan Apr 5, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions docs/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -470,16 +470,6 @@ USE_SWD=y
and perform a clean build. For more details on SWD-only debugging
see https://github.com/spark/firmware/pull/337


## Compilation without Arduino Compatibility Support

Arduino compatibility defines are included by default to support hundreds of libraries that have been ported from Arduino to Particle. If those defines should cause an issue with your build, you may remove them by adding

PARTICLE_NO_ARDUINO_COMPATIBILITY=y to the make command line. This requires a clean build.

There should be no difference in FLASH or RAM allocation with or without these defines.


## Compilation without Cloud Support

[Core only]
Expand Down
8 changes: 0 additions & 8 deletions platform/import.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ ifeq ("$(USE_SWD)","y")
CFLAGS += -DUSE_SWD
endif

ifeq ("$(PARTICLE_NO_ARDUINO_COMPATIBILITY)","y")
PARTICLE_NO_ARDUINO_COMPATIBILITY_VALUE=1
else
PARTICLE_NO_ARDUINO_COMPATIBILITY_VALUE=0
endif

CFLAGS += -DPARTICLE_NO_ARDUINO_COMPATIBILITY=${PARTICLE_NO_ARDUINO_COMPATIBILITY_VALUE}

# pull in the includes/sources corresponding to the target platform

INCLUDE_DIRS += $(PLATFORM_MODULE_PATH)/shared/inc
Expand Down
3 changes: 0 additions & 3 deletions system/inc/system_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
#include "socket_hal.h"
#include "system_cloud.h"
#include "wlan_hal.h"
#include "active_object.h"

extern ISRTaskQueue SystemISRTaskQueue;

#ifdef __cplusplus
extern "C" {
Expand Down
5 changes: 4 additions & 1 deletion system/inc/system_threading.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
#ifndef SYSTEM_THREADING_H
#define SYSTEM_THREADING_H

#include "active_object.h"
extern ISRTaskQueue SystemISRTaskQueue;

#if PLATFORM_THREADING

#include "concurrent_hal.h"
#include "active_object.h"
#include <stddef.h>
#include <functional>
#include <mutex>
Expand All @@ -32,6 +34,7 @@
#error "GTHREAD header not included. This is required for correct mutex implementation on embedded platforms."
#endif


/**
* System thread runs on a separate thread
*/
Expand Down
275 changes: 275 additions & 0 deletions user/inc/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,282 @@
#ifndef ARDUINO_H
#define ARDUINO_H

#ifndef PARTICLE_WIRING_ARDUINO_COMPATIBILTY
#define PARTICLE_WIRING_ARDUINO_COMPATIBILTY 1
#endif

#include "Particle.h"

#if PARTICLE_WIRING_ARDUINO_COMPATIBILTY == 1

#ifndef ARDUINO
#define ARDUINO 10800
#endif

#ifndef __cplusplus
#include <math.h>
#else
#include <cmath>
#endif // __cplusplus

#if PARTICLE_WIRING_ARDUINO_TEMPLATES
#ifdef min
#undef min
#endif

#ifdef max
#undef max
#endif
#endif // #ifdef PARTICLE_WIRING_ARDUINO_TEMPLATES

#include "avr/pgmspace.h"
#include "spark_wiring_arduino_constants.h"
#include "spark_wiring_arduino_binary.h"

#undef F
#define F(X) (reinterpret_cast<const __FlashStringHelper*>(X))

#ifndef makeWord
inline uint16_t makeWord(uint16_t w) {
return w;
}

inline uint16_t makeWord(uint8_t h, uint8_t l) {
return ((uint16_t)h << 8) | ((uint16_t)l);
}
#endif

#ifndef word
#define word(...) makeWord(__VA_ARGS__)
#endif

#ifndef WEAK
#define WEAK __attribute__ ((weak))
#endif

#ifndef SYSTEM_CORE_CLOCK
#define SYSTEM_CORE_CLOCK SystemCoreClock
#endif

#ifndef clockCyclesPerMicrosecond
#define clockCyclesPerMicrosecond() (SystemCoreClock / 1000000L)
#endif

#ifndef clockCyclesToMicroseconds
#define clockCyclesToMicroseconds(a) (((a) * 1000L) / (SystemCoreClock / 1000L))
#endif

#ifndef microsecondsToClockCycles
#define microsecondsToClockCycles(a) ((a) * (SystemCoreClock / 1000000L))
#endif

#ifndef digitalPinToInterrupt
#define digitalPinToInterrupt(P) (P)
#endif

inline void yield() {
#if PLATFORM_THREADING
os_thread_yield();
#endif // PLATFORM_THREADING
}

#ifndef PINS_COUNT
#define PINS_COUNT TOTAL_PINS
#endif

#ifndef NUM_DIGITAL_PINS
#define NUM_DIGITAL_PINS TOTAL_PINS
#endif

#ifndef NUM_ANALOG_INPUTS
#define NUM_ANALOG_INPUTS TOTAL_ANALOG_PINS
#endif

#ifndef NUM_ANALOG_OUTPUTS
#define NUM_ANALOG_OUTPUTS TOTAL_DAC_PINS
#endif

#ifndef analogInputToDigitalPin
#define analogInputToDigitalPin(p) (((p < TOTAL_ANALOG_PINS) && (p >= 0)) ? (p) + FIRST_ANALOG_PIN : -1)
#endif

// XXX
#if PLATFORM_ID == PLATFORM_SPARK_CORE || PLATFORM_ID == PLATFORM_PHOTON_PRODUCTION || PLATFORM_ID == PLATFORM_P1 || PLATFORM_ID == PLATFORM_ELECTRON_PRODUCTION

# ifndef digitalPinToPort
# define digitalPinToPort(P) ( HAL_Pin_Map()[P].gpio_peripheral )
# endif

# ifndef digitalPinToBitMask
# define digitalPinToBitMask(P) ( HAL_Pin_Map()[P].gpio_pin )
# endif
//#define analogInPinToBit(P) ( )
# ifndef portOutputRegister
# define portOutputRegister(port) ( &(port->ODR) )
# endif

# ifndef portInputRegister
# define portInputRegister(port) ( &(port->IDR) )
# endif

//#define portModeRegister(port) ( &(port->CRL) )
# ifndef digitalPinHasPWM
# define digitalPinHasPWM(P) ( HAL_Validate_Pin_Function(P, PF_TIMER) == PF_TIMER )
# endif

#endif // PLATFORM_ID == PLATFORM_SPARK_CORE || PLATFORM_ID == PLATFORM_PHOTON_PRODUCTION || PLATFORM_ID == PLATFORM_P1 || PLATFORM_ID == PLATFORM_ELECTRON_PRODUCTION

#ifndef _BV
#define _BV(x) (((uint32_t)1) << (x))
#endif

// XXX
#ifndef sei
#define sei() HAL_enable_irq(0)
#endif

// XXX
#ifndef cli
#define cli() (void)HAL_disable_irq()
#endif

#ifndef cbi
#define cbi(sfr, bit) ((sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) ((sfr) |= _BV(bit))
#endif

// XXX
#ifndef RwReg
typedef volatile uint32_t RwReg;
#endif

// Pins

// LED
#if PLATFORM_ID == PLATFORM_SPARK_CORE || PLATFORM_ID == PLATFORM_PHOTON_PRODUCTION || PLATFORM_ID == PLATFORM_P1 || PLATFORM_ID == PLATFORM_ELECTRON_PRODUCTION
# ifndef LED_BUILTIN
# define LED_BUILTIN D7
# endif

# ifndef ATN
# define ATN SS
# endif

#endif // PLATFORM_ID == PLATFORM_SPARK_CORE || PLATFORM_ID == PLATFORM_PHOTON_PRODUCTION || PLATFORM_ID == PLATFORM_P1 || PLATFORM_ID == PLATFORM_ELECTRON_PRODUCTION

// C++ only
#ifdef __cplusplus

#ifndef isnan
#define isnan std::isnan
#endif

#ifndef isinf
#define isinf std::isinf
#endif


// Hardware serial defines

#ifndef UBRRH
#define UBRRH
#endif

#ifndef UBRR1H
#define UBRR1H
#endif

#if Wiring_Serial2
#ifndef UBRR2H
#define UBRR2H
#endif
#endif

#if Wiring_Serial3
#ifndef UBRR3H
#define UBRR3H
#endif
#endif

#if Wiring_Serial4
#ifndef UBRR4H
#define UBRR4H
#endif
#endif
#if Wiring_Serial5
#ifndef UBRR5H
#define UBRR5H
#endif
#endif

typedef USARTSerial HardwareSerial;

#ifndef SERIAL_PORT_MONITOR
#define SERIAL_PORT_MONITOR Serial
#endif

#ifndef SERIAL_PORT_USBVIRTUAL
#define SERIAL_PORT_USBVIRTUAL Serial
#endif

#ifndef SERIAL_PORT_HARDWARE_OPEN
#define SERIAL_PORT_HARDWARE_OPEN Serial1
#endif

#ifndef SERIAL_PORT_HARDWARE_OPEN1
#define SERIAL_PORT_HARDWARE_OPEN1 Serial1
#endif

#if !defined(SERIAL_PORT_HARDWARE_OPEN2) && Wiring_Serial2
#define SERIAL_PORT_HARDWARE_OPEN2 Serial2
#endif

#if !defined(SERIAL_PORT_HARDWARE_OPEN3) && Wiring_Serial3
#define SERIAL_PORT_HARDWARE_OPEN3 Serial3
#endif

#if !defined(SERIAL_PORT_HARDWARE_OPEN4) && Wiring_Serial4
#define SERIAL_PORT_HARDWARE_OPEN4 Serial4
#endif

#if !defined(SERIAL_PORT_HARDWARE_OPEN5) && Wiring_Serial5
#define SERIAL_PORT_HARDWARE_OPEN5 Serial5
#endif

#ifndef SERIAL_PORT_HARDWARE
#define SERIAL_PORT_HARDWARE Serial1
#endif

#ifndef SERIAL_PORT_HARDWARE1
#define SERIAL_PORT_HARDWARE1 Serial1
#endif

#if !defined(SERIAL_PORT_HARDWARE2) && Wiring_Serial2
#define SERIAL_PORT_HARDWARE2 Serial2
#endif

#if !defined(SERIAL_PORT_HARDWARE3) && Wiring_Serial3
#define SERIAL_PORT_HARDWARE3 Serial3
#endif

#if !defined(SERIAL_PORT_HARDWARE4) && Wiring_Serial4
#define SERIAL_PORT_HARDWARE4 Serial4
#endif

#if !defined(SERIAL_PORT_HARDWARE5) && Wiring_Serial5
#define SERIAL_PORT_HARDWARE5 Serial5
#endif

#ifndef SerialUSB
#define SerialUSB Serial
#endif

#endif // __cplusplus

#endif // PARTICLE_WIRING_ARDUINO_COMPATIBILTY


#endif /* ARDUINO_H */

7 changes: 0 additions & 7 deletions user/inc/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,6 @@
using namespace spark;
using namespace particle;

#ifndef PARTICLE_NO_ARDUINO_COMPATIBILITY
#define PARTICLE_NO_ARDUINO_COMPATIBILITY 0
#endif
#if !PARTICLE_NO_ARDUINO_COMPATIBILITY
#undef PARTICLE_ARDUINO_COMPATIBILITY
#define PARTICLE_ARDUINO_COMPATIBILITY 1
#endif
#include "spark_wiring_arduino.h"

#endif /* APPLICATION_H_ */
9 changes: 9 additions & 0 deletions user/tests/wiring/api/arduino.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "Arduino.h"

#include "testapi.h"

// SPISettings part of the API
void somefunc(SPISettings& s) {

}

5 changes: 4 additions & 1 deletion user/tests/wiring/api/spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ test(spi_transfer)
API_COMPILE(SPI.transfer(0));
API_COMPILE(SPI.transfer(NULL, NULL, 1, NULL));
API_COMPILE(SPI.transferCancel());
}
}

// without Arduino.h we should not get a clash redefining SPISettings
class SPISettings {};
Loading