Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility issue with AVR DxCore Family #124

Open
sandeepkumar0153 opened this issue Feb 12, 2023 · 4 comments
Open

Compatibility issue with AVR DxCore Family #124

sandeepkumar0153 opened this issue Feb 12, 2023 · 4 comments

Comments

@sandeepkumar0153
Copy link

Description

OneWire wont work on the new AVR Dx Series chips using board variant from SpenceKonde.

modified \Libraries\OneWire\2.3.7\OneWire\util\OneWire_direct_gpio.h

added condition in case ARDUINO_avrdb is defiend to achieve fall back mode and added following code modification.
this should work with DA series and other boards with proper condition in to fall back mode.

#if defined(ARDUINO_avrdb)
#define PIN_TO_BASEREG(pin) (0)
#define PIN_TO_BITMASK(pin) (pin)
#define IO_REG_TYPE uint8_t
#define IO_REG_BASE_ATTR
#define IO_REG_MASK_ATTR
#define DIRECT_READ(base, pin) digitalRead(pin)
#define DIRECT_WRITE_LOW(base, pin) digitalWrite(pin, LOW)
#define DIRECT_WRITE_HIGH(base, pin) digitalWrite(pin, HIGH)
#define DIRECT_MODE_INPUT(base, pin) pinMode(pin,INPUT)
#define DIRECT_MODE_OUTPUT(base, pin) pinMode(pin,OUTPUT)
#warning "OneWire. Fallback mode. Using API calls for pinMode,digitalRead and digitalWrite. Operation of this library is not guaranteed on this architecture."

#elif defined(AVR)

@nurazur
Copy link

nurazur commented Oct 10, 2023

Fallback mode did not work for me, when F_CPU clock is 4 MHz or below.
I am working on ATmega4808 and AVR dd devices.
this line works, replacing line #18 in OneWire\util\OneWire_direct_gpio.h:
#if defined(__AVR_ATmega4809__) || defined(__AVR_ATmega4808__) || defined (ARDUINO_avrdd)
Since the architecture of ATmega480x and AVR Dx is very similar, I assume this to work for AVR db series as well if you add
|| defined (ARDUINO_avrdb) to line #18

@noeldum
Copy link

noeldum commented Jan 17, 2024

Thank you nurazur. It took me hours to find why the avr32db28 did not read the ds18b20. Troubleshooting ended after reading you above.

Your comment has a tipo. So to recap for those encountering the same problem.
In line

#if defined(__AVR_ATmega4809__)

add to the end of line:
|| defined (ARDUINO_avrdb)

@nurazur
Copy link

nurazur commented Jan 21, 2024

typo in my previous post is corrected. Sorry for the inconvenience.

@WeirdConstructor
Copy link

Also stumbled across this one today (had to add ARDUINO_avrdd to line 18).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants