Commit Graph

918 Commits

Author SHA1 Message Date
Harry Geyer
4d7a2ca271 stm32: When setting baudrate of a USART, first get the clock frequency for that USART.
Now that all families have support for calculating the clock of the
uart, use that layer.  Slightly slower for "old" families, but the only
way to be correct for newer families.

Reviewed-by: Karl Palsson <karlp@tweak.au>
2023-02-03 00:02:59 +00:00
Karl Palsson
e643f66342 stm32g4:rcc: add uart peripheral clock source helpers
Required so that the common uart infrastructure can be updated. This was
the last family to receive this implementation.

Signed-off-by: Karl Palsson <karlp@tweak.au>
2023-02-03 00:02:59 +00:00
Karl Palsson
e9426db222 stm32l4: rcc: use SYSCLK consistently with other families
Signed-off-by: Karl Palsson <karlp@tweak.au>
2023-02-02 23:58:02 +00:00
Karl Palsson
f0575c3560 stm32g4: rcc: use datasheet naming for CCIPR fields
Follow HACKING specifications, be consistent with all other parts.
Yes, the SEL suffix is kinda superfluous, but it's _consistent_ which is
why we do it.

Signed-off-by: Karl Palsson <karlp@tweak.au>
2023-02-02 23:51:13 +00:00
Karl Palsson
66e2cc3ea8 doc: stm32f0: flash: more variants than F05x these days.
Don't be so restrictive with the names. Use the standard F0xx style.

Signed-off-by: Karl Palsson <karlp@tweak.au>
2023-02-02 23:17:18 +00:00
Karl Palsson
130075a12d doc: stm32f0: comparator: move to "peripheral api" style
The COMP peripheral was left by it's own.

Signed-off-by: Karl Palsson <karlp@tweak.au>
2023-02-02 23:16:31 +00:00
Karl Palsson
e54650fba4 stm32f0: adc: external trigger selection to unshifted
Cleanup one function at a time.  Use the correct doxygen references, use
unshifted forms in user facing apis.  Yes, only the trigger at the
moment, as the polarity is shared.

Signed-off-by: Karl Palsson <karlp@tweak.au>
2023-02-02 22:47:44 +00:00
neoxic
d262e70fc3 stm32g4/g0: adc: fix clock prescalers
CCR register definitions were completely wrong, both decimal/hex mixups,
and straightup transcriptions from the reference manual errors.

Unify the styles for both g0 and g4, using the same (duplicated)
function for both implmentations.

Reviewed-by: Karl Palsson <karlp@tweak.au>
2023-02-01 21:40:56 +00:00
Karl Palsson
88e91c9a7c stm32:rcc: update _get_clock (uart/i2c) to handle all cases
Adds handling for missing cases.  While i2c only has 3 cases, uarts have
all 4, so make sure they're handled properly.
Removes duplicated/redundant definitions.
Adds doxygen wrappers, even if only for internal use.

Fixes: e41ac6ea71 stm32: added peripheral clock get helpers for all stm32
Signed-of-by: Karl Palsson <karlp@tweak.au>
2023-01-13 02:15:41 +00:00
Karl Palsson
df654d7f28 stm32: spi: drop spi_reset()
It's simply a wrapper around rcc_reset_pulse already.
Just drop it. See 034dbf20ff for the same deletion for timers.

Signed-off-by: Karl Palsson <karlp@tweak.au>
2023-01-13 02:15:41 +00:00
Karl Palsson
b3bdf025d7 stm32: i2c: drop i2c_reset()
It's simply a wrapper around rcc_reset_pulse already.
Just drop it. See 034dbf20ff for the same deletion for timers.

Signed-off-by: Karl Palsson <karlp@tweak.au>
2023-01-13 02:15:41 +00:00
Karl Palsson
de96f0f4aa stm32g0: adc: fix setting sampling time on all channels
Fixes: https://github.com/libopencm3/libopencm3/issues/1448
Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2022-11-29 14:10:52 +00:00
Karl Palsson
7c09d0d14c stm32f3: enable RTC
Fixes: https://github.com/libopencm3/libopencm3/issues/1446
Fixes: 18f4d7c1b7 stm32f3: rtc: include correct shared header

No testing on real hardware, but the docs imply that this should have
always had the "basic" rtc-v2 peripheral.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2022-11-17 21:15:47 +00:00
Karl Palsson
0b414ff649 stm32g0: adc: only clear desired flags in ADC_ISR
Verified against RM0444rev5.

