Kaynağa Gözat

init

master
Robin Thoni 7 yıl önce
işleme
8a69837564
6 değiştirilmiş dosya ile 2457 ekleme ve 0 silme
  1. 1
    0
      .gitignore
  2. 23
    0
      CMakeLists.txt
  3. 18
    0
      README.md
  4. 89
    0
      cmake/ArduinoToolchain.cmake
  5. 2304
    0
      cmake/Platform/Arduino.cmake
  6. 22
    0
      main.ino

+ 1
- 0
.gitignore Dosyayı Görüntüle

@@ -0,0 +1 @@
1
+/.idea

+ 23
- 0
CMakeLists.txt Dosyayı Görüntüle

@@ -0,0 +1,23 @@
1
+cmake_minimum_required(VERSION 2.8.4)
2
+set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/ArduinoToolchain.cmake)
3
+set(PROJECT_NAME arduinoProject)
4
+project(${PROJECT_NAME})
5
+
6
+set(${CMAKE_PROJECT_NAME}_BOARD nano328)
7
+set(${CMAKE_PROJECT_NAME}_PORT /dev/ttyUSB0)
8
+
9
+#nano
10
+#set(${CMAKE_PROJECT_NAME}_BOARD nano328)
11
+#set(${CMAKE_PROJECT_NAME}_PORT /dev/ttyUSB0)
12
+
13
+#mega
14
+#set(${CMAKE_PROJECT_NAME}_BOARD mega2560)
15
+#set(${CMAKE_PROJECT_NAME}_PORT /dev/ttyACM0)
16
+
17
+# /usr/share/arduino/hardware/arduino/boards.txt
18
+
19
+
20
+enable_language(ASM)
21
+
22
+set(${CMAKE_PROJECT_NAME}_SKETCH main.ino)
23
+generate_arduino_firmware(${CMAKE_PROJECT_NAME})

+ 18
- 0
README.md Dosyayı Görüntüle

@@ -0,0 +1,18 @@
1
+CMake Arduino starter kit
2
+=========================
3
+
4
+Here is starter kit for Arduino using CMake build system. The aim is be able to use CLion for Arduino development.
5
+
6
+Usage
7
+-----
8
+Just clone and open the directory with CLion, it will generate a target to build and upload code to the arduino.
9
+
10
+See CMakeLists.txt to configure on which device it should upload.
11
+
12
+So, you just have to set your device and build (do not run, just build, it will do the trick).
13
+
14
+Bonus
15
+-----
16
+A useful plugin to use with it is https://plugins.jetbrains.com/plugin/8031?pr=phpStorm
17
+
18
+It will add a serial monitor window to CLion.

+ 89
- 0
cmake/ArduinoToolchain.cmake Dosyayı Görüntüle

