fknittel / rtc_ds3234

Userspace SPI driver for RTC DS3234 written in Python for use with Rasberry Pi / BeagleBone
MIT License
0 stars 0 forks source link

Bitbang support? #1

Open geotheory opened 8 years ago

geotheory commented 8 years ago

Thanks for sharing. Some of this codebase looks quite close to my project requirement. I have an Intel Edison with SPI bitbang capacity and a DS3234 RTC I want to connect to it. Do you know what changes I might need to make to get this working? I've got a seperate bitbang SPI connection working over Sparkfun's Edison Pi block, which utilises MRAA and Adafruit_GPIO libraries.. Cheers.

fknittel commented 8 years ago

Adafruit_Python_GPIO looks like a nice library. As far as I can tell from a quick look, it would provide abstractions for improved portability of the rtc_ds3234 tool and therefore might allow bitbang SPI. (Although I haven't checked whether the abstractions provide all necessary features, I'd assume so.)

First step would be to refactor hwclock-spi: Split the rtc-code from the low-level SPI code (spi_ioctl_write, _read_data, all occurences of os.write, open_spi) and replace access to the low-level SPI code with a reference to Adafruit_GPIO.SPI.SpiDev or Adafruit_GPIO.SPI.BitBang.

(Looking at the code, there's quite a lot of refactoring potential even without porting in mind... And a few too many magic constants.)

Unfortunately, I don't have the RTC + beagleboard at hand, so I can't currently test any changes.

Cheers, Fabian

geotheory commented 8 years ago

Thanks Fabian. If I get the chance to test this method I'll report results here.