Skip to content

Commit fd27ae3

Browse files
committed
Major bugfix: Correct issue causing various problems with new PWM menu option
Going to attempt to get access to github through webbrowser again today. Fucking 2FA sucks.
1 parent 4d0d756 commit fd27ae3

9 files changed

Lines changed: 251 additions & 25 deletions

File tree

ChangeLog.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ These items are in addition to what was listed under changes already in release.
99

1010
#### Planned 2.7.0
1111
* Migrate to avrdude 7.2
12-
13-
#### Planned 2.6.10/x
1412
* Add support `_getCurrentMillisTimer()` and `getCurrentMillisMode()`, required for sleepTime.
1513

1614

@@ -26,6 +24,9 @@ Changes listed here are checked in to GitHub ("master" branch unless specificall
2624

2725
### Planned 2.6.11
2826
* Correct numerous issues with the microchip board defs. Clearly nobody is using them - since 2 of them didn't compile, and none of the optiboot ones would ever be able to successfully be programmed over the bootloader because selfprogramming wasn't enabled (BOOTEND = 0).
27+
* Major Bugfix: Correct issue #1164 thanks to John Vasileff. This would cause Serial.flush to hang in one-wire mode.
28+
* Major Bugfix: Correct buffered PWM on all parts.
29+
*
2930

3031
## Released Versions
3132

megaavr/boards.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2057,7 +2057,7 @@ atxy2.menu.printf.minimal.build.printfabr=.pfM
20572057
#________________________________________|
20582058
atxy2.menu.PWMmux.default=PA1-3,7 (default)
20592059
atxy2.menu.PWMmux.buffered=PA1-3 (buffered)
2060-
atxy2.menu.PWMmux.I3=PA1-3, PA6/7 (buffered, 1-series only, flash hog)
2060+
atxy2.menu.PWMmux.I3=PWM on all pins: TCA @ PA1-3, TCD @ PA6/7 both buffered. 1-series only, flash hog, NO DACOUT)
20612061
atxy2.menu.PWMmux.buffered.build.pwmflags=-DTCA_BUFFERED_3PIN
20622062
atxy2.menu.PWMmux.I3.build.pwmflags=-DUSE_TIMERD0_PWM -DTCD_USE_WOAB -DTCA_BUFFERED_3PIN
20632063
atxy2.menu.PWMmux.buffered.build.pwmabr=3

megaavr/cores/megatinycore/core_devices.h

Lines changed: 101 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,59 @@
282282
#define __AVR_TINY_2__
283283
#endif
284284

285+
286+
/* These are constant for all tinies, and make the variant stuff look a lot nicer */
287+
#if defined(TCA0) && defined(PORTMUX_TCA00_bm)
288+
#if defined(_TCA_ALT_WO0)
289+
#define _TCA_WO0 PIN_PB0
290+
#else
291+
#define _TCA_WO0 PIN_PB3
292+
#endif
293+
#if defined(_TCA_ALT_WO1)
294+
#define _TCA_WO1 PIN_PB1
295+
#else
296+
#define _TCA_WO1 PIN_PB4
297+
#endif
298+
299+
#if defined(_TCA_ALT_WO2)
300+
#define _TCA_WO2 PIN_PB2
301+
#else
302+
#define _TCA_WO2 PIN_PB5
303+
#endif
304+
#if defined(_TCA_USE_WO3)
305+
#if defined(_TCA_ALT_WO3)
306+
#define _TCA_WO3 PIN_PA3
307+
#else
308+
#define _TCA_WO3 PIN_PC3
309+
#endif
310+
#endif
311+
#if defined(_TCA_USE_WO4)
312+
#if defined(_TCA_ALT_WO4)
313+
#define _TCA_WO4 PIN_PC4
314+
#else
315+
#define _TCA_WO4 PIN_PA4
316+
#endif
317+
#endif
318+
#if defined(_TCA_USE_WO5)
319+
#if defined(_TCA_ALT_WO5)
320+
#define _TCA_WO5 PIN_PA5
321+
#else
322+
#define _TCA_WO5 PIN_PC5
323+
#endif
324+
#endif
325+
#endif
326+
#if defined(USE_TIMERD_PWM)
327+
#if defined(USE_TCD_WOAB)
328+
#define _TCD_WOAC PIN_PA4
329+
#define _TCD_WOBD PIN_PA5
330+
#else
331+
#define _TCD_WOAC PIN_PC0
332+
#define _TCD_WOBD PIN_PC1
333+
#endif
334+
#endif
335+
336+
337+
285338
/* FOLLOWING THIS, SHARED WITH DxCoRE DIRECTLY */
286339
#if defined(AC2)
287340
#define _AVR_AC_COUNT (3)
@@ -316,6 +369,7 @@
316369
#define _AVR_EVSYS_COUNT (3)
317370
#define _AVR_EVSYS_ASYNC (2)
318371
#define _AVR_EVSYS_SYNC (1)
372+
/* Otherwise, we just count down till we find one, since there's no plausible reason for them to number the channels any other way. */
319373
#elif defined(EVSYS_CHANNEL15)
320374
#define _AVR_EVSYS_COUNT (16)
321375
#elif defined(EVSYS_CHANNEL14)
@@ -360,7 +414,8 @@
360414
* generators allows them to add both options for all ports and both RTC options to all generator channels
361415
* Too bad they released so many parts with the other versions :-/ */
362416

