Commit Graph

1530 Commits

Author SHA1 Message Date
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
Daniele Lacamera 09a66cd6d9 lm3s: Support basic UART + RCC 2016-08-18 22:07:36 +00:00
Karl Palsson c94a58e844 stm32f4: dsi: trivial style cleanup 2016-08-16 21:22:53 +00:00
Chuck McManis b897397ba9 stm32f4: dma2d: Add include files for DMA2D
Adds include files and updates memorymap.h file to
include base address of DMA2D
2016-08-16 20:58:18 +00:00
Chuck McManis 32a91e52ff stm32f4: Add QUADSPI Includes
Adds an include file (and required RCC and memorymap changes)
to address registers in the QUADSPI peripheral on the F4 line
of processors.
2016-08-15 22:44:36 +00:00
Chuck McManis 32f2b5042f stm32f4: dsi: DSI Peripheral include file
Adds the dsi.h file to the f4 path of the library.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2016-08-15 22:18:24 +00:00
Eric Kerman 9b642dea2a stm32l0: Add timer support
Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2016-08-15 21:10:07 +00:00
Karl Palsson 614c700edb stm32f0: timers: input capture support rising/falling edges
This is common code for f0234, keep renaming files as has become standard, even
if it's a suboptimal solution.  This doesn't rename the header which was not
renamed for f3.

Reported-by: https://github.com/gtoonstra
2016-08-15 21:10:03 +00:00
Chuck McManis b802bd07b2 stm32f4: rcc: support PLL_SAI and PLL_I2S
Adds the missing enums for the extra clocks on stm32f4x9 parts.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2016-08-15 20:58:33 +00:00
Chuck McManis 2614577e5a stm32f4: rcc: Add missing defines for f4x9 series
Adds missing bit definitions only.
Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2016-08-15 20:58:29 +00:00
Karl Palsson 543ac0f23c stm32l1: rcc: drop magic numbers in favour of defines
Use the same mask/shift defines as other families.
2016-08-15 16:13:43 +00:00
Karl Palsson cf7d0a08ca stm32: rcc_wait_for_sysclk_status should actually wait
Original implementation only checked whether the user had _selected_ the
clock, not whether it had actually switched to the clock or not.  For
almost all cases, this made this function either a no-op, if you _had_
selected the clock, or a blocking loop if you hadn't selected it ahead
of time.

Fixes github issue #687
2016-08-15 16:09:58 +00:00
Urja Rannikko d3fff11c1f stm32/desig: fix/cleanup desig_get_unique_id and to string functionality
This was inspired by an Arch Linux provided ARM GCC 5.3.0 bug:
It gave an
"internal compiler error: in expand_expr_addr_expr_1, at expr.c:7736"
with the array version of the desig_get_unique_id.

While I was at it, fixed:
- a potential alignment issue with casting uint8_t* buf to uint32_t*
- a funny static in the string definition that does nothing (given const)
2016-04-11 22:57:55 +00:00
Cem Basoglu 6b5150a4dc stm32: usart-v2: Extended USART functions (data/pin inversion, half duplex)
Includes receive timeout, all inversions and duplex and convenience functions.

Applies for F0 and F3 so far.
2016-04-01 22:49:18 +00:00
Karl Palsson 2c1757d269 Revert "NOUP: stm32f3: rcc: provide async osc checks"
This reverts commit aa5e108553.

This commit was not meant to land yet, it should have gone for review, and
doesn't yet include all the parts it should touch.
2016-03-30 17:38:13 +00:00
Karl Palsson a3998563cd NOUP: FIXME: flag next work 2016-03-30 16:59:58 +00:00
Karl Palsson aa5e108553 NOUP: stm32f3: rcc: provide async osc checks
replace bulky hardcoded wait for set and wait for clear with a single asynch
routine.  Leave the blocking routines in for compatibility at this point.

NOUP: should be added to other rcc.c files too.
2016-03-30 16:59:57 +00:00
Karl Palsson 0b84540ecb stm32l4: add common timer code. 2016-03-30 16:59:57 +00:00
benjaminlevine 69a3ba6e2a stm32l4: flash: support basic core operations
Heavily reformatted by: Karl Palsson <karlp@tweak.net.au>
Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2016-03-30 16:59:57 +00:00
Karl Palsson c5b00c3dda stm32l4: rcc: MSI range handling 2016-03-30 16:59:57 +00:00
Karl Palsson 97d644c4d3 stm32l4: rcc: Add core functions
Based on STM32L1, and rather a lot of duplication unfortunately.
2016-03-30 16:59:57 +00:00
Karl Palsson b69916837e stm32l4: rcc: missing pllp definitions
These are important for implementing the PLL helper functions.
2016-03-30 16:59:57 +00:00
Karl Palsson 9047b8c5f4 stm32l4: rcc: correct register name
Use the same name as the reference manual and the same name as other parts.
2016-03-30 16:59:57 +00:00
benjaminlevine d60fd7ca94 stm32l4: pwr: basic core functionality
Only support for voltage range setting.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2016-03-30 16:59:57 +00:00
benjaminlevine 326899b05b stm32l4: pwr: include register definitions.
Reviewed and edited for consistency.
2016-03-30 16:59:57 +00:00
Karl Palsson c56bed6e1a stm32l4: Add header base for doxygen 2016-03-30 16:59:57 +00:00
Karl Palsson 04e784d332 stm32l4: gpio: fix doxygen markers
Reported-by: @benjaminlevine
2016-03-30 16:59:57 +00:00
Karl Palsson 0e40d6da02 stm32l4: gpio: Correct ASCR name to match ref manual
Be consistent, not sure why I left off the R originally.
2016-03-30 16:59:57 +00:00
Karl Palsson 1755098617 stm32: adc-v2: pull up voltage regulator control.
L4 and F3 actually have the same bits to write in the same order, but F3 hides
the name of the deep power down bit.  Keep the like that for now, but there's a
standard API for enabling and disabling the regulator.
2016-03-30 16:59:56 +00:00
Karl Palsson f40e34680b stm32: adc-v2: pull up regular sequence setting.
Uses more standardized naming, fills in some missing defintions, removes some
redundant definitions.
2016-03-30 16:59:56 +00:00
Karl Palsson 697c975dde stm32l4: adc: Initial support for the adc-v2 periph
Now that there's an adc-v2 peripheral layer, we can just use it straight away
for L4.
2016-03-30 16:59:56 +00:00
Karl Palsson 81319a96fb stm32: adc-v2: pull up start_regular
Little steps are easy to review, and easy to test.
2016-03-30 16:59:56 +00:00
Karl Palsson 8b7a5ce7aa stm32: adc-v2: pull up function prototypes
These are standard "api" level functions that need per target implementations,
but should all maintain the same signature.
2016-03-30 16:59:56 +00:00
Karl Palsson 5063ea0db7 stm32: adc-v2: pull up overrun and EOC flag methods
EOS vs EOSEQ is really a single/multi variant difference, so leave it out.
2016-03-30 16:59:56 +00:00
Karl Palsson b2af9e632c stm32: adc-v2: Pull up more common basic functionality
Pull up eoc/eos/read_regular functions.  More simple, basic core functionality.
2016-03-30 16:59:56 +00:00
Karl Palsson f1d50d24be stm32: adc-v2: pull up more common functionality
More easy bit on/off settings.  Every piece that gets pulled up here becomes
automatically available for l0/l4 when they land
2016-03-30 16:59:56 +00:00
Karl Palsson 77c0a2058c stm32l0: land adc-v2 peripheral support
Now that the big pieces of the adc-v2 common files are in place, start
including l0 in the builds.  This includes only the very very basic core v2
peripheral functions, and the very basic definitions.
2016-03-30 16:59:56 +00:00
Karl Palsson f67e217ffb stm32: adc-v2: Pull up the two forms of the adc-v2
The adc v2 periph has the same register map, but comes in two flavours, one
supporting injected channels, more watchdogs, per channel sampling times and
so on, and one "simple" version.

