PaulStoffregen / OneWire

Library for Dallas/Maxim 1-Wire Chips
http://www.pjrc.com/teensy/td_libs_OneWire.html
579 stars 382 forks source link

Why has the new AVR controller support been deleted? #126

Closed mikrocoder closed 1 year ago

mikrocoder commented 1 year ago

Hi Paul,

In OneWire v2.3.5 the support for the new AVR controllers is still in there and in v2.3.7 it is not anymore. Why was this deleted? There is no problem to add it. For everything concerning AVR only this small change is necessary. Tested with AVR128DB64, Nano Every (ATmega4809) and Arduino Mega2560.

#if defined(__AVR__)
    #define PIN_TO_BITMASK(pin)                (digitalPinToBitMask(pin))
    #define IO_REG_TYPE uint8_t
    #define IO_REG_BASE_ATTR asm("r30")
    #define IO_REG_MASK_ATTR

    #if ((__AVR_ARCH__ == 102) || (__AVR_ARCH__ == 103) || (__AVR_ARCH__ == 104))
        #define PIN_TO_BASEREG(pin)             ((volatile uint8_t*)((digitalPinToPort(pin))<<2)) // VPORT Base = VPORT.DIR
        #define DIRECT_READ(base, mask)         ((*((base)+2) & (mask)) ? 1 : 0)                  // VPORT.IN
        #define DIRECT_MODE_INPUT(base, mask)   ((*(base))     &= ~(mask))                        // VPORT.DIR
        #define DIRECT_MODE_OUTPUT(base, mask)  ((*(base))     |=  (mask))                        // VPORT.DIR
        #define DIRECT_WRITE_LOW(base, mask)    ((*((base)+1)) &= ~(mask))                        // VPORT.OUT
        #define DIRECT_WRITE_HIGH(base, mask)   ((*((base)+1)) |=  (mask))                        // VPORT.OUT
    #else
        #define PIN_TO_BASEREG(pin)             (portInputRegister(digitalPinToPort(pin)))
        #define DIRECT_READ(base, mask)         (((*(base)) & (mask)) ? 1 : 0)
        #define DIRECT_MODE_INPUT(base, mask)   ((*((base)+1)) &= ~(mask))
        #define DIRECT_MODE_OUTPUT(base, mask)  ((*((base)+1)) |=  (mask))
        #define DIRECT_WRITE_LOW(base, mask)    ((*((base)+2)) &= ~(mask))
        #define DIRECT_WRITE_HIGH(base, mask)   ((*((base)+2)) |=  (mask))
    #endif

You can use the completely revised and better readable formatted file directly. OneWire_direct_gpio_v2.3.8.zip

mikrocoder commented 1 year ago

Hello Paul,

I have to ask. Don't you want to or can't you?

PaulStoffregen commented 1 year ago

I downloaded 2.3.5 and 2.3.7. Both have this, exactly the same:

#if defined(__AVR__)
#define PIN_TO_BASEREG(pin)             (portInputRegister(digitalPinToPort(pin)))
#define PIN_TO_BITMASK(pin)             (digitalPinToBitMask(pin))
#define IO_REG_TYPE uint8_t
#define IO_REG_BASE_ATTR asm("r30")
#define IO_REG_MASK_ATTR
#if defined(__AVR_ATmega4809__)
#define DIRECT_READ(base, mask)         (((*(base)) & (mask)) ? 1 : 0)
#define DIRECT_MODE_INPUT(base, mask)   ((*((base)-8)) &= ~(mask))
#define DIRECT_MODE_OUTPUT(base, mask)  ((*((base)-8)) |= (mask))
#define DIRECT_WRITE_LOW(base, mask)    ((*((base)-4)) &= ~(mask))
#define DIRECT_WRITE_HIGH(base, mask)   ((*((base)-4)) |= (mask))
#else
#define DIRECT_READ(base, mask)         (((*(base)) & (mask)) ? 1 : 0)
#define DIRECT_MODE_INPUT(base, mask)   ((*((base)+1)) &= ~(mask))
#define DIRECT_MODE_OUTPUT(base, mask)  ((*((base)+1)) |= (mask))
#define DIRECT_WRITE_LOW(base, mask)    ((*((base)+2)) &= ~(mask))
#define DIRECT_WRITE_HIGH(base, mask)   ((*((base)+2)) |= (mask))
#endif
mikrocoder commented 1 year ago

Hi Paul,

No, this is not the same as the one I showed. Look closely once. Also, your code does not support AVRxDB controllers. I didn't write this just for fun. I don't want to annoy you. So please take a closer look again.

PaulStoffregen commented 1 year ago

You wrote "In OneWire v2.3.5 the support for the new AVR controllers is still in there and in v2.3.7 it is not anymore. Why was this deleted?"

But I looked at these 2 versions. They have identical AVR defines. Nothing was deleted, nothing was added.

mikrocoder commented 1 year ago

Hi Paul,

Okay, sorry. Then the case is different. Then I thought your 2.3.5 would have been different and I have a supposedly old working 2.3.5. but already adapted. By whoever. Or I have mixed up something during testing. Sorry. I have been experimenting a lot with Spencekonde DxCore and OneWire. Spencekonde wants the support in your OneWire as well. The reason is that your OneWire is very common. :-)

According to that you have never supported the AVRxDB controllers. Would you want to support the AVRxDB controllers? The necessary change is practically in front of you. :-)

PaulStoffregen commented 1 year ago

Let's close this issue. Maybe start a new issue, fresh with what you wanted to request, without this baggage of incorrect facts.

mikrocoder commented 1 year ago

Okay.

PaulStoffregen commented 1 year ago

Just in case this wasn't obvious or common sense, starting an issue with a (wrong) accusation that code was deleted is not the way to make friends and influence people. Please, wait a few days before you open a new issue. Consider the details carefully before you write again.

PaulStoffregen commented 1 year ago

I asked you to wait a few days