363-
#if defined(PORTA_EVGENCTRL) // Ex-series, with EVGENCTRL registers on RTC and PORT.
417+
#if defined(PORTA_EVGENCTRL)||defined(PORTA_EVGENCTRLA) // Starting with EA, they have EVGENCTRL registers onthe PORTS and RTC, so all channels are equal.
418+
// Starting with EB, and retroactively changing EA, they renamed them to EVGENCTRLA. Elsewhere we define the other if either one of the two is defined, as we always do when they change spellings.
364419
#define _AVR_EVSYS_VERSION (3)
365420
#elif defined(EVSYS_STROBE) // mega0 - basically Dx, but different name for strobe.
366421
#define _AVR_EVSYS_VERSION (1)
@@ -446,7 +501,7 @@
446501
#endif
447502

448503
#if defined(TCE0)
449-
#define _AVR_TCE_COUNT (1) // first appears on the EB-series, 16-bit. Some sort of 8-channeled monster who is always with the one they call WEX. I haven't heard from TCA0 after they showed up and started doing
504+
#define _AVR_TCE_COUNT (1) // first appears on the EB-series, 16-bit.
450505
#else // PWM on the same pins. I have a bad feeling that TCA0 is either tied up in the basement, or dead in a wooded area. With the TCE's skill at motor control, they could easily have
451506
#define _AVR_TCE_COUNT (0) // used power-tools to dismember bury the body.... Anyway, whether these guys are as useful in the silicon as they look on paper will depend a lot on the whether those
452507
#endif // 8-channels are independent, and whether they need to split like TCA did to handle 8 WO's if so. And, of course on how flexible their clocking options are.
@@ -718,6 +773,10 @@ setPrescalerValue(oldpsc);
718773

719774
#endif
720775

