Commit Graph

113 Commits

Author SHA1 Message Date
Jacob Walser 854da9635e stm32f0: adjust wwdg threshold signatures to support 12 bit resolution 2020-01-05 00:08:48 +00:00
Karl Palsson 38d88c6113 doc: stm32f0: rcc: add missing groups for pll factors and sources 2019-06-27 14:53:09 +00:00
Guillaume Revaillot e06898d9a4 stm32: dma: cselr: factorize register definition.
F09x and L4 share the same cselr register, as well as some L0s, factorize
definitions in a new shared header and add helpers.

fyi, that register allows to redefine dma channel peripheral mapping - see
device datasheet for mapping tables.
2019-06-17 11:44:44 +00:00
Karl Palsson 867bd164eb doc:stm32: usart: fix grouping and heirarchy of base addrs
They were always landing on the top level, or not even present.
2019-06-12 23:06:22 +00:00
Karl Palsson cfdb9b7856 doc: stm32f0: rcc: add groups and tags for bus prescalers 2019-06-12 23:06:22 +00:00
Karl Palsson c7ce1ddd1a doc: stm32f0: rcc: add groupings for periph resets
As done earlier for other families, makes the doxygen linking working
properly.
2019-06-12 21:56:13 +00:00
Karl Palsson ce5d1ca9a2 doc: restore targets as pages.
You can't have two mainpage items, and the second was just being
ignored.  This restores them, which makes the left side list longer,
which we may or may not like, but it's at least how it was documented to
be.
2019-06-10 11:10:34 +00:00
Guillaume Revaillot 553c876fa5 stm32: exti: define AFIO/SYSCFG_EXTICR_FIELDSIZE for all chip.
While on all current chips, exticr gpio port mux selection is coded on 4 bits,
stm32g0 EXTI_EXTICR register uses 8 bits.  Align all exti header to reference
that value (was previously defined for f0 as SYCFG_EXTICR_SKIP)
2019-01-31 09:57:43 +00:00
Guillaume Revaillot ff9664389b stm32: exti: move register definition of all current stm32 devices to common_v1
Preparation for stm32g0 support, as this chip's exti register map evolved and is
no longer common ...
2019-01-18 18:33:55 +01:00
Guillaume Revaillot 708fe1516c stm32: fix nvic channels name to match dma1/2 on stm32f09x 2019-01-18 10:31:32 +00:00
Karl Palsson 33387e8f96 stm32f0:adc: add missing declaration
fixes: 7e1d3daa stm32f0: adc: API call to clear EOS flag
2019-01-12 22:19:49 +00:00
Karl Palsson 8b13977ea0 stm32f0: add DMA1 compatibility alias 2018-11-09 15:34:58 +00:00
Alfred Klomp b7a9968e4f fixup! stm32f09: add register definitions for DMA2 2018-11-06 18:48:18 +01:00
Alfred Klomp a9c0008290 stm32f09: add register definitions for DMA2 2018-11-06 12:58:36 +01:00
Alfred Klomp 53347c266b stm32f09: add register definitions for USART5..8 2018-11-06 11:35:40 +01:00
Karl Palsson 4840b6bc7e stm32: flash: pull up clear_eop
All the "f" type flash parts have an EOP flag, even if it's in different
bit positions.  Add a header for this common functionality, and move
it's implementation to the existing common file.
2018-07-29 20:31:17 +00:00
Karl Palsson b23dccc7ae stm32: flash: pull up prefetch to _all
Turns out, there's lots of common code for flash.  Pull up prefetch
on/off to start with, as there's only a single bit name different.

Pull up the definitions of common API functions too, starting with
flash_set_ws.  Even if the implementations are different, things that
meant to be the same, should be defined centrally.
2018-07-29 20:31:17 +00:00
Matt Anderson 0d5e51a8a7 STM32F0: Add RCC API for I2C1 clock source
* Providing API to set/clear RCC_CFGR3_I2C1SW on STM32F0, duplicated
	from STM32F3 applies only to I2C1.
2018-07-03 22:30:24 +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
Guillaume Revaillot 54c6c833fe stm32: stm32f09x has two independent dma controlers, add RCC bits. 2018-04-29 13:16:36 +00:00
Guillaume Revaillot bf125e91f9 stm32: rework spi, based on PR #740 and #742.
split spi stuff in three part:
 - v1 : basic spi peripheral
 - v1_frf : v1 spi with frf mode additional bit in spi_cr2 / spi_sr
 - v2 : spi with variable datasize, fifo and other fancy stuff.

v1 maps to f1 chips
v1_frf to f2, f4 and l0,l1
v2 to f0, f3 and l4

