Commit Graph

1530 Commits

Author SHA1 Message Date
Karl Palsson 709d98e0a8 doc: stm32g0: drop redundant @ingroup and close groups
the group defaults to the implicit container based on location, so drop
all the explicit @ingroups, less to maintain.  Properly use /**@}*/ to
close all groups too, even though it mostly seems to have worked anyway.
Properly close all groups opened for files.
2019-05-21 21:44:05 +00:00
Karl Palsson bc6af71443 doc: predefine a group for the cortex peripherals.
They were all trying to use this, via @ingroup CM3_files, but that group
didn't exist, so they just got left dangling as "systick_file" and
similar.
2019-05-21 21:41:41 +00:00
Karl Palsson b24d7f96b5 stm32: standardize OSPEED values
Make the names match the reference manuals properly, and add missing
names.  Still a long way to go to unify across all families, but this is
at least closer.
2019-05-21 00:05:22 +00:00
Guillaume Revaillot ee376eafdb stm32g0: make doc. 2019-05-21 00:05:22 +00:00
Guillaume Revaillot 55121126c3 stm32g0: add exti.
Regular exti, with enhanced EXTI_[FR]PR regs instead of EXTIR_PR.
2019-05-21 00:05:22 +00:00
Guillaume Revaillot afd2db3097 stm32g0: add rcc. 2019-05-21 00:05:22 +00:00
Guillaume Revaillot cbe5425090 stm32g0: add flash.
here, it's a bit of a mess.. G0 flash controller does not really
match exsting feature split. IE it has instruction cache only ..
so, no flash_idcache.c as it. flash_common_f could be used, but
flash_unlock would not take care of option byte ?

prefetch, icache and lock is ok. I had no look at flash programming
or erase yet..
2019-05-21 00:05:22 +00:00
Guillaume Revaillot f13a9eee5b stm32g0: add power.
neither v1 nor v2...
2019-05-20 23:59:42 +00:00
Guillaume Revaillot c49937a09c stm32g0: add gpio.
regular peripheral.
2019-05-20 23:43:46 +00:00
Guillaume Revaillot b8d4b03722 stm32g0: add base, irqs, memorymap and current devices. 2019-05-20 23:43:41 +00:00
Karl Palsson 8a952d8476 gd32: drop commit of generated code 2019-05-19 21:39:46 +00:00
Oliver Meier 82d2ff9d1a stm32f4-7: dma2d: fixed wrong color definition and added missing one 2019-05-19 21:33:07 +00:00
Oliver Meier 07868ad8b6 stm32f7: enable existing dma2d headers 2019-05-19 21:33:07 +00:00
Oliver Meier 82498bb49f stm32f7: fixed typos in dsi header definitions 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
Matthew Lai c801a7ffec stm32f7: Rename USART7/8 to UART7/8.
Matches the existing irq names and the reference manual correctly.
2019-05-19 20:43:57 +00:00
Karl Palsson 888fee1409 stm32l1: adc: use the new v1-multi headers.
This drops a lot of now common definitions.  This is still just
prepratory work before using the v1-multi code itself.
2019-05-10 22:35:10 +00:00
Karl Palsson c858a1e5f5 stm32: adc-v1m: extract some portions back to f4/f7.
While this appears to be a backward change, this moves the _register_
definitions (their addresses) and the actually specific to f4/f7
numbering back into the explicit headers.  Potentially this could be
pulled out again, but it's not much code.

This then allows the stm32l1 to use all the rest of this code, with the
differences really being just the addresses of the registers.
2019-05-10 22:30:31 +00:00
Karl Palsson 7076619dd7 stm32: adc-v1m: drop lots of noisy useless defines.
Never seen any reason for these noisy verbose defines.  They're not
helpful, and we've never needed them for doing sequence setting code
anyway.  Just drop them.
2019-05-10 22:27:20 +00:00
Karl Palsson 53c6e617b5 stm32: adc-v1m: tightenup definitions
Use the masks and shifts defined. common style.
2019-05-10 22:20:29 +00:00
Karl Palsson 45e14a7bd3 stm32: adc: fix f4/f7 temperature sensor channel defines.
Lots of common stuff, but the F7 fixed the temperature sensor randomness
that the f4 had.  Separate the definitions properly.
2019-05-10 22:18:08 +00:00
Karl Palsson cc364d1ac2 stm32: adc-v1m: fix include guard 2019-05-10 22:16:33 +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
Karl Palsson ca43a73ea3 stm32: dac: move DAC_SR to common.
It's available on f0, f2, f3, f4, f7, l0, l1 and l4.
Just note that it's not available on f1.
2019-05-09 11:49:25 +00:00
vector 486446e1db STM32F4-7: add DAC_SR status bits
Include the DAC_SR register and it's bits.  Arguably this should be jsut
included in the common_all file.
2019-05-09 11:39:44 +00:00
vector 5dbdb255d8 STM32F7: dac: include in build.
Based on F4.
2019-05-09 11:34:16 +00:00
Marek Koza e50ce6a876 stm32l4: Correct memorymap and add the existing CAN library 2019-04-30 20:47:14 +02:00
Ross Schlaikjer 4fb67d891f stm32f7: enable existing ethernet libraries 2019-04-15 13:11:05 +00:00
Ross Schlaikjer 395c024458 stm32f7: enable existing syscfg headers 2019-04-15 13:10:48 +00:00
Ross Schlaikjer a92a44a7c2 stm32f7: enable existing CRC support 2019-04-15 13:10:37 +00:00
Ross Schlaikjer 0173ecec9c stm32f7: enable existing IWDG support 2019-04-15 13:10:21 +00:00
Karl Palsson 72a7284355 doc: hook up gd32f1x0 documentation
Super easy now thanks to the earlier changes.
2019-04-15 13:06:48 +00:00
Ross Schlaikjer 4db40e0839 stm32f7: Include i2c_common_v2
With the addition of a define for I2C4, the existing common i2c
functions seem to work out of the box on the F7 (tested on an
STM32F750).
2019-04-04 22:11:20 +00:00
Icenowy Zheng 330d5fd5be gd32: add new chip series f1x0
GD32F1X0 (X can be 3, 5, 7 and 9) is a series of Cortex-M3 MCUs by
GigaDevice, which features pin-to-pin package compatibility with
STM32F030 MCU line. F150 adds USB support to F130, and F170/F190 adds
CAN support.

Currently the code mainly targets GD32F130 and F150 chips. Some register
are different between F130/150 and F170/190, just like the difference
between STM32F1 Performance line and Connectivity line.

From the perspective of registers and memory map, GD32F1X0 seems like a
mixture between STM32F1 and STM32F0 (because it is designed to be
pin-to-pin compatible with F0, but with Cortex-M3 like F1). A bunch of
code are shared between STM32 and GD32, and these code are specially
processed to include the GD32 headers instead of STM32 headers when meet
GD32F1X0.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>

