Add examples for Arduino Framework
This commit is contained in:
parent
3f8d6869b9
commit
790beccb80
|
@ -0,0 +1,3 @@
|
|||
.pioenvs
|
||||
.clang_complete
|
||||
.gcc-flags.json
|
|
@ -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 choose 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=ID_1 --board=ID_2 --board=ID_N
|
|
@ -0,0 +1,38 @@
|
|||
.. Copyright 2014-present PlatformIO <contact@platformio.org>
|
||||
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 <http://docs.platformio.org/en/latest/installation.html>`_
|
||||
2. Download `development platform with examples <https://github.com/platformio/platform-ststm32/archive/develop.zip>`_
|
||||
3. Extract ZIP archive
|
||||
4. Run these commands:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Change directory to example
|
||||
> cd platform-ststm32/examples/arduino-blink
|
||||
|
||||
# Build project
|
||||
> platformio run
|
||||
|
||||
# Upload firmware
|
||||
> platformio run --target upload
|
||||
|
||||
# Build specific environment
|
||||
> platformio run -e maple
|
||||
|
||||
# Upload firmware for the specific environment
|
||||
> platformio run -e maple --target upload
|
||||
|
||||
# Clean build files
|
||||
> platformio run --target clean
|
|
@ -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 organized `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 <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
// 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
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter, extra scripting
|
||||
; Upload options: custom port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; http://docs.platformio.org/en/stable/projectconf.html
|
||||
|
||||
[env:maple]
|
||||
platform = ststm32
|
||||
framework = arduino
|
||||
board = maple
|
||||
|
||||
[env:genericSTM32F103RB]
|
||||
platform = ststm32
|
||||
framework = arduino
|
||||
board = genericSTM32F103RB
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Blink
|
||||
* Turns on an LED on for one second,
|
||||
* then off for one second, repeatedly.
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
void setup()
|
||||
{
|
||||
// initialize LED digital pin as an output.
|
||||
pinMode(PC13, OUTPUT);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// turn the LED on (HIGH is the voltage level)
|
||||
digitalWrite(PC13, HIGH);
|
||||
// wait for a second
|
||||
delay(1000);
|
||||
// turn the LED off by making the voltage LOW
|
||||
digitalWrite(PC13, LOW);
|
||||
// wait for a second
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
.pioenvs
|
||||
.piolibdeps
|
||||
.clang_complete
|
||||
.gcc-flags.json
|
|
@ -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 choose 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=ID_1 --board=ID_2 --board=ID_N
|
|
@ -0,0 +1,38 @@
|
|||
.. Copyright 2014-present PlatformIO <contact@platformio.org>
|
||||
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 <http://docs.platformio.org/en/latest/installation.html>`_
|
||||
2. Download `development platform with examples <https://github.com/platformio/platform-ststm32/archive/develop.zip>`_
|
||||
3. Extract ZIP archive
|
||||
4. Run these commands:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Change directory to example
|
||||
> cd platform-ststm32/examples/arduino-external-libs
|
||||
|
||||
# Build project
|
||||
> platformio run
|
||||
|
||||
# Upload firmware
|
||||
> platformio run --target upload
|
||||
|
||||
# Build specific environment
|
||||
> platformio run -e maple
|
||||
|
||||
# Upload firmware for the specific environment
|
||||
> platformio run -e maple --target upload
|
||||
|
||||
# Clean build files
|
||||
> platformio run --target clean
|
|
@ -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 organized `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 <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
// 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
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter, extra scripting
|
||||
; Upload options: custom port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; http://docs.platformio.org/en/stable/projectconf.html
|
||||
|
||||
[env:maple]
|
||||
platform = ststm32
|
||||
framework = arduino
|
||||
board = maple
|
||||
lib_deps = BMP180
|
||||
|
||||
[env:genericSTM32F103RB]
|
||||
platform = ststm32
|
||||
framework = arduino
|
||||
board = genericSTM32F103RB
|
||||
lib_deps = BMP180
|
|
@ -0,0 +1,169 @@
|
|||
/* SFE_BMP180 altitude example sketch
|
||||
|
||||
This sketch shows how to use the Bosch BMP180 pressure sensor
|
||||
as an altimiter.
|
||||
https://www.sparkfun.com/products/11824
|
||||
|
||||
Like most pressure sensors, the BMP180 measures absolute pressure.
|
||||
Since absolute pressure varies with altitude, you can use the pressure
|
||||
to determine your altitude.
|
||||
|
||||
Because pressure also varies with weather, you must first take a pressure
|
||||
reading at a known baseline altitude. Then you can measure variations
|
||||
from that pressure
|
||||
|
||||
Hardware connections:
|
||||
|
||||
- (GND) to GND
|
||||
+ (VDD) to 3.3V
|
||||
|
||||
(WARNING: do not connect + to 5V or the sensor will be damaged!)
|
||||
|
||||
You will also need to connect the I2C pins (SCL and SDA) to your
|
||||
Arduino. The pins are different on different Arduinos:
|
||||
|
||||
Any Arduino pins labeled: SDA SCL
|
||||
Uno, Redboard, Pro: A4 A5
|
||||
Mega2560, Due: 20 21
|
||||
Leonardo: 2 3
|
||||
|
||||
Leave the IO (VDDIO) pin unconnected. This pin is for connecting
|
||||
the BMP180 to systems with lower logic levels such as 1.8V
|
||||
|
||||
Have fun! -Your friends at SparkFun.
|
||||
|
||||
The SFE_BMP180 library uses floating-point equations developed by the
|
||||
Weather Station Data Logger project: http://wmrx00.sourceforge.net/
|
||||
|
||||
Our example code uses the "beerware" license. You can do anything
|
||||
you like with this code. No really, anything. If you find it useful,
|
||||
buy me a beer someday.
|
||||
|
||||
V10 Mike Grusin, SparkFun Electronics 10/24/2013
|
||||
*/
|
||||
|
||||
// Your sketch must #include this library, and the Wire library.
|
||||
// (Wire is a standard library included with Arduino.):
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <SFE_BMP180.h>
|
||||
#include <Wire.h>
|
||||
|
||||
// You will need to create an SFE_BMP180 object, here called "pressure":
|
||||
|
||||
SFE_BMP180 pressure;
|
||||
|
||||
double baseline; // baseline pressure
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
Serial.println("REBOOT");
|
||||
|
||||
// Initialize the sensor (it is important to get calibration values stored on the device).
|
||||
|
||||
if (pressure.begin())
|
||||
Serial.println("BMP180 init success");
|
||||
else
|
||||
{
|
||||
// Oops, something went wrong, this is usually a connection problem,
|
||||
// see the comments at the top of this sketch for the proper connections.
|
||||
|
||||
Serial.println("BMP180 init fail (disconnected?)\n\n");
|
||||
while(1); // Pause forever.
|
||||
}
|
||||
|
||||
// Get the baseline pressure:
|
||||
|
||||
baseline = getPressure();
|
||||
|
||||
Serial.print("baseline pressure: ");
|
||||
Serial.print(baseline);
|
||||
Serial.println(" mb");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
double a,P;
|
||||
|
||||
// Get a new pressure reading:
|
||||
|
||||
P = getPressure();
|
||||
|
||||
// Show the relative altitude difference between
|
||||
// the new reading and the baseline reading:
|
||||
|
||||
a = pressure.altitude(P,baseline);
|
||||
|
||||
Serial.print("relative altitude: ");
|
||||
if (a >= 0.0) Serial.print(" "); // add a space for positive numbers
|
||||
Serial.print(a,1);
|
||||
Serial.print(" meters, ");
|
||||
if (a >= 0.0) Serial.print(" "); // add a space for positive numbers
|
||||
Serial.print(a*3.28084,0);
|
||||
Serial.println(" feet");
|
||||
|
||||
delay(500);
|
||||
}
|
||||
|
||||
|
||||
double getPressure()
|
||||
{
|
||||
char status;
|
||||
double T,P,p0,a;
|
||||
|
||||
// You must first get a temperature measurement to perform a pressure reading.
|
||||
|
||||
// Start a temperature measurement:
|
||||
// If request is successful, the number of ms to wait is returned.
|
||||
// If request is unsuccessful, 0 is returned.
|
||||
|
||||
status = pressure.startTemperature();
|
||||
if (status != 0)
|
||||
{
|
||||
// Wait for the measurement to complete:
|
||||
|
||||
delay(status);
|
||||
|
||||
// Retrieve the completed temperature measurement:
|
||||
// Note that the measurement is stored in the variable T.
|
||||
// Use '&T' to provide the address of T to the function.
|
||||
// Function returns 1 if successful, 0 if failure.
|
||||
|
||||
status = pressure.getTemperature(T);
|
||||
if (status != 0)
|
||||
{
|
||||
// Start a pressure measurement:
|
||||
// The parameter is the oversampling setting, from 0 to 3 (highest res, longest wait).
|
||||
// If request is successful, the number of ms to wait is returned.
|
||||
// If request is unsuccessful, 0 is returned.
|
||||
|
||||
status = pressure.startPressure(3);
|
||||
if (status != 0)
|
||||
{
|
||||
// Wait for the measurement to complete:
|
||||
delay(status);
|
||||
|
||||
// Retrieve the completed pressure measurement:
|
||||
// Note that the measurement is stored in the variable P.
|
||||
// Use '&P' to provide the address of P.
|
||||
// Note also that the function requires the previous temperature measurement (T).
|
||||
// (If temperature is stable, you can do one temperature measurement for a number of pressure measurements.)
|
||||
// Function returns 1 if successful, 0 if failure.
|
||||
|
||||
status = pressure.getPressure(P,T);
|
||||
if (status != 0)
|
||||
{
|
||||
return(P);
|
||||
}
|
||||
else Serial.println("error retrieving pressure measurement\n");
|
||||
}
|
||||
else Serial.println("error starting pressure measurement\n");
|
||||
}
|
||||
else Serial.println("error retrieving temperature measurement\n");
|
||||
}
|
||||
else Serial.println("error starting temperature measurement\n");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
.pioenvs
|
||||
.clang_complete
|
||||
.gcc-flags.json
|
|
@ -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 choose 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=ID_1 --board=ID_2 --board=ID_N
|
|
@ -0,0 +1,38 @@
|
|||
.. Copyright 2014-present PlatformIO <contact@platformio.org>
|
||||
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 <http://docs.platformio.org/en/latest/installation.html>`_
|
||||
2. Download `development platform with examples <https://github.com/platformio/platform-ststm32/archive/develop.zip>`_
|
||||
3. Extract ZIP archive
|
||||
4. Run these commands:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Change directory to example
|
||||
> cd platform-ststm32/examples/arduino-internal-libs
|
||||
|
||||
# Build project
|
||||
> platformio run
|
||||
|
||||
# Upload firmware
|
||||
> platformio run --target upload
|
||||
|
||||
# Build specific environment
|
||||
> platformio run -e maple
|
||||
|
||||
# Upload firmware for the specific environment
|
||||
> platformio run -e maple --target upload
|
||||
|
||||
# Clean build files
|
||||
> platformio run --target clean
|
|
@ -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 organized `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 <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
// 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
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter, extra scripting
|
||||
; Upload options: custom port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; http://docs.platformio.org/en/stable/projectconf.html
|
||||
|
||||
[env:maple]
|
||||
platform = ststm32
|
||||
framework = arduino
|
||||
board = maple
|
||||
|
||||
[env:genericSTM32F103RB]
|
||||
platform = ststm32
|
||||
framework = arduino
|
||||
board = genericSTM32F103RB
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* test-rtc.c
|
||||
*
|
||||
* Example program that sets up the Real Time Clock and then blinks the
|
||||
* LED in patterns for seconds and alarm interrupts.
|
||||
*
|
||||
* Created by Rod Gilchrist on 11-12-24.
|
||||
Ray Burnette: 20150521:
|
||||
Edited: \Documents\Arduino\hardware\STM32\STM32F1\system\libmaple\stm32f1\include\series\rcc.h to include:
|
||||
#include <libmaple/bitband.h>
|
||||
#define RCC_BDCR_RTCSEL_LSI (0x2 << 8)
|
||||
static inline void rcc_start_lsi(void)
|
||||
static inline void rcc_start_lse(void)
|
||||
static inline void rcc_start_hse(void)
|
||||
|
||||
Arduino GUI 1.7.3 from Arduino.org
|
||||
Sketch uses 20,268 bytes (18%) of program storage space. Maximum is 110,592 bytes.
|
||||
Global variables use 4,552 bytes of dynamic memory.
|
||||
*/
|
||||
|
||||
#include "RTClock.h"
|
||||
|
||||
#define BOARD_LED_PIN PB1
|
||||
|
||||
int globAlmCnt = 0;
|
||||
int globOvCnt = 0;
|
||||
int globSecCnt = 0;
|
||||
int specAlmCnt = 0;
|
||||
int lastGlobAlmCnt = -1;
|
||||
int lastSpecAlmCnt = -1;
|
||||
|
||||
void rtc_sec_intr() { if (rtc_is_second()) globSecCnt++; }
|
||||
void rtc_ovf_intr() { if (rtc_is_overflow()) globOvCnt++; }
|
||||
void rtc_glob_alm_intr() { if (rtc_is_alarm()) globAlmCnt++; }
|
||||
void rtc_spec_alm_intr() { if (rtc_is_alarm()) specAlmCnt++; }
|
||||
|
||||
void setup() {
|
||||
// http://forums.leaflabs.com/topic.php?id=1437
|
||||
// slow! div speed. NOTE! 512 is stop/hang when USB not connected!
|
||||
// rcc_set_prescaler(RCC_PRESCALER_AHB, RCC_AHB_SYSCLK_DIV_256);
|
||||
// Normal speed:
|
||||
// rcc_set_prescaler(RCC_PRESCALER_AHB, RCC_AHB_SYSCLK_DIV_1);
|
||||
|
||||
pinMode(BOARD_LED_PIN, OUTPUT);
|
||||
delay(5000);
|
||||
Serial.println("begin RTC blink");
|
||||
delay(1000);
|
||||
|
||||
rtc_init(RTCSEL_LSI);
|
||||
rtc_set_prescaler_load(0x7fff);
|
||||
rtc_set_count(0);
|
||||
|
||||
rtc_attach_interrupt(RTC_SECONDS_INTERRUPT, rtc_sec_intr);
|
||||
rtc_attach_interrupt(RTC_OVERFLOW_INTERRUPT, rtc_ovf_intr); // expected every 128000 seconds
|
||||
rtc_attach_interrupt(RTC_ALARM_GLOBAL_INTERRUPT, rtc_glob_alm_intr);
|
||||
rtc_attach_interrupt(RTC_ALARM_SPECIFIC_INTERRUPT, rtc_spec_alm_intr);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int i,n;
|
||||
|
||||
Serial.print("Time + interrupt counts: ");
|
||||
Serial.print(rtc_get_count());
|
||||
Serial.print(".");
|
||||
Serial.print(rtc_get_divider());
|
||||
Serial.print(" (");
|
||||
Serial.print(globSecCnt);
|
||||
Serial.print(", ");
|
||||
Serial.print(globOvCnt);
|
||||
Serial.print(", ");
|
||||
Serial.print(globAlmCnt);
|
||||
Serial.print(", ");
|
||||
Serial.print(specAlmCnt);
|
||||
Serial.println(")");
|
||||
|
||||
delay(1000);
|
||||
|
||||
digitalWrite(BOARD_LED_PIN, 1);
|
||||
if ((lastSpecAlmCnt != specAlmCnt) || (lastGlobAlmCnt != globAlmCnt)){
|
||||
lastGlobAlmCnt = globAlmCnt;
|
||||
lastSpecAlmCnt = specAlmCnt;
|
||||
|
||||
Serial.println(" -- alarm -- ");
|
||||
for (i=0;i<3;i++) { digitalWrite(BOARD_LED_PIN, 0); delay(100); digitalWrite(BOARD_LED_PIN, 1); delay(100);}
|
||||
n = rtc_get_count() + 5;
|
||||
rtc_set_alarm(n);
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
digitalWrite(BOARD_LED_PIN, 0);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue