Skip to content

Commit fa150a0

Browse files
committed
Added compatibility define for core's variant files
The variant's file compliance is now determined using a define named ARDUINO_SAMD_VARIANT_COMPLIANCE that refer to the minimum core version required for this variant file to work.
1 parent 931ccc1 commit fa150a0

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

cores/arduino/wiring_analog.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,17 @@ void analogWrite( uint32_t ulPin, uint32_t ulValue )
224224
if ( (attr & PIN_ATTR_PWM) == PIN_ATTR_PWM )
225225
{
226226
if (attr & PIN_ATTR_TIMER) {
227-
pinPeripheral(ulPin, PIO_TIMER);
228-
} else { // attr should have PIN_ATTR_TIMER_ALT bit set...
227+
#if !(ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10602)
228+
// Compatibility with cores based on SAMD core <=1.6.1
229+
if (g_APinDescription[ulPin].ulPinType == PIO_TIMER_ALT) {
230+
pinPeripheral(ulPin, PIO_TIMER_ALT);
231+
} else
232+
#endif
233+
{
234+
pinPeripheral(ulPin, PIO_TIMER);
235+
}
236+
} else {
237+
// We suppose that attr has PIN_ATTR_TIMER_ALT bit set...
229238
pinPeripheral(ulPin, PIO_TIMER_ALT);
230239
}
231240

variants/arduino_zero/variant.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#ifndef _VARIANT_ARDUINO_ZERO_
2020
#define _VARIANT_ARDUINO_ZERO_
2121

22+
// The definitions here needs a SAMD core >=1.6.2
23+
#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10602
24+
2225
/*----------------------------------------------------------------------------
2326
* Definitions
2427
*----------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)