This breaks spi_master_init API for v2 devices : function prototype from
common spi header used to be abused, with DFF bit reused for CRCL bit.
New v2 spi_master_init does not handle anymore CRCL bits, as it does not
usually mess with other crc configuration.
2018-04-28 21:12:27 +00:00
Vegard Lillevoll bbe71b4c4f STM32F0: Added ADC1_CCR definition 2018-04-28 21:12:27 +00:00
Guillaume Revaillot 207eb07d4c stm32: centralize additionnal iwdg window register definition into iwdg-v2.
stm32f0, l3, l4 are currently sharing the same duplicated header, and
stm32l0 uses the same peripheral. Stop copy-pasting stuff and centralize
definitions into a iwdg_common_v2.h header.
2018-03-28 13:06:57 +00:00
Cem Basoglu 34f57ae06e stm32: crc-v2: STM32F0/3 extended crc unit
Implementation of extended crc unit in f0 and f3
2018-02-13 23:57:21 +00:00
Karl Palsson a23d65e7dd stm32: usart-v2: pull up remaining f3/f0 defns
Final chunk of register definitions to be pulled up.

Now the "target" files are _only_ defining the list of u(s)arts
available, and any _specific_ functions for that target.
2017-10-25 23:03:48 +00:00
Karl Palsson b20d0ff1fb stm32: usart-v2: pull up CR2 register values from f0/f3
Just small pieces at a time to make it easy to see what's happening.
Taking definitions currently implemented in both f0/f3 headers and
making combined, documented versions in the -v2 header.
2017-10-25 22:57:18 +00:00
Karl Palsson 670a7cd83e stm32f0: use usart-v2 instead of private usart
Use the usart-common base plus the usart-v2 code, instead of private
implementations.  Less code, more common apis across targets.

Of note is the trick to make F0 look like it has an APB2 bus.  It's the
only stm32 that doesn't have a documented APB2 bus, but still has
peripherals enabled via an "APB2" register, and they match how other
targets have an APB2.  Simply make APB2 an alias of APB1, as it's only
used for clock speed detection.
2017-10-25 22:55:10 +00:00
Karl Palsson fb520ff3dc stm32:usart-v2: pull out registers and values
Only pulling out the _common_ stuff.  This is a single step in a long
process of eliminating all the duplication and "same, but different"
implementations that are stalling adding nice clean easy support for
l0/f7/l4.

This _ignores_ all currently conflict register definitions, even if they
"do the same thing" it just pulls up the common stuff.  A subsequent
commit can look at resolving the implementatations to a single version.
2017-10-25 21:19:23 +00:00
Karl Palsson e11e64330c stm32f0: can: add to build
Added the CAN1 compatibility aliases as has been done for adc and dac to
make code reuse easier.  Only for the magic enums, the raw bit
definitions remain as per the ref mans

Originally suggested as https://github.com/libopencm3/libopencm3/pull/802
2017-07-04 23:24:49 +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
Matthew Lai 383fafc862 stm32: renamed pwr_common_all to pwr_common_v1, and pwr_common_l01 to pwr_common_v2 2017-03-30 21:48:08 +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 0259102560 stm32f0: drop superfluous intermediate speed helpers
If you're interested in slightly underclocking or midrange speeds,
you're into custom environments.  Drop all the "helpers" for these odd
speeds.  This is not the max speed for any existing f0 part.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2017-03-30 21:48:07 +00:00
Sergey Matyukevich 7cacbbfb8d stm32/f0: enable clocking from HSE crystal
The following four new functions enable clocking SoC from HSE crystal:
	rcc_clock_setup_in_hse_8mhz_out_{8,16,32,48}mhz

These functions start HSE as external clock and feed its output to PLL
if higher frequency is needed.

Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
Reviewed-by: Karl Palsson <karlp@tweak.net.au>
 -> Dropped 8,16,32Mhz functions as superfluous.
2017-03-30 21:48:07 +00:00
Sergey Matyukevich 1b97ecefff stm32/f0: more clock helper functions
Add two clock helper defines and functions:
- rcc_set_pll_source: select PLL entry clock source
- rcc_set_pllxtpre: HSE divider for PLL input clock

Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
2017-03-30 21:48:07 +00:00
Sergey Matyukevich ef91856ac1 stm32: unify i2c implementations
The f1, f2, f4, l1 chip families have a similar "v1" i2c peripheral on board.
More recent f0, f3, l0, l3 chip families share another "v2" version  of i2c.

This patch unifies headers and implementation for two types of i2c peripherals:

