Arduino in pure C

I tried to do this by compiling the Arduino libraries into my own standalone library and contacting the project in Eclipse, but there were several problems along the way.

Is there any worthy guide on how to do this? It was hard for me to find one online that really works ... There are a few flaws in the arduino.cc manual, and troubleshooting has put me in trouble.

I am on Mac OS X 10.5 with a Uno board.

Edit: It may be worth noting that most Arduino C manuals do not indicate the required transfer rate, but only the MCLK frequency (16 MHz). Make sure you change this or AVRDude does not understand how to start your IC.

+6
source share
2 answers

Arduino will not work in a clean C setup, as this requires a C ++ compiler. However, if you want to include the arduino kernel and other libraries inside your project, then read it. Here we see how to use the Arduino Ethernet Library with our code.

STEP BY STEP

  • Get Arduino Kernels and Options / Files.
  • Get the appropriate library, for example. Ethernet Arduino Library.
  • Directory structure

    • /
      • Library / Arduino / Cores
      • Library / Arduino / options // pins_arduino.h
      • Library / Arduino / Makefile
      • Library / Arduino / build
      • Library /
  • Sample file can be downloaded from: https://gist.github.com/rjha/b7cda6312552c3e15486

  • First create the Arduino core as a static library. For this:

    • $ cd to lib / arduino folder
    • $ make clean
    • $ make lib
  • This will create a static library file lib / arduino / build / libarduino.a.

  • Next, we move on to the main project Makefile project. There we can define any Arduino library, for example. Arduino SPI or Arduino Ethernet as the target that will compile with the Arduino core library.

  • Inside our own target, we can include the Arduino Target, which in turn includes the Arduino core.

For example (7) and (8) see this meaning

https://gist.github.com/rjha/e7b123d3dc4346b5830c

(9) when creating hexadecimal and general links, use the -larduino link and save libarduino.a in the PATH search engine. @see above Gist for an example.

(10) Using this structure, you can use any Arduino libraries inside your own code.

Most Arduino libraries are mutant dependencies, and the quality of the code is also poor. The only advantage is that you can get ready-made libraries for links to your code.

0
source

Source: https://habr.com/ru/post/905805/


All Articles