Commit Graph

56 Commits

Author SHA1 Message Date
Bastian de Byl 0d72e6739c stm32 added better RTC periph API functions
Originally tracked at https://github.com/libopencm3/libopencm3/pull/1319
2021-03-25 21:11:07 +00:00
Brian Viele e41ac6ea71 stm32: added peripheral clock get helpers for all stm32 platforms.
Allows for abstraction for code that's dependent on knowing the source clock
for a peripheral. Implemented a few core peripherals that tend to have clock
tree differences between platforms (USART, timers, I2C, SPI).
2020-11-28 22:13:25 +00:00
Karl Palsson c7d7a18dd7 stm32: rcc: Standardize prescaler define names
We did have
* _HPRE_SYSCLK_DIVN (3 parts)
* _HPRE_DIVN (5 parts)
* _HPRE_DIV_N (4 parts)

Unify all on _HPRE_DIVN.  Provide deprecated definitions to not break
everything at once.

Also, standardize on "NODIV" instead of DIVNONE.
2020-11-28 22:13:25 +00:00
Karl Palsson 78c23ba5a0 doc: stm32f4: fix broken groupings
Now all the register value sets are in the generated output
2020-03-06 01:14:44 +00:00
Karl Palsson af384dbc7c doc: fix some broken groups uncovered while reviewing h7 code 2019-11-28 22:16:54 +00:00
Jonathan Halmen ec2d96433f stm32f4: rcc: add plli2s config function 2019-09-27 13:55:56 +00:00
Jonathan Halmen 203d0ca295 stm32f4: rcc: remove unnecessary pllsai functions
existing standard functions for these are
 * rcc_osc_on(RCC_PLLSAI);
 * rcc_is_osc_ready(RCC_PLLSAI);
2019-09-27 13:43:06 +00:00
Karl Palsson 5d3f13c40e doc: stm32f4: rcc: add groupings for periph resets 2019-06-12 22:56:38 +00:00
Karl Palsson 49a3cddba0 stm32f4:rcc: add new api directly to deprecated message
This makes the compiler warnings more useful.
2019-06-02 20:36:57 +00:00
Karl Palsson f990030440 stm32f4: rcc: move deprecated attribute to header
This makes it actually generate deprecated warnings.  The deprecated
doxygen stays with the .c file as before.
2019-06-02 12:50:34 +00:00
Karl Palsson a9dde2832e stm32f4: rcc: drop 48 & 120 MHz configs
48Mhz has no purpose other than to be a naiive method of haivng working
USB.  120MHz never had any purpose, other than to match the f2 code it
was copied from.  Drop them both.  Remaining configs are all max speeds
for various F4 parts.  Lower speeds are all custom
2019-06-02 10:50:10 +00:00
Miguel Sánchez de León Peque 1d68c299e8 stm32f4: add HSI clock configurations 2019-06-02 10:39:18 +00:00
Miguel Sánchez de León Peque ca6dcfbea1 stm32f4: rcc: support hsi pll source 2019-06-02 10:38:43 +00:00
Alfred Klomp 1adc418f9a stm32f42/f43: rcc: add 180 MHz clock options 2018-11-12 21:41:05 +00:00
Chris Sp 8b1ac585df stm32f4: rcc: typo fix MCO2
Just a small typo I came across while trying to get MCO to work on my board.
The define is not used in any other files as far as I can tell, but of
course applications might break if they use the misspelt variant.
2018-08-07 15:12:58 +00:00
Jordi Pakey-Rodriguez cc8c8a2f83 stm32f4: power: update rcc_clock_scale enum
- Change .power_save to .voltage_scale, a pwr_vos_scale enum
- Enable pwr clock before setting VOS scale
- Fix flash wait states
- Make flash_set_ws more robust
2018-07-29 20:31:17 +00:00
Karl Palsson 0965e691a9 stm32f2/f4: rcc: deprecate old IO definitions
instead of hard breaking, provide them as macros pointing to the new
values, and document them as deprecated.
2018-02-13 23:57:41 +00:00
Yonghua Zheng eeef996cb0 [BREAKING] rcc: change gpio bit defines to be consistent with reference manual
This _breaks_ your gpio code for F2 and F4.  It makes them consistent
with the reference manual, and more consistent with all other families
and general expectations.

OLD code -> NEW code
RCC_AHB1RSTR_IOPxRST 	->	RCC_AHB1RSTR_GPIOxRST
RCC_AHB1ENR_IOPIxEN	->	RCC_AHB1ENR_GPIOxEN
RCC_AHB1LPENR_IOPxLPEN	->	RCC_AHB1LPENR_GPIOxLPEN

