Commit Graph

844 Commits

Author SHA1 Message Date
Karl Palsson 5f051241a8 stm32f1: rcc: provide struct based clock helpers
As on every other family.

Fixes: https://github.com/libopencm3/libopencm3/issues/1172
2020-11-28 22:13:25 +00:00
Karl Palsson a7902aa4d0 stm32l1: rcc/lcd: fix RTCSEL HSE definition
Wrong since original commit in 2013.

LCD code can't actually automatically determine clock speed if it's HSE,
as we don't know here whether what HSE is, nor what it's divided by.
For more fun, that old 2014 API doesn't have any way of flagging that it
failed either.  Hooray.
2020-11-28 22:13:25 +00:00
Manuel Bl e9c94760e6 stm32l4: enable USB OTG driver 2020-11-28 22:13:25 +00:00
Karl Palsson 76c0a8c289 stm32: rcc: convert to use new standard defines 2020-11-28 22:13:25 +00:00
Karl Palsson 43b3fa5ddc stm32l0/l1: flash: support half page flashing
Tested on L1 and L0 using the "dapboot" project, see
https://github.com/devanlai/dapboot/pull/27 for L1
and
https://github.com/devanlai/dapboot/pull/30 for L0
2020-11-28 22:13:25 +00:00
Karl Palsson 1acfa1c917 stm32l1: desig: handle flash size footnotes from refman
Some of the chipid variants have some footnotes on reading the flash
size register, make sure we report things nicely.
2020-11-28 22:13:25 +00:00
Karl Palsson e15071dbf8 BREAKING: drop all part specific ld files
We were never going to be capable of supporting every single part
variant with their own files, so stop trying.  We've been supporting the
linker script generator for a long time now, so move on from these old
static files.

Breaking: if you were using one of these, and don't wish to use the
linker script generator, you should simply declare a stub linker script,
and include the generic section definitions file, and provide this in
your own application.

Old:
LDSCRIPT = $(OPENCM3_DIR)/lib/stm32/l1/stm32l15xxb.ld

New (linker script generator):

DEVICE=stm32l151cb

New (manual):

* Add file mymemorymap.ld, with contents similar too:
```
MEMORY
{
       rom (rx) : ORIGIN = 0x08000000, LENGTH = 256K
       ram (rwx) : ORIGIN = 0x20000000, LENGTH = 48K
}

/* Include the common ld script. */
INCLUDE cortex-m-generic.ld
```

LDSCRIPT=mymemorymap.ld

See ld/README for more information on using the linker script generator
2020-11-28 22:13:25 +00:00
Dima Barsky 08c5f2a1fb stm32: i2c-v1: Fixed a typo in i2c_read7_v1 and i2c_write7_v1
Replaced & with &&
Wait for all three bits to be set - SB, MSL, and BUSY.

Old code worked by chance, use booleans to correctly convey intent.
Reviewed-by: Karl Palsson <karlp@tweak.net.au>
2020-10-16 12:00:20 +00:00
rma-x 24bef9c49e stm32:adc: Change bitwise AND to logical AND
The original bitwise AND was _functionally_ correct because all operands
were booleans, but it was very poor at conveying the intent.

Fixes #1230
2020-07-03 12:27:44 +00:00
Karl Palsson 503cebab87 stm32g4: turn on FPU in pre_main
Yep, all M4F need this file added.
2020-04-10 14:12:08 +00:00
Guillaume Revaillot 9bf6ce8b64 stm32g0: flash: add erase/program stuff
probably can be refactored with other chips, did not really looked yet.
2020-04-09 23:37:38 +00:00
Guillaume Revaillot d696e2c264 stm32g0: add device electronic signature offsets and build desig. 2020-04-09 23:37:38 +00:00
Karl Palsson 4e70d06d63 stm32g4: Add basic support
* memorymap
* vectors
* rcc
* gpios
* makefiles
* devices for linker script generation
* doc structure
2020-04-09 23:29:00 +00:00
Brian Viele b1d8a4c546 stm32h7: added minimal stm32h7 exti defs, which share with G0.
Separated definitions that did not seem consistent between the "v2" EXTI
platforms. Added SYSCFG defs needed for EXTICR settings.
2020-03-23 09:23:21 -04:00
Karl Palsson 4a11e354a3 stm32l1: desig: use new mechanism to support different densities
Fixes: https://github.com/libopencm3/libopencm3/issues/234

uses the new mechanisms introduced to address a similar problem on F7.

Tested on a medium density part (0x429) that returns the same ids as
before, tested on a high density part that now _doesnt_, but that's now
correct :)
2020-03-06 22:53:03 +00:00
Karl Palsson 3df3ed7db9 doc: stm32f0/f3: adc: fix doxygen warnings 2020-03-06 01:13:22 +00:00
Brian Viele 4953d67aaa stm32h7: per comments, improved consistency with other rcc impls.
Reduced the sea of enums, and renamed config parameters to match other
implementations, cribbing off of the G0 config, as it is closer to the level
of complexity. Updated initialization code to utilize the new values.

