Peter Fleury I2C Library

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

Greetings

 

Was just checking on this library. On the GitHub repository, there is a link to his home page. On the home page, which is at http://homepage.hispeed.ch/peterfleury/avr-software.html#libs there is an announcement in several languages which includes the following:

 

The "My Homepage" service was discontinued on 30.11.2019. The data can still be copied via FTP until 31.03.2020.

The repository is at https://github.com/alx741/avr_i2c

 

A question: I was considering porting this to Mega0 chips. What would be the "protocol"? Should I ask Peter? Or, is it sufficient to acknowledge in headers? Any other courtesy details to resolve?

 

Thanks

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

Due to how different the peripherals are on these, is a port a viable route to go or is it better to start from scratch, although most may find these app notes and code to be a good start: https://www.avrfreaks.net/forum/...

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

Last Edited: Mon. Jan 27, 2020 - 09:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Been through the Microchip appnotes. Zilch on TWI/I2C. It is as if they are afraid to try! I hope that SOMEONE at Microchip will attend to this significant deficiency.

 

There is, however, a nice library from Deiter Reinhardt for xTiny chips that looks like it will do the whole enchilada.

 

My original hope on the Fleury "library" was that it would "just" be a matter of renaming some registers, providing struct-style access, and maybe attending to a few additional new control conditions. Instead, I think that I'll dig through Deiter's code and see if it will run on the Mega0 devices.

 

Thanks

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

ka7ehk wrote:
My original hope on the Fleury "library" was that it would "just" be a matter of renaming some registers

I think you will find the mega TWI has a single interrupt vect used for both master and slave, where the AVR 0/1 has two vectors, one each for master/slave.

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

I understand that there are two interrupt vectors. Also, the BAUD register is different and there does not seem to be a prescaler. Have not done a side-by-side comparison to see what changes.

 

This got me to thinking, is there any sort of compiler flag for xMega and xTiny devices? It seems really awkward to have to test for each unique device number. Of course, one could do that test in a header and issue a #define that would be used to sort this out.

 

Jim

 

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

Yes,  you can test for XMEGA and for AVR8.   Read the docs for "predefined macros"

 

The Xmega, Xtiny peripherals are different to Mega.

 

But the Fleury functions are sensibly chosen and easy to use.   Just follow the same API.

 

Acknowledge Fleury for inspiration to implement the same functions for Xmega, Xtiny, ...

 

David.

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

Alert to the Arduino-Avoiders -

 

