orgua / OneWireHub

OneWire slave device emulator
GNU General Public License v3.0
343 stars 86 forks source link

implementation for DS2408 #17

Closed vytautassurvila closed 7 years ago

vytautassurvila commented 7 years ago

Quite naive implementation for DS2408. This PR:

The code was tested with following w1 masters:

#set all pins to 1 (xFF)
echo -e '\xFF' |dd of=/sys/bus/w1/devices/29-010000000000/output bs=1 count=1 

#get values for all pins
dd if=/sys/bus/w1/devices/29-010000000000/state bs=1 count=1 | hexdump

All tests were run with original DS2408 hooked on same 1wire bus. It was used to compare commands and responses

orgua commented 7 years ago

Nice work and thanks for documenting it so well!

orgua commented 7 years ago

i tested your code with the ds9490 and found that the internal states of the outputs have the wrong start-configuration. getPinState() reads the 0x41 from the initialization of DS2408_PIO_LOGIC_REG but my masters says the ports are written like set in DS2408_PIO_OUTPUT_REG (all ON). Toggling them overwrites DS2408_PIO_LOGIC_REG completely. Maybe we should switch get/set to use DS2408_PIO_OUTPUT_REG?

vytautassurvila commented 7 years ago

Nice catch. I had some pins of original DS2408 pulled up and it was producing start configuration based on those. So I copied the register value to code but it totally slipped my mind that I should get initial values with all pins left floating. Thanks for the library and keep up the good work!

orgua commented 7 years ago

once i had the datasheet open i extended the ds2408 a bit and made it work with my maxim-master. if you have time you could test the changes.

vytautassurvila commented 7 years ago

I tested your changes with another Arduino and BeagleBoneBlack - it works great. Thanks once again