Simple question - how do I include atmel studio into ardunio?

Sorry in advanced - I'm new here so I don't really know if this has been posted in the right place - so apologize if I've made any mistakes in asking this in the wrong place.

Basically - what I'm doing is converting USART0 into an SPI for the due. However the issue that I've run into is pretty basic. I don't know how to actually include the defines for the Sam3 chip, or even Atmel studio ext. (Sorry this is a basic question - but I'm really not familiar with the Arduino IDE - and I am using windows 10 so symbolic links are out of the question).

The exact code to do this more or less covered in this topic and was posted by [ard_newbie] - though it's just pointing it towards a different register group. The code is the conversion a little ways down in the post.

Here

The code is this:

void USART0Init(void) { // SPI Master

  // Output lines driven by the peripheral (MOSI, CS, SCK)
  PIOB->PIO_PDR |= PIO_PB25A_RTS0;        // CS
  PIOA->PIO_PDR |= PIO_PA17B_SCK0         // SCK
                   | PIO_PA11A_TXD0;      // MOSI
  PIOA->PIO_ABSR |= PIO_PA17B_SCK0;       // Peripheral type B

  // USART0 SPI Master
  PMC->PMC_PCER0 |= PMC_PCER0_PID17;       // USART0 power ON
  
  USART0->US_MR |= US_MR_USART_MODE_SPI_MASTER
                   | US_MR_CPOL       // CPOL = 1
                   | US_MR_CPHA       // CPHA = 1
                   | US_MR_CHRL_8_BIT
                   | US_MR_CLKO;
  USART0->US_BRGR = US_BRGR_CD(6); // Baud rate = 84MHz/6 = 14 MHz < 20 MHz
  USART0->US_CR = US_CR_RXEN       // Enable Receiver and Transmitter
                  | US_CR_TXEN;
}

I know that define tree comes from specifically the #include <component_pdc.h> and the <component_usart.h> that are found in atmel studio, and it's basic and straight forward. However the issue is I have no idea how to point my IDE towards this folder - or even the proper way to do it - or even if I should (the question is so simple that it's probably common sense in the community - so I've been unable to find how to actually do it).

obviously there's the brute force way of copy/pasting everything over to the libraries folder, however I'd like to avoid that if at all possible - and I'm sure that the community already has a library or something that handles this.

Basically - how do I include the standard defines for the hardware into the IDE in the proper way?

Have you tried
#include "full_path_to_.h_file"

Not a bad idea - however the code needs to be portable between machines - and it's one of the reasons I've been avoiding it if at all possible.

You either need to put the files in the same location on each machine or have a mechanism to let the sketch know where they are located

Why not put the libraries in the same folder as the sketch which would make it fully portable,. After all, you are going to copy the sketch to other machines anyway so why not copy the files with it in a single operation ?

Not a bad suggestion if I modify it slightly - what I've done is basically copy pasted the folder into the libraries folder - then basically am setting a .h file that puts all the dependencies in order properly. Because I can immediately reference this file - I can set it up that way but it's a little tedious to do.

If I had a command that basically told the linker/make file to "Look in these folders and sub folders" for dependencies I'd be laughing at this point.

Um. I'm pretty sure that they're already included. Arduino.h includes "chip.h" from "libsam", chip.h includes all the CMSIS and peripheral sub-definitions. If I paste your code snippet in to blink.ino and compile for Due, it all works fine with no additionsl include files.

For .cpp files in your sketch or in libraries, you should just do #include "Arduino.h" The IDE also already sets up the paths as appropriate.

Note that Due uses "libsam", which is sort-of "ASF 1.0", and documentation is difficult to find.

Westfw:

You have both saved my day and hours of work - at the same time I'm embarrassed that I overlook the obvious. That was so common sense it wasn't even funny.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.