rust-embedded / rust-i2cdev

Rust library for interfacing with i2c devices under Linux
Apache License 2.0
207 stars 53 forks source link

Re: TODO: figure out what this magic is in nunchuck.rs #2

Closed ghost closed 9 years ago

ghost commented 9 years ago

Greetings, you've put a lot of work in over the long weekend! The "magic" is sort of a magic number you can find defined in the peripherals documentation. Usually you have to find the chipset documentation to find out what these magic numbers are. They are typically found en-masse under a "Hardware Register" section in their respective development documentation.

The init sequences themselves vary from chip to chip, often you will have to instruct the kernel to wait for the chipset to reset itself, the documentation will tell you all of this. I do not know about the nunchuck as I only have worked with a different chipset but I'd guess init sequence 1 is the initial addressing to the wii's operating system setting up the file descriptor and what not, while init sequence 2 prepares the chipset for polling.

Sorry I am unable to help with syntax and semantics but that's the "magic" in a nutshell. "Hardware Registers" should bring you to the proper wiki page. If you'd like a chipsets registers implemented let me know it's the least I can do for the smbus FFI you've provided.

posborne commented 9 years ago

Thanks for the info. I gathered roughly as much from the examples and documentation but didn't feel like digging deeply into the docs as things appeared to be working.

I'm going to move toward releasing a crate now that the API is starting to gel and be usable. I'm hoping to put together a second example that let's me hit the SMBUS code (I have a little sensor network put together that should do the trick). Then I will release add some docs and release 0.1.