Fixes: https://github.com/libopencm3/libopencm3/issues/1443

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2022-10-27 21:56:50 +00:00
Karl Palsson
5db7e87e6e doxygen: stm32:cordic: add a title 2022-10-27 21:37:00 +00:00
Oskar
d8d33ca36d stm32: cordic: add new peripheral
Review-URL: https://github.com/libopencm3/libopencm3/pull/1418
Reviewed-by: Karl Palsson <karlp@tweak.net.au>

Edits: removed non-existant u5 code, squished to a single commit,
whitespace cleanup.
2022-10-27 21:37:00 +00:00
andrej
2f29614133 stm32: Support CRC, SYSCFG and USART on G4 2022-09-19 13:43:46 +02:00
hepoun
c82c7406aa stm32:dmamux: Fix request generator reset
There was reset of DMAMUX request multiplexer channel instead of the DMAMUX request generator channel.
2022-09-08 11:42:52 +00:00
Oskar
4675227783 stm32g4: rng: enable common code support
Also fixes an error in the memory map exposed by enabling this.

Reviewed-by: Karl Palsson <karlp@tweak.net.au>
2022-06-03 21:02:19 +00:00
Oskar
1e71f18be2 stm32g4: i2c: enable common peripheral code. 2022-06-03 20:59:34 +00:00
Vlad Logyin
3122c0b33f stm32l4: rcc: Implement PLL helper as seen in other MCU families
Reviewed-by: Karl Palsson <karlp@tweak.net.au>
2022-06-03 20:53:15 +00:00
me@me.net
d8aa2f17b0 stm32: timer: Add API to set external clock mode 2 2022-04-27 13:11:58 +00:00
Stefan Tauner
5bcf2a0c35 stm32l4: fix various problems with rcc_get* functions
- rcc_get_i2c_clk_freq: Add support by taking RCC_CCIPR2 into account for I2C4.
 - rcc_get_timer_clk_freq: Add support for LP timers
 - rcc_get_usart_clk_freq: Fix APB freq used for LPUART1 and UART1, respectively.
2022-04-13 20:22:47 +00:00
Stefan Tauner
a6927e410c treewide: Fix some typos 2022-04-13 20:22:24 +00:00
Karl Palsson
3f52b7784c stm32/timers: clarify "advanced timers" restriction
by making it vaguer.  These days, there's extra timers that support the
BDTR register, so the simple "advanced" timer description is no longer
sufficiently clear.  You have to check your particular reference manual.

Fixes: https://github.com/libopencm3/libopencm3/issues/1378
2022-02-01 13:15:13 +00:00
mikisama
25b1e4aad9 stm32: fix typo 2021-12-07 09:41:16 +08:00
Tim Børresen
f5813a547a stm32f4: rcc: F411: support Full speed with usb.
F411 parts, found on "black pill" boards support 100MHz operation,
but only 96MHz with USB.  Provide default clock structures for this
common max speed.

Reviewed-by: Karl Palsson <karlp@tweak.net.au>
2021-09-27 10:42:24 +00:00
Bastian de Byl
6763681c26 STM32: Fixed ltdc_setup_windowing helper 2021-08-14 21:44:10 +00:00
Karl Palsson
470a1394a8 doc: stm32: timer: switch f1/other example
Reported in: https://github.com/libopencm3/libopencm3/issues/1353
Fixes: d8d63b3184  (wrongly assumed existing example was for f1)

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2021-07-31 21:45:53 +00:00
weycen76
12da5bbd9e stm32:iwdg: reset counter after changing period.
Fix the bug that the iwdg counter is not refreshed after the configurationis complete, if this counter is not refreshed after the configuration is completed, the first iwdg counting period will be as long as 26 seconds.

Fixes: https://github.com/libopencm3/libopencm3/pull/1333
Reviewed-by: Karl Palsson <karlp@tweak.net.au>
2021-07-01 22:15:23 +00:00
Stephen Holdaway
3ab83bc078 stm32g0: Support DAC
Nothing extra needed to be defined here - this might've just been missed
when adding STM32G0 support. Tested and works well on an STM32G051. Registers
in `stm32/common/dac_common_v1.h` match the STM32G0x1 reference manual.
2021-07-01 22:05:41 +00:00
Eduard Drusa
e9c68ff9e8 Fix STM32H7 FDCAN FIFO acknowledgment process
Fix FDCAN FIFO acknowledge register definition to make it correct for H7
MCUs. Previous definition contained hardcoded offset instead of using
MCU-specific macro.

