Commit graph

31 commits

Author SHA1 Message Date
dherrada
a489e58f48 Ran black, updated to pylint 2.x 2020-03-16 16:45:42 -04:00
Dan Halbert
edd71b8c31 Fix default end values. 2020-02-18 20:22:26 -05:00
Dan Halbert
99e9c32584 avoid allocations by avoiding **kwargs 2020-02-11 12:50:02 -05:00
Chris Osterwood
db586d272f Whitespace change to make pylint happy 2019-11-25 22:07:14 -05:00
Chris Osterwood
6635e40375 Fixed NameErrors caused by moving probing logic into private method 2019-11-25 21:37:47 -05:00
Chris Osterwood
e9459c70f4 Move probing logic into private method. Update comments and doc strings 2019-11-25 21:33:33 -05:00
Chris Osterwood
b726198499 Adding ability to skip device probing upon object init. Some hardware devices do not respond to these probes, or could be in reset when software object is created 2019-11-25 11:15:49 -05:00
Scott Shawcroft
401037a0cd
Change stop to False and throw error if True.
It will be removed from libraries and then from here.
See https://github.com/adafruit/circuitpython/issues/2082 for details.
2019-08-20 21:53:33 -07:00
Scott Shawcroft
15235e2acb
Remove debug param. It increases frozen and RAM by 800ish bytes. 2019-06-12 14:02:42 -07:00
Kattni Rembor
7aa7496fc5 Move write buffer debug print. 2019-02-08 15:27:33 -05:00
Kattni Rembor
d8a7033119 Update to uses slices. 2019-02-08 14:39:27 -05:00
Kattni Rembor
a519739ca6 Added debug to i2c_device. 2019-02-08 14:02:17 -05:00
Drew Fustini
aea9d07e8f Attempt to write then fall back to read for i2c detect
This approach was suggested by ladyada in
Adafruit_CircuitPython_BusDevice PR #22:
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice/pull/22#issuecomment-435209002

> ok tested with a plethora of sensors and the VEML6075 hates this
> so turns out you actually need something like....

    def __init__(self, i2c, device_address):
        """
        Try to read a byte from an address,
        if you get an OSError it means the device is not there
        """
        while not i2c.try_lock():
            pass
        try:
            i2c.writeto(device_address, b'')
        except OSError:
            # some OS's dont like writing an empty bytesting...
            # Retry by reading a byte
            try:
                result = bytearray(1)
                i2c.readfrom_into(device_address, result)
            except OSError:
                raise ValueError("No I2C device at address: %x" % device_address)
        finally:
            i2c.unlock()

        self.i2c = i2c
        self.device_address = device_address
2018-11-19 19:17:49 +00:00
Drew Fustini
793537e64b change the i2c init to just read 1 byte
it is not needed to read more than 1 byte just
to verify that the i2c device is present
2018-10-29 19:38:46 +00:00
Drew Fustini
796e0a1e35 modify i2c init to fix issue on BeagleBone
instead of writing a zero byte, try to read a byte from an address
if you get an OSError it means the device is not there

this fixes issue for BealgeBone Black in Adafruit_Blinka
https://github.com/adafruit/Adafruit_Blinka/pull/42
2018-10-29 18:59:31 +00:00
Drew Fustini
3a1339cb71 Fix I2C init error on BeagleBone Black
This init method verifies that a device exists at the given address.

It was writing a zero byte value to the bus.  This triggered a
bug in the Linux kernel I2C bus OMAP2 driver for the BeagleBone.
The driver returns an invalid write error when msg->len is 0:
https://github.com/beagleboard/linux/blob/4.14/drivers/i2c/busses/i2c-omap.c#L665

The solution is to write the value 'x' instead of ''.

Refer to Adafruit_Blinka PR #42 for more information:
https://github.com/adafruit/Adafruit_Blinka/pull/42#issuecomment-431948703
2018-10-22 20:49:42 +00:00
ladyada
c6e79549b0 Circuitpython requires this or it type-errors 2018-08-17 23:55:56 -04:00
ladyada
2e653c0bc4 specifically name arguments now that we require it 2018-08-17 23:34:15 -04:00
ladyada
9a164067f5 force labeling of extra args 2018-08-17 14:19:47 -04:00
ladyada
6dcbe4bf33 pylint fix & a typo 2018-08-17 13:58:05 -04:00
ladyada
9d82293ad1 add write_then_readinto support for linux (and possibly others!) 2018-08-17 13:41:10 -04:00
sommersoft
b23eaf5cfd updated title docstrings 2018-03-05 17:45:25 -06:00
Scott Shawcroft
c459a7d05e Update to new build process and turn on lint.
I haven't tested these changes on device yet. Please only merge you test it or I follow up later to say its tested.

For https://github.com/adafruit/circuitpython/issues/475
2017-12-08 12:08:08 -08:00
mrmcwethy
be325b94a3 remove deprecated method read_into 2017-11-15 15:07:34 -08:00
Michael McWethy
8a662c543d Added readinto() method to be more consistant with busdevice.spi. (#10)
Added warning on read_into() saying it will be deprecated in the future
2017-11-05 14:43:06 -08:00
Scott Shawcroft
6a20bf8383 Use busio after nativeio split. 2017-04-10 14:06:44 -07:00
Scott Shawcroft
0021da236d Remove to and from from read and write methods because address isn't an argument.
Fixes #4.
2017-04-10 14:06:33 -07:00
Radomir Dopieralski
143df8695b Don't scan the whole bus to verify existence of i2c device
Instead of sending an empty write request to every possible address on
the but to see which devices respond, send it only to the one address
that we are checking. This is not only much faster and more robust
(there might be devices on the bus that respond badly to such requests
at the wrong speed) but also makes it much easier to debug things with a
logic analyzer, as it doesn't get flooded with all those requests.
2017-01-28 22:16:56 +01:00
Scott Shawcroft
9c27f6dcd3 Make a note on the classes that they aren't built in and provide a link to installation instructions. 2017-01-13 17:04:16 -08:00
Scott Shawcroft
fc7b805466 Polish the docs for ReadTheDocs 2017-01-05 17:44:19 -08:00
Scott Shawcroft
bdc4fd7bed First version of I2CDevice 2016-12-01 18:34:46 -08:00