Pull up the f3 and f0 portions into the appropriate files, after comparing with
L0 and L4 reference manuals, even if those are not fully landed yet.
2016-03-30 16:59:56 +00:00
Karl Palsson 4c550648c3 stm32: adc-v2: pull up common register definitions 2016-03-30 16:59:56 +00:00
Karl Palsson 1d090c840f stm32: adc-v2: pull up temp/vref switches
Common for f0,f3,l0,l4
2016-03-30 16:59:55 +00:00
Karl Palsson 7231b9a691 stm32: adc-v2: pull up single/continuous modes 2016-03-30 16:59:55 +00:00
Karl Palsson a89cd86454 stm32f0/f3: adc: extract beginnings of common v2 periph
The f0, f30x and l0 have a very similar "v2" adc peripheral.
Start extracting out some of the common code, and fix the glaring bug in
adc_power_down that was affecting them both.

This is not intended to be a fully comprehensive extraction, just the first
easy steps.
2016-03-30 16:59:55 +00:00
Karl Palsson 0758deb04d stm32f3: adc: migrate CFGR -> CFGR1
The adc peripheral on F30x is the same as F0, L0 and L4.  In the reference
manuals, the following names are used.

F3:	 	CFGR  (no CFGR2)
F0 and L0:	CFGR1 and CFGR2
L4:		CFGR and CFGR2

Moving to a single consistent name, that's more likely to be inline with future
part numbers makes it much easier to extract common driver code for the
peripheral.

While all bit defines are moved to the CFGR1 style, core register definitions:
ADC_CFGR(adc) and ADCx_CFGR are kept to match the original register name in the
reference manual.

Fixes Github issue #548
2016-03-30 16:59:55 +00:00
Karl Palsson ca50f069b6 stm32f3: adc: common registers are per master/slave
They're not a single set just based on ADC1.
2016-03-30 16:59:55 +00:00
Karl Palsson 7373d3ad58 stm32f3: adc: support voltage regulator on/off
The "Intermediate" value isn't a value you can do anything with, you need to
clear those bits when making changes.
2016-03-30 16:59:55 +00:00
Karl Palsson 6eb846d356 stm32f3: adc: rationalize Sampling Time definitions.
There are as many SMPRx registers are needed for channels supported, and on all
other families, the field definitions are just ADC_SMPR_SMP_XXX.  For
consistency, and to avoid any confusion or duplication, use the same style here
too.  Drop silly unused per channel definitions that have no purpose.
2016-03-30 16:59:55 +00:00
Karl Palsson b2e6e5c3b9 stm32: standardize names for temp sensor calibrations
Instead of some parts using _30C and _110C and others using _30C and _110, use
the C suffix in all places to be consistent.
2016-03-30 16:59:55 +00:00
Karl Palsson a22d6a8315 stm32: adc: standardize special channel names
At least temp sensor, vrefint and vbat/vlcd should have consistent names and
consistent doxygen.
Dropped channel definitions that are the same as the raw number.
2016-03-30 16:59:55 +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
tsaitgaist c759ba59d0 stm32: timer: fix trigger selection names
correct TIMx_SMCR TS[2:0]: Trigger selection name are TI1F_ED, TI1FP1,
TI2FP2 according to RM0008 and RM0090
2016-03-28 22:57:01 +00:00
Anatol Pomozov ae41782e1a Fix misspellings using codespell tool 2016-03-08 08:52:54 -08:00
Karl Palsson 20e1ee174d stm32l4: rcc: fix typo in RCC_CR_CSSON bit define
Reported by @benjaminlevine
2016-03-06 23:26:05 +00:00
Karl Palsson ba9cb7dc5d minor stylecheck cleanups 2016-02-29 21:30:31 +00:00
Kuldeep Singh Dhaka 57c7ba3283 usb: Remove unused "usbd_cable_connect" function definition.
It's not used anywhere, and if this sort of api becomes needed, it can be
designed cleanly and finished.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2016-02-29 20:58:47 +00:00
Oliver Meier 92845bc508 stm32: usb-otg: added missing GOTGINT definitions. 2016-02-29 20:53:01 +00:00
fenugrec 1d36685759 Cortex: interrupt handling to use uint32_t instead of bool.
This is more in line with the actual hardware (u32 registers), and will still
work if PRIMASK or FAULTMASK ever have more than 1 bit defined.
The functions cm_is_masked_interrupts() and cm_is_masked_faults() are
unchanged, since returning 'bool' fits with the function naming.

Fixes most of github issue #475. What remains "unfixed" is the absence
of functions to simply 'get' the u32 value of PRIMASK and FAULTMASK registers.
2016-02-28 18:02:57 +00:00
Karl Palsson 58f9909474 cm3: remove duplicate confusing MPU defines.
The MPU RASR AP table has a duplicate entries for Privileged ReadOnly
and Usermode ReadOnly, in the source ARM document (Cortex M3 TRM)
Remove the duplicate here.

