I2C Slave mode support?

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, utzig, tfAteba, barthess

nbon
Posts: 10
Joined: Fri Jan 23, 2015 2:56 pm

Re: I2C Slave mode support?

Postby nbon » Fri Jan 23, 2015 3:14 pm

Hello folks,
I've followed this post with attention.
I'm working on STM32F401 and very interested in ChibiOS, which seems to fit exactly my needs.
I have to use both I2C Master and I2C Slave on the same board.
What I understood is that I2C Slave isn't supported yet in official release (2.6.6).
I've tried the .zip file attached earlier in this topic, but it seems to be designed for the future 3.0 release, is it right ?
Does this mean that only ChibiOS developpers can try and troubleshoot the I2CSlave for now, or is there any way to have it integrated to a beta release of Chibi ?
Thank you for your work & help,
NB

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: I2C Slave mode support?

Postby Giovanni » Fri Jan 23, 2015 3:28 pm

Hi,

If you download ChibiStudio preview 8 you will find both 2.6.6 and 3.0.0. Alternatively you can get 3.0 from the repository.

3.0.0 is almost ready for release and it is usable right now.

Giovanni

nbon
Posts: 10
Joined: Fri Jan 23, 2015 2:56 pm

Re: I2C Slave mode support?

Postby nbon » Sun Mar 22, 2015 5:47 pm

Hi,
I'm getting i2c working, but i2cSlave mode remains a bit confusing to me, despite of the comments embedded in the code.
Would anyone have some lines of example on how to setup and use I2CSlaveMsg & callbacks for receiving & replying ?
This would be of great help ...
Thank you,
NB

genosensor
Posts: 65
Joined: Thu Oct 03, 2013 1:06 am
Location: Santa Cruz, California
Has thanked: 1 time
Been thanked: 1 time

Re: I2C Slave mode support?

Postby genosensor » Sun Mar 22, 2015 7:08 pm

I've attached examples of using the I2C slave API via low-level callbacks and via the i2cslave thread based API.

These examples both output status text via the DCC facilities of the STM microprocessors.
Start by cloning my git repo at: https://github.com/ChibiOS/ChibiOS-RT.git
checkout the I2Cmultimaster branch from that repo
Unzip the attached debugput.zip in the os/various subdirectory of that branch

Then, unzip the i2cslave.zip projects somewhere else.
You may have to alter the paths in their Makefiles.
They assume the chibios lives in $(HOME)/chibios
[ actually in $HOME/$(CHIBIOS) ]

I know that the latest versions of openocd support DCC output with gcc, but I'm not sure about other tools.
If the DCC stuff becomes a stumbling block for you, just alter the examples to use a dedicated serial port instead.

I'd recommend using the thread based API defined in i2cslave.h unless you are extremely memory constrained.
It is really a library built on top of the driver's low-level call back API.

All this is 2.6 based. I've not tested it on 3.0.
I've willing to help if you want to try to port it to 3.0.
Hope this helps.
Attachments
debugput.zip
Debugging output via ARM's DCC mechanism
google "arm dcc"
(6.16 KiB) Downloaded 264 times
i2cslave.zip
Updated I2C multimaster (master and slave) API examples
(15.38 KiB) Downloaded 318 times

steved
Posts: 825
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

Re: I2C Slave mode support?

Postby steved » Sun Mar 22, 2015 8:14 pm

I ported genosensor's routines to V3.0; they're linked to earlier in this thread. And they're working well on a 32F407.

What I haven't ported are his test programs.

nbon
Posts: 10
Joined: Fri Jan 23, 2015 2:56 pm

Re: I2C Slave mode support?

Postby nbon » Sun Mar 22, 2015 8:58 pm

Thank you for the quick reply.
I'm actually trying to use the i2cSlave with ChibiOS V3.0, as mentioned by steved. I'm running on 32F401.

The examples you're providing genosensor will run only under V2.6. I guess they won't help me a lot with 3.0.
Porting them to V3.0 would be a good idea, but I first have to understand how the things are working on V3.0.

genosensor
Posts: 65
Joined: Thu Oct 03, 2013 1:06 am
Location: Santa Cruz, California
Has thanked: 1 time
Been thanked: 1 time

Re: I2C Slave mode support?

Postby genosensor » Thu Dec 10, 2015 6:50 am

Found a bug today with I2C slave support.

During bus contention, the chip may generate a "BUSY" event.
The driver interprets this as an unknown error when it should just ignore it.
This results in its reporting spurious arbitration failures and "unknown" I2C errors then contention on the bus occurs.

I've updated my git repo with a fix for this at:

Code: Select all

    git clone https://github.com/brentr/ChibiOS-RT.git
    cd ChibiOS-RT
    git checkout I2Cmultimaster


The most important bit is to add this case to the big switch in i2c_llc_serve_event_interrupt():

Code: Select all

    case 0:   /* quietly ignore "uninteresting" events (i.e. i2c bus busy) */
 qEvt(0x0000);
     break;

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: I2C Slave mode support?

Postby Giovanni » Thu Dec 10, 2015 9:46 am

Is this on the I2Cv1 or I2Cv2 one?

Giovanni

genosensor
Posts: 65
Joined: Thu Oct 03, 2013 1:06 am
Location: Santa Cruz, California
Has thanked: 1 time
Been thanked: 1 time

Re: I2C Slave mode support?

Postby genosensor » Sat Dec 12, 2015 7:15 am

I'm only maintaining the I2Cv1 version under Chibios 2.6
Hopefully, user steved will be can port the fix to the versions he's maintaining.

steved
Posts: 825
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

Re: I2C Slave mode support?

Postby steved » Sat Dec 12, 2015 5:18 pm

genosensor wrote:Hopefully, user steved will be can port the fix to the versions he's maintaining.

It's on the list (at least, until I forget). Probably in the next couple of weeks.
Might not be necessary with I2CV2 - the interface does seem a lot simpler, to the point that I feel the current driver might be over-complicated.


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 8 guests