229 Commits

Author SHA1 Message Date
Karl Palsson
1bc8a015f7 doc: stm32: timer: fix trivial parameter misnaming 2019-06-17 22:33:32 +00:00
Karl Palsson
c28a5a81cf stm32: rng-v1: fix missing doxygen parameter 2019-06-17 11:48:18 +00:00
Guillaume Revaillot
7d344b187d stm32: dma: add dma_set_channel_request to ease dma cselr usage. 2019-06-17 11:44:44 +00:00
Karl Palsson
9f58ad4393 doc: fix trivial missing trailers or typos 2019-06-12 23:16:58 +00:00
Karl Palsson
9904f9803e doc: stm32: unify "peripheral API" titles
doxygen really wants the @defgroup _and_ the @addtogroup to both have
the full name, matching identically, to avoid all warnings.

Standardize on the "CAPS_PERIPH peripheral API" style.
2019-06-12 23:06:22 +00:00
Karl Palsson
b287bbd322 stm32: hash: move to peripherals API docs
Drop redundant .c files and add groupings and labels.  Eliminates
warnings from doxygen
2019-06-12 23:06:22 +00:00
Karl Palsson
e8f03b4615 doc: usbd: Add missing / incorrect parameters.
Just basic documentation to clear up errors for starters.
2019-06-12 23:06:22 +00:00
Karl Palsson
020d883338 doc: stm32: flash: fix missing doxygen trailer 2019-06-12 23:06:22 +00:00
Karl Palsson
c9d45e0e2c doc: stm32: move RCC to peripheral api style
For f7, it was completely missing doc markers
2019-06-12 21:56:09 +00:00
Bruno Randolf
833ddd9b0a stm32: rtc: clear wakeup clock selection
Clear wakeup clock selection before setting the desired bits, so no
old bits can stay set

Reviewed-by: Karl Palsson <karlp@tweak.net.au>
2019-06-02 22:18:05 +00:00
Karl Palsson
f2a9980638 stm32: doc: rtc: move to peripheral apis
Drop some dummy.c files, add some missing groupings and make sure all
specifics are included in the generated output.
2019-05-22 00:16:40 +00:00
Karl Palsson
0aef9c2ec6 stm32: doc: pwr: move to peripheral_api
Some families had partially moved to peripheral api, and others were
only documenting common code, but not specific code.  Delete dummy .c
files, and check that all specific apis are also being documented, not
just common apis.
2019-05-22 00:10:39 +00:00
Karl Palsson
da76279bc6 stm32: flash: move to peripheral_apis
Change the groupings and headings to make them all consistent.
2019-05-21 23:41:21 +00:00
Karl Palsson
1001a9323b stm32: doc: dma: move to peripheral_apis
drops dummy .c files, and adds proper groupings to the shared files.
2019-05-21 23:27:21 +00:00
Karl Palsson
9382042180 stm32: doc: move timer to peripheral_apis
Drop all the dummy timer.c files, and _actually_ compile the L1 specific
file that was dropped by accident in 5b8953124e in 2013!
2019-05-21 23:17:04 +00:00
Karl Palsson
508f8d9487 stm32: doc: gpio: move gpio to peripheral_apis
Drops dummy gpio.c files that weren't even being compiled in some cases.
2019-05-21 23:16:59 +00:00
Karl Palsson
d77f539013 stm32: doc: rng: migrate to peripheral apis
Gets them all documented properly, and cleans up the language that this
was just for F4.
2019-05-21 23:16:59 +00:00
Karl Palsson
1af3acdba4 stm32: doc: exti: fix missing/wrong groups and move to peripheral_api
Almost all families were missing all docs for the exti apis.
2019-05-21 23:16:59 +00:00
Karl Palsson
fe5e82a3cc stm32: doc: dac: move to peripheral_apis.
Drops all the stub dummy header files, many of which weren't even being
built, and moves them to the clean peripherals_api doc section.
2019-05-21 23:16:51 +00:00
Oliver Meier
07868ad8b6 stm32f7: enable existing dma2d headers 2019-05-19 21:33:07 +00:00
Oliver Meier
92a2340551 stm32f7: enable existing dsi support 2019-05-19 21:33:07 +00:00
Oliver Meier
5a03cfe54e stm32f7: enable existing ltdc
This uses the existing f4 code as a new shared common base code.
2019-05-19 21:33:02 +00:00
Oliver Meier
16cfc6d848 stm32f7: enable fsmc
This uses the existing f4 code as a new shared common base code.
2019-05-19 21:30:48 +00:00
Oliver Meier
4fc7196463 stm32f7: enable existing exti headers 2019-05-19 21:30:38 +00:00
Karl Palsson
e77bc94b8c stm32: adc-v1m: doc cleanups
Try and fix some of the specifics from old f4 source material.
2019-05-10 23:15:42 +00:00
Karl Palsson
8d9b455ac6 stm32: adc-v1m: pull out f4/f7 specifics
Sampling time and sequence length, along with the vbat channel are
specific to the f4/f7, and can't be shared with the l1 and friends.
Pull them out to their own common file.
2019-05-10 22:42:03 +00:00
Matthew Lai
0a3e1cc0e6 Renamed adc_common_v3 to adc_common_v1_multi 2019-05-09 11:54:19 +00:00
Matthew Lai
6703abf5e3 Added F7 ADC support (almost the same as F4) 2019-05-09 11:54:19 +00:00
M J Oldfield
fc8a6aa7a2 stm32: adc-v2: set _only_ the ADC calibration bit
In adc_calibrate_async() we should only set the ADCAL bit and leave the rest alone.

