I’m using STM32-Nucleo board with an “Arduino”. But I can’t understand which framework exactly I use. I see that there are two Arduino frameworks for STM32 are installed into PlatformIO dir. One just arduinostm32 and the second one is arduinostm32-maple. Which one is used? How to understand?
And if under ArduinoSMT32 STM32Duino framework is used then where can I get its API description? Their site doesn’t work.
As can be seen in the documentation the core choice is controlled by the core entry in either the board’s JSON definition file (example) or a per-environment override board_build.core. Possible values are maple or stm32.
It is strange… I’ve managed to define that the default and used is STM32Duino. I’ve managed to find some API at their GitHub… Also some examples… For example, they use HardwareTimer library very broadly. This library is located at .platformio\packages\framework-arduinoststm32\cores\arduino
But this dir is not included into the compile path. I’m guessing why? I think that it should be…
Easy question: how to add this dir to platfromio.ini in order to make it independent from absolute path (eg I need relative path). Because I do this development at several computers and synchronize sources via GitHub.
Or it will be better jsut to copy this lib to Project/include dir?
Ehm, I don’t think this “library” will work when you just copy its files in a custom library. Doesn’t it depend on other files too? Or maybe on different behaviours of functions than what 1.6.1. has? I would advise to attempt a full framework upgrade to this current github bleeding-edge master version if you really need it, or otherwise look for APIs which are supported in the current stable (1.6.1) which help you do the same thing.
Well I got it to work. Just download https://github.com/stm32duino/Arduino_Core_STM32/archive/master.zip, go to the framework-arduinoststm32 folder, delete the cores and libraries folder, then extract the entire content of the ZIP file into the folder and overwrite all existing files.
Example code compiles (probably won’t work though since it’s using random pins and channels)
#include <Arduino.h>
#include <Servo.h>
#include <HardwareTimer.h>
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos = 0; // variable to store the servo position
void setup() {
int pin = PA_5;
int channel = 1;
HardwareTimer *MyTim = new HardwareTimer(TIM3); // TIM3 is MCU hardware peripheral instance, its definition is provided in CMSIS
MyTim->setPWM(channel, pin, 5, 10); // 5 Hertz, 10% dutycycle
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
DATA: [ ] 1.0% (used 1328 bytes from 131072 bytes)
PROGRAM: [ ] 1.8% (used 18724 bytes from 1048576 bytes)
[SUCCESS] Took 5.73 seconds
So it does work. Just a little bit hacky. You would usually want to create your own framework-arduinoststm32 package in your own repository and use platform_packages as in like
Just checked - HardwireTimer alone doesn’t work. Requires also timer and it seems that it won’t be able to trace the whole tree.
Anyway thanks for the clarification.
You cannot just take the Arduino_Core_STM32 git and use it as framework-arduinoststm32 package because it’s missing the package.json and CMSIS and tools directory from PlatformIO. You should take the current framework-arduinoststm32, upgrade the core files as I have described above, and then push it in a new repository, that should work.