I2C Slave mode support?

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

Moderators: RoccoMarco, lbednarz, utzig, tfAteba, barthess

User avatar
HDKLog
Posts: 41
Joined: Thu Aug 18, 2016 12:36 am
Been thanked: 2 times

Re: I2C Slave mode support?

Postby HDKLog » Thu Aug 18, 2016 1:34 am

Hello everybody !
I need I2C slave functionality of I2C HAL driver too and this post is what i found... I have tried to porting code provided by steved to Chibios 3.0 but I'm missing file "i2c_event.h" and i cant find it anywhere. can somebody upload it or maybe provide a link?
Thanks!

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

Re: I2C Slave mode support?

Postby steved » Thu Aug 18, 2016 8:14 am

That file shouldn't be necessary with the V3.0 drivers; its not in my libraries.

IIRC it was used with an optional layer of functionality which genosensor provided for the original V2.6 drivers; I never ported that bit.

User avatar
HDKLog
Posts: 41
Joined: Thu Aug 18, 2016 12:36 am
Been thanked: 2 times

Re: I2C Slave mode support?

Postby HDKLog » Thu Aug 18, 2016 5:24 pm

Thank you for quick replay!
In code provided by you on page 3 of this post you use function i2cSlaveAwaitEvent which i think is implemented in "i2c_event.h" file because i didn't found it anywhere else, I guess this function just check SR1 and SR2 register for any status changes but still wanted to see its implementation.

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

Re: I2C Slave mode support?

Postby steved » Thu Aug 18, 2016 9:21 pm

Edit: I think the latest is here: viewtopic.php?f=16&t=3020&p=23414#p23414
Will try and double check tomorrow.

It might be that the routine you're looking for had its name changed; you can always download genosensor's original code for 2.6 and have a look, since I haven't changed the structure significantly for 3.x

What processor are you using?

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

Re: I2C Slave mode support?

Postby steved » Fri Aug 19, 2016 8:32 am

I've attached the latest versions of the I2C drivers I'm using; any changes from earlier versions are pretty trivial, I think.
Both I2Cv1 and I2Cv2 drivers have been functioning 24/7 for several months without noticeable problems.
Attachments
I2C_Master_Slave.zip
I2C master and slave drivers
(43.77 KiB) Downloaded 320 times

User avatar
HDKLog
Posts: 41
Joined: Thu Aug 18, 2016 12:36 am
Been thanked: 2 times

Re: I2C Slave mode support?

Postby HDKLog » Fri Aug 19, 2016 1:05 pm

I use STM32F446RE and ChibiOS v 3.0.

I figured out that it use I2CDv1 LLD driver... looks like it is different from the version of your I2CDv1, I tried to port your code but stuck on i2c_lld_master_transmit_timeout, looks like it works differently in v 3.0

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

Re: I2C Slave mode support?

Postby steved » Fri Aug 19, 2016 1:38 pm

It should be possible to use my files without any porting - the I2CDv1 files are being used on an STM32F407, which should have the same I2C peripherals as the F446.
Might be worth comparing 'global' features such as interrupts on the two chips to see if they are handled differently.

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

Re: I2C Slave mode support?

Postby steved » Fri Aug 19, 2016 2:58 pm

I've found a test project for I2C slave using the Nucleo F401 - that should be pretty similar to your board.
Attachments
F401_Nucleo_I2C_Slave.zip
(20.18 KiB) Downloaded 300 times

User avatar
HDKLog
Posts: 41
Joined: Thu Aug 18, 2016 12:36 am
Been thanked: 2 times

Re: I2C Slave mode support?

Postby HDKLog » Sat Aug 20, 2016 12:50 pm

Thank you !
I'm using ChibiOS v3.0 and don't know if it will work there, will try to replace I2Cv1 driver...

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

Re: I2C Slave mode support?

Postby steved » Sat Aug 20, 2016 9:13 pm

All the stuff I've done is for ChibiOS 3.x (rather than 2.x).

It should be as simple as adding the new drivers into your ChibiOS directory (I think they are already structured correctly), overwriting existing files. Then create a project and use slave mode - start with the sample to check everything compiles, then convert to your processor.


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 8 guests