Reviewed-by: Karl Palsson <karlp@tweak.net.au>
gd32/rcc.[ch] are forks of stm32f1/rcc
gd32/flash.[ch] are forks of stm32f0/flash
No attempts at deduplicating this have been done at this stage.  We can
see where they move in the future.
2019-04-03 12:53:33 +00:00
ALeX Kazik 8064f6d0cb stm32f4: fmc: add missing DECLS wrappers
Function prototypes need DECLS wrappers for inclusion in c++/asm
2019-01-31 09:59:59 +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 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
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
Harold Tay 9cadd60b3c stm32: rtc: Fixed typo in macro def (RTC_DR_MT_MASK) 2019-01-18 10:32:43 +00:00
Guillaume Revaillot 708fe1516c stm32: fix nvic channels name to match dma1/2 on stm32f09x 2019-01-18 10:31:32 +00:00
Darrell Harmon 718f86935a EFM32 I2C: fix base undeclared
libopencm3/include/libopencm3/efm32/common/i2c_common.h:234:29: error: 'base' undeclared (first use in this function)
 #define I2C0_CTRL  I2C_CTRL(base)
2019-01-14 11:51:08 +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 4edba3111d common: support inclusion into assembly files
Suggested in https://github.com/libopencm3/libopencm3/pull/981
2019-01-11 23:09:27 +00:00
Karl Palsson ad10e96811 stm32l4:dma: add Channel Selection defines
Far from complete support for the channel selection systems on f0/l4,
but at least brings in the defines needed for doing this yourself.

Fixes https://github.com/libopencm3/libopencm3/issues/1001
2018-12-30 21:03:40 +00:00
Alfred Klomp 1adc418f9a stm32f42/f43: rcc: add 180 MHz clock options 2018-11-12 21:41:05 +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 3af05fb862 stm32f7: spi: fix include error
Badly splitting commits.

Fixes: 2619a45 stm32f7: use spi v2 peripheral
2018-10-23 21:43:29 +00:00
Karl Palsson 1883a4311f msp432: whitespace fixups spaces->tabs
whitespace only change.
2018-10-23 21:33:16 +00:00
Dmitry Rezvanov a63d0499de msp432/e4: Add GPIO support 2018-10-23 21:21:54 +00:00
Karl Palsson 076cd67530 stm32: spi-v2: Frame format is available for all.
All spi v2 peripherals include the Motorola/TI Frame formatting options
introduced with F2.
2018-10-23 21:21:36 +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
Karl Palsson bc7e454741 stm32f7: include common dma code
Originally reported at https://github.com/libopencm3/libopencm3/pull/978
2018-10-20 11:40:38 +00:00
Guillaume Revaillot 18eadcfda5 stm32: timer_common: add timer21-22, found on stm32l0 chips.
stm32l0 devices have tim21 and tim22.
2018-10-06 09:53:54 +00:00
Karl Palsson 239b4a4704 stm32f7: add irqs from latest ref manuals
Updated from RM410 rev4, RM0385rev8 and RM0431 rev3

Originally reported at https://github.com/libopencm3/libopencm3/issues/974
2018-10-03 17:12:42 +00:00
Karl Palsson 6b0fd864a1 stm32f7: fix RCC_APB1 defns for USART7/USART8
The reset and low power definitions for USART7/USART8 were correct, but
not the primary enable registers.

Fixes: https://github.com/libopencm3/libopencm3/issues/969
2018-09-24 10:35:16 +00:00
Karl Palsson 0d7f1f7708 stm32: f24: dma: clarify stream/channel
It's always stream on the "new" dma controller (unless it's channel....)

Fix a couple of inconsistent prototypes that had carried over from f1
originally.  Reported by vampi on irc.
2018-09-15 09:27:31 +00:00
Karl Palsson 9ddafa6284 stm32f7: enable common timers support 2018-09-09 16:38:56 +00:00
Karl Palsson cae295ee2c doc: cm3/scb+scs: turn on existing documentation
Lots of registers were already documented extensively.  Turn it all in
doxygen with groups and the right syntax.
2018-09-09 15:27:41 +00:00
Karl Palsson 1ad2cda496 doc: add all cm3 headers to doxygen.
Just get them all included as they are.  Gets them grouped up and
visible so we can start clarifying the rest of their docs.
2018-09-09 15:27:41 +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 824beaa472 lm4f: timers: add basic register definitions
Add the timers to the memory map and the basic registers at least.
2018-08-28 13:26:11 +00:00
Florian R. Hölzlwimmer f3c620b51b stm32f7: spi: include common code 2018-08-27 22:57:28 +00:00
Karl Palsson 22754f0919 usb: provide lm4fusb driver reference
We provided references for all the others, provide it for the lm4f
driver too.
2018-08-27 15:11:32 +00:00
David Lamparter ebcf197810 usb: make usb_disconnect() weak
usb_disconnect() is board/platform specific for chips that don't have
built-in handling for this.  Allow the application to provide its own
version of usb_disconnect() to handle this.

See https://github.com/libopencm3/libopencm3/pull/924
2018-08-27 15:11:32 +00:00
David Lamparter 343cff4675 usb: make strings "const char * const *"
This allows the pointer table to be in Flash, by using
"static const char * const strings[] = { ... };"

See https://github.com/libopencm3/libopencm3/pull/924
2018-08-27 13:34:52 +00:00
Karl Palsson fa7a908027 doc: msp432/e4: Fix groupings for doxygen
Proper closing tags, an outer grouping, and don't refer to missing
groups.
2018-08-27 13:34:40 +00:00
Dmitry Rezvanov 2adefd95fe msp432/e4: new target
Basic memory map and system control.

Originally tracked via: https://github.com/libopencm3/libopencm3/pull/946
2018-08-27 13:34:29 +00:00
Karl Palsson 0c91dbf57e cm3: scs: drop (superseded) helper macros for systick
These are superseded by cm3/systick.h and the functions there.

Reported originally under: https://github.com/libopencm3/libopencm3/issues/125
2018-08-21 21:20:57 +00:00
Karl Palsson cfe514913f cm3: scs: drop (superseded) dwt macros
They are all superseded by dwt.h, and the function dwt_enable_cycle_counter

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

(But only for the cycle count enabling)
2018-08-21 21:20:51 +00:00
Karl Palsson 6fa75afbc6 usb: add USB_REQ_TYPE_OUT to match USB_REQ_TYPE_IN
#defines are free.

Fixes https://github.com/libopencm3/libopencm3/issues/515
2018-08-20 23:53:07 +00:00
Jordi Pakey-Rodriguez 21b23f1ff1 stm32f4: adc: Add VBat sensor enable/disable
Original discussion at: https://github.com/libopencm3/libopencm3/pull/770
2018-08-19 23:26:04 +00:00
Karl Palsson 0787675332 st32l1: adc: there is no adc_chan_vbat on L1x. 2018-08-19 23:26:04 +00:00
Karl Palsson 0e58ee2f65 stm32: support i2c3 properly
I2C3 is on many parts, but wasn't properly supported with the register
definitions.  Declare them centrally, just depending on the memorymap
defining them. On some parts, the rcc bits were defined, but not the
base registers.