The MPU RASR Shareable, Bufferable and Cacheable bits are all individual
bits, and none of the existing defines appear to even match the ARM
documentation.  Remove them, but leave the definitions of the bit
positions.

Reported by MightyPork on IRC
2016-02-28 18:00:22 +00:00
Karl Palsson 5738e9515d stm32: rcc: fix missing ahb_frequency struct
Original commits, while appearing clean and tidy, hadn't even been
compile tested.  Trust no-one. Not even Scully.

Fixes: 770878e7b4
Fixes: 86d20ef00c
Fixes: 05ff0df322
2016-02-17 16:21:30 +00:00
fenugrec ad5ec6af08 Cortex-M defines : fix potential issue where PRIMASK and FAULTMASK operations could be optimized out by gcc.
This adds the "volatile" keyword to all the inline assembly. gcc docs say "You can prevent an asm instruction from being deleted by writing the keyword volatile after the asm.". Testing (see comments of github issue #475) shows that indeed gcc can remove some inline asm, in at least this situation:
-multiple calls to cm_is_masked_interrupts() in the same scope/context
- -Os or -O2 optimization
This is problem because the value of PRIMASK could change between two calls to cm_is_masked_interrupts().
Adding the volatile keyword fixes this, and probably costs less than adding a full barrier (like adding "memory" to the clobber list).
2016-01-10 11:13:25 -05:00
Karl Palsson 609cfe7f28 stm32: spi: correct typo in PHILIPS
Fixes: #589 on github
2016-01-04 17:13:30 +00:00
kbob faf69592cb Fixed misc. errata found in efm32/lg include files. 2015-12-17 19:35:02 -08:00
Piotr Esden-Tempski 17f159dec9 [PWR] Removed unneeded vos_scale_t definiton. 2015-12-15 00:51:18 +01:00
Piotr Esden-Tempski 830cf7bfc4 [RCC] Added missing prefix to the hsi setup table in f3. 2015-12-15 00:28:52 +01:00
Piotr Esden-Tempski 5828a77749 [Style] More whitespace fixes. 2015-12-14 23:42:27 +01:00
Karl Palsson 3a7cbec776 stm32l/stm32f: name space standardization [BREAKING]
As done by esden for the F4, remove typedefs and add prefixes to clock enums
This extends this to all stm32 families.

    Let's not hide the fact that these variables are structs/enums.

    We are filling up the namespace badly enough, we should be prefixing as
    much as we can with the module names at least. As users we already run
    often enough in namespace colisions we don't have to make it worse.

    * CLOCK_3V3_xxx enums renamed to RCC_CLOCK_3V3_xxx
    * clock enums (PLL, HSI, HSE ...) prefixed with RCC_
    * scale enum of pwr module prefixed with PWR_
2015-12-14 23:26:42 +01:00
Piotr Esden-Tempski d680be81b5 [stm32f4] Remove rcc typedefs added prefixes to clock related enums.
Let's not hide the fact that these variables are structs/enums.

We are filling up the namespace badly enough, we should be prefixing as
much as we can with the module names at least. As users we already run
often enough in namespace colisions we don't have to make it worse.

* CLOCK_3V3_xxx enums renamed to RCC_CLOCK_3V3_xxx
* clock enums (PLL, HSI, HSE ...) prefixed with RCC_
* scale enum of pwr module prefixed with PWR_
2015-12-14 23:26:32 +01:00
Piotr Esden-Tempski b1049f9a6f [Style] Stylefix sweep over the whole codebase. 2015-12-14 22:57:15 +01:00
Piotr Esden-Tempski 1f6fd11dd9 [Style] Fixed all style errors in the efm32. 2015-12-14 19:30:04 +01:00
Kuldeep Singh Dhaka 77354cb371 Inital support for EFM32LG 2015-12-13 19:56:19 +01:00
Devan Lai c28d9727d7 stm32f0: flash: Add BOOT_SEL and nBOOT0 definitions for FLASH_OBR
Checked against RM0091rev8
2015-12-13 01:07:26 +00:00
Jim Paris 01f08c4638 Remove WEAK from handler prototypes
These prototypes affect functions defined by application code.  Only
the implementations in libopencm3 are supposed to be weak; the
functions in application code should definitely not be.  Otherwise,
you'll end up with two weak symbols being linked together, and
it's luck as to which one the linker picks.
2015-11-24 09:55:27 +00:00
Karl Palsson 1ebfc4b26e lpc17xx: Correct duplicate CLKOUT definition
Checked against UM10360 rev3.1

Reported-by: <karl.robinsod@gmail.com>
2015-11-23 09:51:18 +00:00
Karl Palsson f14c678ccb stm32l4: add gpio support
Just the basic core common functionality gained for free by being a common
peripheral.  Enough for a miniblink.

Fixes some errors in the GPIO memory map.  ST's naming of AHB2 vs AHB3 is
confusing.
2015-11-13 02:13:31 +00:00
Karl Palsson 8afc983f3e stm32l4: Add RCC definitions
Bring in the core common code, and now that it's used, pull in the common
memorymap
2015-11-13 01:15:17 +00:00
Karl Palsson 507c184456 stm32l4: initial memorymap and vector support
Values from RM0351rev1, with the correction of the duplicate TIM1_CC entry.

Only stub support so far, but this opens up the beginning of build testing.
2015-11-10 23:47:57 +00:00
Karl Palsson a939810940 stm32f0: Add rcc compatibility aliases
Many stm32 families have multiple ADC and DAC peripherals.  F0 (so far) only
has one.  To make it easier to use the same code on many stm32 families,
provide an alias for ADC1 to ADC.
2015-11-10 22:00:11 +00:00
Nicolas Schodet 9b8d44e8a3 stm32f4: add GPIOJ & GPIOK
They are available on STM32F429 and STM32F439.
2015-11-10 14:27:57 +01:00
Karl Palsson fd100ea6c2 stm32f0: rcc: doxygen update prediv
After adding support to the f3, add missing doxygen support to the f0
equivalent.  This improves things and keeps them consistent until/if they are
pulled out as common code.
2015-11-08 15:36:32 +00:00
Karl Palsson a444aa4476 stm32f3: rcc: Add pll source prediv support
Based on the f0 support, which has identical functionality, but with doxygen
added.  Bits renamed as they are only HSE prediv on some targets, and makes
things more consistent with the f0.

Fixes part of github issue #560
2015-11-08 15:36:32 +00:00
Karl Palsson 489dc5125e stm32f3: rcc: support setting ADC prescalers
If you are in async mode (ADC_CCR.CKMODE == 0) (the reset default) you still
need to set the prescalers before the ADC will actually enable.
2015-11-08 15:36:32 +00:00
Karl Palsson 674cd9bfe9 stm32f3: rcc: Update ENR/RST definitions for newer docs
Based on latest RM0316rev5, and fixed a bug in f37x CEC bit definition that
overlapped.
2015-11-08 15:36:32 +00:00
Karl Palsson 4d7694b454 stm32f3: rcc: consistent masks for pll multiplier
All other masks consistently used a separate mask/shift define, bring the pll
multiplier function in line, and use the same form as other functions.
2015-11-08 15:36:32 +00:00
Karl Palsson 129a874cf8 stm32f3: rcc: Correct name of pll multiplier helper.
This function was badly copied and pasted from the f4 library, where there are
two functions, rcc_set_main_pll_hsi and rcc_set_main_pll_hse which combine
source, multipliers, dividers and other pll factors.

On F3, (not all of them, but the ones we support now), the function as
implemented has nothing to do with hsi / hse, and instead is simply selecting
the PLL multiplier.
2015-11-08 15:36:32 +00:00
Karl Palsson 10ef294e5d stm32f3: rcc: Set prescalers properly.
Copypasta from f4 rcc code was only modified to shift the result, but not clear
the existing settings properly. Add mask/shift definitions and use them
properly.
2015-11-08 15:36:32 +00:00
Karl Palsson e6f267e103 stm32f7: Update TODO memory map items
DBGMCU and flash size and unique id registers had simply been copied from F4,
with TODO markers.  Checked against current datasheet and ref manual
2015-11-01 14:21:07 +00:00
Karl Palsson ab0552b1f7 stm32f7: correct addresses for calibration values 2015-11-01 14:12:37 +00:00
Alexandru M Stan 435cbcc675 stm32f0: Fix TSC_IOGxCR
TSC_IOGxCR is actually a 32 bit register, of which 13 bits are used
(rest are reserved).

Also, added x-1 since G0 is not a valid group, TSC_IOGCSR_GxE(1) is supposed
to be at 0x34, not 0x38.
2015-10-24 20:06:12 -07:00
Karl Palsson ff6cc954b7 stm32: adc: drop non-existant adc_set_single_channel
Was only in the (obviously out of date) documented example and as a
declaration.  No implementations.  Dropping immediately, but documentation
still needs further work.
2015-10-17 01:23:56 +00:00
Karl Palsson fbd25fb16f stm32f7: missing ; in rcc enumerations 2015-10-15 12:31:01 +00:00
Karl Palsson 5ece67ad5d stm32f7: Add rcc.h
Full clean manually checked against RM0385rev2.

Header definitions only.
2015-10-15 11:49:28 +00:00
Karl Palsson c1c37a8b0f stm32f7: Update IRQs from latest ref manual
One name change and some new ones.
2015-10-15 10:36:54 +00:00
Frantisek Burian 3ef2c38120 [stm32f7] Add initial support of the family, GPIO support.
Most changes are noise from doxygen.
Readme udpated to explain newer FP_FLAGS for m7
stm32f7 library is skipped if the toolchain doesn't support it yet.
2015-10-15 10:34:28 +00:00
Karl Palsson 2e25d678ba Surround all macro parameters with ()
Followup from c72f3d588a
2015-10-15 01:03:18 +00:00
Karl Palsson 75d508246e usb: otg: drop confusing invalid definitions
GUSBCFG TRDT fields have very particular meanings, and the field should be set
depending on your bus speed.  There's no 8/16bit meaning in any current
reference manual for this field.

Fixes github issue #530
2015-10-14 22:42:49 +00:00
Karl Palsson c72f3d588a Surround all macro parameters with ()
All the macro arguments that are user supplied, or potentially, wrap properly
in () as good practice.

Probably missed one or two, and a lot of them are possibly unnecessary, but
it's straightforward to just do it always.

Fixes github issue #321
2015-10-14 22:15:15 +00:00
fenugrec c899273c62 usb: Improved comments of USB API
usbd.h: more comments for bmRequestType and bmAttributes bitfield macros
usbd.h: migrated and added API doxyblocks from implementations (*.c)
2015-10-14 20:48:26 +00:00
Karl Palsson 7814d06095 usb: control complete callback has no return value
It's never used, so let's make it void to avoid any confusion.
It was also an unintentional change from void to int in 4b89272
2015-10-14 10:04:37 +00:00
Devan Lai 5270c11a09 stm32f0: Fix offset for GPIO_BRR
Correct as per RM0091rev5
2015-10-07 10:08:47 +00:00
Karl Palsson 17bc66c46b stm32f4: fmc: Use standard form shift definitions.
It's confusing and unhelpful to use a different style of shift definitions for
bitfields.

Originally reported by "mox-mox" in
https://github.com/libopencm3/libopencm3/pull/467
2015-10-06 01:26:56 +00:00
Karl Palsson f1d8a7ef04 stm32l0: Add USB support via st_usbfs driver. 2015-10-06 00:54:17 +00:00
Robin Kreis 8e7a89ac75 stm32l0: add EXTI definitions 2015-10-06 00:53:51 +00:00
Robin Kreis 112cf5d085 stm32l0: commonize PWR definitions and add to l0 2015-10-06 00:53:51 +00:00
Robin Kreis 0a76a24286 stm32l0: add LPTIM definitions 2015-10-06 00:53:51 +00:00
Robin Kreis 232a33b01d stm32l0: add SYSCFG definitions
Modified to update to latest reference manual.

Changes to CFGR3, some extra bits.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2015-10-06 00:53:51 +00:00
Karl Palsson 29ede503f3 stm32l0: rcc: add more helper routines. 2015-10-06 00:53:51 +00:00
Karl Palsson cebc335846 stm32l0: Simplify rcc defines.
More could probably be found, but this makes some of the basic RCC defines for
the L0 much more inline with other platforms, and much less verbose.  This
helps us have more identical code for library users across different targets.
2015-10-06 00:53:02 +00:00
Karl Palsson 63cfc6932a stm32l0: Add Clock Recovery System to build 2015-10-06 00:53:02 +00:00
Karl Palsson d67aec1cc8 stm32: Clock Recovery System is a common peripheral.
Pull it out of the F0 directory ready to be used by other devices with this
peripheral.
2015-10-06 00:52:39 +00:00
Karl Palsson f5eb96caf3 usb: Add st_usbfs_v2 for f0/l0 devices
Based on previous work, add a new driver for the v2 usb peripheral found on
stm32f0 and l0 devices.

Correspondingly, add a usb gadget zero test suite for the f0.  L0 device level
code isn't yet ready, but will add the test case when it moves in.

Work by Frantisek Burian, Kuldeep
Singh Dhaka, Robin Kreis, fenugrec and zyp on irc, and all those forgotten.
2015-10-03 02:03:58 +00:00
Karl Palsson e121243ce2 usb: extract ST USB FS peripheral core. [BREAKING CHANGE]
The breaking changes here changes in header location, and changes in driver
name passed down to the usb stack.

Changes affect: stm32f102/f103, stm32l1, and some f3 parts

* instead of the confusingly generic "usb" use the name "st_usbfs" for the USB
  Full speed peripheral ST provides in a variety of their stm32 products.
  Include directives should change as:
      #include <libopencm3/stm32/usb.h> => <libopencm3/stm32/st_usbfs.h>

* instead of the confusingly specific "f103" name for the driver, use
  "st_usbfs_v1"  [BREAKING_CHANGE]

  Instead of:
    usbd_init(&stm32f103_usb_driver, .....) ==>
    usbd_init(&st_usbfs_v1_usb_driver, .....) ==>

The purpose of these changes is to reduce some confusion around naming, but
primarily to prepare for the "v2" peripheral available on stm32f0/l0 and some
f3 devices.

Work by Frantisek Burian, Kuldeep Singh Dhaka, Robin Kreis, fenugrec and zyp
on irc, and all those forgotten.
2015-10-03 01:32:34 +00:00
Karl Palsson f49cbee683 usb: otg-dev: disable and flush endpoints on reset
Only resetting the fifo memory pointers can result in corrupt data.

Tested on f4 disco board with the gadget0 test suite.
2015-09-22 22:28:02 +00:00
Hanspeter Portner be56146407 stm32f3: fix ADC2/4 "slave" memory map.
Main memory map just lists the base address for the pairs, doesn't clarify the
offset for the slave devices.
2015-08-23 11:34:21 +00:00
Kuldeep Singh Dhaka 0d1f5fc036 usb: Added USB_FNR register defines
credit: @fenugrec
2015-08-18 00:38:48 +00:00
Kuldeep Singh Dhaka 5c73d60176 usb: Moved USB_PMA_BASE address definition to family-specific memorymap.h
credit: @fenugrec
2015-08-17 00:21:16 +00:00
Amir Hammad 6357630a90 stm32/usb: otg_fs and otg_hs register definitions
* USB host register definitions added.
* Extracted common register and bitfield definitions
	from 'otg_fs.h' and 'otg_hs.h'
	into new file 'otg_common.h'.
	Modified usb low-level drivers to adopt to new style of bitfields.
* Fixed typo OTG_GOTGIN -> OTG_GOTGINT (according to the datasheet)

Signed-off-by: Amir Hammad <amir.hammad@hotmail.com>
2015-08-16 22:13:53 +00:00
Karl Palsson f4d6da9554 cm3: MPU is optional on both v6m and v7m.
The MPU is an implementation option available for both ARMv6-M and ARMv7-M.
Remove poorly merged code that attempted to include this only for cortex m0+.

Added doxygen, updated the definitions of the RBAR register, (though if you're
really using this periperhal, you should be looking at the ref man for further
information)

Reported-by: forrestv on irc.
2015-08-16 13:35:35 +00:00
Ken Sarkies 4d315288cf stm32: pwr: Use consistent include guards.
All STM32 family pwr.h must use LIBOPENCM3_PWR_H as include guard so that
pwr_common.h can detect that it has been referenced by pwr.h for
each family. F2 and F3 had the wrong include guard.

Fixes Github issue #513
2015-08-10 10:08:05 +00:00
Karl Palsson a2af34d0e1 stm32f1:rtc: whitespace/style cleanup.
Improperly checked pulls before commiting.  Trivial whitespace only change.
2015-07-31 05:21:46 +00:00
Ken Sarkies d316bbca39 stm32:f1:RTC: Replace direct register access with API calls
Some additional functions added to rcc to support the rtc.
2015-07-31 04:49:56 +00:00
Ken Sarkies 957c5233f4 stm32:f1:RTC: add documentation 2015-07-31 04:48:57 +00:00
Karl Palsson 40cde559a7 stm32: f24: doxygen updates for flash program width.
More doxygen, more better.
2015-07-31 03:51:32 +00:00
Karl Palsson ec15c1ca64 stm32: f24: flash: Make code match documentation
This removes the shift from the defines, and includes them in the helper
function, making the code match the documentation, and following how the
rest of the library commonly operates.

Code using the existing defines will continue to work.
2015-07-31 03:51:25 +00:00
Jorik Jonker 07ee71cf23 stm32f4: rcc: Add 84Mhz, max speed for f401
Basic helpers to at least support common configurations for the f401.

Original submission specified 5 wait states, but the reference manual and other
reviewers all believe that 2ws is sufficient for these modes.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2015-07-31 02:25:23 +00:00
Karl Palsson a28ba5cb65 docs: Update license and targets to be more current
Was rather odd describing a GPL project and linking everywhere to LGPL.  Carry
over from old codebase.  Updated the list of targets a bit while there.
2015-07-30 00:26:12 +00:00
Karl Palsson 07094ea418 usb: Fix typo in Battery Charge Detection defines
Correct register name for f0/l0 is USB_BCDR.
Correctly add the register descriptions that were missing in the
original commit.
2015-07-29 21:44:11 +00:00
Kuldeep Singh Dhaka afefa6888c stm32: usb: Rename USB_DADDR_ENABLE flag per ref manual
Use the standard REG_BIT name from the reference manuals, as specified
in HACKING  All the other bits have the correct naming.
2015-07-29 21:22:32 +00:00
Kuldeep Singh Dhaka 4b892724cf usb: provide typedefs for all the function callbacks.
This makes it easier to read for most people, and makes it substantially
easier to review changes in the function signatures themselves at a
later date.
2015-07-29 13:52:00 +00:00
Karl Palsson b1e495f51a stm32f3: adc: Add support for sequence completion flags
The f3 adc has separate bits for end of conversion and end of sequence.
Support those fully, with the regular enable/disable irq methods, and
the flag checking methods.

Discovered in github bug: #493
2015-07-29 13:28:18 +00:00
Karl Palsson e65140d0d3 stm32f3: adc: remove invalid eoc group methods.
This code was copied from the f4, and blindly modified to make it seem
to work.  The f3 has separate flags for EOC and EOS, it doesn't use a
second bit to configure what the EOC bit does.

Consequently, update the documentation to correctly indicate that the
EOC bits are only set per conversion.

Discovered in github bug: #493
2015-07-29 13:22:17 +00:00
Kuldeep Singh Dhaka 43e66927fc usb: Remove redundant stm32/usb_desc.h
This file is a renamed and restructured copy of /usb/usbstd.h.  The usbstd.h
file should be used instead, as it uses standard usb names.
2015-07-15 12:24:53 +00:00
Karl Palsson 1a398fd742 stm32f0: syscfg cfgr1 bit define updates
Use _FMP for the bit definitions as per the ref manual.
Add missing bits from newer ref manual (RM0091r6)
2015-07-15 12:19:39 +00:00
Karl Palsson a4bb8f7e24 stm32f4: fix i2s_ext register addresses
Registers were swapped.

Fixes #465
2015-06-22 01:11:50 +00:00
Kuldeep Singh Dhaka c28d7bc187 stm32: spi: Standard mode selection
Allow setting cpol/cpha via standard mode numbers, instead of separate calls
for each bit.
2015-05-25 13:03:20 +00:00
Karl Palsson aac78ba464 cm3: include stdint.h and stdbool.h
While there might be other places that are missing this include, this
particular file is clearly missing them, and has resulted in a few separate bug
reports.  Fix it right now, in the name of continuous improvement.

Fixes #310 and #427
2015-04-29 01:30:47 +00:00
Karl Palsson 5746fd4d25 stm32: common: Extract MCO source setting
This adds MCO source selection to some targets, and removes and standardizes
the mask/shift usage for all targets.  For devices that support MCO2, this
supports only MCO1.  No attempt has been made to extract MCO prescaler, which
is not available on all F1 and F3.
2015-04-29 01:22:27 +00:00
Felix Held 7ba1b57481 [sam3] add basic SMC support 2015-04-29 01:19:30 +00:00
Felix Held 235734ea42 [sam3] add support for the PIO peripheral of all devices
Add register definitions and access functions.
2015-04-29 01:19:23 +00:00
Felix Held 8a24685d0c [sam3] add basic pmc support
some peripheral ID definitions already added in periph.h were removed
2015-04-29 01:14:17 +00:00
Felix Held 6d69cbf98f [sam3] add peripheral identifiers 2015-04-29 01:14:17 +00:00
Karl Palsson 4f5863e372 usb: add endpoint address calculation macros
Some people find it easier to read without the direction bit included.
2015-04-23 15:17:49 +00:00
Andrey Smirnov db58d5ae82 Add provisions to support multiple altsettings
This commit implements the support for one interface to have multiple
altsettings. It also adds hook that user can use to perform actions
when the alsetting switch is performed by host.

Changes:
* For backward compatibility, placed a pointer instead of allocating memory for whole interface struct.
* Always execute callback (even if the current interface alternate-settings matches).
* Multiple configuration support.

Signed-off-by: Kuldeep Singh Dhaka <kuldeepdhaka9@gmail.com>
2015-03-30 00:07:32 +00:00
kbob fd141a8131 Definitions for LTDC (LCD-TFT video). 2015-02-20 19:40:23 -08:00
Piotr Esden-Tempski 5658a4ebcf [stm32f4-ltdc] Style cleanup.
Mainly replaced function like defines with static inline functions.
2015-02-12 19:02:51 -08:00
Piotr Esden-Tempski 34e9e8c3e1 [stm32f4-ltdc] Remove the LCD_TFT_BASE define.
This define name was used because of datasheet inconsistency. The
correct name is LTDC.
2015-02-12 19:02:51 -08:00
Angus Peart 60739968bd STM32F1: Support for I2C_OAR2 (Dual addressing) 2015-02-05 20:11:06 -08:00
Ondrej Palenicek 377f782d23 Removed extra underscore. 2015-02-05 18:27:29 -08:00
Karl Palsson 721f3d74eb headers: Explicitly error when you include an internal header
People should not be using the dispatch/ headers directly.
Try and make this more explicit.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2015-02-05 18:20:57 -08:00
Oliver Meier 7fbd49b3fc [stm32f4-ltdc] Helper function to wait for SRCR reload to complete 2015-02-05 16:44:38 -08:00
Oliver Meier 4b8f5e613b [stmf4-ltdc] added 3 spaces 2015-02-05 16:44:38 -08:00
Oliver Meier 3c9b07d776 [ltdc-stm32f4] add helper function to convert rgb565 to rgb888 2015-02-05 16:44:38 -08:00
Oliver Meier c26831fab0 [stm32f4-stdc] fixed includes 2015-02-05 16:44:38 -08:00
Oliver Meier eaae7731e9 [stm32f4-ltdc] initial commit 2015-02-05 16:44:38 -08:00
George McCollister 418fdd08dd usb: Prevent RX_CTR and TX_CTR from being cleared
When writing the USB endpoint register, USB_EP_RX_CTR (bit 15) and
USB_EP_TX_CTR (bit 7) should be set to avoid inadvertently clearing
either bit.

Prior to this patch end points could indefinately stall if the hardware
changed these bits between the time they are read and when they were
written.

Signed-off-by: George McCollister <george.mccollister@gmail.com>
2015-01-02 19:01:16 +00:00
George McCollister 9eb551c127 tools: Added *REG_BIT_MSK_AND_SET macros
Added CLR_REG_BIT_MSK_AND_SET and TOG_SET_REG_BIT_MSK_AND_SET because we
need version of CLR_REG_BIT_MSK and TOG_SET_REG_BIT_MSK that allow us to
OR in bits before the register is written.

Signed-off-by: George McCollister <george.mccollister@gmail.com>
2015-01-02 19:01:07 +00:00
Karl Palsson 8a15cec6bf stm32: f4: flash: support extended sector ranges
F42xx and F43xx have extended sector ranges.

Reported-by: H2OBrain@irc
2014-12-18 23:29:10 +00:00
Daniel Thompson e3b8adec10 usb: Support for MIDI class devices
Provides all of the config descriptors for MIDI class devices together
with a sub-set of the audio class sufficient to put together a full
fledged MIDI device.
2014-12-18 22:50:27 +00:00
Daniel Thompson d3aa579e0a usb: Support for class specific endpoint descriptors.
Extends struct usb_endpoint_descriptor to make it possible to provide
the USB host with class-specific extensions to endpoint descriptors.

The approach taken, based on extra and extralen and removing the sizeof()
from USB_DT_ENDPOINT_SIZE, is identical to the approach used to add
class-specific extensions to interface descriptors. All libopencm3-examples
use the USB_DT_ENDPOINT_SIZE (rather than directly using sizeof) so there
should be no compatibility problems resulting from this change.
2014-12-18 22:50:27 +00:00
Kuldeep Singh Dhaka 342ec6e9e3 [STM32F0] Add support functions for USB clock setup in F072 chips.
There is remaining an issue with PREDIV connected just after clock multiplexer (only F072). This should be fixed in another commit.
2014-12-18 23:43:04 +01:00
Kuldeep Singh Dhaka 331acce4fc [STM32F0] add support of autotrimming HSI to USB SOF frames
Signed-off-by: Frantisek Burian <BuFran@seznam.cz>
2014-12-18 23:43:04 +01:00
Karl Palsson 3974e5f48d ethernet: mac stm32fxx7: Fix style and docs
Rushed commits are bad mkay :)
2014-12-18 22:00:03 +00:00
Frantisek Burian cf6d8d7235 [fix] after phyid addition, the init function should init correct phy. 2014-12-18 21:26:59 +01:00
brabo 9cced2c0b4 [ETH] Phy ID configurable as parameter 2014-12-17 23:40:06 +01:00
Karl Palsson c09d2583dd stm32: f4: Add FLASH_OPTCR1 definition
This is required for stm32f42xx and stm32f43xx with second bank options.
2014-12-17 17:26:25 +00:00
Chuck McManis 14ad92015e Audit RTCPRE Shift and Mask Values
L0 - RTC Prescaler appears in RCC_CR, bit 20, 2 bits wide (RM0367 Rev 2)
L1 - RTC Prescaler appears in RCC_CR, bit 29, 2 bits wide (RM0038 Rev 10)
F0 - no prescaler setting (RM0091 Rev 7)
F1 - no prescaler setting (RM0041 Rev 4)
F2 - RTC Prescaler appears at RCC_CFGR, bit 16, 4 bits wide (RM0033 Rev 6)
F3 - no prescaler setting (RM0316 Rev 3)
F4 - RTC Prescaler appears at RCC_CFGR, bit 16, 4 bits wide (RM0090 Rev 8)
2014-12-14 16:29:03 -08:00
Chuck McManis 9ddfcb0e53 Rename rcc_ppre1_frequency and rcc_ppre2_frequency
Rename rcc_ppre1_frequency and rcc_ppre2_frequency to rcc_apb1_frequency and rcc_apb2_frequency
Also add rcc_ahb_frequency (although it is not set correctly in all cases) which will be fixed by
the rcc commits later. Also fixup the only use in the library of these variables, the USART code.