Fix incorrect decoding of buffer element size. During decoding, value
returned was erratically set to 7 instead of setting 4th LSB. Buffer
element size was then always reported as 15 bytes.
2021-07-01 22:02:44 +00:00
Eduard Drusa
9478931d69 Fix FDCAN incorrect FIFO acknowledgment
Fix incorrect way of acknowledging FIFO processing. Old code ORed old
value of register with index of FIFO buffer just processed, which
generated invalid value for acknowledge. This caused FIFO to repeatedly
returning same content. Both fdcan_receive() and fdcan_release_fifo were
affected.
2021-07-01 21:48:12 +00:00
Karl Palsson
504dc95d9b stm32:fdcan: fix doxygen warnings
Added some descriptions for missing parameters, (hopefully) clarified
some along the way.  Fixed all can related warnings in doxygen logs.
Added doxgen tags where meaningful comments had been provided.  Dropped
redundant comment separators.
2021-04-16 12:38:31 +00:00
Eduard Drusa
32354846bd STM32H7: Implement basic FDCAN support
Add stm32h7 support for FDCAN peripheral. Source level compatibility is
provided with stm32g4. Additional features of stm32h7 such as
configurable buffers are supported. Implementation offers feature parity
with stm32g4 implementation.
2021-04-16 11:47:02 +00:00
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
Eduard Drusa
458250dc61 STM32G4: Add support for FDCAN
Add stm32g4 support for FDCAN peripheral. Normal / FDCAN operation
supported, bitrate switching and filtering supported via API.
Timestamping and transmit event buffer support in API are TBD.

Originally tracked as: https://github.com/libopencm3/libopencm3/pull/1317
Reviewed-by: Karl Palsson <karlp@tweak.net.au>
2021-03-16 20:46:15 +00:00
Jean THOMAS
a9cc695381 stm32: i2c: Use const qualifier for read-only pointer in i2c_transfer7 2021-02-26 13:07:20 +00:00
Brian Viele
c2dbea012b stm32h7: Updated pwr and rcc configs to support devices with SMPS.
Worked in nuances for differences between versions of STM32H7 devices, such as
handling of ODEN, explicit SCUEN bit, and different VOS mappings. This has
been validated on the STM32H7A3 and STM32H743 MCUs.
2021-02-04 09:43:47 +00:00
Karl Palsson
8722a03e2f stm32: enable quadspi for f7/g4/l4
Seeing as we'd started it, might as well finish enabling all the common
platforms.
2021-01-29 14:03:46 +00:00
Karl Palsson
ca479ad7d2 stm32: quadspi overhaul documentation
Provide all doxygen framework boilerplate.
Provide a very initial stub .c file to ensure that heirarchical headers
are pulled in properly.
2021-01-29 13:00:53 +00:00
Karl Palsson
5f4e2b3758 stm32:i2c-v1: eliminate doxygen warnings
We deprecated the defines in favour of just using the value itself, so
there's no longer a defined group to reference.
2021-01-28 00:33:07 +00:00
Karl Palsson
0f1f1ebd1a stm32:dac: Fix waveform generation apis
These were broken earlier, with no sane way of passing in correctly shifted
values, and didn't match examples.

Noticed while merging: https://github.com/libopencm3/libopencm3/pull/1281
2021-01-27 23:50:22 +00:00
Karl Palsson
8295d248e0 stm32:dac: new api for waveform characteristics
Old API required users to manually construct bit maps frm opaquely named
defines, with little help.  It also was a pure OR operation, with no way
to ever clear bits.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2021-01-27 23:50:15 +00:00
Stijn Martens
f9d5fb738e stm32: usart: add idle interrupt enable/disable 2021-01-26 10:43:23 +01:00
Karl Palsson
34a44af4e4 stm32: dac: fix doxygen parameter link 2021-01-24 22:34:10 +00:00
Karl Palsson
4576f29048 stm32g4: adc: fix doxygen grouping
avoids stub groups
2021-01-24 22:28:15 +00:00
Karl Palsson
59fdb61bf2 stm32: dac: doc: link data types
And also drop pointless whitespace and divider markers
2021-01-24 22:23:25 +00:00
Karl Palsson
3eb94bb335 stm32: dac: document: whitespace for legibility 2021-01-24 22:10:05 +00:00
Ben Brewer
1ebf172bcb stm32/dac: Update API to support multiple DACs and add v2 support 2021-01-07 15:30:51 +00:00