Need I2C Driver

Discussion about writing software for VS1005 and the VSOS Operating System. Also posts about VS1005-related hardware design and device drivers should be posted here.
Post Reply
Passionate Jaguar
Senior User
Posts: 69
Joined: Sun 2014-05-04 9:17

Need I2C Driver

Post by Passionate Jaguar » Mon 2016-12-05 1:48

Hello Panu,

You had mentioned in a distant past post that you had written an I2C driver for the VS1005. Is that driver available?

Could you list known modifications that would be needed for compatibility with the current VSOS. It is not necessary to interface to the UART driver as I have already implemented a bare bones customized one that I must adapt it to.

Right now, we will configure a battery management chip during startup and shutdown, periodically inquire for battery status display, and upon interrupt, handle low battery conditions. It does, however, need to be MIPS efficient as it will be called while endode/decode runs. We run these display tasks from within the main task during known windows of opportunity so as to not disturb the already MIPS-stressed machine.

EDIT: Oh, yes, and if it just happens to use the Debug Bus, I would not need to modify other VS1005 drivers.

This will make a great VS1005 library addition as, inevitably, someone here will think of another new necessity right after the boards come back from fabrication.

Thanks,
Scott
VS1005 Demo Board v1.8, custom designed VS1005 boards, with VSOS 3.43 - VSIDE v2.42

User avatar
Panu
VLSI Staff
Posts: 2418
Joined: Tue 2010-06-22 13:43

Re: Need I2C Driver

Post by Panu » Mon 2016-12-05 12:09

Hi!

Right, I've written several I2C implementations for various ICs... Which pins do you want to use for SCL, SDA?
...need to be MIPS efficient...
As per spec, the I2C is very slow bus (400 kHz) but in reality most ICs can perform faster than this...

-Panu
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo, VLSI Solution Oy

Passionate Jaguar
Senior User
Posts: 69
Joined: Sun 2014-05-04 9:17

Re: Need I2C Driver

Post by Passionate Jaguar » Mon 2016-12-05 14:14

Hi Panu,
Which pins do you want to use for SCL, SDA?
TDO for SDA and TCK for SCK. That would work fine.

By MIPS efficient, I would prefer not to use Delays and such where a timer and/or interrupt would potentially minimize delays to the Main task. You have already mentioned these types of things when discussing most drivers on the forum. Also, code optimization for execution speed would be handy. I am offloading everything not relevant to audio DSP, decoding, encoding, reading and writing audio files to/from storage, etc. to hardware external to the VS1005. Ran out of code space and MIPS. And still need to add some DSP routines for sound processing!
the I2C is very slow bus
No problem, relatively speaking. Only "real time" process that happens during encoding/saving tasks is reading a register occasionally to make sure there is enough battery to finish recording..., or warn the user to plug it in. I am planning to use TDI for receiving an "Impending Battery Doom" interrupt from the chip, also. Hopefully, it will be fast enough to not interrupt audio encoding. I looked for an SPI controlled chip but did not find the functions I needed.

EDIT: By the way, the chip is a MAX17043 Fuel Gauge.

Let me know if there is anything I have left out.

Thanks,
Scott
VS1005 Demo Board v1.8, custom designed VS1005 boards, with VSOS 3.43 - VSIDE v2.42

User avatar
Henrik
VLSI Staff
Posts: 1041
Joined: Tue 2010-06-22 14:10

Re: Need I2C Driver

Post by Henrik » Mon 2016-12-12 11:04

Hello Scott,

how fast does the I2S driver need to be? By "fast" I don't mean CPU cycles but I2S bitspeed. The reason I am asking is that if you are ok with an uneven I2S speed of 100-1000 bits/s, then it would be possible to use the Cyclic process method to implement it. That would use up very little CPU and not very much code space either.

Kind regards,
- Henrik
Good signatures never die. They just fade away.

Passionate Jaguar
Senior User
Posts: 69
Joined: Sun 2014-05-04 9:17

Re: Need I2C Driver

Post by Passionate Jaguar » Tue 2016-12-13 0:04

Hello Henrik,
it would be possible to use the Cyclic process method to implement it. That would use up very little CPU and not very much code space either.
Yes, this is what I had thought of. I already use the Cyclic process for handling other processes for the same reason. Note that this is for an I2C driver which can run at any slow speed to transfer only a few bytes every 10 seconds or even less often. I'm only using it for periodic battery level check (fuel gauge) and do not want to disrupt audio dsp and recording.

I am already using a Cyclic process for decode while reading/writing to the Nand Flash. So every few hundred NF block cycles, I could alter (interleave) the read battery charge data byte on I2C. It would be like adding another "hand" to the mechanical watch, each set to its own "gear".

The only data on I2C consists of sending a command byte to the chip to request charge level, and the chip returns a single byte to report the charge status. Not much data. Your idea would work perfectly.

Thanks,
Scott
VS1005 Demo Board v1.8, custom designed VS1005 boards, with VSOS 3.43 - VSIDE v2.42

Passionate Jaguar
Senior User
Posts: 69
Joined: Sun 2014-05-04 9:17

Re: Need I2C Driver

Post by Passionate Jaguar » Sun 2017-06-04 6:09

Hi,

Our custom boards are up and running. Any ideas on when the I2C driver may be ready.?

Thanks,
Scott
VS1005 Demo Board v1.8, custom designed VS1005 boards, with VSOS 3.43 - VSIDE v2.42

User avatar
Panu
VLSI Staff
Posts: 2418
Joined: Tue 2010-06-22 13:43

Re: Need I2C Driver

Post by Panu » Mon 2017-06-05 17:35

Hi!

Hmmh, the last thing I did with I2C was to implement I2C boot for VS1010...

Ok, I exported the i2c files from that project into a new VS1005 solution. I wonder if you could test if it does anything useful. It compiles, but I have no way of testing if it works or even does anything worth mentioning. What it tries to do is read a byte from an I2C EEPROM and print its contents.

There's a header file, i2cp2.h which defines the IO pin mappings. The code assumes that they are GPIO1 pins, because the code uses the bit router engine in the peripheral controller to make very efficient code. If you want to use GPIO2 pins instead (as I suppose you want), you'll have to change the rest of the code to access GPIO2 controller registers instead of GPIO1 controller.

Code: Select all

// I2C Pin Mappings: I2C pins are assumed to be in GPIO1.
#define SDA_PIN_GPIO1 0 /* SDA is GPIO1[0] (MOSI0) */
#define SCL_PIN_GPIO1 2 /* SCL is GPIO1[2] (SCLK0) */
I know it's far from finished code, sorry about that. But let's take this step by step, we'll get there in the end.

Thanks for your help!

-Panu
Attachments
arch-i2cRead05-2017-06-05-18-29-test1.zip
Experimental I2C test code
(7 KiB) Downloaded 18 times
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo, VLSI Solution Oy

Passionate Jaguar
Senior User
Posts: 69
Joined: Sun 2014-05-04 9:17

Re: Need I2C Driver

Post by Passionate Jaguar » Tue 2017-06-06 7:57

Hi, Panu,

Thanks for the update and code. I will give it a go.
I know it's far from finished code, sorry about that. But let's take this step by step, we'll get there in the end.
No worries. I've observed this process on the USB directory work in the past and am not concerened. Just needed a good starting point. My battery gauge is much simpler to operate than most and requires very little interaction with the host.

Thanks for the code. I'll let you know when I trip myself up.

Scott
VS1005 Demo Board v1.8, custom designed VS1005 boards, with VSOS 3.43 - VSIDE v2.42

Post Reply

Who is online

Users browsing this forum: Baidu [Spider]