And fix the typos that resulted
Make l1 generic too
2014-12-13 19:49:04 -08:00
Oliver Meier a2fe6c49a8 [cm3/sync] Add mutex_trylock()
Allows non-blocking use in user code.
2014-12-11 09:58:34 +00:00
Chuck McManis 99f83eedcd stm32/f0: rcc.c Use common version instead of duplicate code.
Pulls out duplicate calls from f0/rcc.c and uses the common version which
also means that f0 can use rcc_peripheral_enable() now which is in common
but not the old rcc versions.
2014-12-03 11:14:26 +00:00
Karl Palsson f51698fff4 stm32:l0: RCC: add osc_on/osc_off helpers
These are the routines that have custom switch cases, and aren't easy targets
for pulling out.
2014-12-03 11:13:39 +00:00
Karl Palsson 378069091a stm32:l0: Add RCC register definitions
Tested with a miniblink example on the l053 discovery board.

Only register definitions at this stage, no helpers.
Register definitions from RM0367r2, hopefully the biggest
superset of L0 parts.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2014-12-03 11:13:39 +00:00
Karl Palsson 3a44b1311b stm32: f1: Additional GPIO Remappings for F100
F100 has more remap options than F10x, particularly on the High Density
devices.

Fixes github issue #365

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2014-11-21 10:38:03 +00:00
Karl Palsson fb95997b3b stm32f1: rcc: timer 15,16,27 rcc bits missing for old style
The bits definitions for direct manipulation were missing, and should be
present for completeness.  However, this only affects the legacy (error prone)
API, replaced some time ago.