Added flash and LDO configuration from RCC init to be more consistent with
STM32 platform initialization.
2020-03-05 22:07:10 +00:00
François Finfe fb0cac49cb stm32: adc-v2: add adc_{en,dis}able_delayed_conversion_mode
To control AUTODELAY feature of the ADC.
2020-03-04 23:29:31 +00:00
Karl Palsson f1073e7991 stm32h7: stop attempting to use common usart code.
Until h7 implements a method of providing the periph clocks in a
compatible manner, they simply can't use the common_all files.
2020-03-04 23:24:02 +00:00
Brian Viele 2ca56f4c21 stm32h7: updates to PWR and RCC to support PLL configuration.
PLL configuration on the H7 is pretty involved, and takes a number of
configurations to make it work. In order to make peripheral drivers a bit
easier to implement, working with a soft clock tree in the rcc module which
stores the clock settings for each clock as they are setup such that users
can request the clock value from the RCC module for configuration. Added
getter for the clock which allows the user to pass the base address of the
peripheral, and get the peripheral clock value for convenience.

Clock configuration is still missing values for setting up all of the kernel
clocks for the peripherals, but this is in work, and there is a framework to
do so.

Have tested to 400MHz without issue. Peripherals that are explicitly supported
are working and the clock tree values appear to follow correctly.

Added LDO settings to allow setting the scaling to support high frequencies.
2020-03-04 23:17:02 +00:00
Matthew Lai 97688b913e stm32: desig: refactor to allow targets to have different addresses
In this commit, support for the different base addresses for different
F7 parts is added, but the mechanism is now in place for L1 and others.

Reviewed-by: Karl Palsson <karlp@tweak.net.au>
(whitespace fixed, commit msg reworded)
2020-03-04 22:16:31 +00:00
Karl Palsson f1b4a4dfff stm32f3: adc: consistently use unshifted
and tweak teh docs a little
2020-03-04 22:02:45 +00:00
François Finfe 49285ed8e1 stm32f3: fix missing reg mask for adc_set_multi_mode
Missing defines for ADC_CCR DUAL values have also been added.
2020-02-19 00:13:00 +01:00
Karl Palsson 7da29d3d5f stm32: desig: doc: merge duplicate documentation sections
Use the best one.
2020-01-28 23:03:39 +00:00
Karl Palsson 8c37e5cea0 stm32: crc: merge duplicate documentation
Avoids warnings from doxygen.  Leaves it purely in the headers so it's
accessible in code completion as well.
2020-01-28 22:41:14 +00:00
Guillaume Revaillot a8a92b4c11 rng: fix clock error handling, based on RM.
According to L4/L0/G0 RM, in case of clock error, interrupt flag must
be cleared, and CECS flag should be cleared as soon as clock meets
requirement.

Reviewed-on: https://github.com/libopencm3/libopencm3/pull/1062
2020-01-05 00:25:12 +00:00
Guillaume Revaillot 5866852a90 rng: handle noise source / seed error.
If noise source error occurs, flag must be cleared and data register
must be discarded (at least 12 reads to flush pipeline on G0). Other
device mention start/restart of chip, so, do both (better safe than
sorry).

Reviewed-on: https://github.com/libopencm3/libopencm3/pull/1062
2020-01-05 00:25:00 +00:00
Guillaume Revaillot 5a53f18a78 rng: check error before checking if data ready.
mostly cosmetic, but ease debugging.
2020-01-05 00:24:43 +00:00
Guillaume Revaillot 64baacfbbf rng: add irq enable/disable helper. 2020-01-05 00:24:43 +00:00
Jacob Walser e2ac1a6358 stm32f3: bugfix + adjust wwdg threshold signatures to support 12 bit resolution
- these registers are 12 bits wide
- bugfix clearing thresholds so that both upper and lower thresholds can be
  configured on the **window** watchdog
