Jan Rychter

Tiny asynchronous I2C driver

Discussion created by Jan Rychter on Dec 17, 2014

I wrote a tiny driver that allows you to access I2C (IIC, I²C, or I squared C) on Freescale Kinetis microcontrollers. It works asynchronously (interrupt-driven), supports repeated start (restart) and does not depend on any large software framework.

 

It isn't anything particularly great, but I couldn't find anything like it (Kinetis SDK is nowhere near done, unfortunately), so I wrote my own and I thought I'd share the code. It is MIT-licensed, which means you can do pretty much anything you want with it.

 

It is not a fully-featured driver. Only master mode is implemented. Only 7-bit addressing is supported. Addressing is fully manual: it is your responsibility to shift the 7-bit I2C address to the left and add the R/W bit (actually, I see this as an advantage). There is almost no error handling.

 

Find it on the Kinetis I2C Driver page, or go directly to the GitHub repo with the code.

 

Enjoy!

 

--Jan (@jrychter on Twitter)

Outcomes