old and error prone: (stop using code like this)
    rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_TIM16EN);
    rcc_peripheral_reset(&RCC_APB2RSTR, RCC_APB2RSTR_TIM16RST);

new:
    rcc_periph_clock_enable(RCC_TIM16);
    rcc_periph_reset_{pulse,hold,release}(RCC_TIM16);

Fixes github issue #361
2014-11-14 22:32:49 +00:00
Silvio Gissi 1420be5577 lpc17xx: power: basic peripheral power functions and defns 2014-10-27 22:05:36 +00:00
Silvio Gissi ff8e2743e8 lpc17xx: clock: Add basic clock control definitions 2014-10-27 22:05:30 +00:00
Silvio Gissi 91dca33789 lpc17xx: memorymap: Add APB1 peripherals 2014-10-27 22:05:23 +00:00
Silvio Gissi f44a8cf696 lpc17xx: memorymap: Add GPIO block at correct location 2014-10-27 22:05:16 +00:00
Silvio Gissi fe52894cf4 lpc17xx: memorymap: Fix AHB address and add peripherals 2014-10-27 22:05:08 +00:00
Frantisek Burian eee5a45019 [stm32l0] Integrate the L0 architecture to the doxygen documentation
Conflicts:
	doc/Makefile
2014-10-15 19:33:20 +02:00
Frantisek Burian f9152eb00a [stm32l0] Initial support for STM32L0 architecture, Add GPIO peripheral 2014-10-15 19:31:41 +02:00
Stefan Agner 7cef59a83f vf6xx: add I/O mux controller
Add I/O mux controller which is required to mux pins according to
their used function. For all pads, the alternative function 0 is
GPIO. For different pin mux function refer to the reference manual.
2014-10-15 19:31:09 +02:00
Stefan Agner 2e1cbcae22 vf6xx: initial GPIO support
This adds GPIO module support. GPIO can be controlled using the GPIO
number as stated in the reference manual, similar to Linux. Also
32-bit access to whole ports is possible. Reading a GPIO is possible
without muxing the pad as GPIO, however writing a GPIO needs the pad
to be muxed as GPIO.
2014-10-15 19:31:09 +02:00
Stefan Agner a1d456521d vf6xx: add UART support
This adds UART support for Vybrid VF6xx. Baud rate is calculated
from IPG clock, which need to be initialized by using the
ccm_calculate_clocks functions. Also clock need to be gated using
the ccm_clock_gate_enable function. Tested with an unitialized
UART with a baud rate of 115200.
2014-10-15 19:31:02 +02:00
Stefan Agner c9857ad52a vf6xx: calculate core clocks
Extend the clock controller module with a function to calculate
core clocks from the current registers settings. On Vybrid, we
assume that the core clocks are setup by the main operating system
running on the Cortex-A5. Nevertheless we need to know their actual
values in order to calculate other clocks or baud rates.