2020-01-05 00:10:12 +00:00
Jacob Walser a759a0d9c9 stm32f3: unify implementation with f0 adc_enable_analog_watchdog_on_selected_channel
- match the same logic as the f0 api
- use ADC_CFGR1_AWD1CH_VAL macro to mask the channel bits
- don't check if channel is < 18q
- enable the awd in addition to setting the selection to single channel monitoring (in following with the signature and @brief 'enable'
2020-01-05 00:10:01 +00:00
Jacob Walser 854da9635e stm32f0: adjust wwdg threshold signatures to support 12 bit resolution 2020-01-05 00:08:48 +00:00
balanceTWK 6fc1ff225e stm32:L4:flash: support erasing pages on bank 2
Reviewed-by: Karl Palsson <karlp@tweak.net.au> (fixed code style)
2020-01-05 00:03:06 +00:00
Guillaume Revaillot db6237cd1e stm32: extract g0 exti stuff to exti_common_v2.
stm32l5 basically uses the same stuff.
2020-01-01 19:47:13 +01:00
Sam Protsenko f7a952c41a stm32: Fix typo in RCC related comments
ABP -> APB

Signed-off-by: Sam Protsenko <joe.skb7@gmail.com>
2019-12-26 13:46:30 +00:00
Karl Palsson df15b263d2 usb: hid: add a stub file for doxygen
Unlike with the doxygen source generation, we can't autoguess which of
the class files are eligible automatically.  Instead, make a stub hid
file, (which we can now start adding to, if desired) and include it in
all builds that include other class stubs.
2019-12-25 21:04:17 +00:00
Guillaume Revaillot f70f0d0b7b stm32g0: pwr: doc: remove duplicated ingroup 2019-12-25 20:34:11 +00:00
Guillaume Revaillot 169d23568f stm32: lptimer: fix documentation 2019-12-25 20:34:11 +00:00
Karl Palsson a5b6673b62 stm32: usart-v2: fix some doxygen linking problems 2019-12-25 20:30:03 +00:00
Brian Viele aabefeac92 stm32h7: usart: support new fifo features
Supported by H7 and G4 varieties at present.
2019-12-25 20:29:24 +00:00
Karl Palsson 9598b7f424 doc: stm32:rcc: flag "better" periph enable options
The original rcc_peripheral_enable_clock aren't explicitly deprecated,
as they do let you enable multiple periphs in one call.  But they're
error prone, from user feedback, so update the docs to ensure people
know what the other options are.
2019-12-12 20:37:58 +00:00
Karl Palsson 85275fd62e stm32f1: adc: doc: drop undocumented examples
There's already example code, this was just conflicting extra code that
wasn't being included in doxygen anyway.
2019-12-12 20:36:51 +00:00
Karl Palsson 557e7aa50f doc: avoid usage of rcc_peripheral_enable_clock
Use the simpler, safer rcc_periph_clock_enable instead
2019-12-12 20:35:57 +00:00
TomasPech 4a9ba30138 stm32f4: rcc_clock_setup_pll() correctly enable PWR
Original code used the special macros for rcc_periph_clock_enable
instead of the appropraite APB1ENR bit definition.

Switch to the correct, simpler form, using the correct parameter.
2019-12-12 20:12:27 +00:00
Mathias Nord 9af9a1dbfa stm32g0: use spi v2 2019-12-03 14:45:47 +01:00
Brian Viele 53302439df stm32h7: Initial introduction into libopencm3.
Updates to a base set of includes to map to the h7 include files which are
mainly based on the f7 versions for simple devices (e.g. SPI, USART, GPIO).

Custom files that have been implemented from the datasheet/ref manual include
the memory map, RCC, PWR definitions, and irq.json file for generation of
nvic files for interrupt mapping.

Additional functionality, especially PLL and tweaks for non-F7 compatible
implementations coming in future commits.

Added documentation tree configuration.

Reviewed-by: Karl Palsson <karlp@tweak.net.au>
Changed dmaX_streamX to dmaX_strX in a few places for consistency
2019-11-28 22:15:24 +00:00
Guillaume Revaillot 38b45c8786 stm32g0: add adc.
v2 "single" peripheral with a couple of tweaks :
 - added registers to configure two additionnal advanced analog watchdog.
 - different adc sampling time time based on channel groups.
 - 8 steps adc sequence injection, using chselr/chselrmode.

And a note on the rm explaining that after every configuration change to ADC_CFGR1's
SCANDIR or CHSELRMOD or CHSELR register, user need to check that configuration
is applied before any other modification / adc conversion start.. making adc_set_reqular
a bit painfull to read..
2019-11-08 14:19:17 +00:00
Guillaume Revaillot a34da53c30 stm32g0: add dmamux
DMAMUX peripheral is a dma request router/trigger, present on g0, wb, h7 and l4+.

Basically it allows to easily map peripheral requests to whatever dma channel we
want to use (similarily to the DMA_CSELR register, but without limitation) but,
it also also adds some clever dma request synchronization and even some dma request
generation logic via internal request generator "channels", allowing some requests
chaining, or triggering reqs from non dma capable peripherals.

nb: g0 only features 1 dmamux bloc, supports 7 irq and 4 generators, l4+ supports 13
dma channels and 3 generators and h7 has two dmamuxes, with support for the 15 dma
channels and 7 generators - so as much CxCR and RGxCR register - but they are bit
to bit compatible - excluding of course the sync/sig and dma requests id mappings.
btw, currently, request generator channels are defined in common header, but maybe
we should define them in device header ? or we dont care (like for dma channels,
only defined in dma_f24 but not for other devices ?).

See ST AN5224 for more information
2019-11-08 13:47:41 +01:00
Guillaume Revaillot b9f183bf1e stm32g0: add dma.
same same, bit for bit, except not ;) - Channel request mapping now
depends on a new DMAMUX peripheral, and there's no default preset.
So, before enabling dma channel after its configuration, request
must be configured by :

dmamux_set_dma_channel_request(DMAMUX1, DMA_CHANNELx, request_number_from_datasheet);
2019-11-08 13:47:41 +01:00
Nicholas Rossomando 77d96a3430 stm32l0: crc: enable common code 2019-10-12 14:11:39 +00:00