Open SpenceKonde opened 4 years ago
Just discovered something: __AVR_ARCH__ is 102, 103, or 104 for the new Dx series parts, not always 104. 103 which is what it is on the tinyAVR/megaAVR 0/1-series as well as 32k Dx parts; these can map all of their flash in the data space at once. 102 is for 64k (two sections), and 104 is for 128k parts (which have to split their flash into 4 sections)
Updated pr to account for this discovery.
Please add this support for the new AVRs in the next version. Thanks!
I would really love to have this PR merged and a current version of this. Currently I have to manually modify util/OneWire_direct_gpio.h with a hack to get OneWire to work with DS18B20.
Try OneWireNg
Try OneWireNg
Ah, thanks a lot! That one works out of the box (even though the API is a slight bit more complicated).
These all have the same patterns in register locations, so can use the same formulae for them.
This also switches to using the VPORT registers instead of the PORT registers, which makes setting or clearing a single bit into an atomic, single word, single cycle operation (SBI/CBI), as opposed to requiring a read-modify-write cycle like the PORT.OUT and PORT.DIR registers do, making those operations interrupt safe like they were on classic AVRs, as well as reducing sketch size and executing faster. Taking advantage of the consistent numbering of ports returned by digitalPinToPort() among the cores supporting these parts to get the base register address shrinks the compiled sketch size a touch too.
Non-pins passed to digitalPinToPort() will get back NOT_A_PORT, which is defined as 255, would give base reg of 0x03FC, which falls into one of the many gaps in the register space on these parts as well - so it won't fiddle with some random other peripheral somewhere (as it happens, it's right before where the PORT registers start at 0x0400, which seems fitting for "port -1")