While in the past there were only "rs" bits in this register, this is no
longer the case.

Reviewed-by: Karl Palsson <karlp@tweak.net.au>
2019-04-28 00:11:56 +00:00
Guillaume Revaillot
c4c0d14ea4 stm32: exti: stm32g0 have enhanced EXTI_[FR]PR regs instead of EXTIR_PR, use them if defined.
Make exti_get_flag_status and exti_reset_request use EXTI_RPR and EXTI_FPR if present instead of EXTI_PR.

This is less precise than offered by the RPR/FPR registers, but makes
for a consistent experience in the common API.

Reviewed-by: Karl Palsson <karlp@tweak.net.au>
2019-01-31 09:57:46 +00:00
Guillaume Revaillot
b98dd8eee0 stm32: exti: exti_select_source: rework and use EXTI_EXTICR.
EXTICR on stm32g0 is in exti registers range. Previous chips used to have that
gpio port exti mux configuration accessible via AFIO_EXTICR or SYSCFG_EXTICR.

Also, the new chip now use 8 bits coded value instead of previously 4 for the
extcr mux selection value (see AFIO/SYSCFG/EXTI_EXTICR_FIELDSIZE)

Let's define two helpers:  EXTICR_SELECTION_REG (to get proper AFIO/SYSCFG/
EXTI_EXTICR register) and EXTICR_SELECTION_FIELDSIZE (to get proper AFIO/SYSCFG/
EXTI_EXTICR_FIELDSIZE value), and use it them exti_select_source to determine
exticr mux selection bits shift and mask.
2019-01-31 09:57:46 +00:00
Guillaume Revaillot
7afd86db30 stm32l[01]: flash common: add flash_unlock_acr, allowing to unlock FLASH_ACR RUN_PD bit.
flash_unlock_acr allows to unlock RUN_PD bit from FLASH_ACR register. Relock is done automatically
when writing 0 to RUN_PD, so no flash_lock_acr method.
2019-01-31 09:35:55 +00:00
mfm
f6517f7816 stm32: adc common v2: add circular dma mode
Tested only on the F3 so far.
2018-10-20 11:46:47 +00:00
Filip Moc
4b16af6e24 stm32: iwdg: correct calculation for all ranges.
The original calculations miscalculated ranges such as
512..639 or 1024..1151 or ... or 32768..32895

Reviewed-by: Karl Palsson <karlp@tweak.net.au>
2018-10-05 23:31:52 +00:00
Clara Casas
889b7de0d7 stm32: adc: Add functions to get and clear flags
This includes adding documentation to the status flags.

Originally tracked at: https://github.com/libopencm3/libopencm3/pull/833

Modified to drop whitespace changes, and simply boolean return.
2018-08-28 22:00:07 +00:00
Daniel Gröber
743513a4b1 stm32: add dma_get_number_of_data
Original discussion at: https://github.com/libopencm3/libopencm3/pull/702
2018-08-28 22:00:01 +00:00
Karl Palsson
26ab78a710 usb: fix race between setup complete and endpoint nak
See https://github.com/libopencm3/libopencm3/issues/873

Commentary describing this patch originally by zyp:

