Skip to content

Commit 7873aa7

Browse files
committed
PIO Arduino example
1 parent b094843 commit 7873aa7

File tree

7 files changed

+174
-3
lines changed

7 files changed

+174
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.pio
2+
.vscode/.browse.c_cpp.db*
3+
.vscode/c_cpp_properties.json
4+
.vscode/launch.json
5+
.vscode/ipch
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
This directory is intended for project header files.
3+
4+
A header file is a file containing C declarations and macro definitions
5+
to be shared between several project source files. You request the use of a
6+
header file in your project source file (C, C++, etc) located in `src` folder
7+
by including it, with the C preprocessing directive `#include'.
8+
9+
```src/main.c
10+
11+
#include "header.h"
12+
13+
int main (void)
14+
{
15+
...
16+
}
17+
```
18+
19+
Including a header file produces the same results as copying the header file
20+
into each source file that needs it. Such copying would be time-consuming
21+
and error-prone. With a header file, the related declarations appear
22+
in only one place. If they need to be changed, they can be changed in one
23+
place, and programs that include the header file will automatically use the
24+
new version when next recompiled. The header file eliminates the labor of
25+
finding and changing all the copies as well as the risk that a failure to
26+
find one copy will result in inconsistencies within a program.
27+
28+
In C, the usual convention is to give header files names that end with `.h'.
29+
It is most portable to use only letters, digits, dashes, and underscores in
30+
header file names, and at most one dot.
31+
32+
Read more about using header files in official GCC documentation:
33+
34+
* Include Syntax
35+
* Include Operation
36+
* Once-Only Headers
37+
* Computed Includes
38+
39+
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
This directory is intended for project specific (private) libraries.
3+
PlatformIO will compile them to static libraries and link into executable file.
4+
5+
The source code of each library should be placed in a an own separate directory
6+
("lib/your_library_name/[here are source files]").
7+
8+
For example, see a structure of the following two libraries `Foo` and `Bar`:
9+
10+
|--lib
11+
| |
12+
| |--Bar
13+
| | |--docs
14+
| | |--examples
15+
| | |--src
16+
| | |- Bar.c
17+
| | |- Bar.h
18+
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
19+
| |
20+
| |--Foo
21+
| | |- Foo.c
22+
| | |- Foo.h
23+
| |
24+
| |- README --> THIS FILE
25+
|
26+
|- platformio.ini
27+
|--src
28+
|- main.c
29+
30+
and a contents of `src/main.c`:
31+
```
32+
#include <Foo.h>
33+
#include <Bar.h>
34+
35+
int main (void)
36+
{
37+
...
38+
}
39+
40+
```
41+
42+
PlatformIO Library Dependency Finder will find automatically dependent
43+
libraries scanning project source files.
44+
45+
More information about PlatformIO Library Dependency Finder
46+
- https://docs.platformio.org/page/librarymanager/ldf.html
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
; PlatformIO Project Configuration File
3+
; Please visit documentation to check options and examples
4+
; https://docs.platformio.org/page/projectconf.html
5+
6+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7+
8+
; Select here wich default environment build (comment and uncomment the line that is needed)
9+
10+
[platformio]
11+
default_envs = arduino_esp32 ; Build ESP32 with Arduino Framework
12+
;default_envs = arduino_esp8266 ; Build ESP8266 with Arduino Framework
13+
;default_envs = arduino_uno_atmega328 ; Build Arduino Uno with Arduino Framework
14+
;default_envs = arduino_mega_atmega2560 ; Build Arduino Mega with Arduino Framework
15+
;default_envs = arduino_nano_atmega168 ; Build Arduino Nano (atmega168) with Arduino Framework
16+
;default_envs = arduino_nano_atmega328 ; Build Arduino Nano (atmega328) with Arduino Framework
17+
;default_envs = arduino_micro_atmega32u4 ; Build Arduino Micro (atmega32u4) with Arduino Framework
18+
19+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20+
21+
[env]
22+
23+
24+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
25+
26+
; Arduino Build Configs
27+
28+
; ESP32 Arduino
29+
[env:arduino_esp32]
30+
31+
board = esp32dev
32+
framework = arduino
33+
34+
; ESP8266 Arduino
35+
[env:arduino_esp8266]
36+
37+
board = esp12e
38+
framework = arduino
39+
40+
; Arduino Uno (atmega328)
41+
[env:arduino_uno_atmega328]
42+
43+
board = uno
44+
framework = arduino
45+
46+
; Arduino Mega (atmega2560)
47+
[env:arduino_mega_atmega2560]
48+
49+
board = megaatmega2560
50+
framework = arduino
51+
52+
; Arduino Nano (atmega168)
53+
[env:arduino_nano_atmega168]
54+
55+
board = nanoatmega168
56+
framework = arduino
57+
58+
; Arduino Nano (atmega328)
59+
[env:arduino_nano_atmega328]
60+
61+
board = nanoatmega328
62+
framework = arduino
63+
64+
; Arduino Pro Micro (atmega32u4)
65+
[env:arduino_micro_atmega32u4]
66+
67+
board = micro
68+
framework = arduino
69+
;build_flags = -DUSBCON=1
File renamed without changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
This directory is intended for PlatformIO Unit Testing and project tests.
3+
4+
Unit Testing is a software testing method by which individual units of
5+
source code, sets of one or more MCU program modules together with associated
6+
control data, usage procedures, and operating procedures, are tested to
7+
determine whether they are fit for use. Unit testing finds problems early
8+
in the development cycle.
9+
10+
More information about PlatformIO Unit Testing:
11+
- https://docs.platformio.org/page/plus/unit-testing.html

platformio.ini

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ default_envs = espidf_esp32 ; Build ESP32 with ESP-IDF Framework
2626
; ESP32 ESP-IDF
2727
[env:espidf_esp32]
2828
29-
board = esp32-c3-devkitm-1
3029
framework = espidf
30+
board = esp32-c3-devkitm-1
3131
build_flags =
3232
-DLOG_LOCAL_LEVEL=ESP_LOG_INFO
3333
board_build.mcu = esp32c3
@@ -44,7 +44,7 @@ framework = arduino
4444

4545
; ESP8266 Arduino
4646
[env:arduino_esp8266]
47-
platform = espressif8266@3.0.0
47+
platform = espressif8266@3.2.0
4848
board = esp12e
4949
framework = arduino
5050

@@ -74,7 +74,7 @@ framework = arduino
7474

7575
; Arduino Pro Micro (atmega32u4)
7676
[env:arduino_micro_atmega32u4]
77-
platform = atmelavr
77+
platform = atmelavr@3.3.0
7878
board = micro
7979
framework = arduino
8080
;build_flags = -DUSBCON=1
@@ -87,6 +87,7 @@ framework = arduino
8787
[env:linux]
8888
8989
build_flags =
90+
-O0
9091
-lpthread
9192

9293
; Windows

0 commit comments

Comments
 (0)