Skip to content

Commit 918379d

Browse files
authored
Merge pull request #180 from nekuneko/patch-1
Change references from A0 & A1 to DAC0 & DAC1
2 parents f739f3c + a09d821 commit 918379d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

cores/arduino/wiring_analog.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ uint32_t analogRead(uint32_t pin)
280280
#ifdef DAC
281281

282282
#if defined(__SAMD51__)
283-
if (pin == A0 || pin == A1) { // Disable DAC, if analogWrite(A0,dval) used previously the DAC is enabled
284-
uint8_t channel = (pin == PIN_A0 ? 0 : 1);
283+
if (pin == PIN_DAC0 || pin == PIN_DAC1) { // Disable DAC, if analogWrite(A0,dval) used previously the DAC is enabled
284+
uint8_t channel = (pin == PIN_DAC0 ? 0 : 1);
285285

286286
if(dacEnabled[channel]){
287287
dacEnabled[channel] = false;
@@ -298,7 +298,7 @@ uint32_t analogRead(uint32_t pin)
298298

299299
while (DAC->SYNCBUSY.bit.ENABLE);
300300
#else
301-
if (pin == A0) { // Disable DAC, if analogWrite(A0,dval) used previously the DAC is enabled
301+
if (pin == PIN_DAC0) { // Disable DAC, if analogWrite(A0,dval) used previously the DAC is enabled
302302
syncDAC();
303303

304304
DAC->CTRLA.bit.ENABLE = 0x00; // Disable DAC
@@ -410,17 +410,17 @@ void analogWrite(uint32_t pin, uint32_t value)
410410
{
411411
// DAC handling code
412412
#if defined(__SAMD51__)
413-
if (pin == PIN_A0 || pin == PIN_A1) { // 2 DACs on A0 (PA02) and A1 (PA05)
413+
if (pin == PIN_DAC0 || pin == PIN_DAC1) { // 2 DACs on A0 (PA02) and A1 (PA05)
414414
#else
415-
if (pin == PIN_A0) { // Only 1 DAC on A0 (PA02)
415+
if (pin == PIN_DAC0) { // Only 1 DAC on A0 (PA02)
416416
#endif
417417

418418
#if defined(__SAMD51__)
419419

420420
value = mapResolution(value, _writeResolution, _dacResolution);
421421

422422

423-
uint8_t channel = (pin == PIN_A0 ? 0 : 1);
423+
uint8_t channel = (pin == PIN_DAC0 ? 0 : 1);
424424

425425
pinPeripheral(pin, PIO_ANALOG);
426426

0 commit comments

Comments
 (0)