Skip to content

Commit e034b1a

Browse files
committed
Added compatibility defines 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 4abdb77 commit e034b1a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

cores/arduino/wiring_analog.c

+11-2
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 >= 10603)
228+
// Compatibility for cores based on SAMD core <=1.6.2
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

+3
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.3
23+
#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10603
24+
2225
/*----------------------------------------------------------------------------
2326
* Definitions
2427
*----------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)