Still very new to AVR embedded C programming with Atmel Studio 7 and running into a steep learning curve. It seems Atmel Software Framework (ASF) is supposed to be the way to quickly get functionality with abstracted programming schemes, but I find ASF bewildering. My frame of reference is something like Arduino or (without hardware) Matlab -- Matlab's documentation is incredible and it's easy to look up all aspects of the language, functionalities available, and how to use them. When I look for something similar for ASF, I usually don't find what I'm looking for or get even more confused than I was before. Am I missing something?
Let's take an example: I want to do some USART communication and see my MCU's output on terminal. So in Atmel Studio I start a new Example Project and find one called "USART Example - UC3C-EK". This evaluation kit and project are set up for the AT32UC3C0512C and I have a custom board with AT32UC3C1512C - very similar. When I change the "device" (to my MCU), I get a warning saying "ASF does not support device change since some of the existing modules in the project may not work." ...that seems like a major difficulty with using example projects, but ok. When I look at the main code in the example project, I see there are tons of pin definitions for different devices, like this:
#elif BOARD == UC3C_EK # define EXAMPLE_USART (&AVR32_USART2) # define EXAMPLE_USART_RX_PIN AVR32_USART2_RXD_0_1_PIN
Let's say that I want to understand what these mean (crazy, right?). If I highlight anything, right click, and go to "View Help" it simply opens a web page for the Atmel Studio 7 Getting Started Guide, which is really about using the IDE itself, and has no reference anywhere in it to the language, macros, or functions of ASF. When I Google search for something like &AVR32_USART2 to see what it means and how it should be used, I get an ASF page like this, which seems pretty useless. If I then search from the main ASF documentation page, I will get something like this, which is a little more helpful but also makes some things very confusing, for example:
If I understand correctly, these are values that can be returned by some of the transmit/receive functions? Why are they all preceded by #define ?? Are these things really being defined? I wouldn't ever define them in my implementation, would I? Can you see how this is confusing?
Let's ignore that for now and say I want to edit the original example code to make it work with my MCU. If I right click on a pin definition and do "Goto Implementation" it takes me to the header file for the original MCU the example project was based on and shows the pin definition, which eventually is just a number, like 42. Having already changed the device of the project to my MCU, how do I make an implementation point to the header file for my MCU? Furthermore, where do I even find the header file for my MCU (or rather, how do I introduce it to my project)? If I start typing a new pin definition, the autocomplete ("Intellisense", I guess) populates a list of possible pins that it seems to be getting from a header file, but how do I change this to my MCU? Once I accept a suggestion, I can look at the implementation and it seems to have definitions for both the original MCU and mine:
Which raises the question: at compile time, which of those will it choose for the definition? How do I strip the references to the original board out of my project?
Clearly I have a lot of confusion here. Sorry if this sounds more like a general complain about ASF or Atmel studio, but I hope that answering some of these questions here will help other beginners as they find it. Thanks for the help.