776+
777+
778+
779+
721780
/* Microchip has shown a tendency to rename registers bitfields and similar between product lines, even when the behavior is identical.
722781
* This is a major hindrance to writing highly portable code which I assume is what most people wish to do. It certainly beats having
723782
* to run code through find replace making trivial changes, forcing a fork where you would rather not have one.
@@ -753,6 +812,8 @@ has once worked for the same thing as meaning that thing */
753812
#define RTC_CLKSEL_XTAL32K_gc RTC_CLKSEL_XOSC32K_gc
754813
#endif
755814
#endif
815+
816+
756817
/* General Purpose Register names, GPR.GPRn, vs GPIORn vs GPIOn
757818
* They now appear to have decided they don't like either of the previous conventions, one just a few years old. Now they are grouping
758819
* them under a "General Purpose Register". "peripheral". I cannot argue that GPR doesn't make more sense, as there's not really any
@@ -940,7 +1001,7 @@ has once worked for the same thing as meaning that thing */
9401001
#define TCA_SINGLE_EVACTA_CNT_HIGHLVL_gc TCA_SINGLE_EVACTA_CNT_HIGHLVL_gc
9411002
#define TCA_SINGLE_EVACTA_UPDOWN_gc TCA_SINGLE_EVACTA_UPDOWN_gc
9421003
#endif
943-
// TCA V1.1 - DA, DB, tinyAVR 2?
1004+
// TCA V1.1 - DA/2-series and everthing since
9441005
// with two inputs changes the names the existing ones to specify channel A
9451006
// We add in the non-postfixed ana
9461007
#if !defined(TCA_SINGLE_CNTEI_bm)
@@ -951,6 +1012,43 @@ has once worked for the same thing as meaning that thing */
9511012
#define TCA_SINGLE_EVACT_CNT_HIGHLVL_gc TCA_SINGLE_EVACTA_CNT_HIGHLVL_gc
9521013
#define TCA_SINGLE_EVACT_UPDOWN_gc TCA_SINGLE_EVACTA_UPDOWN_gc
9531014
#endif
1015+
// Some versions of the EA headers have it as PORTx_EVGENCTRL, retroactively changed to PORTx_EVGENCTRLA, implying plans for more.
1016+
#if defined(PORTA_EVGENCTRL)
1017+
#define PORTA_EVGENCTRLA PORTA_EVGENCTRL
1018+
#else
1019+
#define PORTA_EVGENCTRL PORTA_EVGENCTRLA
1020+
#endif
1021+
#if defined(PORTB_EVGENCTRL)
1022+
#define PORTB_EVGENCTRLA PORTB_EVGENCTRL
1023+
#else
1024+
#define PORTB_EVGENCTRL PORTB_EVGENCTRLA
1025+
#endif
1026+
#if defined(PORTC_EVGENCTRL)
1027+
#define PORTC_EVGENCTRLA PORTC_EVGENCTRL
1028+
#else
1029+
#define PORTC_EVGENCTRL PORTC_EVGENCTRLA
1030+
#endif
1031+
#if defined(PORTD_EVGENCTRL)
1032+
#define PORTD_EVGENCTRLA PORTD_EVGENCTRL
1033+
#else
1034+
#define PORTD_EVGENCTRL PORTD_EVGENCTRLA
1035+
#endif
1036+
#if defined(PORTE_EVGENCTRL)
1037+
#define PORTE_EVGENCTRLA PORTE_EVGENCTRL
1038+
#else
1039+
#define PORTE_EVGENCTRL PORTE_EVGENCTRLA
1040+
#endif
1041+
#if defined(PORTF_EVGENCTRL)
1042+
#define PORTF_EVGENCTRLA PORTF_EVGENCTRL
1043+
#else
1044+
#define PORTF_EVGENCTRL PORTF_EVGENCTRLA
1045+
#endif
1046+
#if defined(PORTG_EVGENCTRL)
1047+
#define PORTG_EVGENCTRLA PORTG_EVGENCTRL
1048+
#else
1049+
#define PORTG_EVGENCTRL PORTG_EVGENCTRLA
1050+
#endif
1051+
9541052

9551053
#if (!defined(MEGATINYCORE) || MEGATINYCORE_SERIES >= 2)
9561054
#define TCB_CLKSEL_CLKDIV1_gc TCB_CLKSEL_DIV1_gc

megaavr/cores/megatinycore/timers.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,17 @@
3232
#define _TCA_ALT_WO2
3333
#endif
3434
#if !defined(TCA_BUFFERED_3PIN)
35+
#define _TCA_USE_WO4
36+
#define _TCA_USE_WO5
37+
#define _TCA_USE_WO3
3538
#if TCA_PORTMUX & 0x08
3639
#define _TCA_ALT_WO3
37-
#else
38-
#define _TCA_USE_WO3
3940
#endif
4041
#if TCA_PORTMUX & 0x10
4142
#define _TCA_ALT_WO4
42-
#else
43-
#define _TCA_USE_WO4
4443
#endif
4544
#if TCA_PORTMUX & 0x20
4645
#define _TCA_ALT_WO5
47-
#else
48-
#define _TCA_USE_WO5
4946
#endif
5047
#endif
5148
#if defined(USE_TIMERD0_PWM)

megaavr/cores/megatinycore/wiring_digital.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
Boston, MA 02111-1307 USA
2121
2222
Modified 28 September 2010 by Mark Sproul
23-
Modified extensively 2018~2021 by Spence Konde for
23+
Modified extensively 2018~2025 by Spence Konde for
2424
megaTinyCore and DxCore.
2525
*/
2626

@@ -144,7 +144,7 @@ void turnOffPWM(uint8_t pin)
144144
if(bit_mask & 0b00111000) {
145145
bit_mask <<= 1; // 0b01110000
146146
} else {
147-
//bit_maslk <<= 3; same result, but in 3 clocks 3 words instead of 1 and 1!
147+
//bit_mask <<= 4; same result, but in 3 clocks 3 words instead of 1 and 1!
148148

149149
_SWAP(bit_mask); // 0b0111000
150150
}

