Header files in AS7

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

This of course applies to the AVR related Studio.

 

I have just realised that, unlike AS4, there doesn't seem to be different section for header files and C files.

Looking at a START example I can see that they are thrown in together like this (my attempted port of a program)

 

 

AS4 has them separated, notice the separated folders for each

 

 

Obviously I don't get how to separate them, do I create the 2 folders and add files there?

 

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

In AS7 you can right click on the project name (e.g. GLCD test) or any folder and do Add / New Folder.

You can then move files into the new folder.

I usually add the *.h files directory into the path at Project / Properties / Toolchain / Compiler / Directories ...

David (aka frog_jr)

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

But they can be in the same project directory where the .atsln etc are located?? Maybe code_files and header_files directories?

 

I'll try it now as I have reduced the number of files to a minimum and commented out a lot of stuff.

 

Exciting, I have managed to "compile" the main file, now I'm starting to add other bits as I understand the difference between the LPC M0 hardware and the SAMD21, the first being more complicated as I didn't have 16 bits continuous for a 16 bit data bus so I had to write the data in 2 chunks.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

When I create a project, I typically check the "Create directory for solution" box, then all of the files are located in a directory under the one containing the .atsln file.

David (aka frog_jr)

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

DOOONGG fail! I can't add a preexisting directory but can add a new directory which I have done, one for each as above, but I can't open them even though I have put the files in there.

 

And of course Studio can't find main which is located in the code_files newly created directory.

I have added the path in Project / Properties / Toolchain / Compiler / Directories ... but no cigar

EDIT correct screen shot

 

 

 

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

Last Edited: Sat. Mar 11, 2017 - 04:42 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

check the "Create directory for solution" box, then all of the files are located in a directory under the one containing the .atsln file.

which what I have done, the 4 files with a x in the name are now in the 2 new folders for headers and code

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

When adding the directories to include,

David (aka frog_jr)

Last Edited: Sat. Mar 11, 2017 - 04:51 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I deleted the 2 copied and pasted paths and used the buttons using full path (unchecked relative path) , nothing

 

Restarted Studio, removed folders previously added and used button with relative path, , nothing, now the 2 folders no longer appear in the solution explorer anywhere and can't add a preexisting folder but only new folders and those files in the folder are not accessible from Studio to add to the projects.

 

Maybe I'll quit for now and go back to what I was doing before and simply add everything until things become a little clearer.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

I have my own directory structure system:

 

and my paths look like (I use relative paths):

I point to Source since board_defs.h has info on everything associated with this project (port/pin assignments, gclk sources & frequencies, peripheral multiplexer settings, baud rates).

 

Then Source/utils contains my common macros

 

In main.c I use:

   #include "board_defs.h"
   #include "timers/timers.h"
   #include "spi_lcd/spi_lcd.h"
   #include "usart/edbg_uart.h"
   #include "usb_if/usb_if.h"

 

David (aka frog_jr)

Last Edited: Sat. Mar 11, 2017 - 05:17 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK thanks, I'll try more things later on.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

In the solution explorer, there's a button called 'show all files' or similar. This will change the solution explorer from a project view to a file view (i.e it will show files/folders not in the project). You can then right-click and include full file-trees if you want.

 

As for not having implicit Headers and Files node, that's how we do it... The solution explorer shows the organization you want, not how some project systems sees it. How this is done varies between IDEs...

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

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

I get this with show all files, maybe I did not add the path correctly, I tried a couple of ways, same result.

 

 

having all the files together is not stopping me from what I'm trying to do.
 

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

I can't help thinking that space has something to do with it. I guess there is a space between "John" and "Samperi", but the name of the last folder is written with "%20".

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

I guess there is a space between "John" and "Samperi",

That's how the M$ gurus did it wink but there is also a space in the project folder name.

C:\Users\John Samperi\Documents\Atmel Studio\7.0\SAMD21\GLCD test

 

I can redo a new folder without the space for the project folder but can't do much about the name.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

I use the "relative path" and that eliminates some of the problems with odd chars in the early path. (Still keep project names with underscores rather than spaces.)

David (aka frog_jr)

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

 

 

Thanks js, this approach helped me to solve my issue (that is to include any .c file into solution hence project otherwise it was required to include it in c code within the main program with many definitions and functions)..

 

Emin Kulturel

 

 

regards