[We're not actually breaking it, see the next commit for deprecated
aliases]
2018-02-13 23:57:21 +00:00
Karl Palsson db7a8d71ca stm32f4: rcc: doxygen updates
Uses doxygen groups instead of just  ------ comments, so they now
automatically get documented online.
2017-09-09 20:35:48 +00:00
Karl Palsson db5f550611 stm32f4: Add new clock gate enable register for f413
Yet more clock enable bits on new F413/F423.
Sourced from RM490rev5
2017-09-09 19:59:04 +00:00
Karl Palsson 29c712326f stm32: rcc: extract osc_bypass functions
rcc_osc_bypass_enable and rcc_osc_bypass_disable have been copy/pasted
around for the last time!  There's a compile bit to check for L0/L1, but
otherwise this is just code duplication for no gain.
2017-06-08 23:01:45 +00:00
Karl Palsson d1d511c6f4 stm32: rcc: add reset reason group flags.
Originally suggested in https://github.com/libopencm3/libopencm3/pull/399

At least provide macros for each family that allows easy masking of the
full set of reset reason flags.  Trying to provide a function that
provides these in random upper bits seems unclear at best.
2017-03-30 21:48:08 +00:00
Karl Palsson 6c034c8981 stm32f4: rcc: fix compilation error missed in testing
Fixes: 57c2b00a69

Running make for final sanity failed to catch this due to jobserver
issues.  *fumes*
2016-08-23 22:13:33 +00:00
Chuck McManis 57c2b00a69 stm32f4: rcc: support new plls for new f4 parts
Revise the PLL inits to support new and old PLL configurations,
particularly to support F4x9 devices.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2016-08-23 22:02:12 +00:00
Karl Palsson 4eb51ecaea stm32: rcc: rcc_wait_for_osc_ready is always available
Move the prototype to the common_all header and include documentation.
2016-08-18 23:41:04 +00:00
Chuck McManis 32a91e52ff stm32f4: Add QUADSPI Includes
Adds an include file (and required RCC and memorymap changes)
to address registers in the QUADSPI peripheral on the F4 line
of processors.
2016-08-15 22:44:36 +00:00
Chuck McManis b802bd07b2 stm32f4: rcc: support PLL_SAI and PLL_I2S
Adds the missing enums for the extra clocks on stm32f4x9 parts.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2016-08-15 20:58:33 +00:00
Chuck McManis 2614577e5a stm32f4: rcc: Add missing defines for f4x9 series
Adds missing bit definitions only.
Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2016-08-15 20:58:29 +00:00
Karl Palsson cf7d0a08ca stm32: rcc_wait_for_sysclk_status should actually wait
Original implementation only checked whether the user had _selected_ the
clock, not whether it had actually switched to the clock or not.  For
almost all cases, this made this function either a no-op, if you _had_
selected the clock, or a blocking loop if you hadn't selected it ahead
of time.

Fixes github issue #687
2016-08-15 16:09:58 +00:00
Karl Palsson 5738e9515d stm32: rcc: fix missing ahb_frequency struct
Original commits, while appearing clean and tidy, hadn't even been
compile tested.  Trust no-one. Not even Scully.

Fixes: 770878e7b4
Fixes: 86d20ef00c
Fixes: 05ff0df322
2016-02-17 16:21:30 +00:00
Piotr Esden-Tempski d680be81b5 [stm32f4] Remove rcc typedefs added prefixes to clock related enums.
Let's not hide the fact that these variables are structs/enums.

We are filling up the namespace badly enough, we should be prefixing as
much as we can with the module names at least. As users we already run
often enough in namespace colisions we don't have to make it worse.

* CLOCK_3V3_xxx enums renamed to RCC_CLOCK_3V3_xxx
* clock enums (PLL, HSI, HSE ...) prefixed with RCC_
* scale enum of pwr module prefixed with PWR_
2015-12-14 23:26:32 +01:00
Nicolas Schodet 9b8d44e8a3 stm32f4: add GPIOJ & GPIOK
They are available on STM32F429 and STM32F439.
2015-11-10 14:27:57 +01:00
Jorik Jonker 07ee71cf23 stm32f4: rcc: Add 84Mhz, max speed for f401
Basic helpers to at least support common configurations for the f401.

