14 Commits

Author SHA1 Message Date
Christian Tacke
c55ec70f49 STM32: USART: Fix baudrate calculation for LPUART1
LPUART1 needs BRR to be 256 times the normal value.

Doing this with 64 bit math would work, but that pulls in quite a lot of
code for every platform, even if they don't have LPUART.

A little bit of maths, thanks to zyp on irc, lets us keep it in 32bit,
provided people don't try and use > 16MBaud on LPUARTs

Originally tracked via https://github.com/libopencm3/libopencm3/pull/888
2018-08-17 00:15:01 +00:00
Karl Palsson
b47b967440 doc: use common naming for peripheral apis
Only applied to STM32 doc trees at present.

Instead of declaring a group for "STM32blah" in the doc-blah.h files,
and then trying to put all the common+specific peripheral code into
those groups, (which is what led to the stub doxygen holder empty .c
files)  Just use a standard name like "Peripheral APIS" and place
everything into that.

Demonstrated by converting ADC and USART peripherals, which is
definitely not complete, but it shows how to make things less magical,
and less prone to copy/paste errors.  Now, you can copy/paste and it
will do the right thing, because everyone uses the same group names.

This is also how to unify the mix of "STM32blah->Periphblah" and _also_
the dangling "periph_file" modules in doxygen, it merges them together
properly, as they're intended to be really.
2018-07-03 22:23:00 +00:00
Karl Palsson
5dd0b46298 stm32: usart_common_all: fix bug in baudrate calculation
This function was using apb1 for quite a few families instead of apb2.
This only mattered for L1 and F3, and for USART1/USART6, and only if
apb1 speed != apb2 speed.

Instead of using families explicitly, just check for the peripherals
themselves.  On F0,F1,F2,F3,F4,F7,H7,L0,L1,L4, usart1/6 are _always_ in
the rcc_apb2 register and the other uarts are all on apb1.
(F0 doesn't actually _have_ apb2, but it's still called the apb2
register)
2017-10-25 22:55:09 +00:00
Anatol Pomozov
ae41782e1a Fix misspellings using codespell tool 2016-03-08 08:52:54 -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
Piotr Esden-Tempski
590135b65f [STM32F3] Moved all F3 specific functions out of common. 2013-07-07 16:01:51 -07:00
Federico Ruiz Ugalde
e9375dbfd2 usart set baudrate clock source incorrect. Now fixed. 2013-07-07 16:01:49 -07:00
Federico Ruiz Ugalde
ef762f0448 Stm32f3: usart support added. 2013-07-07 16:01:48 -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
Felix Ruess
af98521301 [stm32] update doxy for usart_set_baudrate 2013-04-29 18:35:06 +02:00
Felix Ruess
1b818a3679 [stm32] usart6 for F2/F4 2013-04-29 18:14:36 +02:00
Ken Sarkies
e2022f5884 Repair to documentation (most documented files)
to remove errors, duplications and inconsistencies.
File lib/stm32/f1/pwr.c - all code removed as it duplicates that in common/pwr_common.c
Remaining changes do not affect code. Compiles OK.
TODO efm32 has no code so generates no modules
TODO F2 needs pwr.c
TODO L1 needs dma.h and dma.c
2013-03-07 11:14:06 +10:30
Ken Sarkies
0878a534cd Move usart files to common area
Again added to L1 which is similar to F1
2013-01-08 19:51:08 +10:30