The Deiter Reinhardt library referenced above (at the bottom of https://www.avrfreaks.net/forum/...) appears to be compatible with Tiny0, Tiny1, and Mega1 chips BUT uses constructs such as  PORTB_set_pin_dir(0, PORT_DIR_OUT);  It should take very little to convert since this only happens in a few places and with seemingly obvious intent. But, it is there.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Mon. Jan 27, 2020 - 10:22 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:
What would be the "protocol"?

The applicable licence is:

Peter Fleury, in i2cmaster.h, wrote:

 @copyright (C) 2015 Peter Fleury, GNU General Public License Version 3

 

So it's GPL v3https://www.gnu.org/licenses/gpl-3.0.en.html

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Mon. Jan 27, 2020 - 10:41 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jim,

 

You should read the license.   Also, check LGPL 3.

 

From my understanding, if someone puts the Fleury code in a product they need to make available the source code for the product.   That would not be the case for a LGPL 3 license.

 

Matt

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

MattRW wrote:
read the license.  

It's GPL v3 - see #8.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

MattRW wrote:

read the license.  

 

It's GPL v3 - see #8.

 

#8 tells me that if you violate the license, you no longer are licensed to use the software, until you correct violations.

What did I miss?

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


#8 is where I showed that the applicable licence is GPL v3:

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If I match the API but don't copy the underlying code, does that violate GPL or LGPL?

 

Jim

 

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

GPL all hinges around the term "derivative work" so I challenge you to read an understand:  https://en.wikipedia.org/wiki/Derivative_work  and then decide if code that presented the same API but not the same implementation would constitute "derivative work".

 

Personally I can't tell so I would steer well clear of anything "GPL" though "LGPL" could be OK.

 

BTW if you are looking for TWI support for AVR-0/AVR-1 does "Start" really have nothing to offer?? (can't remember the licence but I think the Microchip one is very free for Start code as long as it's used with Microchip chips).

 

I've never looked at anything "X" in detail but other threads I've read here seemed to suggest that X/AVR0/1 implementation of TWI could be radically different to mega/(tiny) so I doubt this really is as simple as a register and bit renaming exercise. Someone with more experience would need to confirm that of course.

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

clawson wrote:
steer well clear of anything "GPL"

Oh dear - time to recant all those recommendations of the Fleury libraries, then ... ?

 

surprise

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


I once received a "cease and desist" order from the Free Software Foundation (don't ask!) so possibly know a little more about GPL, derivative work and so on than most ;-)

 

Anyway coming back to the original question I have to admit I don't actually know which models are AVR-0 and which are AVR-1 so almost completely at random I asked Start to make a project for mega4808 with I2C and it said:

 

 

I haven't gone through what it delivered in great depth but it certainly seems to have created something for me here!

 

As for "licence" it appears to have a "waffle, waffle, waffle" licence:

 

 

quite a few words, not saying very much. I kind of hoped to see words like "Microchip hereby grants you a licence to do this, this and that with this software" but see no such thing. Perhaps the whole start.atmel.com site has a more detailed description somewhere explaining the exact basis on which they give you this code?

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

Not that all these 'licenses' affect me really but.......

 

If I use something from someone that I found off the net I make sure to give them credit in the source file(s).  If the site looks for a donation to the server payments I donate.  Only fair.

 

But IMO once you put something on the net theres no protection/copyright.  You posted it for the world to see.  If you are so hung up on a License/copyright then you accept payment and send out a file.  But understand once you hand over that source code it's officially out there.  SOMEONE is gonna show the world.

 

With regards to START, and its generated code.  The whole purpose of START was to make code development easier....was Microchip actually thinking that the masses are only supposed to 'get an idea' on how to do the configurations from the generated source and then go roll ones own?  I don't think so.

 

At the same time, theres only so many ways you can configure a USART, or I2C and read/write to it.  Not hard to end up with two of the same routines with different names.

 

Same thing goes for code posted here.  For example, how many pages of code has Cliff banged out over the years and the recipient used for their homework or otherwise?  Does Cliff have a copyright where the recipient must adhere to a license?  Since the site is owned by The Overlords, do they have a license regarding posted code?

 

I guess in teh end it's up to the honesty of the person that has copy/pasted.

 

I'll go back under my rock now.

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

clawson wrote:
but not the same implementation would constitute "derivative work"

 

I use a derivative (of a derivative) of the Fleury UART library, which I turned into LGPL since GPL seems wrong. GPL, in my mind, is for the application, not the library. I am reasonably sure those functions were derived from Microsoft DOS serial libraries, so they required no effort for me to learn. If derivatives are a problem, then it may be that the real owner of this UART library is Microsoft.

 

Since I learned TWI somewhat on Arduino, those are my preferred functions (not the Wire wrapper, but the C stuff under it). They are LGPL, so that is as it should be.

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

A derivative of a derivative of a derivative of a derivative (ad infinitum) is still subject to the GPL at the start. If code starts that way you can't just drop it part way along the journey.

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

If bit-bang i2c is what you want, I recently started writing one.  It's still what I'd call beta, but so far it works OK with ssd1306 displays and i2c eeproms.

https://github.com/nerdralph/pic...

 

I have no special talents.  I am only passionately curious. - Albert Einstein

 

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

clawson wrote:
If code starts that way you can't just drop it part way along the journey

 

I guess I should know that I need to revert it to GPL, and then spin something else. The m4809 is probably a good opportunity to do so; it is different enough, and probably needs a new API anyway, then I can license it how I want.