Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit 5d06dec

Browse files
authored
Merge pull request #68 from arduino-cmake/platform-lib-example
Added platform lib example
2 parents 57994d9 + 74f4076 commit 5d06dec

File tree

5 files changed

+27
-5
lines changed

5 files changed

+27
-5
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ fabric.properties
118118

119119
### VisualStudioCode ###
120120
.vscode/*
121-
.vscode/settings.json
122121
!.vscode/tasks.json
123122
!.vscode/launch.json
124123
!.vscode/extensions.json
124+
!.vscode/cmake-kits.json
125125

126126
### VisualStudioCode Patch ###
127127
# Ignore all local history of files

cmake/Platform/Targets/PlatformLibraryTarget.cmake

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ endfunction()
2929
#=============================================================================#
3030
function(_add_platform_library _library_name _board_id)
3131

32-
find_library_header_files("${ARDUINO_CMAKE_PLATFORM_LIBRARIES_PATH}/${_library_name}/src"
33-
lib_headers)
34-
find_library_source_files("${ARDUINO_CMAKE_PLATFORM_LIBRARIES_PATH}/${_library_name}/src"
35-
lib_source_files)
32+
find_library_header_files("${ARDUINO_CMAKE_PLATFORM_LIBRARIES_PATH}/${_library_name}/src" lib_headers)
33+
find_library_source_files("${ARDUINO_CMAKE_PLATFORM_LIBRARIES_PATH}/${_library_name}/src" lib_source_files)
3634

3735
set(lib_sources ${lib_headers} ${lib_source_files})
3836

examples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ project(Examples LANGUAGES C CXX ASM)
44

55
add_subdirectory(hello-world)
66
add_subdirectory(arduino-library)
7+
add_subdirectory(platform-library)
78
add_subdirectory(3rd-party-library)
89
add_subdirectory(header-only-library)
910
add_subdirectory(blink-example)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cmake_minimum_required(VERSION 3.8.2)
2+
3+
project(Platform_Library)
4+
get_board_id(board_id nano atmega328)
5+
6+
add_arduino_executable(Platform_Library ${board_id} platformLibrary.cpp)
7+
8+
link_platform_library(Platform_Library Wire ${board_id})
9+
link_platform_library(Platform_Library SPI ${board_id})
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <Arduino.h>
2+
3+
void setup()
4+
{
5+
pinMode(LED_BUILTIN, OUTPUT);
6+
}
7+
8+
void loop()
9+
{
10+
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
11+
delay(1000); // wait for a second
12+
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
13+
delay(1000); // wait for a second
14+
}

0 commit comments

Comments
 (0)