- rename: i2c_common_all.[ch] to i2c_common_v1.[ch]
- remove i2c_common_f24.h: extra I2C blocks are defined in specific headers
- use f3 i2c code as a basis for common "v2" i2c implementation
- add f0 i2c support: use "v2" i2c implementation

Tests:
- tested on a custom f0 board
- compile-tested both libopencm3 and libopencm3-examples for all stm32

Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
2017-03-30 21:48:07 +00:00
Sergey Matyukevich 43736cf03f stm32/f0: RTC clock helpers
Add three more RTC clock helper functions:

- rcc_set_rtc_clock_source
  RTC on stm32/f0 can be clocked from the following three
  sources: LSI, LSE (32.768Hz), HSE/32.

- rcc_enable_rtc_clock
- rcc_disable_rtc_clock
  enable/disable clocking RTC module using selected clock source

Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
2017-03-30 21:48:07 +00:00
Karl Palsson 7ee1d948e9 stm32f0:usart: Correctly allow >8bit words.
Make them 16bit regs, like on other periphs.  This allows proper access
to the "8th" bit.  (0..8 is 9 bits, not 8)

Found and reported in https://github.com/libopencm3/libopencm3/pull/651
2017-03-30 21:48:07 +00:00
Karl Palsson d964dcfca4 stm32:usart: drop usart_get_interrupt_source()
It was never complete, even for F1 family code, and went on to be even
less complete for f0 and f3.  The usefulness of a library function to
check for both the irq being enabled _and_ the status flag is highly
questionable, and caused known user confusion.

The existing, much simpler, and fully functional usart_get_flag() is
a good replacement in almost all sane use cases.

Fixes https://github.com/libopencm3/libopencm3/issues/734
2017-03-30 21:48:07 +00:00
Karl Palsson c9c5cb7c9c style: fix some of the easier style bugs
No real changes.
2017-03-30 21:48:07 +00:00
Karl Palsson 23cf491501 stm32: adc-v2: extract common calibration code
Extract the calibration code from the f0, and share it with the other
adc-v2 peripheral users (f0,l0,f3,l4)

Uses the same naming set of is/async naming conventions requested by the
RTOS guys instead of having blocking only calls.

Old code:
	adc_calibrate_start(ADC);
	adc_calibrate_wait_finish(ADC);

New code (blocking):
	adc_calibrate(ADC);

New code (asynch):
	adc_calibrate_async(ADC);
	// do stuff
	adc_is_calibrating(ADC);  // will be false when it's finished.

Old code for f0 is still available, but marked deprecated.
2016-09-12 23:29: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
Karl Palsson 614c700edb stm32f0: timers: input capture support rising/falling edges
This is common code for f0234, keep renaming files as has become standard, even
if it's a suboptimal solution.  This doesn't rename the header which was not
renamed for f3.

Reported-by: https://github.com/gtoonstra
2016-08-15 21:10:03 +00:00
Cem Basoglu 6b5150a4dc stm32: usart-v2: Extended USART functions (data/pin inversion, half duplex)
Includes receive timeout, all inversions and duplex and convenience functions.

Applies for F0 and F3 so far.
2016-04-01 22:49:18 +00:00
Karl Palsson 81319a96fb stm32: adc-v2: pull up start_regular
Little steps are easy to review, and easy to test.
2016-03-30 16:59:56 +00:00
Karl Palsson 8b7a5ce7aa stm32: adc-v2: pull up function prototypes
These are standard "api" level functions that need per target implementations,
but should all maintain the same signature.
2016-03-30 16:59:56 +00:00
Karl Palsson 5063ea0db7 stm32: adc-v2: pull up overrun and EOC flag methods
EOS vs EOSEQ is really a single/multi variant difference, so leave it out.
2016-03-30 16:59:56 +00:00
Karl Palsson b2af9e632c stm32: adc-v2: Pull up more common basic functionality
Pull up eoc/eos/read_regular functions.  More simple, basic core functionality.
2016-03-30 16:59:56 +00:00
Karl Palsson f1d50d24be stm32: adc-v2: pull up more common functionality
More easy bit on/off settings.  Every piece that gets pulled up here becomes
automatically available for l0/l4 when they land
2016-03-30 16:59:56 +00:00
Karl Palsson f67e217ffb stm32: adc-v2: Pull up the two forms of the adc-v2
The adc v2 periph has the same register map, but comes in two flavours, one
supporting injected channels, more watchdogs, per channel sampling times and
so on, and one "simple" version.

Pull up the f3 and f0 portions into the appropriate files, after comparing with
L0 and L4 reference manuals, even if those are not fully landed yet.
2016-03-30 16:59:56 +00:00