From 3989ed3769239890bece4acc250c6301ac88964c Mon Sep 17 00:00:00 2001 From: alfran Date: Thu, 2 Mar 2017 16:40:17 +0100 Subject: [PATCH 1/3] added README.md --- README.md | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..040bef6 --- /dev/null +++ b/README.md @@ -0,0 +1,70 @@ +# Arduino Core for STM32F4 CPU + +This repository contains the source code and configuration files of the Arduino Core +for ST Microelectronics STM32F4 processor (used on the Arduino STAR OTTO). + +## Installation on Arduino IDE + +This core is available as a package in the Arduino IDE cores manager. +Just open the "Boards Manager" and install the package called: + +"Arduino STM32F4 Boards (32-bit ARM Cortex-M4)" + +## Support + +There is a dedicated section of the Arduino Forum for general discussion and project assistance: + +http://forum.arduino.org/index.php?board=98.0 + +## Bugs or Issues + +If you find a bug you can submit an issue here on github: + +https://github.com/arduino/Arduino-core-stm32f4/issues + +Before posting a new issue, please check if the same problem has been already reported by someone else +to avoid duplicates. + +## Contributions + +Contributions are always welcome. The preferred way to receive code cotribution is by submitting a +Pull Request on github. + +## Hourly builds + +This repository is under a Continuous Integration system that every hour checks if there are updates and +builds a release for testing (the so called "Hourly builds"). + +The hourly builds are available through Boards Manager. If you want to install them: + 1. Open the **Preferences** of the Arduino IDE. + 2. Add this URL `http://downloads.arduino.cc/Hourly/STM32F4/package_stm32f4-hourly-build_index.json` in the **Additional Boards Manager URLs** field, and click OK. + 3. Open the **Boards Manager** (menu Tools->Board->Board Manager...) + 4. Install **Arduino STM32F4 core - Hourly build** + 5. Select one of the boards under **STM32F4 Hourly build XX** in Tools->Board menu + 6. Compile/Upload as usual + +If you already installed an hourly build and you want to update it with the latest: + 1. Open the **Boards Manager** (menu Tools->Board->Board Manager...) + 2. Remove **Arduino SAMD core - Hourly build** + 3. Install again **Arduino SAMD core - Hourly build**, the Board Manager will download the latest build replacing the old one. + +## License and credits + +This core has been developed by Arduino.org in collaboration with STM. + +``` + Copyright (c) 2017 Arduino.org All right reserved. + + This library 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 2.1 of the License, or (at your option) any later version. + + This library 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 this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA From 9eba9b18f013874fbf00ec1454d96d81dea5e00d Mon Sep 17 00:00:00 2001 From: alfran Date: Fri, 3 Mar 2017 10:21:08 +0100 Subject: [PATCH 2/3] fixed Firmata compatibility --- cores/arduino/io.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cores/arduino/io.h b/cores/arduino/io.h index 20410bb..56fd8a4 100755 --- a/cores/arduino/io.h +++ b/cores/arduino/io.h @@ -49,6 +49,14 @@ * @see pinMode() */ typedef enum WiringPinMode { + INPUT, /**< Basic digital input. The pin voltage is sampled; when + it is closer to 3.3v (Vcc) the pin status is high, and + when it is closer to 0v (ground) it is low. If no + external circuit is pulling the pin voltage to high or + low, it will tend to randomly oscillate and be very + sensitive to noise (e.g., a breath of air across the pin + might cause the state to flip). */ + OUTPUT, /**< Basic digital output: when the pin is HIGH, the voltage is held at +3.3v (Vcc) and when it is LOW, it is pulled down to ground. */ @@ -69,13 +77,7 @@ typedef enum WiringPinMode { mode, no current is ever actually sourced from the pin. */ - INPUT, /**< Basic digital input. The pin voltage is sampled; when - it is closer to 3.3v (Vcc) the pin status is high, and - when it is closer to 0v (ground) it is low. If no - external circuit is pulling the pin voltage to high or - low, it will tend to randomly oscillate and be very - sensitive to noise (e.g., a breath of air across the pin - might cause the state to flip). */ + INPUT_PULLUP, /**< The state of the pin in this mode is reported the same way as with INPUT, but the pin voltage From 64ab58d0e376ea721876921c629f4c1b7afee049 Mon Sep 17 00:00:00 2001 From: alfran Date: Fri, 3 Mar 2017 12:15:00 +0100 Subject: [PATCH 3/3] improved compatibility --- cores/arduino/io.h | 62 ++------------------------------ cores/arduino/wiring_constants.h | 23 ++++++++++++ cores/arduino/wiring_digital.cpp | 2 +- 3 files changed, 27 insertions(+), 60 deletions(-) diff --git a/cores/arduino/io.h b/cores/arduino/io.h index 56fd8a4..b81ca2e 100755 --- a/cores/arduino/io.h +++ b/cores/arduino/io.h @@ -43,72 +43,16 @@ #include "adc.h" #include "wiring_time.h" - -/** - * Specifies a GPIO pin behavior. - * @see pinMode() - */ -typedef enum WiringPinMode { - INPUT, /**< Basic digital input. The pin voltage is sampled; when - it is closer to 3.3v (Vcc) the pin status is high, and - when it is closer to 0v (ground) it is low. If no - external circuit is pulling the pin voltage to high or - low, it will tend to randomly oscillate and be very - sensitive to noise (e.g., a breath of air across the pin - might cause the state to flip). */ - - OUTPUT, /**< Basic digital output: when the pin is HIGH, the - voltage is held at +3.3v (Vcc) and when it is LOW, it - is pulled down to ground. */ - - OUTPUT_OPENDRAIN, /**< In open drain mode, the pin indicates - "low" by accepting current flow to ground - and "high" by providing increased - impedance. An example use would be to - connect a pin to a bus line (which is pulled - up to a positive voltage by a separate - supply through a large resistor). When the - pin is high, not much current flows through - to ground and the line stays at positive - voltage; when the pin is low, the bus - "drains" to ground with a small amount of - current constantly flowing through the large - resistor from the external supply. In this - mode, no current is ever actually sourced - from the pin. */ - - - - INPUT_PULLUP, /**< The state of the pin in this mode is reported - the same way as with INPUT, but the pin voltage - is gently "pulled up" towards +3.3v. This means - the state will be high unless an external device - is specifically pulling the pin down to ground, - in which case the "gentle" pull-up will not - affect the state of the input. */ - - INPUT_PULLDOWN, /**< The state of the pin in this mode is reported - the same way as with INPUT, but the pin voltage - is gently "pulled down" towards 0v. This means - the state will be low unless an external device - is specifically pulling the pin up to 3.3v, in - which case the "gentle" pull-down will not - affect the state of the input. */ - - INPUT_FLOAT, /**< Synonym for INPUT. */ - - OUTPUT_DAC, /**< This is a special mode for when the pin will be used for - PWM output (a special case of digital output). */ -} WiringPinMode; +#include "wiring_constants.h" /** * Configure behavior of a GPIO pin. * * @param pin Number of pin to configure. * @param mode Mode corresponding to desired pin behavior. - * @see WiringPinMode + * @see PinMode */ -void pinMode(uint8 pin, WiringPinMode mode); +void pinMode(uint8 pin, uint8 mode); /** * Writes a (digital) value to a pin. The pin must have its diff --git a/cores/arduino/wiring_constants.h b/cores/arduino/wiring_constants.h index 4e6584a..3bb79b5 100755 --- a/cores/arduino/wiring_constants.h +++ b/cores/arduino/wiring_constants.h @@ -41,6 +41,29 @@ extern "C"{ #endif +#define INPUT 0x0 +#define OUTPUT 0x1 +#define INPUT_PULLUP 0x2 +#define OUTPUT_OPENDRAIN 0x3 +#define INPUT_PULLUP 0x4 +#define INPUT_PULLDOWN 0x5 +#define INPUT_FLOAT 0x6 +#define OUTPUT_DAC 0x7 + +#define true 0x1 +#define false 0x0 + +#define PI 3.1415926535897932384626433832795 +#define HALF_PI 1.5707963267948966192313216916398 +#define TWO_PI 6.283185307179586476925286766559 +#define DEG_TO_RAD 0.017453292519943295769236907684886 +#define RAD_TO_DEG 57.295779513082320876798154814105 +#define EULER 2.718281828459045235360287471352 + +#define SERIAL 0x0 +#define DISPLAY 0x1 + + typedef unsigned short word; enum BitOrder { diff --git a/cores/arduino/wiring_digital.cpp b/cores/arduino/wiring_digital.cpp index 4eef059..9a37e4a 100755 --- a/cores/arduino/wiring_digital.cpp +++ b/cores/arduino/wiring_digital.cpp @@ -38,7 +38,7 @@ #include "Arduino.h" #include "dac.h" -void pinMode(uint8 pin, WiringPinMode mode) +void pinMode(uint8 pin, uint8 mode) { gpio_pin_mode outputMode; boolean pwm = false;