Commit Graph

201 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 76c0a8c289 stm32: rcc: convert to use new standard defines 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
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
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
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
Karl Palsson 66e6a2092e doc: stm32f1: gpio: remove redundant doxygen types
Fixes https://github.com/libopencm3/libopencm3/issues/1108
2019-09-30 10:28:21 +00:00
Karl Palsson 8002148286 stm32f1: Makefile: sort objects
periphs, ethernet, usb. Sorted for ease of finding, ease of merging.
2019-06-17 22:33:32 +00:00
Karl Palsson 5eefc214f6 doc: stm32: fix "osc" incorrect linkages
Was copied around a lot, was always wrong.
2019-06-12 23:06:27 +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 a143e5644e doc: stm32f1:rtc: fix trivial param typos 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
Karl Palsson 7be50a5e75 make: use $(PREFIX)gcc instead of $(PREFIX)-gcc
The leading - makes it rather inconsistent with the majority of other
projects around the world.  Use the form everyone else uses.
To solve this, properly pass prefix to inner makes as was always
intended.

Fixes: https://github.com/libopencm3/libopencm3/issues/1058
2019-06-07 21:25:46 +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 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
Mike Szczys 0fd4f74ee3 stm32f1: adc: fixed deprecated/broken example code 2019-02-09 16:47:52 -06:00
Karl Palsson 08c76f25ec stm32: spi: drop empty spi.c files.
They were originally used to make sure that the doxygen was generated
correctly, but that style is no longer necessary.

There may be more peripherals that can be "cleaned" like this, but let's
do them one step at a time, as we work on that area.
2018-08-27 22:57:41 +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
Guillaume Revaillot 8310de2f5b doc: convert stm32 iwdg peripheral to common naming 2018-07-03 22:23:00 +00:00
Karl Palsson b9cf3a7072 doc: convert CRC periphal to common naming
Previously scattered about under "crc_file" and under "STM32blah->CRC"

Deletes empty doxygen marker files, and uses groups instead.
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 7b9baabd69 stm32: drop empty usart.c files
On some targets these weren't even being referenced, on others they
were, in all cases they were empty and contributed no value.

They _actually_ served to declare groupings for doxygen, but we can do
that in a different manner, without having to have dummy files around.
2018-07-03 22:23:00 +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 9a05dcb6c0 ld scripts: drop duplication of standard sections
Instead of every "simple" target having their own duplicate file with
all the section mappings, just provide a single, simple,
"cortex-m-generic.ld" that works with our startup code and any simple
rom/ram system.  This also drops the pointless copying of files all over
the place.  Using -L flags properly is sufficient, and the standard file
is now in the root of the library already.
2018-04-28 21:12:27 +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
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
Adam Heinrich 08dc7dac1c stm32f1: rcc: Fix number of wait states in comment to match the code
Signed-off-by: Adam Heinrich <adam@adamh.cz>
2017-10-02 21:47:06 +00:00
Diego Herranz 1b64b1494b stm32f1: doc: Fix gpio cnf parameter
GPIO_CNF_INPUT (non existing) -> GPIO_CNF_INPUT_FLOAT
2017-09-26 09:42:47 +00:00
Amitesh Singh e3c78b8825 stm32f1:rcc: fix typo in usb prescaler api document
usb scalar value 1.5 is used when clock runs at 72MHz not 64MHz

Reviewed-by: Karl Palsson <karlp@tweak.net.au>
2017-09-01 22:02:28 +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 b860319785 make: use std=c99 everywhere by default.
setting "STANDARD_FLAGS=-std=c11" or similar will let you try out
alternate compilation modes.

Fixes https://github.com/libopencm3/libopencm3/issues/773
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
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
Ken Sarkies 808cd44a41 STM32F1: RTC: rtc_awake_from_off() clears CR register incorrectly.
It sets bit 5 (manual says "read only") and clears bit 4 which takes the RTC
out of config mode. The RTC registers are not cleared as a result.
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 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 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 50c056f965 stm32: adc: standardize adc_power_off naming. [BREAKING]
Instead of a mismatch of adc_power_on/adc_off, we now have a matched pair of
adc_power_{on,off}

For some people, this is a breaking change in the API!
2016-03-30 16:59:55 +00:00