Arduino library.zip

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

Has anyone managed to extract some of the nice libraries, or at least the files that some arudino libraries are dependant on out of the arduino core files?

I have now got a nice development envrioment set up that I am pleased with.
I have Notepad++ setup with macros to compile with avr-g++, and currently I am using avrstudio to program the hex because I cant figure out the correct command for using avrispmkII with AvrDude - I cant work out what port it should be on.

But my real question is how can I use certain arduino libraries for instance this one:
[url]
http://arduino.cc/playground/Int...
[/url]
I am not bothered about controlling pins with bitwise operations and I dont need the arduino serial libraries etc, but I can not for the life of me get that library to be happy talking with the program. I tried just taking the server (sending) example and getting it to play ball but it just wont.
googling this kind of thing and it seems notoriously hard to extract the files needed to be able to use arduino libraries independantly of arduino.

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

I read this a couple of times and looked at the library in question and I'm still not certain what you are asking.

If you use the Arduino libraries as intended, no problem. If you want to port them to something else, then you must somehow port all the lower level library dependencies which require drilling down and looking at each lower level until you get to the bottom. I've ported some Arduino libraries and due to the inherent Arduino inefficiencies I've wound up just porting the API and rewriting the lower level stuff with more efficient functions. That isn't really all that hard if you are already experienced programming AVRs, but I can't imagine someone trying to port these libraries who doesn't have that skill set.

Can you provide more details about what you are trying to do and why you are trying to do it? What have you done that works and what doesn't work?

What am I missing?

Smiley

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

Well Im not bothered about serial.print, or digitalWrite, or analogRead or anything like that, its purely some of the libraries that dont come as standard. In fact I dont want the nrf24L01 library to be reliant on the other "arduino" libraries, but what i do like about it is its simplicity and i havent found a C library that i can get to work - a lot of people say they have got that one working.
Do you have a standard set of libraries - like a template that you use when you start a project (not using the arduino enviroment?)

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

As far as I can see the only part of the main Arduino library infrastructure that code uses is SPI() so it should be pretty simple to simply cut that out of the library code. However in looking at this code I noticed something awfully suspicious. The constructor has:

Nrf24l::Nrf24l(){
	cePin = 8;
	csnPin = 7;
	channel = 1;
	payload = 16;
	spi = NULL;
}

That setting of 'spi' to NULL is something I might have expected to see in the destructor, not the constructor?

If the goal here is simply to find code for the Nordic module have you tried Sparkfun:

https://www.sparkfun.com/product...

Notice all the links under "Documents"

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

Yeah, I saw those thanks Clawson, but the problem is they are for pic and mbed controllers. I have been looking for code for 8 bit avrs - the reason I dont want to convert it is because if I know the code already works, and I cant get it to work, then I can blame problems on my hardware setup...If I start adjusting code then I may build a problem in...

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

Quote:

but the problem is they are for pic and mbed controllers.

Yeah but all micros are almost identical. It doesn't take much more than a glance at a datasheet to see how one differs from another. Remember that the only hardware peripheral being used here is SPI, the very simplest of all micro peripherals, I'd be pretty astonished if it's really radically different in a PIC or mbed or whatever.

Did you have any success in contacting Leon Heller as I suggested by PM?

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

I found some contact details for him - his CV is on google, however he never replied. Maybe being banned meant he no longer wants to work with AVR's....

Well Im trying to really understand SPI anyway, so changing the code over from PIC to AVR is resulting in me just trying to work out why the version of SPI library I have is hanging in the loop. In this code here:

    SPDR = data;
    while((SPSR & (1<<SPIF)) == 0);
    return SPDR;

Im finding myself just trying to understand what could stop SPSR & (1<<SPIF) ===1.
Is this most likely a hardware problem? It sounds to me like one

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

Quote:

Is this most likely a hardware problem? It sounds to me like one

There's a nasty gotcha when using SPI in that if you are configuring the AVR as a master but the _SS pin is left as a floating input or is even pulled low the AVR switches from master to slave mode so that writing to SPDR no longer triggers the generation of eight SCK pulses and SPIF is never set because the transfer never happens. So make sure _SS is set as output or is tied high if an input.

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

Yeah, you taught me that when we were dealing with FatFs... I have this line that should cover me on that:

    DDR_SPI &= ~( (1<<SPI_MOSI) | (1<<SPI_MISO) | (1<<SPI_SS) | (1<<SPI_SCK) );
    DDR_SPI |= ( (1<<SPI_MOSI) | (1<<SPI_SS) | (1<<SPI_SCK) );
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

a.mlw.walker wrote:
Do you have a standard set of libraries - like a template that you use when you start a project (not using the arduino enviroment?)
I wrote a couple of articles about SPI and put them on my blog at:
http://smileymicros.com/blog/cat...
These mostly use the Butterfly but have some information on using the SPI with the Arduino Board - NOT the Arduino libraries. This may be of interest to you.

Smiley