Skip to content

fix: correct I2C address from 8-bit to 7-bit for periph.io#44

Open
ashitaka1 wants to merge 1 commit intoZaparooProject:mainfrom
ashitaka1:pr/fix-i2c-address
Open

fix: correct I2C address from 8-bit to 7-bit for periph.io#44
ashitaka1 wants to merge 1 commit intoZaparooProject:mainfrom
ashitaka1:pr/fix-i2c-address

Conversation

@ashitaka1
Copy link

Summary

  • The I2C transport uses 8-bit addresses (pn532WriteAddr = 0x48 / pn532ReadAddr = 0x49) but periph.io's i2c.Dev.Addr expects 7-bit addresses (passed directly to the Linux I2C_SLAVE ioctl). With 0x48, the kernel puts 0x90/0x91 on the wire — an address nothing responds to.
  • Replace both constants with pn532Addr = 0x24 (0x48 >> 1). periph.io handles the R/W bit automatically.
  • Add parseI2CPath() to handle composite detection paths like /dev/i2c-1:0x24.
  • Add scripts/i2c-validate.sh for hardware validation on Raspberry Pi.

Testing

  • Confirmed on Raspberry Pi 5 with PN532 on /dev/i2c-1
  • i2cdetect -y 1 shows device at 0x24
  • All existing unit tests pass
  • Validation script passes on hardware

The PN532 datasheet documents 0x48/0x49 as 8-bit addresses (including
the R/W bit). periph.io and the Linux kernel expect 7-bit addresses,
so the correct value is 0x24 (0x48 >> 1).

Also add parseI2CPath() to handle composite detection paths
(/dev/i2c-1:0x24) that the detection layer produces, and a hardware
validation script for testing on Raspberry Pi.
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

Successfully merging this pull request may close these issues.

1 participant