I2C implementation for STM32

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: I2C implementation for STM32

Post by barthess »

Those bits cannot be cleared, may be you could mask the interrupt source instead?

I am already use interrupt source masking, but it could not completely solve the problem.

A dedicated thread does not look like a good idea considering that the whole point of having an asynchronous driver is to not have to use a dedicated thread for I/O.

Hmm... I have took this idea here http://chibios.org/dokuwiki/doku.php?id ... tos:wakeup
Whats better to do in callback function generally?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: I2C implementation for STM32

Post by Giovanni »

I was assuming you suggested to put a thread inside the driver as integral part of it, waking up an application thread from a callback is fine but this must be application code.

From callbacks you usually call other I-class functions which may wakeup a thread or invoke another HAL function.

I can't give you more specific suggestions until I'll have the time to study your implementation. Right now I am still working on the USB.

Giovanni
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: I2C implementation for STM32

Post by barthess »

Yes, this is application code. Inside that tread I have realized protocol to exchange data with accelerometer.
I can't give you more specific suggestions until I'll have the time to study your implementation

There is no need for now. Driver still in draft stage.

In ADC driver I have founded following code:

Code: Select all

#if ADC_USE_WAIT || defined(__DOXYGEN__)
  /**
   * @brief Waiting thread.
   */
  Thread                    *ad_thread;

Is there a pointer to application tread? When this tread must be waking up?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: I2C implementation for STM32

Post by Giovanni »

The ADC driver has both an asynchronous and an optional synchronous API, that field is used in synchronous mode, it is the thread that started the conversion and is waiting for completion.

Giovanni
redfox74
Posts: 21
Joined: Sat Feb 12, 2011 12:08 am

Re: I2C implementation for STM32

Post by redfox74 »

Dear Friends,
some news about i2c support ?
I try to use the code of Angelo , with the code write by Marko on his quadricopter but it's incompatible ...
What is the right reference for future development ?
Now I try to understand hwo to update the Marko quad code on your version of code 2.1.7 revision.
Giovanni what kind of version do you port on new revision of OS ? I have an a doubt about the i2c support is supported on MD and HD version of ST32 or only on MD now ? What is the file to update for support the HD ,too ?
Best
Roberto
redfox74
Posts: 21
Joined: Sat Feb 12, 2011 12:08 am

Re: I2C implementation for STM32

Post by redfox74 »

@Angelo,
Hi Angelo, i try your code , but there 're some things that is not clear ... i see that you use i2c2 on pb6 and pb7 ... but is not i2c2 but i2c1 ?
So I'm using STM32F103VE but i think that is the same on the other type of micro or not ? I compile your example code , but don't work .
Another strange things is that your revision of os 2.1.7 i don't see the data on UART4. I configure it and compile fine the code .. I'm using the same board with right configuration . MULTIPILOT32 board so the configuration is right .. I don't undertand what is the problem :(
Regards
Roberto
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: I2C implementation for STM32

Post by barthess »

Hi, Roberto.
You can try to use I2C driver from my branch
https://chibios.svn.sourceforge.net/svn ... es/i2c_dev
and send suggestions and bugs directly to me in this forum.
Low level part mostly done, but hi level part needs discussion.

I temporally stop driver development because I must to finalize all
I2C PCBs of my project. On this weekend I plan to resume development.
albi
Posts: 32
Joined: Mon Dec 13, 2010 9:18 pm
Has thanked: 1 time
Been thanked: 1 time

Re: I2C implementation for STM32

Post by albi »

Roberto you can also try my i2c driver,
you can download it from http://forum.chibios.org/phpbb/viewtopic.php?f=3&t=25&start=10#p222 post
It came with some example of usage in the projects subdir
It's only master and work only by interrupt, but work very well by two month, end also is well tested
and i can help you

good luck

Alberto
redfox74
Posts: 21
Joined: Sat Feb 12, 2011 12:08 am

Re: I2C implementation for STM32

Post by redfox74 »

Hi Barthess,
thank you very much for your support. What's the starting point revision of code for this branch ? Now I'm implementing the code on MP32 on revision 2.2.0 .
There're some example inside the branch ? In what kind of application are you using the i2c ?
Regards
Roberto
barthess wrote:Hi, Roberto.
You can try to use I2C driver from my branch
https://chibios.svn.sourceforge.net/svn ... es/i2c_dev
and send suggestions and bugs directly to me in this forum.
Low level part mostly done, but hi level part needs discussion.

I temporally stop driver development because I must to finalize all
I2C PCBs of my project. On this weekend I plan to resume development.
redfox74
Posts: 21
Joined: Sat Feb 12, 2011 12:08 am

Re: I2C implementation for STM32

Post by redfox74 »

redfox74 wrote:Hi Barthess,
thank you very much for your support. What's the starting point revision of code for this branch ? Now I'm implementing the code on MP32 on revision 2.2.0 .
There're some example inside the branch ? In what kind of application are you using the i2c ?
Regards
Roberto
barthess wrote:Hi, Roberto.
You can try to use I2C driver from my branch
https://chibios.svn.sourceforge.net/svn ... es/i2c_dev
and send suggestions and bugs directly to me in this forum.
Low level part mostly done, but hi level part needs discussion.

I temporally stop driver development because I must to finalize all
I2C PCBs of my project. On this weekend I plan to resume development.

Hi Barthess,
i try to compile the code but i have this problem when i try to compile :
../../os/hal/src/i2c.o: In function `i2cInit':
C:\Documents and Settings\Roberto\Desktop\lavoro\Multipilot32 Workspace\VROS-ChibiOS\ChibiOS_2.3.0-I2CDEV\Project\MP32-TESTPROGRAM/../../os/hal/src/i2c.c:57: undefined reference to `i2c_lld_init'
collect2: ld returned 1 exit status
make: *** [ch.elf] Error 1

I think that the branch code is broken .... or i'm using wrong example ... What's the correct example ? I don't found any doc inside the branch that explain how i can start to test i2c ... a simple demo ... :)
Regards
Roberto
Post Reply