contrib-drivers icon indicating copy to clipboard operation
contrib-drivers copied to clipboard

I have a device similar to i2c interface, but it is not a standard protocol like i2c. What should I do

Open jmying opened this issue 7 years ago • 10 comments

t 2g pqeix 1rq7 h roq q

I need to control the clock and IO data myself

jmying avatar Nov 19 '18 05:11 jmying

How to independently control SCK and sdio on raspberry pi

jmying avatar Nov 19 '18 05:11 jmying

The best option is to open a bunch of GPIO ports on the Pi and bit-bang on the clock and data lines through software.

Fleker avatar Nov 19 '18 17:11 Fleker

There are examples?

jmying avatar Nov 19 '18 23:11 jmying

I don't think there's an example for Android Things. It'd be tough to have a good example, as you'd have to do it for every specific subformat that exists.

Fleker avatar Nov 20 '18 01:11 Fleker

I think GPIO for java can't do that. SDIO and SCLK can be control by ndk ?

jmying avatar Nov 20 '18 02:11 jmying

@jmying The driver for TM1637 displays is bit-banging kind of a I2C protocol over custom GPIOs (using Java), I guess that is exactly what you'll want: https://github.com/androidthings/contrib-drivers/blob/master/tm1637/src/main/java/com/google/android/things/contrib/driver/tm1637/I2cBitBangDevice.java

nohum avatar Nov 20 '18 10:11 nohum

@nohum thanks ~

jmying avatar Nov 20 '18 12:11 jmying

and thanks @Fleker

jmying avatar Nov 21 '18 01:11 jmying

@nohum Can you help me again I also need to read and delay operations using android things gpio

jmying avatar Nov 21 '18 06:11 jmying

Depending on what you mean with "delay" you could either

  • sleep via SystemClock.sleep(10) (for e.g. 10ms) or
  • you could register a GpioCallback via PeripheralManager.getInstance().openGpio() to be notified if your GPIO changes (and then do something with that information).

If you go with option one just pay attention that you do not sleep on the main thread as this will stall the whole app.

nohum avatar Nov 21 '18 19:11 nohum