Help Needed with Peter Fleury I2C library

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

 

First off, thank you for taking you time to read this.

Now, I'm new to AVR studio 6.2 and I'm trying to get Peter Fleury i2c library to work.

 

I started out very simply:

1) A new project (c++) 

2) copied the .h and .S to the same directory as the .cpp

3) used the Solution Explorer to add both the i2cmaster.h and i2cmaster.S (I need the asm version)

4) modified the i2cmaster.S to map the pines that I am going to use.

5) modified the delay rutine to fit a 1.8432 cristal.

6) copied the example program in the i2cmaster.h

7) changed the #include <i2cmaster.h> to #include "i2cmaster.h"

8) build the project.

 

Then, I get a boatload of errors: 

Error    11    ld returned 1 exit status    collect2.exe    

Error    1    undefined reference to `i2c_init()

 

And so on for all the routines.

 

I've searched the forum for two days now and read all the posts, but all I  can figure out is that I'm missing a step to map the .h to the .S

 

Can someone please point out my mistake?

 

Thank you again

 

 

This topic has a solution.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

If you are writing a C++ project,   you need to tell it that the Fleury code is C.

 

Otherwise the linker can't find the mangled symbols.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you for you quick answer!

 

And ehhhh, how do I do that?

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

By the way, I forgot to mention that I get the same errors when I build the solution even if I don't include the .S file. 

Now, I can compile the i2cmaster.S asm file just fine on it's own, but I still can't figure out how to "connect" the i2cmaster.h to the i2cmaster.S

 

Last Edited: Mon. Sep 15, 2014 - 06:05 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 3

Have you actually added i2cmaster.S to the source files in Atmel Studios Solution Explorer?

 

There are a lot of things we might need to know. One easy way to give us lots of info, without us asking repeatedly for tidbits, is to show the complete build output. Do a clean, then a build, switch to the Output tab/pane, mark everything, copy it and paste it into a reply here.

 

If you are writing a C++ project,   you need to tell it that the Fleury code is C.

 ehhhh, how do I do that?

 In this particular case:

extern "C"
{
#include "i2cmaster.h"
}

For further information about 'extern "C"', search this site and Google it. If you get nowhere, ask again here.

 

 

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Mon. Sep 15, 2014 - 06:19 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you Johan,

 

You post solved my problem.

 

Have a great day and again, thank you for you time and knowledge (and no to mention patience)

 

Urant

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

Just for future readers that might have similar problems, what solved it (the "extern "C"" or the adding of the file to the project, or both)?

 

Also, I believe you can maybe  mark my post as a solution. This will rub my ego excellently, and possibly give me point in the future if this site becomes technically enabled to be a meritocracy. (I've never seen the solution marking mechanism myself - perhaps it is only visible to the user posing the original question...)

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It was the "extern "C" ". I had included the file to the project from the start, and only removed it to see if it changed anything.

 

Again, thank you 

 

Urant