From 004125a2ca451191554842fca8cc8220e1052e89 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 14 Dec 2015 19:50:50 +0200 Subject: [PATCH] Add support for Raspberry Pi WiringPi framework // Resolve #372 --- HISTORY.rst | 5 +- docs/frameworks/index.rst | 1 + docs/frameworks/wiringpi.rst | 62 +++++++++++++++ docs/platforms/native.rst | 45 ++++++++++- .../raspberrypi/wiringpi-blink/.gitignore | 1 + examples/raspberrypi/wiringpi-blink/.skiptest | 0 .../raspberrypi/wiringpi-blink/.travis.yml | 65 ++++++++++++++++ .../raspberrypi/wiringpi-blink/README.rst | 29 +++++++ .../raspberrypi/wiringpi-blink/lib/readme.txt | 38 ++++++++++ .../raspberrypi/wiringpi-blink/platformio.ini | 23 ++++++ .../raspberrypi/wiringpi-blink/src/blink.c | 48 ++++++++++++ .../raspberrypi/wiringpi-serial/.gitignore | 1 + .../raspberrypi/wiringpi-serial/.skiptest | 0 .../raspberrypi/wiringpi-serial/.travis.yml | 65 ++++++++++++++++ .../raspberrypi/wiringpi-serial/README.rst | 29 +++++++ .../wiringpi-serial/lib/readme.txt | 38 ++++++++++ .../wiringpi-serial/platformio.ini | 23 ++++++ .../wiringpi-serial/src/serialTest.c | 75 +++++++++++++++++++ platformio/__init__.py | 2 +- platformio/boards/raspberrypi.json | 53 +++++++++++++ .../builder/scripts/frameworks/wiringpi.py | 65 ++++++++++++++++ platformio/builder/tools/platformio.py | 38 ++++++---- scripts/docspregen.py | 16 ++++ tests/test_examples.py | 2 +- 24 files changed, 704 insertions(+), 20 deletions(-) create mode 100644 docs/frameworks/wiringpi.rst create mode 100644 examples/raspberrypi/wiringpi-blink/.gitignore create mode 100644 examples/raspberrypi/wiringpi-blink/.skiptest create mode 100644 examples/raspberrypi/wiringpi-blink/.travis.yml create mode 100644 examples/raspberrypi/wiringpi-blink/README.rst create mode 100644 examples/raspberrypi/wiringpi-blink/lib/readme.txt create mode 100644 examples/raspberrypi/wiringpi-blink/platformio.ini create mode 100644 examples/raspberrypi/wiringpi-blink/src/blink.c create mode 100644 examples/raspberrypi/wiringpi-serial/.gitignore create mode 100644 examples/raspberrypi/wiringpi-serial/.skiptest create mode 100644 examples/raspberrypi/wiringpi-serial/.travis.yml create mode 100644 examples/raspberrypi/wiringpi-serial/README.rst create mode 100644 examples/raspberrypi/wiringpi-serial/lib/readme.txt create mode 100644 examples/raspberrypi/wiringpi-serial/platformio.ini create mode 100644 examples/raspberrypi/wiringpi-serial/src/serialTest.c create mode 100644 platformio/boards/raspberrypi.json create mode 100644 platformio/builder/scripts/frameworks/wiringpi.py diff --git a/HISTORY.rst b/HISTORY.rst index 387714aa..52bda7be 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,9 +4,12 @@ Release History PlatformIO 2.0 -------------- -2.5.1 (2015-12-??) +2.6.0 (2015-12-??) ~~~~~~~~~~~~~~~~~~ +* Added support for Raspberry Pi `WiringPi `__ + framework + (`issue #372 `_) * Implemented Over The Air (OTA) upgrades for `Espressif `__ development platform. (`issue #365 `_) diff --git a/docs/frameworks/index.rst b/docs/frameworks/index.rst index e1b2bd89..1aff07e4 100644 --- a/docs/frameworks/index.rst +++ b/docs/frameworks/index.rst @@ -23,3 +23,4 @@ Frameworks libopencm3 mbed spl + wiringpi diff --git a/docs/frameworks/wiringpi.rst b/docs/frameworks/wiringpi.rst new file mode 100644 index 00000000..004a7ff2 --- /dev/null +++ b/docs/frameworks/wiringpi.rst @@ -0,0 +1,62 @@ +.. Copyright 2014-2015 Ivan Kravets + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +.. _framework_wiringpi: + +Framework ``wiringpi`` +====================== +WiringPi is a GPIO access library written in C for the BCM2835 used in the Raspberry Pi. It's designed to be familiar to people who have used the Arduino "wiring" system. + +For more detailed information please visit `vendor site `_. + +.. contents:: + +Boards +------ + +.. note:: + * You can list pre-configured boards by :ref:`cmd_boards` command or + `PlatformIO Boards Explorer `_ + * For more detailed ``board`` information please scroll tables below by horizontal. + +Raspberry Pi +~~~~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``raspberrypi_1b`` + - `Raspberry Pi 1 Model B `_ + - BCM2835 + - 700 MHz + - 524288 Kb + - 524288 Kb + + * - ``raspberrypi_2b`` + - `Raspberry Pi 2 Model B `_ + - BCM2836 + - 900 MHz + - 1048576 Kb + - 1048576 Kb + + * - ``raspberrypi_zero`` + - `Raspberry Pi Zero `_ + - BCM2835 + - 1000 MHz + - 524288 Kb + - 524288 Kb diff --git a/docs/platforms/native.rst b/docs/platforms/native.rst index ba4864d0..8094d0bc 100644 --- a/docs/platforms/native.rst +++ b/docs/platforms/native.rst @@ -17,4 +17,47 @@ Native development platform is intended to be used for desktop OS. This platform For more detailed information please visit `vendor site `_. -.. contents:: \ No newline at end of file +.. contents:: + +Boards +------ + +.. note:: + * You can list pre-configured boards by :ref:`cmd_boards` command or + `PlatformIO Boards Explorer `_ + * For more detailed ``board`` information please scroll tables below by + horizontal. + +Raspberry Pi +~~~~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``raspberrypi_1b`` + - `Raspberry Pi 1 Model B `_ + - BCM2835 + - 700 MHz + - 524288 Kb + - 524288 Kb + + * - ``raspberrypi_2b`` + - `Raspberry Pi 2 Model B `_ + - BCM2836 + - 900 MHz + - 1048576 Kb + - 1048576 Kb + + * - ``raspberrypi_zero`` + - `Raspberry Pi Zero `_ + - BCM2835 + - 1000 MHz + - 524288 Kb + - 524288 Kb diff --git a/examples/raspberrypi/wiringpi-blink/.gitignore b/examples/raspberrypi/wiringpi-blink/.gitignore new file mode 100644 index 00000000..e90612ed --- /dev/null +++ b/examples/raspberrypi/wiringpi-blink/.gitignore @@ -0,0 +1 @@ +.pioenvs \ No newline at end of file diff --git a/examples/raspberrypi/wiringpi-blink/.skiptest b/examples/raspberrypi/wiringpi-blink/.skiptest new file mode 100644 index 00000000..e69de29b diff --git a/examples/raspberrypi/wiringpi-blink/.travis.yml b/examples/raspberrypi/wiringpi-blink/.travis.yml new file mode 100644 index 00000000..b57f6fa8 --- /dev/null +++ b/examples/raspberrypi/wiringpi-blink/.travis.yml @@ -0,0 +1,65 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < http://docs.platformio.org/en/latest/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < http://docs.platformio.org/en/latest/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < http://docs.platformio.org/en/latest/userguide/cmd_ci.html > +# +# +# Please choice one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to by used as a library with examples +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# +# script: +# - platformio ci --lib="." --board=TYPE_1 --board=TYPE_2 --board=TYPE_N diff --git a/examples/raspberrypi/wiringpi-blink/README.rst b/examples/raspberrypi/wiringpi-blink/README.rst new file mode 100644 index 00000000..c6a571ca --- /dev/null +++ b/examples/raspberrypi/wiringpi-blink/README.rst @@ -0,0 +1,29 @@ +.. Copyright 2014-2015 Ivan Kravets + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO `_ +2. Download `source code with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platformio-develop/examples/raspberrypi/wiringpi-blink + + # Process example project + > platformio run + + # Run program + > .pioenvs/raspberrypi_2b/program diff --git a/examples/raspberrypi/wiringpi-blink/lib/readme.txt b/examples/raspberrypi/wiringpi-blink/lib/readme.txt new file mode 100644 index 00000000..b06c9408 --- /dev/null +++ b/examples/raspberrypi/wiringpi-blink/lib/readme.txt @@ -0,0 +1,38 @@ + +This directory is intended for the project specific (private) libraries. +PlatformIO will compile them to static libraries and link to executable file. + +The source code of each library should be placed in separate directory, like +"lib/private_lib/[here are source files]". + +For example, see how can be organised `Foo` and `Bar` libraries: + +|--lib +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| |--Foo +| | |- Foo.c +| | |- Foo.h +| |- readme.txt --> THIS FILE +|- platformio.ini +|--src + |- main.c + +Then in `src/main.c` you should use: + +#include +#include + +// rest H/C/CPP code + +PlatformIO will find your libraries automatically, configure preprocessor's +include paths and build them. + +See additional options for PlatformIO Library Dependency Finder `lib_*`: + +http://docs.platformio.org/en/latest/projectconf.html#lib-install + diff --git a/examples/raspberrypi/wiringpi-blink/platformio.ini b/examples/raspberrypi/wiringpi-blink/platformio.ini new file mode 100644 index 00000000..e295bad2 --- /dev/null +++ b/examples/raspberrypi/wiringpi-blink/platformio.ini @@ -0,0 +1,23 @@ +# +# Project Configuration File +# +# A detailed documentation with the EXAMPLES is located here: +# http://docs.platformio.org/en/latest/projectconf.html +# + +# A sign `#` at the beginning of the line indicates a comment +# Comment lines are ignored. + +# Simple and base environment +# [env:mybaseenv] +# platform = %INSTALLED_PLATFORM_NAME_HERE% +# framework = +# board = +# +# Automatic targets - enable auto-uploading +# targets = upload + +[env:raspberrypi_2b] +platform = native +framework = wiringpi +board = raspberrypi_2b diff --git a/examples/raspberrypi/wiringpi-blink/src/blink.c b/examples/raspberrypi/wiringpi-blink/src/blink.c new file mode 100644 index 00000000..c27a20e3 --- /dev/null +++ b/examples/raspberrypi/wiringpi-blink/src/blink.c @@ -0,0 +1,48 @@ +/* + * blink.c: + * Standard "blink" program in wiringPi. Blinks an LED connected + * to the first GPIO pin. + * + * Copyright (c) 2012-2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include + +// LED Pin - wiringPi pin 0 is BCM_GPIO 17. + +#define LED 0 + +int main (void) +{ + printf ("Raspberry Pi blink\n") ; + + wiringPiSetup () ; + pinMode (LED, OUTPUT) ; + + for (;;) + { + digitalWrite (LED, HIGH) ; // On + delay (500) ; // mS + digitalWrite (LED, LOW) ; // Off + delay (500) ; + } + return 0 ; +} diff --git a/examples/raspberrypi/wiringpi-serial/.gitignore b/examples/raspberrypi/wiringpi-serial/.gitignore new file mode 100644 index 00000000..e90612ed --- /dev/null +++ b/examples/raspberrypi/wiringpi-serial/.gitignore @@ -0,0 +1 @@ +.pioenvs \ No newline at end of file diff --git a/examples/raspberrypi/wiringpi-serial/.skiptest b/examples/raspberrypi/wiringpi-serial/.skiptest new file mode 100644 index 00000000..e69de29b diff --git a/examples/raspberrypi/wiringpi-serial/.travis.yml b/examples/raspberrypi/wiringpi-serial/.travis.yml new file mode 100644 index 00000000..b57f6fa8 --- /dev/null +++ b/examples/raspberrypi/wiringpi-serial/.travis.yml @@ -0,0 +1,65 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < http://docs.platformio.org/en/latest/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < http://docs.platformio.org/en/latest/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < http://docs.platformio.org/en/latest/userguide/cmd_ci.html > +# +# +# Please choice one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to by used as a library with examples +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# +# script: +# - platformio ci --lib="." --board=TYPE_1 --board=TYPE_2 --board=TYPE_N diff --git a/examples/raspberrypi/wiringpi-serial/README.rst b/examples/raspberrypi/wiringpi-serial/README.rst new file mode 100644 index 00000000..fbcc9f28 --- /dev/null +++ b/examples/raspberrypi/wiringpi-serial/README.rst @@ -0,0 +1,29 @@ +.. Copyright 2014-2015 Ivan Kravets + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO `_ +2. Download `source code with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platformio-develop/examples/raspberrypi/wiringpi-serial + + # Process example project + > platformio run + + # Run program + > .pioenvs/raspberrypi_2b/program diff --git a/examples/raspberrypi/wiringpi-serial/lib/readme.txt b/examples/raspberrypi/wiringpi-serial/lib/readme.txt new file mode 100644 index 00000000..b06c9408 --- /dev/null +++ b/examples/raspberrypi/wiringpi-serial/lib/readme.txt @@ -0,0 +1,38 @@ + +This directory is intended for the project specific (private) libraries. +PlatformIO will compile them to static libraries and link to executable file. + +The source code of each library should be placed in separate directory, like +"lib/private_lib/[here are source files]". + +For example, see how can be organised `Foo` and `Bar` libraries: + +|--lib +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| |--Foo +| | |- Foo.c +| | |- Foo.h +| |- readme.txt --> THIS FILE +|- platformio.ini +|--src + |- main.c + +Then in `src/main.c` you should use: + +#include +#include + +// rest H/C/CPP code + +PlatformIO will find your libraries automatically, configure preprocessor's +include paths and build them. + +See additional options for PlatformIO Library Dependency Finder `lib_*`: + +http://docs.platformio.org/en/latest/projectconf.html#lib-install + diff --git a/examples/raspberrypi/wiringpi-serial/platformio.ini b/examples/raspberrypi/wiringpi-serial/platformio.ini new file mode 100644 index 00000000..e295bad2 --- /dev/null +++ b/examples/raspberrypi/wiringpi-serial/platformio.ini @@ -0,0 +1,23 @@ +# +# Project Configuration File +# +# A detailed documentation with the EXAMPLES is located here: +# http://docs.platformio.org/en/latest/projectconf.html +# + +# A sign `#` at the beginning of the line indicates a comment +# Comment lines are ignored. + +# Simple and base environment +# [env:mybaseenv] +# platform = %INSTALLED_PLATFORM_NAME_HERE% +# framework = +# board = +# +# Automatic targets - enable auto-uploading +# targets = upload + +[env:raspberrypi_2b] +platform = native +framework = wiringpi +board = raspberrypi_2b diff --git a/examples/raspberrypi/wiringpi-serial/src/serialTest.c b/examples/raspberrypi/wiringpi-serial/src/serialTest.c new file mode 100644 index 00000000..0d6da5f0 --- /dev/null +++ b/examples/raspberrypi/wiringpi-serial/src/serialTest.c @@ -0,0 +1,75 @@ +/* + * serialTest.c: + * Very simple program to test the serial port. Expects + * the port to be looped back to itself + * + * Copyright (c) 2012-2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include +#include + +#include +#include + +int main () +{ + int fd ; + int count ; + unsigned int nextTime ; + + if ((fd = serialOpen ("/dev/ttyAMA0", 115200)) < 0) + { + fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ; + return 1 ; + } + + if (wiringPiSetup () == -1) + { + fprintf (stdout, "Unable to start wiringPi: %s\n", strerror (errno)) ; + return 1 ; + } + + nextTime = millis () + 300 ; + + for (count = 0 ; count < 256 ; ) + { + if (millis () > nextTime) + { + printf ("\nOut: %3d: ", count) ; + fflush (stdout) ; + serialPutchar (fd, count) ; + nextTime += 300 ; + ++count ; + } + + delay (3) ; + + while (serialDataAvail (fd)) + { + printf (" -> %3d", serialGetchar (fd)) ; + fflush (stdout) ; + } + } + + printf ("\n") ; + return 0 ; +} diff --git a/platformio/__init__.py b/platformio/__init__.py index 7c330bb1..0e62f577 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (2, 5, "1.dev1") +VERSION = (2, 6, "0.dev0") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/boards/raspberrypi.json b/platformio/boards/raspberrypi.json new file mode 100644 index 00000000..9499b8a0 --- /dev/null +++ b/platformio/boards/raspberrypi.json @@ -0,0 +1,53 @@ +{ + "raspberrypi_1b": { + "build": { + "extra_flags": "-DRASPBERRYPI -DRASPBERRYPI1", + "f_cpu": "700000000L", + "mcu": "bcm2835" + }, + "frameworks": ["wiringpi"], + "name": "Raspberry Pi 1 Model B", + "platform": "native", + "upload": { + "maximum_ram_size": 536870912, + "maximum_size": 536870912 + }, + "url": "https://www.raspberrypi.org", + "vendor": "Raspberry Pi" + }, + + "raspberrypi_2b": { + "build": { + "core": "esp8266", + "extra_flags": "-DRASPBERRYPI -DRASPBERRYPI2", + "f_cpu": "900000000L", + "mcu": "bcm2836" + }, + "frameworks": ["wiringpi"], + "name": "Raspberry Pi 2 Model B", + "platform": "native", + "upload": { + "maximum_ram_size": 1073741824, + "maximum_size": 1073741824 + }, + "url": "https://www.raspberrypi.org", + "vendor": "Raspberry Pi" + }, + + "raspberrypi_zero": { + "build": { + "extra_flags": "-DRASPBERRYPI -DRASPBERRYPIZERO", + "f_cpu": "1000000000L", + "mcu": "bcm2835" + }, + "frameworks": ["wiringpi"], + "name": "Raspberry Pi Zero", + "platform": "native", + "upload": { + "maximum_ram_size": 536870912, + "maximum_size": 536870912 + }, + "url": "https://www.raspberrypi.org", + "vendor": "Raspberry Pi" + } +} diff --git a/platformio/builder/scripts/frameworks/wiringpi.py b/platformio/builder/scripts/frameworks/wiringpi.py new file mode 100644 index 00000000..7ef80892 --- /dev/null +++ b/platformio/builder/scripts/frameworks/wiringpi.py @@ -0,0 +1,65 @@ +# Copyright 2014-2015 Ivan Kravets +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +WiringPi + +WiringPi is a GPIO access library written in C for the BCM2835 used in the +Raspberry Pi. It's designed to be familiar to people who have used the Arduino +"wiring" system. + +http://wiringpi.com +""" + +from os.path import join + +from SCons.Script import DefaultEnvironment + +env = DefaultEnvironment() + +env.Replace( + CPPFLAGS=[ + "-O2", + "-Wformat=2", + "-Wall", + "-Winline", + "-pipe", + "-fPIC" + ], + + LIBS=["pthread"] +) + +env.Append( + CPPDEFINES=[ + "_GNU_SOURCE" + ], + + CPPPATH=[ + join("$BUILD_DIR", "FrameworkWiringPi") + ] +) + + +# +# Target: Build Core Library +# + +libs = [] +libs.append(env.BuildLibrary( + join("$BUILD_DIR", "FrameworkWiringPi"), + join("$PIOPACKAGES_DIR", "framework-wiringpi", "wiringPi") +)) + +env.Append(LIBS=libs) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index c9e82a22..6db8acfe 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -46,7 +46,10 @@ def BuildProgram(env): env.get("BUILD_FLAGS"), getenv("PLATFORMIO_BUILD_FLAGS"), ]) - env.BuildFramework() + + if env.get("FRAMEWORK"): + env.BuildFrameworks([ + f.lower().strip() for f in env.get("FRAMEWORK", "").split(",")]) # build dependent libs deplibs = env.BuildDependentLibraries("$PROJECTSRC_DIR") @@ -171,23 +174,26 @@ def LookupSources(env, variant_dir, src_dir, duplicate=True, src_filter=None): return sources -def BuildFramework(env): - if "FRAMEWORK" not in env or "uploadlazy" in COMMAND_LINE_TARGETS: +def BuildFrameworks(env, frameworks): + if not frameworks or "uploadlazy" in COMMAND_LINE_TARGETS: return - if env['FRAMEWORK'].lower() in ("arduino", "energia"): - env.ConvertInoToCpp() - - for f in env['FRAMEWORK'].split(","): - framework = f.strip().lower() - if framework in env.get("BOARD_OPTIONS", {}).get("frameworks"): - SConscript( - env.subst(join("$PIOBUILDER_DIR", "scripts", "frameworks", - "%s.py" % framework)) - ) + board_frameworks = env.get("BOARD_OPTIONS", {}).get("frameworks") + if frameworks == ["platformio"]: + if board_frameworks: + frameworks.insert(0, board_frameworks[0]) else: - Exit("Error: This board doesn't support %s framework!" % - framework) + Exit("Error: Please specify board type") + + for f in frameworks: + if f in ("arduino", "energia"): + env.ConvertInoToCpp() + + if f in board_frameworks: + SConscript(env.subst( + join("$PIOBUILDER_DIR", "scripts", "frameworks", "%s.py" % f))) + else: + Exit("Error: This board doesn't support %s framework!" % f) def BuildLibrary(env, variant_dir, src_dir, src_filter=None): @@ -351,7 +357,7 @@ def generate(env): env.AddMethod(IsFileWithExt) env.AddMethod(VariantDirWrap) env.AddMethod(LookupSources) - env.AddMethod(BuildFramework) + env.AddMethod(BuildFrameworks) env.AddMethod(BuildLibrary) env.AddMethod(BuildDependentLibraries) return env diff --git a/scripts/docspregen.py b/scripts/docspregen.py index 378d42d9..290c34fe 100644 --- a/scripts/docspregen.py +++ b/scripts/docspregen.py @@ -226,6 +226,18 @@ def generate_framework(type_, data): print "Processing framework: %s" % type_ lines = [] + lines.append(""".. Copyright 2014-2015 Ivan Kravets + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""") + lines.append(".. _framework_%s:" % type_) lines.append("") @@ -248,15 +260,19 @@ Platforms * - Name - Description""") + _found_platform = False for platform in sorted(PlatformFactory.get_platforms().keys()): if not is_compat_platform_and_framework(platform, type_): continue + _found_platform = True p = PlatformFactory.newPlatform(platform) lines.append(""" * - :ref:`platform_{type_}` - {description}""".format( type_=platform, description=p.get_description())) + if not _found_platform: + del lines[-1] lines.append(""" Boards diff --git a/tests/test_examples.py b/tests/test_examples.py index 702a82ab..0089c27f 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -28,7 +28,7 @@ def pytest_generate_tests(metafunc): example_dirs = normpath(join(dirname(__file__), "..", "examples")) project_dirs = [] for root, _, files in walk(example_dirs): - if "platformio.ini" not in files: + if "platformio.ini" not in files or ".skiptest" in files: continue project_dirs.append(root) project_dirs.sort()