```
After looking further into it, I've concluded that my preliminary
analysis looks correct. The problem is that setting CNAK before
the SETUP complete event is received causes a race condition. The
SETUP callback is called when the SETUP packet event is received,
which means that setting CNAK from the callback is too early.

Originally the problem was that CNAK was set by ep_read() which is
called by the callback. #672 solved this by moving CNAK out of
ep_read() and calling it after the SETUP complete event is received
instead.

The regression by #785 is caused by the introduction of flow control
calls into the SETUP callback. They also set CNAK.

To solve this properly, I propose changing the event handling code
to only call the SETUP callback after the SETUP complete event is
received. Unfortunately, this implies that the callback can't call
ep_read() itself anymore, because the packet has to be read out of
the FIFO before the SETUP complete event arrives. This implies a
change of the API between the hardware drivers and _usbd_control_setup().
```

L1 (st_usbfs) works and passes tests as before change
F4 (dwc_otg_fs) works and now passes tests. (yay)
LM4f still compiles, and has had the same style of implementation as
st_usbfs, however has not been tested on any hardware.
2018-08-27 15:11:32 +00:00
fenugrec
01f33f47b7 USB: st_usbfs : fix USB_COUNTn_RX buffer size calculation:
Fixes https://github.com/libopencm3/libopencm3/issues/476

Sets USB_COUNTn_RX reg fields : bits <14:10> are NUM_BLOCK; bit 15 is BL_SIZE.
 - When (size <= 62), BL_SIZE must be 0 and NUM_BLOCK set to (size / 2).
 - When (size > 62), BL_SIZE must be 1 and NUM_BLOCK=((size / 32) - 1).

Previous code improperly set NUM_BLOCK and assumed the requested size was set.
Now, we use the next largest legal buffer size. Examples:
size BL_SIZE NUM_BLOCK => Actual bufsize
0    0       0         ??? (illegal !)
1    0       1         2
63   1       1         64
Algo is valid for F102, F103 and F0 devices (USB_FS peripheral).
In addition, the new usb_set_ep_rx_bufsize() function returns the actual
size set.

Tested-by: Karl Palsson <karlp@tweak.net.au>
2018-08-17 00:16:18 +00:00
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
231f21296f stm32: f247: flash: use common code.
This shows what is _actually_ different for f7.  A couple of option
bits, and a renaming of bit 7 of the status register, from Program
Sequence Error to Erase Sequence Error.

We keep the separate implementation of wait_for_last_operation, to meet
the "suggestions" of the reference manual to insert a DSB instruction.

Keeping the renamed bit/functions also requires us to keep separate
implementations of the flag clearing functions
2018-07-29 20:31:17 +00:00
Karl Palsson
46d4103c1d stm32: flash: move wait_for_last to f2/f4 explicitly.
We're preparing to use all the common code for f2, f4, f7 and large
chunks of l4.  Extract things that we know need to be done differently
there.
2018-07-29 20:31:17 +00:00
Karl Palsson
eafc46ff24 stm32: flash: extract wait_for_last_operation to top level
This then eliminates the misguided attempts at merging f2/4 and f3 flash
support.  Some headers remain.
2018-07-29 20:31:17 +00:00
Karl Palsson
a949b223c3 stm32f3: flash: pgerr is not the same as pgperr
F3's flash interface is actually quite different, don't try and force
sharing code that isn't really related.  The "PGERR" is a very different
bit than the parallelism error that f2/4/7 have.
2018-07-29 20:31:17 +00:00
Karl Palsson
850931dbcd stm32: flash_unlock_option_bytes is common code.
The keys differ between some familes, but the documentation and
implementation are standard.
2018-07-29 20:31:17 +00:00
Karl Palsson
c5a3350a7d stm32l: flash: rename option unlock keys or consistency
Paves the way for using common code.
2018-07-29 20:31:17 +00:00
Karl Palsson
4517ec81fd stm32: flash: remove superfluous locking of option bytes
Comments were not consistent, and this serves no purpose.  There's no
reason to explicitly lock the flash first before unlocking.  These bits
are simply set when the keys are written.
2018-07-29 20:31:17 +00:00
Karl Palsson
7a27795d8c stm32: flash: pull out i/d cache support.
Copied a few times.
2018-07-29 20:31:17 +00:00
Karl Palsson
2bf7eb4a0c stm32: flash: pull set_ws up to common code
All that changes is the size of the field.
2018-07-29 20:31:17 +00: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
da7ebafcbe stm32: flash: pull lock/unlock up to common_f.
This is a common operation, so definition in _all, and every part except
l0/l1 have the same implementation.  Bring in an _f file too.
2018-07-29 20:31:17 +00:00