The math with pointers is failing. I try to add the offset to the base register and it gets a value that I can't explain.
I'm using pin 7 of due.
For this pin, the port address is 400E1200 and PDSR register is 400E123C. This is taken from datasheet.
I've added Serial.println to the reset function to see the backstage.
uint8_t OneWire::reset(void)
{
IO_REG_TYPE mask = bitmask;
//volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg;
volatile IO_REG_TYPE *reg = baseReg;
//volatile IO_REG_TYPE *regout = baseOutReg;
Serial.println((long)(&(digitalPinToPort(7)->PIO_PER)),HEX);
Serial.println((long)(reg),HEX);
Serial.println((long)(bitmask),HEX);
volatile uint32_t *value=reg+1;
Serial.println((uint32_t)value,HEX);
uint8_t r;
uint8_t retries = 125;
noInterrupts();
DIRECT_MODE_INPUT(reg, mask);
Serial.println(((*(reg+0x3c))),HEX);
From this serial.print i get:
for -> Serial.println((long)(&(digitalPinToPort(7)->PIO_PER)),HEX);
I have 400E1200
for -> Serial.println((long)(reg),HEX);
I also have 400E1200
for -> Serial.println((long)(bitmask),HEX);
I have 800000
for - > Serial.println((uint32_t)value,HEX);
I have 400E1204 !!!!!!!!!!!!!!
Remenber that I've done this one line before:
volatile uint32_t *value=reg+1;
Why I don't have 400E1201 ?????