Fixes: https://github.com/libopencm3/libopencm3/issues/820
2018-08-17 00:15:01 +00:00
Karl Palsson b8ede60d9d stm32f3: flash: support basic write/erase operations
Originally filed as https://github.com/libopencm3/libopencm3/pull/627
2018-08-17 00:15:01 +00:00
Karl Palsson 3293913be2 stm32f3: flash: add clear write protect flag
Could actually move to flash_common_f, but they have different names for
the same bit at present.
2018-08-17 00:15:01 +00:00
Karl Palsson f4bbe7c5bb usb: prevent registering duplicate config callbacks
Originally discussed at https://github.com/libopencm3/libopencm3/pull/722
2018-08-17 00:15:01 +00:00
Karl Palsson 49a8c041ff stm32f3: comparator: fix doxygen and use standard mask/shifts
Convert to standard style of unshifted field values.
2018-08-17 00:15:01 +00:00
Markus Kasten 0d0f59d8ce stm32f3: add comparator register definitions 2018-08-17 00:15:01 +00:00
Chris Sp 8b1ac585df stm32f4: rcc: typo fix MCO2
Just a small typo I came across while trying to get MCO to work on my board.
The define is not used in any other files as far as I can tell, but of
course applications might break if they use the misspelt variant.
2018-08-07 15:12:58 +00:00
Karl Palsson ddc7ab8c6c stm32l4: flash: don't use misleading names
flash_clear_pgperr_flag is a name used on f247, which is actually most
analogous to the SIZERR bit on l4, (it's a parallelism error)

the bit being cleared originally in this function, PROGERR is a new bit,
and should have it's own name.

Add a function to handle the previously unhandled size/parallelism flag,
and rename the existing one to properly reflect it's new name.
2018-07-29 20:31:17 +00:00
Karl Palsson 659d52b952 stm32f7: flash: drop unimplemented function declaration
flash_art_disable was never implemented, and isn't really a super useful
function anyway, so just drop the decl, rather than implementing it.
2018-07-29 20:31:17 +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 76d392ee47 stm32: flash: drop common_f234
Move the last few register defines back to their relevant headers, add
doxygen and groups.  While these registers _were_ "common" they were the
_only_ common things, so it's simpler for future work (merging f7 with
f2/4) to move them back separately.
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 c272ea410e stm32: flash: move clear all status flags to single common header
We've got a "f" flash file for common apis now, use it.
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 b9448bff16 stm32l4: flash: fix page erase for second bank
l4 is pages, not sectors, so update apis to be consistent. (other
families use page/sector as defined in the reference manual)
Make sure that pages on the second bank can also be erased.  Use the
same style in use for f2/4/7 for sector numbers across banks.
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 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
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
Karl Palsson 9dd901ba27 stm32: flash: BSY bit has never been writable.
This has been copied around for years, but has never been a writable bit
on any target.
2018-07-29 20:31:17 +00:00
DanielePettenuzzo 6e1edc3656 stm32f7 usart.h: add macro for usart6 and uart 7 and 8 2018-07-29 20:31:17 +00:00
Jordi Pakey-Rodriguez cc8c8a2f83 stm32f4: power: update rcc_clock_scale enum
- Change .power_save to .voltage_scale, a pwr_vos_scale enum
- Enable pwr clock before setting VOS scale
- Fix flash wait states
- Make flash_set_ws more robust
2018-07-29 20:31:17 +00:00
Karl Palsson e076c3cadd doc: stm32: rtc common v2: convert comments to doxygen
Grouping and making the existing comments doxygen friendly
2018-07-29 20:31:17 +00:00
Alexey Ryabov 22f7348b89 stm32: rtc: add missing definitions 2018-07-29 20:31:17 +00:00
Karl Palsson 33ef6fd816 stm32f3: rcc: fix extern name for hsi structs
Fixes: ab9e425272
2018-07-29 20:31:17 +00:00
keepkeyjon f53e12d2da cm3: Only inline asm is allowed in naked functions
According to: https://gcc.gnu.org/onlinedocs/gcc-6.2.0/gcc/ARM-Function-Attributes.html