megaavr/variants/txy2/pins_arduino.h

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,21 @@
4242
#define PIN_PA3 (4)
4343
#define PIN_PA0 (5)
4444

45-
#define digitalPinHasPWM(p) ((p) != 0 && (p) != 5)
45+
#if !defined(USE_TIMERD0_PWM) && !defined(TCA_BUFFERED_3PIN)
46+
#define digitalPinHasPWM(p) (((uint8_t)((p) - 1) < (uint8_t) 4 ) //PA7, PA1. PA2. PA3.
47+
#elif !defined(USE_TIMERD0_PWM) && defined(TCA_BUFFERED_3PIN)
48+
#define digitalPinHasPWM(p) (((uint8_t)((p) - 2) < (uint8_t) 3 ) //PA1. PA2. PA3.
49+
#elif defined(USE_TIMERD0_PWM)
50+
#define digitalPinHasPWM(p) (((uint8_t)(p)) < (uint8_t) 5) /* every pin except the reset pin, whichmakes since, seeing as it barely has output drivers... */
51+
#endif
4652

47-
#ifdef DAC0
48-
#define DAC_PIN (PIN_PA6)
53+
#if defined(DAC0)
54+
#if !defined(USE_TIMERD0_PWM)
55+
#define DAC_PIN (PIN_PA6)
56+
#else
57+
#pragma message("TCD is enabled for PWM output; DAC output via analogWrite() is disabled in favor of TCD PWM")
58+
/* If you got a problem with that, do it manually! The DAC is about as easy to confgiure as it gets!*/
59+
#endif
4960
#endif
5061

5162
#ifndef LED_BUILTIN
@@ -190,7 +201,11 @@ const uint8_t digital_pin_to_timer[] = {
190201
#endif
191202
TIMERA0, // 2 PA1
192203
TIMERA0, // 3 PA2
193-
TIMERA0, // 4 PA3
204+
#if !defined(TCA_BUFFERED_3PIN)
205+
TIMERA0, // 4 PA3
206+
#else
207+
NOT_ON_TIMER, // 4 PA3
208+
#endif
194209
NOT_ON_TIMER // 5 PA0
195210
};
196211
//*INDENT-ON*

megaavr/variants/txy4/pins_arduino.h

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,44 @@
5656
#define PINS_COUNT (NUM_DIGITAL_PINS)
5757
#define EXTERNAL_NUM_INTERRUPTS (12)
5858

