Products > Embedded Computing

importing arduino "sketch" to Microchip Studio

<< < (6/7) > >>

Simon:
OK, I got it, that is a list of the libraries that depend on this one, not really useful, I need to know what other libraries this one depends on. If i look at the api documentation page I get a list of files, do I need these? I mean it's not like someone is intentionally not very well documenting this stuff are they. It seems everywhere I go to involving programming assumes I know something but no one explains the stuff that apparently I should know already from some secret source!

westfw:

--- Quote ---The specific chip is irrelevant to the discussion. We were talking about how to open the Arduino code in Microchip studio.
--- End quote ---
My experience (limited) with the Studio "Import Arduino Sketch" is that it works pretty well for Official AVR-based Arduino boards, but is pretty questionable on the SAMD boards (even the Arduino official SAMD boards.)  And it may be pretty hopeless on 3rd party boards/packages :-(

AFAIK, this feature was added to Studio back during the infancy of the current Board and Library management system, and has not been very actively maintained :-(



--- Quote ---I don'n know C++ yet so have some books on the way
--- End quote ---
Unfortunately, most C++ books are likely to send you off in unproductive directions, if your goal is to understand Arduino/embedded C++.
(Not unlike C books, if you want to write embedded C.)


--- Quote ---I believe one of the big potential pitfalls of the Arduino is that it tries to have a uniform usage on many different micro controllers.
--- End quote ---
Silly me.  I thought platform independence was a good thing, most of the time.


--- Quote ---// Arduino.h should properly define PROGMEM, PGM_P, strcpy_P, pgm_read_byte, pgm_read_ptr
--- End quote ---
PROGMEM, strcpy_P, etc, are the special functions for AVR's Harvard architecture to access data in flash memory.  They're completely unnecessary on ARM CPUs, but it "would be nice" for them to be aliased for backward compatibility.  Many Arduino non-AVR platforms do that.


--- Quote ---// if any this becomes unnecessary as platforms improve, please send a pull req.
--- End quote ---
"Pull Request" is a github thing.  This is approximately "if you fix this, let us know what you did."



--- Quote ---there does not seem to be a well defined way to have a program in multiple files in the arduino "IDE".
--- End quote ---
There is, although I don't know whether the Microchip Studio continues to follow it.
Multiple .ino files are concatenated into a single file, which then goes through arduino "pre-processing" to generate prototypes and derive library paths.
Assembler, C and C++ (.S, .c, .cpp) files are compiled individually and "normally"; that means they need their own prototypes to allow forward references, plus "extern" declarations (even in the .ino files), and probably at least "#include <Arduino.h>" to pull in the Arduino definitions.
So you can split a .ino file into multiple .ino files relatively easily, but extracting some of the code into .cpp files will require more effort.

Simon:

--- Quote from: westfw on October 10, 2021, 08:19:42 pm ---

--- Quote ---I believe one of the big potential pitfalls of the Arduino is that it tries to have a uniform usage on many different micro controllers.
--- End quote ---
Silly me.  I thought platform independence was a good thing, most of the time.


--- End quote ---

Yes providing it does not introduce bugs and make a mess of things. I have come across a a few funnies in the little amount I have used arduino and prefer to be truly platform independant not locked to some system. Right now I spend more time trying to work out what is what than just looking at programming the thing.

I tried making everything an ino file but it fell over. So is the ino file like a C file, so I create an accompanying header file for each for function prototypes? if so why all the bat shit crazy stuff on arduino forums about how to do it? that is why I do not like it, everyone is suddenly an expert and the ones that do most the talking are the ones doing it wrong!

Nusa:
You might find this useful: https://arduino.github.io/arduino-cli/0.19/sketch-build-process/

From a user viewpoint, ino files are cpp files with the usual stuff like function prototypes added in preprocessing and arduino.h included at the top before it's handed to the usual compiler. Makes it very easy for newbies to get off the ground with no h file required.

The arduino-style setup() loop() structure is implemented by the default main() that looks very much like (it's in main.cpp in the core, if you want to find it):

--- Code: ---int main(void){
  init(); // init hardware timers, etc
  setup(); // user setup function
  for(;;){
    loop(); // user run function
  }
  return 0;
}
--- End code ---
If you provide your own main(), it'll override the default one and you can do what you want. Remember to still call init() or otherwise initialize stuff.

Simon:
So I have created a new project in studio and added the files from SDfilesystem and FATfilesystem on the mbed website. The empty project compiles file using over 5kB of RAM so I assume that these files were compiled in and all is fine. Now I just need to work out what to do with them.....

Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version