Original submission specified 5 wait states, but the reference manual and other
reviewers all believe that 2ws is sufficient for these modes.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2015-07-31 02:25:23 +00:00
Karl Palsson 5746fd4d25 stm32: common: Extract MCO source setting
This adds MCO source selection to some targets, and removes and standardizes
the mask/shift usage for all targets.  For devices that support MCO2, this
supports only MCO1.  No attempt has been made to extract MCO prescaler, which
is not available on all F1 and F3.
2015-04-29 01:22:27 +00:00
kbob fd141a8131 Definitions for LTDC (LCD-TFT video). 2015-02-20 19:40:23 -08:00
Piotr Esden-Tempski 5658a4ebcf [stm32f4-ltdc] Style cleanup.
Mainly replaced function like defines with static inline functions.
2015-02-12 19:02:51 -08:00
Oliver Meier eaae7731e9 [stm32f4-ltdc] initial commit 2015-02-05 16:44:38 -08:00
Chuck McManis 14ad92015e Audit RTCPRE Shift and Mask Values
L0 - RTC Prescaler appears in RCC_CR, bit 20, 2 bits wide (RM0367 Rev 2)
L1 - RTC Prescaler appears in RCC_CR, bit 29, 2 bits wide (RM0038 Rev 10)
F0 - no prescaler setting (RM0091 Rev 7)
F1 - no prescaler setting (RM0041 Rev 4)
F2 - RTC Prescaler appears at RCC_CFGR, bit 16, 4 bits wide (RM0033 Rev 6)
F3 - no prescaler setting (RM0316 Rev 3)
F4 - RTC Prescaler appears at RCC_CFGR, bit 16, 4 bits wide (RM0090 Rev 8)
2014-12-14 16:29:03 -08:00
Chuck McManis 9ddfcb0e53 Rename rcc_ppre1_frequency and rcc_ppre2_frequency
Rename rcc_ppre1_frequency and rcc_ppre2_frequency to rcc_apb1_frequency and rcc_apb2_frequency
Also add rcc_ahb_frequency (although it is not set correctly in all cases) which will be fixed by
the rcc commits later. Also fixup the only use in the library of these variables, the USART code.

And fix the typos that resulted
Make l1 generic too
2014-12-13 19:49:04 -08:00
Freek van Tienen ac8ac8c64d [f4] Added a 25mhz clock 2014-10-15 17:27:18 +02:00
Ken Sarkies 7816501dbc Changes to the header includes for all STM32 peripherals
to remove variations, redundancies, add missing, fix errors. All c files
refer only to the dispatch style headers in /include/stm32. Those headers
#include memorymap.h and cm3/common.h. All references to
these are removed from the family specific headers. Ethernet untouched as
it appears incomplete.

Added dummy spi.c for F0/F3. Fix some doxygen anomalies.
2014-03-11 16:40:31 +00:00
cmcmanis 07d0076934 Updates for STM32F429 chip
After a few rounds of review, changes are added to support
additional peripherals of the STM32F427/429
2014-02-06 00:41:52 +01:00
Ken Sarkies 3c6e9fd56d Fix a number of top level doxygen issues.
So that the navigation pane works correctly in browsers.
Some additional doc fixes put in where found (but many more still to go).
Added some dummy .c and .h files to bring the associated docs into line.
makefile changed to allow 'make html' as well as 'make doc' (the latter only does html anyway).
2014-01-15 22:19:52 +01:00
Piotr Esden-Tempski a909b5ca9e [Style] Global style fix run. 2014-01-03 01:07:30 +01:00
BuFran 723e1a69bd Better method of reset and clock handling with RCC, support L1, F1, F2, F3, F4 2014-01-02 22:00:11 +01:00
Piotr Esden-Tempski 39fa9e4c58 Stile fixes run, 80 char boundry. 2013-06-12 21:07:35 -07:00
Piotr Esden-Tempski 34de1e776e Changed to use stdint types. 2013-06-12 19:11:22 -07:00
Piotr Esden-Tempski 7df63fcae0 First coarse run to fix coding style in locm3.
Added --terse and --mailback options to the make stylecheck target. It
also does continue even if it enounters a possible error.

We decided on two exceptions from the linux kernel coding standard:
- Empty wait while loops may end with ; on the same line.
- All blocks after while, if, for have to be in brackets even if they
  only contain one statement. Otherwise it is easy to introduce an
  error.

Checkpatch needs to be adapted to reflect those changes.
2013-06-12 18:22:56 -07:00
Gautier Hattenberger a4b582f91d add 16MHz resonator for stm32f4 2013-04-23 17:52:27 +02:00
Piotr Esden-Tempski 1a025b5379 Fix all warnings for stm32f4 lib. 2013-02-26 17:19:22 -08:00