I know there are a lot of questions on this topic, and I've looked through a fair number of them. However I am still having problems. I started writing a test program for a prototype PCB, and now that it's grown to nearly 1000 lines I'm trying to break it up into libraries that I can use for particular functions. I thought this would be very simple. Make.c and.h files for each library that I need. I would have OLED.h and OLED.c for functions that control an OLED display.
Download and Install Studio 6 This works on Windows only. It's the official tool for programming AVR chips, but if you ask me, compared to Eclipse I find it rather unintuitive and awkward.
Copy the appropriate functions/definitions into each file. Then copy these files into the solution in Atmel Studio. I put them into the src folder under the project name. However, this doesn't work! I get an exceedingly long list of errors.
All of the things that are defined in the.h file are apparently undefined as far as the compiler is concerned. I also get many error messages of the type 'unknown type name int16_t/uint16_t/uint8_t/etc.' That part is really baffling to me. Why should it matter that functions are in an external library, now the compiler doesn't understand what those data types mean? So, this is probably a stupid problem to have. I don't want Atmel Studio to control my libraries by wrapping them up in some 'library project' or somethig, I want to put them in a folder of my choosing and add them when I need them.
I've searched for answers to this problem and I find long tutorials about changing the compiler settings for the project, the linker settings, etc. I tried this tutorial and still no dice: I also can't find a way to add something by right clicking the project and clicking 'Add.' It wants me to find.a files. The 'Add Library' dialog box in Atmel Studio is awful, it seems.
Surely it can't be that convoluted to just add a library to an existing project and have it function normally?! I've used PICs in the past and coming to Atmel I've found horrible documentation and a weird super-slick super-fly whizz bang interface that can't leave well enough alone and obfuscates simple function. What can I do to add these libraries? UPDATE: Seemed to answer my own question. Turns out I needed to include all of the libraries to recognize data types and whatnot into the.c file. I somehow assumed this only had to be done in the main file but obviously I was mistaken. Adding asf.h seems to work well as it includes all of the MCU specific port definitions/names and all of that.
All good for now!