neděle 29. března 2020

CLion - how to create an Arduino Project



Using CLion cross platform IDE for Arduino project

29. 3. 2020
CLion ver 2019.3



The process of creating a new Arduino project:


1. CLion Menu -> File -> Settings -> Plugins:
- search and install plugins:

- Arduino  
  CLion Arduino Plugin v2
  (1.2.3 by Francois Campbell)
  
- Serial Port Monitor 
  (0.5.4  by Dmitry Cherkas)


2. CLion Menu -> File -> Settings -> Build, Extension, Deployment -> Toolchains:
- add or select MinGW 
- environment "C:\MinGW" (if not exist download and install MinGW with C++/C modules)


3. CLion Menu -> New arduino sketch project

 
4. Open the created project

 
5. Edit CMakeLists.txt (depends of arduino type):

a) NANO:
  5.1. Set nano specific params:

# set board nano (tested with the Arduino Nano clone)
set(${CMAKE_PROJECT_NAME}_BOARD nano)

# set port by real used COM value of connected device
set(${CMAKE_PROJECT_NAME}_PORT COM9)

# set mcu: atmega328p
set(nano.build.mcu atmega328p)

#set protocol: arduino
set(nano.upload.protocol arduino)

# set speed: 57600
set(nano.upload.speed 57600)

b) MEGA2560:
5.1. set Mega2560 specific params:

# set board Mega2560 (tested with the original board)
set(${CMAKE_PROJECT_NAME}_BOARD mega)

# set port by real used COM value of connected device
set(${CMAKE_PROJECT_NAME}_PORT COM16)

# set mcu: atmega2560
set(mega.build.mcu atmega2560)

#set protocol: wiring
set(mega.upload.protocol wiring)

# set speed: 115200
set(mega.upload.speed 115200)

5.2. Add line (path to arduino user library folder ):

LINK_DIRECTORIES(d:\\Users\\michal\\Arduino\\libraries)



6. Check or modify the cmake/ArduinoToolchain.cmake file - setexisting path to Arduino application folder:
For example, if real Arduino app path is "c:\programs\Arduino\":
  
from
  set(SDK_PATH_HINTS "C:\\Program Files\\Arduino"
  "C:\\Program Files (x86)\\Arduino"
)
to 
  set(SDK_PATH_HINTS 
  "C:\\Programs\\Arduino"
  "C:\\Program Files\\Arduino"
  "C:\\Program Files (x86)\\Arduino"
)


7. Click to CLion Menu -> Tools -> CMake -> Reload CMake Project


8. Done
 

Žádné komentáře:

Okomentovat