59-
#define digitalPinHasPWM(p) ((p) == PIN_PA4 || (p) == PIN_PA5 || (p) == PIN_PB2 || (p) == PIN_PB1 || (p) == PIN_PB0 || (p) == PIN_PA3)
60-
59+
/* Ugh! What a mess! */
60+
#if (defined(TCD0) && defined(USE_TIMERD0_PWM) && defined(USE_TCD_WOAB))
61+
#if defined(_TCA_USE_WO3) && defined(_TCA_USE_WO4) && defined(_TCA_USE_WO5)
62+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO3 || (p) == _TCA0_WO4 || (p) == _TCA0_WO5 || (p) == PIN_PA4 || (p) == PIN_PA5)
63+
#elif defined(_TCA_USE_WO3) && defined(_TCA_USE_WO4) && !defined(_TCA_USE_WO5)
64+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO3 || (p) == _TCA0_WO4 || (p) == PIN_PA4 || (p) == PIN_PA5)
65+
#elif defined(_TCA_USE_WO3) && !defined(_TCA_USE_WO4) && defined(_TCA_USE_WO5)
66+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO3 || (p) == _TCA0_WO5 || (p) == PIN_PA4 || (p) == PIN_PA5)
67+
#elif defined(_TCA_USE_WO3) && !defined(_TCA_USE_WO4) && !defined(_TCA_USE_WO5)
68+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO3 || (p) == PIN_PA4 || (p) == PIN_PA5)
69+
#elif !defined(_TCA_USE_WO3) && defined(_TCA_USE_WO4) && defined(_TCA_USE_WO5)
70+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO4 || (p) == _TCA0_WO5 || (p) == PIN_PA4 || (p) == PIN_PA5)
71+
#elif !defined(_TCA_USE_WO3) && defined(_TCA_USE_WO4) && !defined(_TCA_USE_WO5)
72+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO4 || (p) == _TCA0_WO5 || (p) == PIN_PA4 || (p) == PIN_PA5)
73+
#elif !defined(_TCA_USE_WO3) && !defined(_TCA_USE_WO4) && defined(_TCA_USE_WO5)
74+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO5 || (p) == PIN_PA4 || (p) == PIN_PA5)
75+
#elif !defined(_TCA_USE_WO3) && !defined(_TCA_USE_WO4) && !defined(_TCA_USE_WO5)
76+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == PIN_PA4 || (p) == PIN_PA5)
77+
#endif
78+
#else
79+
#if defined(_TCA_USE_WO3) && defined(_TCA_USE_WO4) && defined(_TCA_USE_WO5)
80+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO3 || (p) == _TCA0_WO4 || (p) == _TCA0_WO5 )
81+
#elif defined(_TCA_USE_WO3) && defined(_TCA_USE_WO4) && !defined(_TCA_USE_WO5)
82+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO3 || (p) == _TCA0_WO4 )
83+
#elif defined(_TCA_USE_WO3) && !defined(_TCA_USE_WO4) && defined(_TCA_USE_WO5)
84+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO3 || (p) == _TCA0_WO5 )
85+
#elif defined(_TCA_USE_WO3) && !defined(_TCA_USE_WO4) && !defined(_TCA_USE_WO5)
86+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO3 )
87+
#elif !defined(_TCA_USE_WO3) && defined(_TCA_USE_WO4) && defined(_TCA_USE_WO5)
88+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO4 || (p) == _TCA0_WO5 )
89+
#elif !defined(_TCA_USE_WO3) && defined(_TCA_USE_WO4) && !defined(_TCA_USE_WO5)
90+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO4 || (p) == _TCA0_WO5 )
91+
#elif !defined(_TCA_USE_WO3) && !defined(_TCA_USE_WO4) && defined(_TCA_USE_WO5)
92+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO5 )
93+
#elif !defined(_TCA_USE_WO3) && !defined(_TCA_USE_WO4) && !defined(_TCA_USE_WO5)
94+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 )
95+
#endif
96+
#endif
6197