Verified on a Colibri VF61, which calculates following values:
ccm_core_clk: 500210526
ccm_platform_bus_clk: 166736842
ccm_ipg_bus_clk: 83368421
2014-10-15 19:31:02 +02:00
Stefan Agner c83e16926e vf6xx: doc: initial commit
Add documentation Makefile and DoxygenLayout for Freescale Vybrid
VF6xx support.
2014-10-15 19:31:02 +02:00
Stefan Agner 3132ae50cb vf6xx: initial memorymap and clock control module
Add initial memorymap for Vybrid VF6xx module. Also add the clock
control module which allows to control system clocks and enable
clocks of individual pheripherials.
2014-10-15 19:31:02 +02:00
Stefan Agner 07b7d3e805 vf6xx: initial add of Vybrid VF6xx support
Freescale Vybrid is a familiy of ARM SoC, wheras the VF6xx models
have two cores in one SoC, a Cortex-A5 and a Cortex-M4. This adds
initial support for the Cortex-M4 in the libopencm3 library.

By using two different ram areas (pc_ram and ps_ram) the user can
put the code in a RAM area bounded to the code bus. The data can
be stored in the data area. However, currently the initial values
of for the variables in the data section are stored in the code
section and copied to the ram section by the initialization code
(like it's copied from ROM to RAM on microcontrollers).
2014-10-15 19:31:01 +02:00
Freek van Tienen ac8ac8c64d [f4] Added a 25mhz clock 2014-10-15 17:27:18 +02:00
Geoffrey Hausheer 4ff07df7b2 stm32: Add timers 9-17. This should support all F0, F1, and F2 products 2014-10-07 11:23:52 +00:00
Karl Palsson 5d4437fe43 stm32/spi: Replace all SPIx_I2S_BASE with SPIx_BASE
Latest versions of all reference manuals refer to the address as SPIx_BASE, and
simply name some of the individual registers as SPI_I2SXXXX.  Likewise, the
interrupts are simply SPIx, not SPIx/I2Sx.  Rather than hacking more duplicates
into the F0 and L0 parts where this was turning up, remove the pointless _I2S_
from SPI2/SPI3 and make it all consistent

Compile tested only, with the examples collection.

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

Fixes #331
Fixes #347
2014-10-07 11:21:40 +00:00
Karl Palsson 2211944233 stm32: exti: Define all irqs in common header.
There's more exti lines on many more devices now. F0 and F3 have extras, as did
L1 and L0.  There's no real reason not to have higher order EXTI definitions
defined at the top level, and it reduces the number of files to merge together
to find all definitions for the bigger devices.

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

Fixes #338
2014-09-30 22:32:52 +00:00
Nippius d2808b8486 tiva lm4f: ssi: Initial implementation for SSI peripheral 2014-08-11 21:51:09 +01:00
Karl Palsson cf5fb002f6 [l1-flash/eeprom] Add lock/unlock/eeprom helper routines 2014-07-14 17:54:20 +00:00
Frantisek Burian 4d28c1b849 USB: Fix definition of function according to previous commit. 2014-07-14 14:50:07 +02:00
Pavol Rusnak 806ebb18fa add MSC (Mass Storage Class) support 2014-07-03 18:46:55 +02:00
Karl Palsson 67b538a540 usb/stm32: Add top level commentary for scope
Remove some unncessary commentary and fixed bit fields introduced earlier via
insufficient review.
2014-05-25 19:54:06 +00:00
Roger Wolff c07a1291f4 usb/stm32 added NOVBUSSENS bit definitions 2014-05-25 19:45:52 +00:00
Roger Wolff 5c5c77d4dc stm32/f0: DMA base address compatibility tweak 2014-05-25 19:35:20 +00:00
Karl Palsson d3e228176f libopencmsis: Fill in missing CMSIS interrupt links
And correct a minor typo in the generated code.
2014-05-14 16:11:43 +00:00
Felix Ruess 67242de60d [f3] add USART_SR_x defines for common status flags
enables the use of usart_get_flag(USARTx, USART_SR_x) on F3 just like on F124

closes #283
2014-04-09 16:41:20 +02:00
Karl Palsson d839ce41f6 stm32f1: Fix RCC CAN defines
Thanks to Марко Краљевић <krasnaya.zvezda@gmail.com>
2014-04-08 18:51:26 +00:00
Karl Palsson cb33acc32a stm32f1: Add missing peripheral base address for F100 2014-03-31 13:56:50 +00:00
Ken Sarkies 1f5ce647ff stm32: adc.h regression: Add missing register definitions
The adc unification pull left out some of the shortcut definitions for
ADC1.  See 27bc12de61
2014-03-12 09:27:56 +00:00