Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I2C scanner #59

Open
andrewtholt opened this issue May 21, 2020 · 4 comments
Open

I2C scanner #59

andrewtholt opened this issue May 21, 2020 · 4 comments

Comments

@andrewtholt
Copy link

Hi,

Not so much an issue, as a question.

micropython and amforth both (and Linux) have a mechanism for 'scanning' an i2c bus and reporting on what it finds. I was wondering if anybody had already written such a thing for cforth ?

Regards,
Andrew

@MitchBradley
Copy link
Owner

I never bothered to create such a tool because it is so easy to write #127 0 do i (some I2c command) loop

@quozl
Copy link
Collaborator

quozl commented May 21, 2020 via email

@andrewtholt
Copy link
Author

Thanks for the advice. I like the simple approach. I guess something like:

#127 do i
read address 0
test for ACK if
i . cr
then
loop
;

@MitchBradley
Copy link
Owner

Something like that. It depends on how the I2C interface library is structured. At the protocol level, all you have to do is send a start followed by the address byte, then look for ack, then issue i2c stop to get back to idle. That level of control might or might not be possible in some libraries, but for any library there will be some simple op that will return a flag or throw an error if you get no ack. I have, in the past, attempted to create a standardized interface, but lately I have tended to mimic whatever is available in the SDK I am using on the particular system.

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

No branches or pull requests

3 participants