"Only basic asm statements can safely be included in naked functions (see Basic
Asm). While using extended asm or a mixture of basic asm and C code may appear
to work, they cannot be depended upon to work reliably and are not supported."
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
Matthew Lai 68fce5a0ab stm32f7: rcc: fixed wrong constants, added more settings, clock setup refactoring 2018-07-03 22:23:00 +00:00
Matthew Lai ba0e0424b5 stm32f7: flash: added proper support 2018-07-03 22:23:00 +00:00
Karl Palsson ab9e425272 stm32f3: rcc: add hse preconfigurations
Just a single 8Mhz in, 72mhz (max) out, which suits the f3 discovery
boards for instance.
2018-07-03 22:23:00 +00:00
Karl Palsson ee8b5bf4ac stm32f3: rcc: drop useless 44MHz clock structure.
This clock speed is not USB compatible, it's not the maximum for
anything, nor the minimum, it's just a distraction.  Drop it.
2018-07-03 22:23:00 +00:00
Chuck McManis 1e9a2e641c stm32F4: LTDC - bit defines without semantics
The LTDC include file was defined with combined bit
semantics and bit position. As a result instead of
LTDC_GCR_VSPOL which is the bit which defines vertical
sync polarity, this had been defined to be
LTDC_GCR_VSPOL_LOW (0) and LTDC_GCR_VSPOL_HIGH (non zero).
This sort of define makes it impossible to know ahead of
time what operation would set or reset the bit (some are
negative logic, others are postive logic, so affirmative
defines could mean either "set the bit" or "reset the bit"
I've added the non-semantic bit define so that it is clear
in my code if the bit is being set or reset.

Discussion took place at https://github.com/libopencm3/libopencm3/pull/889
2018-07-03 22:23:00 +00:00
Karl Palsson 034dbf20ff stm32: timers: drop deprecated timer_reset()
We didn't actually mark it deprecated very well, but it was
non-functional, and simply a poorly implemented wrapper for
rcc_periph_reset_pulse() anyway.

It's now been obsoleted in the examples for more than a year, and it's
time to kill it outright.

Fixes: https://github.com/libopencm3/libopencm3/issues/709
2018-07-03 22:23:00 +00:00
Sebastian Holzapfel dfc67c03dc usb audio: add descriptors for streaming feature units 2018-07-03 22:23:00 +00:00
Martin Sivak 572a50a53c stm32l0: include rtc module 2018-07-03 22:23:00 +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 2352d5d1fb stm32: i2c-v2: Fix typo in CR1_ADDRIE
Reported in: https://github.com/libopencm3/libopencm3/issues/925
2018-06-07 12:01:11 +00:00
Karl Palsson 2204f447bb BREAKING: stm32f3:rcc: add more generic pll setup routines
Deprecate the old routine and make a new one that actually handles HSI
and HSE properly, and includes the predivider and the usb divider
settings as well.
2018-05-01 22:23:44 +00:00
Karl Palsson 622475f543 BREAKING: stm32f3:rcc: use more common MUL names
Make the defines as they are on other families, try and make more
defines the same, not arbitrarily different.
2018-05-01 22:19:28 +00:00
Karl Palsson ef44bdd09e BREAKING: stm32f0/f1: standardize flash_prefetch_xx
use the same API on all families, flash_prefetch_{enable,disable}()
2018-05-01 22:19:28 +00:00
Karl Palsson 389ec82538 stm32f3: flash: add prefetch helpers
Should be added to f2/f4 as well, but the bit definitions are different.
2018-05-01 22:19:28 +00:00
Martin Sivak f0e128673d Add DMA support to STM32L0
STM32L0 uses the same DMA peripheral as STM32F0, F1, L1 and others
with some differences. Those are mostly in the number of supported
controllers and channels.

This patch enables the basic support with no attempt to only expose
the available controllers / channels.

For more information see the ST Application Note AN2548.

Signed-off-by: Martin Sivak <mars@montik.net>
2018-04-29 19:22:13 +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
Karl Palsson 34462ac54a stm32: adc v2: add some minor doxygen 2018-04-28 21:12:27 +00:00
Vegard Lillevoll 41cad7c065 stm32: adc-v2: Add ADC_CFGR1_AUTOFF 2018-04-28 21:12:27 +00:00
Vegard Lillevoll bbe71b4c4f STM32F0: Added ADC1_CCR definition 2018-04-28 21:12:27 +00:00
Karl Palsson 64c5535693 stm32l0: adc: add sample time definitions 2018-04-28 21:12:27 +00:00
kbob e8154aa44a efm32: Add EZR32WG "EZRadio Wonder Gecko" family. 2018-04-27 21:37:03 +00:00
kbob c3889b91df efm32: Add EFM32WG "Wonder Gecko" family. 2018-04-27 21:37:03 +00:00
kbob 5160d7996c efm32: Split efm32/lg into /lg and /common.
Somewhat replaces some earlier work done by hg/lg, but much more
complete, so we kept it as is, because it's bringing in even more parts
after this.

Reviewed-by: Karl Palsson <karlp@tweak.net.au>
2018-04-27 21:36:42 +00:00
Karl Palsson 6675be5326 efm32: cmu: lh/hg fix AUXHFRCOCTRL values
Applies to both, and clearly shows that cmu.h needs to be extracted as
common code.

Originally from: e31d312331
and checked in the HG/LG reference manuals.
2018-04-14 18:40:54 +00:00
kbob 0d815061d9 efm32lg: adc: Misspelling in ADC_CTRL_LPFMODE definition. 2018-04-14 18:40:54 +00:00
kbob 90ea97c3e5 efm32lg: Fixed BURTC_CTRL_LPCOMPC_IGNxLSB definition. 2018-04-14 18:40:54 +00:00
kbob 74316e6901 efm32lg: acmp: Fixed ACMP_CTRL_HYSTSEL_HYSTx definition. 2018-04-14 18:40:54 +00:00
Maxim Sloyko 2b1ddc8490 sam/4l: monster commit
The original submitter of this squished everything into one series, and
has not returned. The code mostly appears good, and review comments were
followed for the most part.  The project doesn't really maintain any
testing or board farm for sam3/sam4 parts, so we're going to just trust
our users.

Reviewed-by: Karl Palsson <karlp@tweak.net.au>

sam/4l: IRQ Configuration file (irq.json)

sam/4l: Basic Memory Map.

sam/4l: GPIO Defines.

sam/4l: GPIO Functions

Added everything that needed to compile the library: Makefile, Linker
Script and common includes.

sam/4l: SCIF function to start OSC.

sam/4l: GPIO Enable/Disable and Multiplexing configuration functions.

sam/4l: PLL Clock configuration.

sam/4l: Peripheral clock configuration and basic USART support.

sam: USART Character length configuration.

sam/4l: Generic Clock configuration functions.

sam/4l: Analog to Digital Converter Interface (ADCIFE) basic support.
2018-04-14 18:40:54 +00:00
Karl Palsson 23fc65d44c ethernet: ksz80x1: fix build/compile
Originally sourced from: https://github.com/libopencm3/libopencm3/pull/382

fixed some typos from the manual and poor merging/rebaseing,
and one judgment call on using a specific name for a conflicting
bit definition.
2018-04-14 18:40:54 +00:00
Frantisek Burian 20b7956d82 [ETH/PHY] Add support for Micrel KSZ80X1 family of PHYs 2018-04-14 18:40:54 +00:00
Karl Palsson 6e65170390 cmsis: add new families to dispatch handlers.
Some people use the opencmsis headers.  Update them to include all the
recently added targets.

Fixes: https://github.com/libopencm3/libopencm3/pull/907
2018-04-13 11:15:32 +00:00
Karl Palsson 297a51a27e stm32: iwdg (v2) Update doxygen
Turn the existing comments into doxygen comments to get more value
2018-03-28 13:23:22 +00:00
Karl Palsson cab07c0703 stm32: iwdg: fix Window Register name
The f0 copy of this file originally had a copy/paste error in the
documentation.  F3 and L4 had the "right" name.
2018-03-28 13:17:39 +00:00
Guillaume Revaillot c670bdca1a stm32l0: enable iwdg 2018-03-28 13:06:57 +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
Guillaume Revaillot b79de32e9e stm32: iwdg: fix typo in (unused) register name 2018-03-27 18:35:23 +02:00
Karl Palsson fb28b4cb7c stm32f1: bkp: include in doxygen output
The original author had included nice descriptions, so only a tiny bit
of massaging to get it all in doxygen nicely too.
2018-03-08 10:57:50 +00:00
Karl Palsson 6b40e9777e stm32f1: bkp: fix typo in CR_TPAL register
Even original documentation had the full TPAL matching the ref man bit
descriptions.

Reported-by: _ami_ on irc.
2018-03-08 10:56:45 +00:00
Karl Palsson 7bd7d48408 stm32l0: add all new IRQs from later families 2018-03-08 09:52:21 +00:00
Guillaume Revaillot 1ab0d2445f stm32l0: NVIC: channel 16 is tim3 on stm32l0x0, stm32l0x1 and stm32l0x2.
tim3 interrupt is wired to nvic channel 16 if present.
2018-03-08 10:25:34 +01:00
Karl Palsson 1379ab4777 stm32l4: enable common exti functionality
tested on l476 disco board.
2018-03-04 00:02:44 +00:00
Karl Palsson 8feb711ca0 stm32l0:rcc: add rcc_set_pll_source() as per L1
reported by: kaeipnos in https://github.com/libopencm3/libopencm3/pull/609
2018-03-02 22:42:05 +00:00
Frantisek Burian 28aa1e57e9 [ETH/PHY] Add support for STE100 PHY used on some boards from ST 2018-03-02 22:42:05 +00:00
Frantisek Burian 67c2f19d19 [ETH/PHY] Add support for LAN87XX family of PHYs 2018-03-02 22:42:05 +00:00
Frantisek Burian c2c2ac766b [eth/phy] Updated style 2018-03-02 22:42:05 +00:00
Karl Palsson 54b117c5a5 usb: Use enumerated return codes
The enum usbd_request_return_codes has been available for some time.  It
should be used internally, not just by users of this code.
2018-03-02 22:42:05 +00:00
Karl Palsson 93cf76b9d1 stm32l1: syscfg: add USB pullup control definition
On original stm32l1s, this internal pullup was out of spec, and not
recommended for use.  But the -A parts have this fixed, so make sure we
can use it.
2018-03-02 22:42:05 +00:00
Sebastian Holzapfel 995d19ebfd efm32hg: usb: add usb support 2018-03-02 22:42:05 +00:00
Sebastian Holzapfel a2ee90fbfe usb: stm32fx07 -> usb_dwc_common
The stm32fx07 is common DesignWare IP, used in both STM32 and EFM32 chips.
Rename the files to make this more clear, and easier to use in other
targets.
2018-03-02 22:42:05 +00:00
Sebastian Holzapfel 3c855e75d1 efm32hg: cmu: add updated cmu implementation based on efm32lg 2018-03-02 22:42:05 +00:00
Sebastian Holzapfel 18f64812eb efm32hg/lg: timer: use common timer implementation 2018-03-02 22:42:04 +00:00
Sebastian Holzapfel b0fdbe2aea efm32hg/lg: wdog: use common wdog implementation 2018-03-02 22:42:04 +00:00
Sebastian Holzapfel c6296a4d88 efm32hg/lg: gpio: use common gpio implementation 2018-03-02 22:42:04 +00:00
Sebastian Holzapfel fd28881559 efm32hg: add memory map 2018-03-02 22:42:04 +00:00
Sebastian Holzapfel a86948ec6e efm32hg: add basic makefile, interrupts, device information 2018-03-02 22:42:04 +00:00
Christian Tacke a1264f5065 stm32l4: usart: Fix USART3 definition/typo
USART*3* should point to *3* not *2*.
2018-02-26 12:53:42 +00:00
Bruno Randolf ec748dc895 stm32:l4: Add SYSCFG definitions
From RM0394 and RM0351
2018-02-13 23:57:43 +00:00
Bruno Randolf b438edf45d stm32:l4: Add SPI
Same as F3, tested
2018-02-13 23:57:43 +00:00
Bruno Randolf 075ef82a4b stm32:l4: Enable USB FS support
Reviewed against RM0394 and tested with STM32L433CC.
Aparently some other L4 have USB OTG.
2018-02-13 23:57:42 +00:00
Bruno Randolf de39ab1584 stm32:l4: Add CRS
Reviewed against RM0394, untested
2018-02-13 23:57:42 +00:00
Bruno Randolf 2dd4655aed stm32:l4: rcc: Add CLK48SEL HSI48
This is not NONE on the L4 but HSI48.

Reviewed against RM0394 and RM0351.
2018-02-13 23:57:42 +00:00
Bruno Randolf f2c629c4ff stm32:l4: rcc: Add support for HSI48 clock 2018-02-13 23:57:42 +00:00
Bruno Randolf 0cd92c31d6 stm32:l4: Add RTC
Use common, some additional registers missing
2018-02-13 23:57:42 +00:00
Bruno Randolf c90c9fe801 stm32:l4: Add IWDG
Same as F3, reviewed against RM0394, tested
2018-02-13 23:57:42 +00:00
Karl Palsson 55ea31fd04 stm32l4: crc-v2: enable common code
Possible now that the v2 unification code has landed.
2018-02-13 23:57:42 +00:00
Bruno Randolf 7b6710a914 stm32:l4: Add DMA
Same as L1 according to L1-L4 migration guide, untested
2018-02-13 23:57:42 +00:00
Karl Palsson 316c33a6a3 stm32: crc-v2: tweak doxygen output
Make it group better and include labels
2018-02-13 23:57:42 +00:00
Gregory Schlomoff 88ca8058aa ethernet: Add missing BEGIN_DECLS / END_DECLS 2018-02-13 23:57:42 +00:00
Gregory Schlomoff 329b611e4f stm32: ethernet, flash: tagging some function arguments as const 2018-02-13 23:57:42 +00:00
Grigory Revzin 9ef5860863 stm32: can: removed canport argument from can_filter functions 2018-02-13 23:57:42 +00:00
Karl Palsson 0965e691a9 stm32f2/f4: rcc: deprecate old IO definitions
instead of hard breaking, provide them as macros pointing to the new
values, and document them as deprecated.
2018-02-13 23:57:41 +00:00
Yonghua Zheng eeef996cb0 [BREAKING] rcc: change gpio bit defines to be consistent with reference manual
This _breaks_ your gpio code for F2 and F4.  It makes them consistent
with the reference manual, and more consistent with all other families
and general expectations.

OLD code -> NEW code
RCC_AHB1RSTR_IOPxRST 	->	RCC_AHB1RSTR_GPIOxRST
RCC_AHB1ENR_IOPIxEN	->	RCC_AHB1ENR_GPIOxEN
RCC_AHB1LPENR_IOPxLPEN	->	RCC_AHB1LPENR_GPIOxLPEN

[We're not actually breaking it, see the next commit for deprecated
aliases]
2018-02-13 23:57:21 +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 6580721fd1 doc: stm32 can: fix missing doxygen group 2018-02-13 23:05:21 +00:00
Karl Palsson 67d1a63412 doc: stm32:gpio: fix invalid doxygen
Just reduces more doxygen warnings, and adds more helpful text.
2018-02-13 23:05:21 +00:00
King Kévin 3922cc7d3e STM32: add MASK defines in sdio.h 2018-01-08 11:18:38 +00:00
Karl Palsson ed90df85f0 stm32:i2c-v2: Clarify digital filter setting
Drop redundant field definitions, fix truncation of argument bug and add
documentation.

Fixes: https://github.com/libopencm3/libopencm3/issues/831
2018-01-08 11:16:24 +00:00
WGH f59d47cbd1 docs: usb: clarify usbd_register_control_callback()
Expand notes on when the control callbacks must be registered.

Reviewed-by: Karl Palsson <karlp@tweak.net.au>
2018-01-04 17:01:48 +00:00
Yonghua Zheng 580a2a4a63 stm32f7: usart: enable usart peripheral
Add usart-v2 to stm32f7 to provide usart support in f7 series.
2017-12-07 10:59:32 +00:00
Karl Palsson ef04708e92 stm32: pwr-v1: doxygen-ize bit definitions.
Rich commentary already existed, just add the second * to let doxygen
pick it up.
2017-12-07 10:33:09 +00:00
Karl Palsson 297d996fa0 stm32f3: pwr: drop duplicate definitions
These definitions were in the already included pwr_common_v1.h file.

And add extra WKUP bit definitions.
2017-12-07 10:33:09 +00:00
Damien Nicolet 19d296dd7b stm32f4: qspi: Typo correction in QUADSPI_ABR 2017-11-16 23:57:11 +00:00
Karl Palsson 368a33773f stm32:l4: usart: add missing header
Fixes: f6796604 stm32:l4: enable usart peripheral
2017-11-10 18:02:14 +00:00
Karl Palsson f67966046a stm32:l4: enable usart peripheral
Tests in https://github.com/karlp/libopencm3-tests/tree/master/tests/uart-basic
2017-10-25 23:54:32 +00:00
Karl Palsson c119ee7f9a stm32:l0: enable usart peripheral
Now that the usart-v2 peripheral is extracted cleanly, adding it for l0
is very simple.
2017-10-25 23:26:52 +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 9d709e52b4 stm32: usart: move USARTX definitions to target/version specific
Instead of declaring that _every_ device has USART1,2,3 and UART4,5, let
the targets themselves define what periphs they do, along with their
USARTx_BASE defines, and let the common headers just have the common
abstractions.
2017-10-25 22:55:09 +00:00
Karl Palsson 0b84caa13e stm32: usart: Move f3 TDR/RDR definitions to -v2
Data registers are standard.
2017-10-25 22:55:02 +00:00
Karl Palsson 557e2a0b09 stm32: uart: add USART_FLAG_ defines
Similar to how we have abstract defines for the stop bits, parity and
flow control common mode namees, provide abstract flag names for the
"standard" flags.  This allows us to start using common API code for v1
and v2 uarts

For stm32f3, drop the "compatibility" defines that simply pollute the
namespace, making it confusingly appear as if f3 has both SR and ISR
registers.
2017-10-25 22:53:31 +00:00
Karl Palsson 2bc19d499c stm32:usart: Pull stop bit definitions up as common 2017-10-25 22:42:26 +00:00
Karl Palsson 3dbbbe1113 stm32: usartv2 use pragma once
Easier on the eyes, less lines of code, easier on doxygen
2017-10-25 21:19:23 +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
Lucas Pickering 668c7c5079 stm32: adc: Fix address offset for ADC_CDR register 2017-10-25 21:16:26 +00:00
Matthias Bock 5fc4f48ae2 stm32: can: Fixed incorrect CAN_FMR_CAN2SB_SHIFT value 2017-10-25 16:59:38 +02:00
Karl Palsson 0663341244 stm32f4: dcmi: doc: group register bit defns
Makes the doxygen much much prettier and easier to follow.
2017-10-23 21:31:19 +00:00
Marek Koza 3dbcd16ced stm32: f4: Add DCMI peripheral register definitions 2017-10-23 21:31:16 +00:00
Karl Palsson 38125e9941 vector: fix externs
Improper/lazy build testing.

Fixes: c6743f9 vector: make common linker definitions available to users
2017-10-18 20:51:33 +00:00
Karl Palsson c6743f9ecd vector: make common linker definitions available to users
_data_loadaddr, _data, _edata, _ebss, _stack and vector_table all now
available in vector.h.

Suggested on IRC
2017-10-18 20:05:14 +00:00
Karl Palsson f475d459d3 stm32: hrtim: doc: group all regs and values 2017-10-12 11:30:07 +00:00
Florian Larysch 1bc8b4e719 stm32f3/rcc: add HRTIM RCC bits 2017-10-12 10:24:21 +00:00
Florian Larysch 5a80eb4bee stm32f3: add HRTIM definitions
Add definitions for the High Resolution Timer peripheral (currently only
present on the F334).
2017-10-12 10:24:15 +00:00
Fabián Inostroza 35ed6926a9 stm32f1: can: fix RST_CANx bit definitions
RCC_CANx bits were correct, typos in RST_CANx bits.
2017-10-05 09:29:38 +00:00
Karl Palsson 181ca054d7 stm32l4: add missing flash wait states
Fixes https://github.com/libopencm3/libopencm3/issues/832
2017-10-02 21:59:58 +00:00
Karl Palsson db7a8d71ca stm32f4: rcc: doxygen updates
Uses doxygen groups instead of just  ------ comments, so they now
automatically get documented online.
2017-09-09 20:35:48 +00:00
Karl Palsson db5f550611 stm32f4: Add new clock gate enable register for f413
Yet more clock enable bits on new F413/F423.
Sourced from RM490rev5
2017-09-09 19:59:04 +00:00
Jordi Pakey-Rodriguez 26ca4cc88a stm32: timer: Add missing TIM_CCER_CC4NP 2017-08-24 21:44:28 +00:00
vollst-induktion a42a058966 stm32f1/f4: adc: Fix ADC_SMPRx_SMPy_MSK defines
Referred to obsolete definition names.
2017-08-24 21:34:28 +00:00
Grigory Revzin b31b3985b7 stm32: can: fixed naming for ABRQ2 2017-08-24 21:32:09 +00:00
Grigory Revzin 5cd4577489 stm32: can: fixed typos in CAN_RFxR_FOVR 2017-08-24 21:32:09 +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
Jonathan Halmen 83adad0aed stm32: can: change filter match index to uint8_t
The variable can only be 8bits, and converting pointers resulted in
cases of overwriting nearby variables.
2017-07-04 23:23:29 +00:00
Karl Palsson 2a61740a90 stm32f1: rcc: Fix TIM17/TIM18 enable bits
the RCC_TIM17 and RCC_TIM18 macros used in the "new" style were ok, just
the old style raw bit definitions.

Reported-by: Karl Hammar <karl@aspodata.se>
2017-06-17 21:54:07 +00:00
Fabián Inostroza 98ff5c23aa stm32: can: Add support for getting the message timestamp.
Provide an optional parameter to receive the timestamp in
2017-06-08 23:01:45 +00:00
Fabián Inostroza fac1013ccb stm32: can: fix timestamp mask and shift amount. 2017-06-08 23:01:45 +00:00
Karl Palsson bc898d1f92 stm32l0: rcc: Add clock struct setup helper
Based on l1, l4 and friends.
2017-06-08 23:01:45 +00:00
Karl Palsson ec1d2855b0 stm32l1: rcc: use better naming for flash wait states
More compatible with developments in l0/l4/f7, and just a better choice
of names overall.
2017-06-08 23:01:45 +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
Karl Palsson 2547bf66d9 stm32l0: flash: use common functionality
Provides all the basic core functionality shared with L1.  No special L0
functionality supported at this point.
2017-06-08 23:01:45 +00:00
Karl Palsson ce787c0f40 stm32l1: flash: extract common code
Extracted all code that will be common with l0.  Compared with ref mans
for l0 and l4.  No functional change, just moving things getting ready.
2017-06-08 23:01:45 +00:00
Karl Palsson 9e36b8f29c usb: improve c++ compatiblity
Extract the definition of the usb_interface internal data to allow
easier integration with c++ code.

Fixes: https://github.com/libopencm3/libopencm3/issues/762
2017-06-08 23:01:45 +00:00
Karl Palsson 0f4c032548 trivial: change include guard name to match file
File was renamed to -vX style.
2017-06-08 23:01:45 +00:00
Karl Palsson 5af89ae596 stm32f3: can: use CAN1 compatibility naming
Makes it far easier to write portable code when CAN1 is always
available, not having to decide between CAN and CAN1.
2017-06-08 23:01:45 +00:00
Karl Palsson ba0c97bf42 stm32f7: pwr: add more doxygen
Seeing as Matthew went to the effort of all the descriptions, it seemed
only reasonable to get them to show up in the generated docs too.
2017-06-08 23:01:45 +00:00
Matthew Lai 17553da946 stm32f7: pwr: added basic support for pwr (VOS and overdrive) 2017-06-08 23:01:45 +00:00
Karl Palsson 6678da39bd stm32: i2c: Support auto speed configuration
For both v1 and v2, support automatic calculation of timing registers
for 100khz and 400khz i2c modes.

Based on work by Chuck in
https://github.com/libopencm3/libopencm3/pull/470 for v1
2017-06-08 23:01:45 +00:00
King Kévin 1f58917cb2 cm3: scb: rename SEVEONPEND to SEVONPEND
SEVEONPEND is a typo. According to the The ARM v7-M
Architecture Reference Manual SEVONPEND is the correct name.
2017-06-08 23:01:45 +00:00
Karl Palsson 2f4f8ad85b stm32: can: BTR baud rate prescaler is a 10 bit field
Reported on the mailing list, verified in RM0090 and RM008
2017-05-08 10:49: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
Marek Koza 904345eaf1 stm32: l1: Change RI defines to be more readable
Reserved bits are marked explicitly in the comments. ASCR defines
are changed to be consistent with the reference manual. HYSCR,
ASMR, CMR and CICR register defines are rewritten to be more
concise and readable.
2017-03-30 21:48:08 +00:00
Marek Koza a10bc7071a stm32: l1: Add routing interface register definitions 2017-03-30 21:48:08 +00:00
Jordi Pakey-Rodriguez 90d8bd6753 stm32f234: flash: Add FLASH_ACR_LATENCY_MASK 2017-03-30 21:48:08 +00:00
Jordi Pakey-Rodriguez 6798cee2a5 stm32f2+: flash: Rename FLASH_ACR_XCE -> FLASH_ACR_XCEN
Match the datasheet register names better.

squish into xcev
2017-03-30 21:48:08 +00:00
Karl Palsson b40c72828d stm32: i2c: provide "transfer" level helper routines
For both v1 and v2, provide routines to help do arbitrary length
write/read transfers.

Tested with multiple byte writes and reads, for both 100khz and 400khz,
with repeated starts and stop/starts.  However, only tested (presently)
with a single i2c target device, a Sensiron SHT21 sensor.  Extended
testing against eeproms and alternative devices would be useful
2017-03-30 21:48:08 +00:00
Karl Palsson fb3b5e08f3 stm32: i2c-v2: drop overly restrictive helpers.
* didn't follow naming conventions
* overly restricted to single byte register style commands.

Will be replaced by freeform transfer functions
2017-03-30 21:48:08 +00:00
Karl Palsson 1edcc1b7da stm32: i2c-v2: drop overly specific speed helpers
Will be replaced by generic speed helpers.
2017-03-30 21:48:08 +00:00
Karl Palsson 24225816a1 stm32: i2c-v2: simplify boolean functions
No need to check results and return 1 or 0.  The result itself is
suitable for use directly as a boolean, and a boolean is the intended
outcome.
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
Karl Palsson ca7b27e039 stm32: i2cv2: drop i2c_set_clock_frequency
It's not implemented, and not meaningful for i2c v2 peripheral
2017-03-30 21:48:07 +00:00
Karl Palsson 623fabca5f stm32l0: rcc: add new peripheral enable bits
I2C3, USART4/5, GPIOE
2017-03-30 21:48:07 +00:00
Karl Palsson b556a72fdb stm32l0: use current RCC bit names
Early revisions of the reference manuals used different names for the
touch sense controller and firewall bits.  These have now been changed
to be more in line with other families, and as these parts and bits were
new in this library, simply move forward to the current naming
convention.
2017-03-30 21:48:07 +00:00
Sergey Matyukevich 59ef83a440 stm32: l0/l4: add i2c support
According to reference manuals both l0 and l4 have "v2" i2c peripheral.
This patch adds i2c support to l0 and l4 using previously unified "v2" i2c
headers and implementation.

No real hardware has been tested so far. Only compilation tests for both
libopencm3 and libopencm3-examples for all stm32 families.

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 d2540e5fc6 stm32f7: rcc: replace magics with existing defines
The defines already existed, use them, rather than the copied constants
from F4 code.
2017-03-30 21:48:07 +00:00
Sync c285bcb493 stm32f7: rcc: initial clock config for disco board
Add clock config for the 25MHz crystal found on the discovery board.
Verified to work on the STM32F7-Disco.

Reviewed-by: Karl Palsson <karlp@tweak.net.au>
Modified namespaces and types->structs to avoid namespace pollution as
was fixed for other families in:

3a7cbec7: stm32l/stm32f: name space standardization [BREAKING]
2017-03-30 21:48:07 +00:00
Sync 3fc0c9d001 stm32f7: rcc: intial stubs support
Reviewed-by: Karl Palsson <karlp@tweak.net.au>
(Added defines and used them)
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
Jonathan Challinger 7f8b32efed stm32f3: include CAN 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 f07b58c6d8 stm32:rng: add helper to actually get random numbers
Simplified blocking API, with an async routine if you really need it.
Follows as best as I can understand the reference manual, but testing
those conditions will be difficult.
2017-03-30 21:48:07 +00:00
Karl Palsson 05829037de stm32:rng: add common v1 to l0,l4,f7
This is a common peripheral based on reference manual inspection.
2017-03-30 21:48:07 +00:00
Karl Palsson 2476099f29 stm32:rng: f4 rng peripheral is common with at least f2
Pull it up as common code immediately. Rename to v1, extract to common
with a doxygen marker stubs, add to F2 makefiles.
2017-03-30 21:48:07 +00:00
Sulter ac45247f60 stm32f4:rng: basic functions with documentation.
Reviewed-by: Karl Palsson <karlp@tweak.net.au>
Removed higher level helpers from this commit, they are not a very
friendly API to use.
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
Matthew Lai 62b58555e2 stm32: rcc: added missing ifdef for STM32F7 in rcc 2017-02-28 16:57:20 +00:00
Matthew Lai b1839265f9 stm32: syscfg: fixed copy and paste error in comment 2017-02-28 16:57:09 +00:00
Lixing Ding 13fe431919 stm32: timer: fix TIM_CCMR2 definitions
CC3S and CC4S channel names were badly copy/pasted from CCMR1
2017-02-15 09:55:24 +00:00
Karl Palsson ed3cbffc2a cm3/sync.h: Add DECLS to allow use with c++
Reported by vvirag on IRC. Diagnosed and fixed by zyp on IRC
2017-01-27 17:08:37 +00:00
Dave Hylands 755ce402e2 stm32:desig: Add DFU compatible serial generation
Reviewed-by: Karl Palsson <karlp@tweak.net.au>
Modified to provide better doxygen and consistent api names.
2017-01-10 23:07:00 +00:00
Karl Palsson 5bf61c537f trivial: stop referring to STM32F when we mean all 2017-01-10 23:06:59 +00:00
David Sidrane cf80e2bd5e stm32f4: USB support for newer OTG cores
Support for the  conflicting bit definitions for vbus sensing on core id
version 0x2000+

Reviewed-by: Karl Palsson <karlp@tweak.net.au>
2017-01-10 22:32:20 +00:00
Karl Palsson 1963f3296f stm32:ethernet: drop outdated broken include file.
Use  #include <libopencm3/ethernet/mac.h> instead of
stm32/ethernet.h

MAC peripherals are not stm32 specific, and are more like USB.

Fixes #729
2016-12-20 11:03:43 +00:00
Henning W f974861cba cm3: SCB on M0/M0+ has SHCSR and DFSR regs too
SHCSR and DFSR are only implement on ARMv6 if the "Debug extension" is
implemented, but that's pretty much everywhere, so allow access to the
defines.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2016-12-17 01:01:40 +00:00
Karl Palsson 7c3d39fda4 stm32l0: rcc: fix definition of RCC_CSR_RTCEN bit
Fixes https://github.com/libopencm3/libopencm3/issues/720
2016-12-08 10:44:32 +00:00
Karl Palsson da91794f52 stm32: rcc: Rationalize MCO definitions
Some parts used HSICLK, some used HSI.  Most used NOCLK, f3 used
DISABLED.  Try and move all to the shorter, simpler forms, instead of
having mixed defines for different targets for the same thing.  Just
because the bits themselves are different doesn't mean we should make it
more difficult for users to port code.
2016-11-29 15:06:19 +00:00
Karl Palsson 29602c94c1 stm32l4: rcc: Fix MCO Prescaler shift
Transcription error from ref manual I presume.
2016-11-29 14:56:57 +00:00
Karl Palsson 4130064318 stm32l1: rcc: use mask/shift consistently for MCO
MCOPRE prescaler definitions used a _SHIFT and a preshiftd definition.
The rest of the file uses separate _MASK and _SHIFT definitions.

Fix whitespace on the definitions while we're here.
2016-11-29 14:25:12 +00:00
Devan Lai 011b5c615a cm3/fpb: Fix overly strict ARMv7 check 2016-11-05 13:54:09 -07:00
Urja Rannikko 62b02c515f usb: Simplify TOG_SET_REG_BIT_MSK_AND_SET
A xor B with B=0 is A, thus this should be correct and faster.
2016-10-01 00:15:22 +00:00
Karl Palsson 3add0d2054 stm32f1: drop leftover ethernet files
The f107 ethernet peripheral is the same as in f4, and was pulled out
into lib/ethernet/mac_stm32fxx7.c in 52758bb8fd

This drops the duplicate code.
Fixes Github issue #694
2016-09-12 23:30:53 +00:00
Karl Palsson 9a0b07d4de stm32f1: adc: standardize temperature sensor API
The TSVREFE bit is defined to only be present on ADC1, so drop the
pointless adc argument.  This has the added benefit of making the
API consistent with all other STM32 adc parts.
2016-09-12 23:29:32 +00:00
Karl Palsson cda59c3855 stm32f1: adc: remove confusing "adc_on" function
This is _similar_ to adc_power_on, the common name, but has been marked
deprecated since 2012.
2016-09-12 23:29:28 +00:00
Karl Palsson d035a9cd39 stm32f1: adc: use common api for calibration routines
Use same names as adv-v2 peripheral uses. F1 is the only v1 peripheral
adc that has calibration modes at all.

Old:
	adc_calibration(ADC1);  // blocking call

New (blocking):
	adc_calibrate(ADC1);

New (asynch):
	adc_calibrate_async(ADC1);
	// do stuff
	adc_is_calibrating(ADC1);  // false when calibration finished

Old routines are preserved but marked deprecated for now.
2016-09-12 23:29:21 +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 6c034c8981 stm32f4: rcc: fix compilation error missed in testing
Fixes: 57c2b00a69

Running make for final sanity failed to catch this due to jobserver
issues.  *fumes*
2016-08-23 22:13:33 +00:00
Chuck McManis 57c2b00a69 stm32f4: rcc: support new plls for new f4 parts
Revise the PLL inits to support new and old PLL configurations,
particularly to support F4x9 devices.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2016-08-23 22:02:12 +00:00
Karl Palsson 41fa001620 doc: adc: fix syntax and missing groupings 2016-08-18 23:51:49 +00:00
Karl Palsson 75011168f7 doc: stm32: fix doxygen syntax
Missing endgroups, some accidental syntax errors/unknown commands.
2016-08-18 23:51:49 +00:00
Karl Palsson 34c3a64177 doc: stm32l power: properly include and document
Was missing group markers.
2016-08-18 23:51:48 +00:00
Karl Palsson 08aac020ad stm32: rcc: provide async routines for osc checks
Start providing async routines for all blocking routines, to make it
easier to use libopencm3 in some RTOS environments.  This is not in
anyway intended to be complete, this just covers a single blocking
routine, rcc_wait_for_osc_ready.  Documentation added to the top level,
and provided for all stm32 families.
2016-08-18 23:41:04 +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 29277adbe3 [BREAKING] stm32f2: rcc: use correct namespace prefixes for osc
Most other families were fully converted earlier, f2 missed a few.

Fixes: 3a7cbec7
2016-08-18 23:40:52 +00:00
Karl Palsson 90debb9fd7 stm32l1: rcc: Extract msi range function
Include doxygen documentation for arguments.
2016-08-18 23:38:40 +00:00
Karl Palsson 53de290fda atmel samd: Basic framework.
Thoughts: should this be a "sam0" family rather than samd?  (Much like Atmel's
own software package lumps all the cortex-m0+ devices in one family)

This was enough to get a basic blinky working at least.
2016-08-18 22:08:58 +00:00