6298
#if MEGATINYCORE_SERIES != 2
6399
#define digitalPinToAnalogInput(p) (((p) < 4) ? ((p) + 4) : ((p) == 11 ? 0 : (((p) > 7 && (p) < 11) ? ((p) - 7) : (((p) == 6) ? 10 : ((p) == 7 ? 11 : NOT_A_PIN)))))
@@ -350,4 +386,8 @@ const uint8_t digital_pin_to_timer[] = {
350386
#define SERIAL_PORT_MONITOR Serial
351387
#define SERIAL_PORT_HARDWARE Serial
352388

389+
#if defined (USART1)
390+
#define SERIAL_PORT_HARDWARE_OPEN Serial1
391+
#endif
392+
353393
#endif

megaavr/variants/txy6/pins_arduino.h

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,45 @@
4646

4747
#define EXTERNAL_NUM_INTERRUPTS (20)
4848

49+
/* Ugh! What a mess! */
4950
#if (defined(TCD0) && defined(USE_TIMERD0_PWM))
50-
#define digitalPinHasPWM(p) ((p) == PIN_PA4 || (p) == PIN_PA5 || (p) == PIN_PB2 || (p) == PIN_PB1 || (p) == PIN_PB0 || (p) == PIN_PC0 || (p) == PIN_PC1 || (p) == PIN_PA3)
51+
#if defined(_TCA_USE_WO3) && defined(_TCA_USE_WO4) && defined(_TCA_USE_WO5)
52+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO3 || (p) == _TCA0_WO4 || (p) == _TCA0_WO5 || (p) == _TCD_WOAC || (p) == _TCD_WOBD)
53+
#elif defined(_TCA_USE_WO3) && defined(_TCA_USE_WO4) && !defined(_TCA_USE_WO5)
54+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO3 || (p) == _TCA0_WO4 || (p) == _TCD_WOAC || (p) == _TCD_WOBD)
55+
#elif defined(_TCA_USE_WO3) && !defined(_TCA_USE_WO4) && defined(_TCA_USE_WO5)
56+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO3 || (p) == _TCA0_WO5 || (p) == _TCD_WOAC || (p) == _TCD_WOBD)
57+
#elif defined(_TCA_USE_WO3) && !defined(_TCA_USE_WO4) && !defined(_TCA_USE_WO5)
58+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO3 || (p) == _TCD_WOAC || (p) == _TCD_WOBD)
59+
#elif !defined(_TCA_USE_WO3) && defined(_TCA_USE_WO4) && defined(_TCA_USE_WO5)
60+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO4 || (p) == _TCA0_WO5 || (p) == _TCD_WOAC || (p) == _TCD_WOBD)
61+
#elif !defined(_TCA_USE_WO3) && defined(_TCA_USE_WO4) && !defined(_TCA_USE_WO5)
62+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO4 || (p) == _TCA0_WO5 || (p) == _TCD_WOAC || (p) == _TCD_WOBD)
63+
#elif !defined(_TCA_USE_WO3) && !defined(_TCA_USE_WO4) && defined(_TCA_USE_WO5)
64+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO5 || (p) == _TCD_WOAC || (p) == _TCD_WOBD)
65+
#elif !defined(_TCA_USE_WO3) && !defined(_TCA_USE_WO4) && defined(_TCA_USE_WO5)
66+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCD_WOAC || (p) == _TCD_WOBD)
67+
#else
68+
#error "Error determining PWM pins."
69+
#endif
5170
#else
52-
#define digitalPinHasPWM(p) ((p) == PIN_PA4 || (p) == PIN_PA5 || (p) == PIN_PB2 || (p) == PIN_PB1 || (p) == PIN_PB0 || (p) == PIN_PA3)
71+
#if defined(_TCA_USE_WO3) && defined(_TCA_USE_WO4) && defined(_TCA_USE_WO5)
72+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO3 || (p) == _TCA0_WO4 || (p) == _TCA0_WO5 )
73+
#elif defined(_TCA_USE_WO3) && defined(_TCA_USE_WO4) && !defined(_TCA_USE_WO5)
74+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO3 || (p) == _TCA0_WO4 )
75+
#elif defined(_TCA_USE_WO3) && !defined(_TCA_USE_WO4) && defined(_TCA_USE_WO5)
76+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO3 || (p) == _TCA0_WO5 )
77+
#elif defined(_TCA_USE_WO3) && !defined(_TCA_USE_WO4) && !defined(_TCA_USE_WO5)
78+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO3 )
79+
#elif !defined(_TCA_USE_WO3) && defined(_TCA_USE_WO4) && defined(_TCA_USE_WO5)
80+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO4 || (p) == _TCA0_WO5 )
81+
#elif !defined(_TCA_USE_WO3) && defined(_TCA_USE_WO4) && !defined(_TCA_USE_WO5)
82+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO4 || (p) == _TCA0_WO5 )
83+
#elif !defined(_TCA_USE_WO3) && !defined(_TCA_USE_WO4) && defined(_TCA_USE_WO5)
84+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 || (p) == _TCA0_WO5 )
85+
#elif !defined(_TCA_USE_WO3) && !defined(_TCA_USE_WO4) && defined(_TCA_USE_WO5)
86+
#define digitalPinHasPWM(p) ((p) == _TCA0_WO0 || (p) == _TCA0_WO1 || (p) == _TCA0_WO2 )
87+
#endif
5388
#endif
5489

5590

@@ -67,7 +102,6 @@
67102
#if defined(ADC1) // 3216 and 1616 only have second ADC.
68103
#define digitalPinToAnalogInput_ADC1(p) ((p) < 6 ? (p) : ((p) < PINS_COUNT && ((p) >= PIN_PC0) ? (6 + (p) - PIN_PC0) : NOT_A_PIN))
69104
#endif
70-
71105
#else
72106
/* 2-series MUX table says ADC channel 0 is tied to ground, not PA0, PC0 through PC3 are a A12-15 */
73107
#define digitalPinToAnalogInput(p) (((p) < 6) ? ((p) + 4) : (((p) > 13 && (p) < 17) ? ((p) - 13) : ((((p) >= 8) && ((p) < 14)) ? ((p) + 2) : NOT_A_PIN)))
@@ -473,4 +507,8 @@ const uint8_t digital_pin_to_timer[] = {
473507
#define SERIAL_PORT_MONITOR Serial
474508
#define SERIAL_PORT_HARDWARE Serial
475509

510+
#if defined (USART1)
511+
#define SERIAL_PORT_HARDWARE_OPEN Serial1
512+
#endif
513+
476514
#endif

0 commit comments

Comments
 (0)