Rockbox Technical Forums

Support and General Use => Plugins/Viewers => Topic started by: mssc on August 24, 2019, 10:55:39 AM

Title: Ipod i2c commands
Post by: mssc on August 24, 2019, 10:55:39 AM
Hi!
I'm planning on making this famous "bluetooth in ipod classic" mod in my own u2 5g. I don't like the idea of making holes in device housing, but I need a way to turn module and pairing mode on/off. My idea is to use some kind of i2c gpio expander (like SC16IS752), connect it to the ipods' i2c dataline (propably TEA1211 pins) and control it using rockbox plugin. I'm unsure whether plugin can even do something like this, I've found i2c_begin(), i2c_end() and i2c_write() functions in plugin.h but I don't know if they will work or not. Can someone from dev team shed light on this subject?
Title: Re: Ipod i2c commands
Post by: saratoga on August 24, 2019, 06:21:39 PM
Assuming you have access to an i2c line on the device, you could add whatever driver functions you wanted to the plugin API, or even just put the i2c code directly into your plugin.  On simple devices like the ipods there is no memory management unit, and hardware registers can be directly accessed by anything.
Title: Re: Ipod i2c commands
Post by: mssc on August 25, 2019, 05:58:51 AM
Great, I have one more question, how to interact with CPU register with plugin code? Is there even such functionality or I need to extend plugin library?
Title: Re: Ipod i2c commands
Post by: __builtin on August 25, 2019, 12:53:13 PM
Most registers are memory-mapped. See your target's header files. Ex: https://github.com/Rockbox/rockbox/blob/master/firmware/export/pp5020.h (https://github.com/Rockbox/rockbox/blob/master/firmware/export/pp5020.h)
Title: Re: Ipod i2c commands
Post by: mssc on August 26, 2019, 03:09:02 AM
Thanks, but how can I interact with these adresses using plugin code? Is it even possible or do I need to write additional middleware myself?
Title: Re: Ipod i2c commands
Post by: __builtin on August 26, 2019, 12:44:45 PM
You should be able to access them by name in C code. Like so:
Code: [Select]
GPIOA_ENABLE = 1;
Title: Re: Ipod i2c commands
Post by: saratoga on August 26, 2019, 11:08:12 PM
Take a look at the I2C driver for your device, should make it clear how it works.