andysworkshop / stm32plus

The C++ library for the STM32 F0, F100, F103, F107 and F4 microcontrollers
http://www.andybrown.me.uk
Other
745 stars 224 forks source link

Added support for f4x1 #231

Open slavdors opened 3 years ago

slavdors commented 3 years ago

I added support for the STM32F401 and STM32F411 chips. Briefly tested with both (on Black Pill modules)

andysworkshop commented 3 years ago

Thank you very much for contributing. I tried to build your PR from the command line and got lots of errors. This was the first:

$ scons mode=debug mcu=f401 hse=8000000
scons: Reading SConscript files ...
stm32plus build version is 040100
scons: done reading SConscript files.
scons: Building targets ...
arm-none-eabi-g++ -o examples/adc_analog_watchdog/build/debug-f401-8000000e/adc_analog_watchdog.o -c -Wextra -pedantic-errors -fno-rtti -std=gnu++14 -fno-threadsafe-statics -Wall -Werror -Wno-implicit-fallthrough -ffunction-sections -fdata-sections -fno-exceptions -mthumb -gdwarf-2 -pipe -DHSE_VALUE=8000000 -mcpu=cortex-m4 -DSTM32PLUS_F401 -O0 -g3 -Ilib/include -Ilib/include/stl -Ilib -Iexamples/adc_analog_watchdog examples/adc_analog_watchdog/adc_analog_watchdog.cpp
In file included from lib/include/config/dac.h:35:0,
                 from examples/adc_analog_watchdog/adc_analog_watchdog.cpp:10:
lib/include/dac/features/DacFeatureBase.h:19:7: error: 'Dac' does not name a type
       Dac& _dac;
       ^~~

This is using gcc version 7.3.1

slavdors commented 3 years ago

[redacted to contain only the response relevant to this issue - other issues will be covered separately]

I must admit, that I simply didn't check my change with the examples. That's because I'm using MSYS on Windows which installs Python3, which your examples' scons scripts, as you may be aware, are not compatible with. So, I tested my changes with "examples=no" for all possible F4 targets (just to make sure that I didn't break the existing support). Finally, I tried my change with the examples (after correcting the scons files) and you're obviously right: I got the same errors. The problem is not with my change though, but in the fact that the examples seem to overstate their support in the "compat.txt". The first error you showed is in the first example, the "adc_analog_watchdog" which, despite listing F401 and F411 in the "compat.txt" uses the DAC which is not in these chips. The compilation therefore, correctly fails, as the code tries to use non existing hardware.

I'm happy to go through all the examples and correct their "compat" files. I could then update my PR with these changes.

slavdors commented 3 years ago

I have the examples built correctly, but haven't pushed my changes yet, because I'd like to ask you Andy for your preference. The system files for f4xx in the examples assume 168MHz system clock which is way too high for f401 and f411. I could either lower it down to 84MHz to cover all versions of f4xx or create separate folders with the proper corresponding system files for each f401 and f411.

What's your preference?

andysworkshop commented 3 years ago

I have the examples built correctly, but haven't pushed my changes yet, because I'd like to ask you Andy for your preference. The system files for f4xx in the examples assume 168MHz system clock which is way too high for f401 and f411. I could either lower it down to 84MHz to cover all versions of f4xx or create separate folders with the proper corresponding system files for each f401 and f411.

What's your preference?

I think I would prefer separate folders for the F401 and F411 that are clocked at 84MHz. The earlier devices that can run at 168MHz should still run at that speed.