From c6ce36d56cd5e874e60c3ba8a36cc77c307df718 Mon Sep 17 00:00:00 2001 From: Pharap <2933055+Pharap@users.noreply.github.com> Date: Sat, 18 Aug 2018 09:09:15 +0100 Subject: Add placement new operator --- cores/arduino/new.cpp | 4 ++++ cores/arduino/new.h | 1 + 2 files changed, 5 insertions(+) diff --git a/cores/arduino/new.cpp b/cores/arduino/new.cpp index cf6f89c..bfb219d 100644 --- a/cores/arduino/new.cpp +++ b/cores/arduino/new.cpp @@ -26,6 +26,10 @@ void *operator new[](size_t size) { return malloc(size); } +void * operator new(size_t size, void * ptr) { + return ptr; +} + void operator delete(void * ptr) { free(ptr); } diff --git a/cores/arduino/new.h b/cores/arduino/new.h index 6e1b68f..7690911 100644 --- a/cores/arduino/new.h +++ b/cores/arduino/new.h @@ -23,6 +23,7 @@ void * operator new(size_t size); void * operator new[](size_t size); +void * operator new(size_t size, void * ptr); void operator delete(void * ptr); void operator delete[](void * ptr); -- cgit v1.2.3-18-g5258 From b410611ffcdcb822d69c828f01dd6216c1ef3348 Mon Sep 17 00:00:00 2001 From: Pharap <2933055+Pharap@users.noreply.github.com> Date: Sat, 18 Aug 2018 09:27:06 +0100 Subject: Prevent possible compiler warning Casting to void is a well known trick for prevening 'unused parameter' warnings. --- cores/arduino/new.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cores/arduino/new.cpp b/cores/arduino/new.cpp index bfb219d..86a1fa5 100644 --- a/cores/arduino/new.cpp +++ b/cores/arduino/new.cpp @@ -27,6 +27,7 @@ void *operator new[](size_t size) { } void * operator new(size_t size, void * ptr) { + (void)size; return ptr; } -- cgit v1.2.3-18-g5258 From 1db33d24b7ae99e71b9843bc6301f5b932df2aa3 Mon Sep 17 00:00:00 2001 From: PaulStoffregen Date: Fri, 31 Aug 2018 05:06:13 -0700 Subject: Treat narrowing conversion as warning, not error --- platform.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.txt b/platform.txt index f1546a3..0133dcb 100644 --- a/platform.txt +++ b/platform.txt @@ -25,7 +25,7 @@ compiler.c.elf.flags={compiler.warning_flags} -Os -g -flto -fuse-linker-plugin - compiler.c.elf.cmd=avr-gcc compiler.S.flags=-c -g -x assembler-with-cpp -flto -MMD compiler.cpp.cmd=avr-g++ -compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto +compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto compiler.ar.cmd=avr-gcc-ar compiler.ar.flags=rcs compiler.objcopy.cmd=avr-objcopy -- cgit v1.2.3-18-g5258 From 6848ea443cfb118d01ae317c0e676c1629199fdb Mon Sep 17 00:00:00 2001 From: Brian Park Date: Wed, 29 Aug 2018 23:18:10 -0700 Subject: Fix compiler warnings about ignored 'const' in EEPROM.h --- libraries/EEPROM/src/EEPROM.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/EEPROM/src/EEPROM.h b/libraries/EEPROM/src/EEPROM.h index cde75db..c8ec271 100644 --- a/libraries/EEPROM/src/EEPROM.h +++ b/libraries/EEPROM/src/EEPROM.h @@ -40,7 +40,7 @@ struct EERef{ //Access/read members. uint8_t operator*() const { return eeprom_read_byte( (uint8_t*) index ); } - operator const uint8_t() const { return **this; } + operator uint8_t() const { return **this; } //Assignment/write members. EERef &operator=( const EERef &ref ) { return *this = *ref; } @@ -89,7 +89,7 @@ struct EEPtr{ EEPtr( const int index ) : index( index ) {} - operator const int() const { return index; } + operator int() const { return index; } EEPtr &operator=( int in ) { return index = in, *this; } //Iterator functionality. @@ -143,4 +143,4 @@ struct EEPROMClass{ }; static EEPROMClass EEPROM; -#endif \ No newline at end of file +#endif -- cgit v1.2.3-18-g5258 From 2663be17272e19f00c55f3f2d8f1ebfac47158d6 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 10 Sep 2018 11:45:34 +0200 Subject: Release 1.6.23 --- platform.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.txt b/platform.txt index 0133dcb..cb48698 100644 --- a/platform.txt +++ b/platform.txt @@ -6,7 +6,7 @@ # https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification name=Arduino AVR Boards -version=1.6.22 +version=1.6.23 # AVR compile variables # --------------------- -- cgit v1.2.3-18-g5258 From 6a717473175cc7d900fe67bc071f7e7c72f01e29 Mon Sep 17 00:00:00 2001 From: Pharap <2933055+Pharap@users.noreply.github.com> Date: Fri, 26 Oct 2018 19:34:34 +0100 Subject: Add noexcept specifier to placement new operator The standard mandates that placement new should be have a noexcept specifier. --- cores/arduino/new.cpp | 2 +- cores/arduino/new.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cores/arduino/new.cpp b/cores/arduino/new.cpp index 86a1fa5..fc30cf8 100644 --- a/cores/arduino/new.cpp +++ b/cores/arduino/new.cpp @@ -26,7 +26,7 @@ void *operator new[](size_t size) { return malloc(size); } -void * operator new(size_t size, void * ptr) { +void * operator new(size_t size, void * ptr) noexcept { (void)size; return ptr; } diff --git a/cores/arduino/new.h b/cores/arduino/new.h index 7690911..763f5cc 100644 --- a/cores/arduino/new.h +++ b/cores/arduino/new.h @@ -23,7 +23,7 @@ void * operator new(size_t size); void * operator new[](size_t size); -void * operator new(size_t size, void * ptr); +void * operator new(size_t size, void * ptr) noexcept; void operator delete(void * ptr); void operator delete[](void * ptr); -- cgit v1.2.3-18-g5258 From d518be6797790a6055deeb1a00f4a7c20773b970 Mon Sep 17 00:00:00 2001 From: Florian Schweiger Date: Mon, 26 Nov 2018 09:12:24 +0000 Subject: Removed historic Arduino-0012 workaround Removed #undefs in SoftwareSerial.h that were marked as Arduino 0012 workaround and that broke several macros, including abs. See https://github.com/arduino/ArduinoCore-avr/issues/30 --- libraries/SoftwareSerial/src/SoftwareSerial.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/libraries/SoftwareSerial/src/SoftwareSerial.h b/libraries/SoftwareSerial/src/SoftwareSerial.h index b1a37c4..d8b88ce 100644 --- a/libraries/SoftwareSerial/src/SoftwareSerial.h +++ b/libraries/SoftwareSerial/src/SoftwareSerial.h @@ -111,13 +111,4 @@ public: static inline void handle_interrupt() __attribute__((__always_inline__)); }; -// Arduino 0012 workaround -#undef int -#undef char -#undef long -#undef byte -#undef float -#undef abs -#undef round - #endif -- cgit v1.2.3-18-g5258 From c87bc7ba9a94cbeca3b652ea068c4bdb38c76b6c Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Tue, 11 Dec 2018 00:01:57 +0100 Subject: Add USBDevice.isSuspended() Based on code originally by Rob van der Veer , this adds USBDevice.isSuspended(), so user sketches can run custom code in their `loop` methods after checking if the device is suspended or not. Signed-off-by: Gergely Nagy --- cores/arduino/USBAPI.h | 2 ++ cores/arduino/USBCore.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/cores/arduino/USBAPI.h b/cores/arduino/USBAPI.h index 479ced9..701a14f 100644 --- a/cores/arduino/USBAPI.h +++ b/cores/arduino/USBAPI.h @@ -65,6 +65,8 @@ public: void detach(); // Serial port goes down too... void poll(); bool wakeupHost(); // returns false, when wakeup cannot be processed + + bool isSuspended(); }; extern USBDevice_ USBDevice; diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp index 81f689d..c0a4c7c 100644 --- a/cores/arduino/USBCore.cpp +++ b/cores/arduino/USBCore.cpp @@ -855,4 +855,10 @@ bool USBDevice_::wakeupHost() return false; } +bool USBDevice_::isSuspended() +{ + return (_usbSuspendState & (1 << SUSPI)); +} + + #endif /* if defined(USBCON) */ -- cgit v1.2.3-18-g5258 From a901b081aed0c60e97777c9c92350d354b721094 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 19 Dec 2018 01:12:26 -0800 Subject: Revert "Updated Arduino as ISP setting" This reverts commit b084848f2eaf9ccb3ac9a64ac5492d91df4706bf. --- programmers.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/programmers.txt b/programmers.txt index d0d2cc1..c100e84 100644 --- a/programmers.txt +++ b/programmers.txt @@ -43,9 +43,9 @@ parallel.program.extra_params=-F arduinoasisp.name=Arduino as ISP arduinoasisp.communication=serial -arduinoasisp.protocol=arduino +arduinoasisp.protocol=stk500v1 arduinoasisp.speed=19200 -arduinoasisp.program.protocol=arduino +arduinoasisp.program.protocol=stk500v1 arduinoasisp.program.speed=19200 arduinoasisp.program.tool=avrdude arduinoasisp.program.extra_params=-P{serial.port} -b{program.speed} -- cgit v1.2.3-18-g5258 From 98c8a138c18592e7385feb800e30165a403802d9 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 19 Dec 2018 01:45:56 -0800 Subject: Add ATmega32U4-compatible Arduino as ISP programmer Use of the stk500v1 protocol for Arduino as ISP does not work with native USB boards on Windows. The arduino protocol does. However, the arduino protocol makes it more likely that boards with an external USB interface chip will require the auto-reset circuitry to be disabled to allow them to be used as Arduino as ISP. That adds extra complexity to a process already difficult for the average Arduino user. For this reason, a new programmer using the arduino protocol is added specifically for using native USB boards as Arduino as ISP and the previous Arduino as ISP configuration is retained for use with all other boards. --- programmers.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/programmers.txt b/programmers.txt index c100e84..69ddf69 100644 --- a/programmers.txt +++ b/programmers.txt @@ -50,6 +50,15 @@ arduinoasisp.program.speed=19200 arduinoasisp.program.tool=avrdude arduinoasisp.program.extra_params=-P{serial.port} -b{program.speed} +arduinoasispatmega32u4.name=Arduino as ISP (ATmega32U4) +arduinoasispatmega32u4.communication=serial +arduinoasispatmega32u4.protocol=arduino +arduinoasispatmega32u4.speed=19200 +arduinoasispatmega32u4.program.protocol=arduino +arduinoasispatmega32u4.program.speed=19200 +arduinoasispatmega32u4.program.tool=avrdude +arduinoasispatmega32u4.program.extra_params=-P{serial.port} -b{program.speed} + usbGemma.name=Arduino Gemma usbGemma.protocol=arduinogemma usbGemma.program.tool=avrdude -- cgit v1.2.3-18-g5258 From c27aef0ed6638a635d92fcb97412dbd3e65e8c31 Mon Sep 17 00:00:00 2001 From: Paulo Costa Date: Fri, 4 Jan 2019 15:41:14 -0200 Subject: Remove commented out code for I2C interrupts on WInterrupts.c These are currently implemented by the Wire library, on twi.c --- cores/arduino/WInterrupts.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/cores/arduino/WInterrupts.c b/cores/arduino/WInterrupts.c index cef1106..ac72dda 100644 --- a/cores/arduino/WInterrupts.c +++ b/cores/arduino/WInterrupts.c @@ -65,7 +65,6 @@ static volatile voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS] = { nothing, #endif }; -// volatile static voidFuncPtr twiIntFunc; void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) { if(interruptNum < EXTERNAL_NUM_INTERRUPTS) { @@ -274,11 +273,6 @@ void detachInterrupt(uint8_t interruptNum) { } } -/* -void attachInterruptTwi(void (*userFunc)(void) ) { - twiIntFunc = userFunc; -} -*/ #define IMPLEMENT_ISR(vect, interrupt) \ ISR(vect) { \ @@ -314,11 +308,3 @@ IMPLEMENT_ISR(INT2_vect, EXTERNAL_INT_2) #endif #endif - -/* -ISR(TWI_vect) { - if(twiIntFunc) - twiIntFunc(); -} -*/ - -- cgit v1.2.3-18-g5258 From 8f752bf8c2785049eca2b546f8105ff856a06f48 Mon Sep 17 00:00:00 2001 From: "Paul R. Nash" Date: Mon, 21 Jan 2019 17:23:44 -0800 Subject: Add parameters names to common prototypes Putting the parameter names in these commonly used prototypes makes syntax help like VS Code's Intellisense work 99% more useful. Without them, it doesn't give you the names of the parameters and you have to remember the semantics yourself. :( --- cores/arduino/Arduino.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cores/arduino/Arduino.h b/cores/arduino/Arduino.h index 09c1448..e178cf4 100644 --- a/cores/arduino/Arduino.h +++ b/cores/arduino/Arduino.h @@ -130,16 +130,16 @@ void initVariant(void); int atexit(void (*func)()) __attribute__((weak)); -void pinMode(uint8_t, uint8_t); -void digitalWrite(uint8_t, uint8_t); -int digitalRead(uint8_t); -int analogRead(uint8_t); +void pinMode(uint8_t pin, uint8_t mode); +void digitalWrite(uint8_t pin, uint8_t val); +int digitalRead(uint8_t pin); +int analogRead(uint8_t pin); void analogReference(uint8_t mode); -void analogWrite(uint8_t, int); +void analogWrite(uint8_t pin, int val); unsigned long millis(void); unsigned long micros(void); -void delay(unsigned long); +void delay(unsigned long ms); void delayMicroseconds(unsigned int us); unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout); unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout); @@ -147,8 +147,8 @@ unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout); void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); -void attachInterrupt(uint8_t, void (*)(void), int mode); -void detachInterrupt(uint8_t); +void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode); +void detachInterrupt(uint8_t interruptNum); void setup(void); void loop(void); -- cgit v1.2.3-18-g5258 From 9e9f54d34dbab45e152d8163e048a879d736eedf Mon Sep 17 00:00:00 2001 From: David Madison Date: Sun, 17 Feb 2019 12:07:22 -0500 Subject: Define descriptor return var in pluggable block Avoids unused variable warning if USB is enabled but pluggable USB is not --- cores/arduino/USBCore.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp index c0a4c7c..dc6bc38 100644 --- a/cores/arduino/USBCore.cpp +++ b/cores/arduino/USBCore.cpp @@ -496,14 +496,13 @@ bool SendConfiguration(int maxlen) static bool SendDescriptor(USBSetup& setup) { - int ret; u8 t = setup.wValueH; if (USB_CONFIGURATION_DESCRIPTOR_TYPE == t) return SendConfiguration(setup.wLength); InitControl(setup.wLength); #ifdef PLUGGABLE_USB_ENABLED - ret = PluggableUSB().getDescriptor(setup); + int ret = PluggableUSB().getDescriptor(setup); if (ret != 0) { return (ret > 0 ? true : false); } -- cgit v1.2.3-18-g5258 From 29bfd08cd7fc1399f897255f81804595a4776d16 Mon Sep 17 00:00:00 2001 From: Akihiro YAMAZAKI Date: Wed, 4 Sep 2019 20:04:45 +0900 Subject: remove unnecessary if branch checking `length` in below while statement --- cores/arduino/Stream.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/cores/arduino/Stream.cpp b/cores/arduino/Stream.cpp index d284631..9eff663 100644 --- a/cores/arduino/Stream.cpp +++ b/cores/arduino/Stream.cpp @@ -218,7 +218,6 @@ size_t Stream::readBytes(char *buffer, size_t length) size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length) { - if (length < 1) return 0; size_t index = 0; while (index < length) { int c = timedRead(); -- cgit v1.2.3-18-g5258 From becb995388d7cbdd5f9cfbd41b82c7152ef6513f Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Mon, 16 Sep 2019 09:58:35 +0200 Subject: Adding parenthesis around 'bitvalue' allowing correct macro expansion when using with ternary operator such as bitWrite(value, bit, some_computed_value == 5 ? 1: 0);' --- cores/arduino/Arduino.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/arduino/Arduino.h b/cores/arduino/Arduino.h index 09c1448..d1a46d0 100644 --- a/cores/arduino/Arduino.h +++ b/cores/arduino/Arduino.h @@ -111,7 +111,7 @@ void yield(void); #define bitRead(value, bit) (((value) >> (bit)) & 0x01) #define bitSet(value, bit) ((value) |= (1UL << (bit))) #define bitClear(value, bit) ((value) &= ~(1UL << (bit))) -#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) +#define bitWrite(value, bit, bitvalue) ((bitvalue) ? bitSet(value, bit) : bitClear(value, bit)) // avr-libc defines _NOP() since 1.6.2 #ifndef _NOP -- cgit v1.2.3-18-g5258