@@ -0,0 +1,89 @@
1
+#=============================================================================#
2
+# Author: Tomasz Bogdal (QueezyTheGreat)
3
+# Home:   https://github.com/queezythegreat/arduino-cmake
4
+#
5
+# This Source Code Form is subject to the terms of the Mozilla Public
6
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
7
+# You can obtain one at http://mozilla.org/MPL/2.0/.
8
+#=============================================================================#
9
+set(CMAKE_SYSTEM_NAME Arduino)
10
+
11
+set(CMAKE_C_COMPILER   avr-gcc)
12
+set(CMAKE_CXX_COMPILER avr-g++)
13
+
14
+# Add current directory to CMake Module path automatically
15
+if(EXISTS  ${CMAKE_CURRENT_LIST_DIR}/Platform/Arduino.cmake)
16
+    set(CMAKE_MODULE_PATH  ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR})
17
+endif()
18
+
19
+#=============================================================================#
20
+#                         System Paths                                        #
21
+#=============================================================================#
22
+if(UNIX)
23
+    include(Platform/UnixPaths)
24
+    if(APPLE)
25
+        list(APPEND CMAKE_SYSTEM_PREFIX_PATH ~/Applications
26
+                                             /Applications
27
+                                             /Developer/Applications
28
+                                             /sw        # Fink
29
+                                             /opt/local) # MacPorts
30
+    endif()
31
+elseif(WIN32)
32
+    include(Platform/WindowsPaths)
33
+endif()
34
+
35
+
36
+#=============================================================================#
37
+#                         Detect Arduino SDK                                  #
38
+#=============================================================================#
39
+if(NOT ARDUINO_SDK_PATH)
40
+    set(ARDUINO_PATHS)
41
+
42
+    foreach(DETECT_VERSION_MAJOR 1)
43
+        foreach(DETECT_VERSION_MINOR RANGE 5 0)
44
+            list(APPEND ARDUINO_PATHS arduino-${DETECT_VERSION_MAJOR}.${DETECT_VERSION_MINOR})
45
+            foreach(DETECT_VERSION_PATCH  RANGE 3 0)
46
+                list(APPEND ARDUINO_PATHS arduino-${DETECT_VERSION_MAJOR}.${DETECT_VERSION_MINOR}.${DETECT_VERSION_PATCH})
47
+            endforeach()
48
+        endforeach()
49
+    endforeach()
50
+
51
+    foreach(VERSION RANGE 23 19)
52
+        list(APPEND ARDUINO_PATHS arduino-00${VERSION})
53
+    endforeach()
54
+
55
+    if(UNIX)
56
+        file(GLOB SDK_PATH_HINTS /usr/share/arduino*
57
+            /opt/local/arduino*
58
+            /opt/arduino*
59
+            /usr/local/share/arduino*)
60
+    elseif(WIN32)
61
+        set(SDK_PATH_HINTS "C:\\Program Files\\Arduino"
62
+            "C:\\Program Files (x86)\\Arduino"
63
+            )
64
+    endif()
65
+    list(SORT SDK_PATH_HINTS)
66
+    list(REVERSE SDK_PATH_HINTS)
67
+endif()
68
+
69
+find_path(ARDUINO_SDK_PATH
70
+          NAMES lib/version.txt
71
+          PATH_SUFFIXES share/arduino
72
+                        Arduino.app/Contents/Java/
73
+                        Arduino.app/Contents/Resources/Java/
74
+                        ${ARDUINO_PATHS}
75
+          HINTS ${SDK_PATH_HINTS}
76
+          DOC "Arduino SDK path.")
77
+
78
+if(ARDUINO_SDK_PATH)
79
+    list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${ARDUINO_SDK_PATH}/hardware/tools/avr)
80
+    list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${ARDUINO_SDK_PATH}/hardware/tools/avr/utils)
81
+else()
82
+    message(FATAL_ERROR "Could not find Arduino SDK (set ARDUINO_SDK_PATH)!")
83
+endif()
84
+
85
+set(ARDUINO_CPUMENU)
86
+if(ARDUINO_CPU)
87
+    set(ARDUINO_CPUMENU ".menu.cpu.${ARDUINO_CPU}")
88
+endif(ARDUINO_CPU)
89
+

+ 2304
- 0
cmake/Platform/Arduino.cmake
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 22
- 0
main.ino Dosyayı Görüntüle

@@ -0,0 +1,22 @@
1
+#include <Arduino.h>
2
+
3
+#define ledPin 13
4
+
5
+void setup() {
6
+    pinMode (ledPin, OUTPUT);
7
+
8
+    digitalWrite (ledPin, LOW);
9
+}
10
+
11
+void delayMs(unsigned int ms)
12
+{
13
+    for (unsigned i = 0; i < ms; i++) {
14
+        delayMicroseconds(1000);
15
+    }
16
+}
17
+
18
+void loop() {
19
+
20
+    digitalWrite(ledPin, !digitalRead(ledPin));
21
+    delayMs(1000);
22
+}

Loading…
İptal
Kaydet