Commit graph

605 commits

Author SHA1 Message Date
Marti Bolivar f7e7cf0930 Add stm32_private.h.
This will hold STM32-related things that I'm not sure are well-thought
out enough to go into <libmaple/stm32.h>. Currently, it contains an
accessor routine that tells you the purpose of the memory block
containing an address.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-12 16:04:02 -04:00
Marti Bolivar b95f3e56b5 Build libmaple/dma.c on STM32F1.
F2 doesn't work yet.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-12 16:02:13 -04:00
Marti Bolivar 78f2bb290b enum spi_mode: Add more descriptive enumerators, documentation.
Instead of requiring everyone to figure it out for themselves, add
enumerators specifying the idle logic level and what clock edge
triggers data capture. Yes, it's easy enough to figure it out. It's
also convenient to have these.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 21:47:46 -04:00
Marti Bolivar d71254f8f9 Bring back <libmaple/spi.h>.
Add a spi_private.h with a SPI_DEV(), for convenience. Use it in the
F1 and F2 implementations. We could probably unify these with an
STM32_HAVE_SPI(n) macro, but we'll leave that for the future.

Most everything from F1 is portable; F2 has some additional bit
definitions and a spi_get_af() routine, but that's about it.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 21:46:25 -04:00
Marti Bolivar d14105d11e Move syscalls.c into Wirish.
libmaple takes orders, it doesn't give them.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 19:15:05 -04:00
Marti Bolivar 3365fc03e0 libmaple/timer.h: Capitalization fix
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 19:15:05 -04:00
Marti Bolivar 3cdab05f52 libmaple/timer.h: Lose BIT().
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 19:15:05 -04:00
Marti Bolivar 89f991bf6a libmaple/timer.h: Move deprecated bits to bottom.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 19:15:05 -04:00
Marti Bolivar d1f279a85c struct timer_dev: Don't touch ->handlers!
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 19:15:05 -04:00
Marti Bolivar 4e05eee606 libmaple/timer.h: Nuke useless comment.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 19:15:05 -04:00
Marti Bolivar 5c48a50f85 libmaple/timer.h: Doxygen beautification and fixups
Make the Doxygen comments nicer to look at. Some of the docstrings are
out-of-date since F2 support was added, so update them.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 19:15:04 -04:00
Marti Bolivar 47d3326f3a Move timer_dev definitions into libmaple/timer.c.
The addition of STM32_HAVE_TIMER() allows us to avoid some
repetition. There's still an issue with names on F1 preventing us from
moving the IRQ handlers to libmaple/timer.c, but once that's resolved,
we'll be able to remove even more.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 19:15:04 -04:00
Marti Bolivar 29518f6e34 Tweak some timer_private APIs.
The current versions of DELARE_*_TIMER() don't play well with cscope,
which is a bad sign. Fix that.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 19:15:04 -04:00
Marti Bolivar db3efddaa9 series/timer.h: Remove silly duplicate declarations.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 19:15:04 -04:00
Marti Bolivar 2cc3749c19 stm32.h: Soften "missing MCU" errors into warnings.
It's not important whether the MCU is specified. What's important is
that <libmaple/stm32.h> gets everything it needs -- which it now
ensures that it does. Requiring people to do things on a per-MCU basis
hurts hackability and is just asking for trouble.

On the other hand, it's nice to provide a clue as to why
<libmaple/stm32.h> might be giving #errors, so do leave the
warnings. People can always hack the header to shut them up if they
want.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 03:38:29 -04:00
Marti Bolivar 6f91cfc425 Bring back libmaple/dac.h.
Minor variations on F2: DMA underrun interrupts, and a status register
to hold the notification bits.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-04 00:20:21 -04:00
Marti Bolivar 19aebdf425 stm32.h: Add STM32_HAVE_DAC feature-test.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-04 00:17:01 -04:00
Marti Bolivar 8558b62e06 STM32F1: gpio.h: Add hack mode macro, for F2 compatibility.
I'm sure we can work the compatible subset of F1/F2 GPIO functionality
into the F1 gpio.h interface in a clean way. This is not that clean
way, but I'm short on time.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-04 00:17:01 -04:00
Marti Bolivar 3cc2ff5f50 STM32F2: Add EXTI support.
Add series headers to keep the base pointers, and (on F2) use SYSCFG
to tell exti_do_select() where the EXTI control registers are. No
surprises.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-03 22:45:41 -04:00
Marti Bolivar 647c4b1027 STM32F2: Add SYSCFG support.
Turn it on at init() time on F2.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-03 22:44:43 -04:00
Marti Bolivar aeb6ae44b8 STM32F1: gpio.h: Cosmetics.
Those ugly Doxygen comments have been bothering me since forever. Fix
them up and throw some M-x align around.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-03 22:40:40 -04:00
Marti Bolivar 9557be1f25 Bring back EXTI on F1, with deprecations for gpio.h on F1.
Tested on Maple Mini with examples/mini-exti-test. Changes to Wirish
are minor: use the new EXTI types exti_num and exti_cfg (see below) in
place of now-deprecated variants in ext_interrupts.cpp.

The way I originally did libmaple/exti.h was stupid, and fixing it
turned out to be a little disruptive.

libmaple/exti.h depends on libmaple/gpio.h (for AFIO), but that's a
classic case of exposed implementation detail. So invert the
dependency: make gpio.h depend on exti.h. Do this by adding exti_num
and exti_cfg to exti.h; these respectively replace afio_exti_num and
afio_exti_port. The afio_* variants are now deprecated. (Throw in a
typedef and some macros at the bottom of the F1 series/gpio.h for
backwards compatibility).

Make exti_attach_interrupt() and exti_detach_interrupt() take
exti_num/exti_cfg arguments instead of the afio_* variants.

Make the EXTI dispatch routines __always_inline to defeat GCC -Os.

Many renames throughout libmaple/stm32f1/ to stop using the deprecated
names. Also move the previously F1-only gpio_exti_port() function into
the public libmaple header. Reimplementing it in terms of rcc_clk_ids
lets us deprecate the gpio_dev->exti_port field, which will save space
in the future.

While we're there, I notice that struct gpio_dev is defined once per
series. That's dumb, as it misses the entire point of having device
structs: they contain what's portable. So put the F1 version (which
has the extra EXTI port field) into libmaple/gpio.h, and add the
necessary exti_ports to libmaple/stm32f2/gpio.c. Sigh. We'll get rid
of it eventually, at least.

Clean up some other mistakes in gpio.h files as well (mostly removing
util.h dependency). Sorry for the messy commit.

For portability, add a new series-specific exti function,
exti_select(). The F1 version in (new) libmaple/stm32f1/exti.c uses
AFIO and some new private functionality in libmaple/exti.c and (new)
libmaple/exti_private.h to make this convenient.  We'll be able to do
the SYSCFG equivalent on F2 without any trouble.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-03 22:40:40 -04:00
Marti Bolivar 6b5c8417ef <libmaple/bitband.h>: Doxygen
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-03 22:40:40 -04:00
Marti Bolivar 1c5a7ecb98 libmaple/dac.c: Copyright.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-03 22:40:40 -04:00
Marti Bolivar 0b93e882bf libmaple/dac.c: Generalize comment about PA4/PA5.
Seems like this is true on F2 as well!

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-03 22:40:39 -04:00
Marti Bolivar 44aa07d181 Add ISRs and vector table for F1 value line.
Now libmaple/stm32f1/rules.mk tries to pull in ISRs and a vector table
on a per-line basis. Move isrs_performance.S and
vector_table_performance.S to (new) libmaple/stm32f1/performance, and
rename them.

Add corresponding files for value line under (new)
libmaple/stm32f1/value. This helps clean up some
performance-line-isms, and allows implementing e.g. the CEC interrupt,
which is used by something else on performance line.

Untested (I don't have access to a value line MCU); hopefully this
works.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-03 22:40:39 -04:00
Marti Bolivar 8796a81efc Slightly improve and generify the USB infrastructure.
The good news is that <libmaple/usb.h> and <libmaple/usb_cdcacm.h> did
turn out generic enough in what they specify to go on unchanged.

However, we can't just go on assuming that there's USB just because
we're on an F1. Now that there's value line in the tree, we need to be
more careful (value line F1s don't have USB peripherals). To that end,
make all the F1 board-includes/*.mk files specify what line their MCU
is with an MCU_F1_LINE variable. Use that to hack
libmaple/usb/rules.mk so we only try to build the USB module under
appropriate circumstances.

While we're at it, add a vector_symbols.inc for value line MCUs under
support/ld/. We need this to get the target-config.mk modifications
implied by the addition of MCU_F1_LINE. We'll fix up some other
performance-line-isms under libmaple/stm32f1 in a separate commit.

Also in libmaple/usb/:

- Move everything into a new stm32f1 directory. Due to aforementioned
  rules.mk hacks, there is no immediate need for an stm32f2
  directory (USB support doesn't exist there).

- Update the README for style and content.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-03 22:40:39 -04:00
Marti Bolivar a9381eb090 libmaple_types.h: Add __unused.
We'll need this soon.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-03 22:40:38 -04:00
Marti Bolivar 9ee2f6c79d F2: Add usart_get_af().
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-03 02:23:27 -04:00
Marti Bolivar 97b01c0b98 Globally switch style for GPIO config routines.
Stupidly, spi_gpio_cfg() didn't take a spi_dev* argument on F1,
because it doesn't matter there. On F2, where we need to set an
alternate function when configuring GPIOs for SPI, we need to know the
dev.

We can't add break backwards compatibility, so we need a new
function. However, we've since added a bunch of foo_gpio_cfg()
routines, and we don't want confusing asymmetry in the names. So a
global style change is needed. (Fortunately, the new functions weren't
part of a release, so it's no problem to change their names).

Change all foo_gpio_cfg() routines to foo_config_gpios() (or
foo_config_gpio(), if there's only one GPIO to configure). For
backwards compatibility, make spi_gpio_cfg() on F1 an __always_inline
call to spi_config_gpios().

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-03 02:15:22 -04:00
Marti Bolivar cd494c17d9 STM32F2: Add timer_get_af().
Pull some code out of the F2 pinMode() into a utility function. This
feels generally useful enough to be exposed to the users (it will, for
example, make it easier to implement input capture in a clean way).

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-03 00:04:01 -04:00
Marti Bolivar 49794bbbee Add timer_has_cc_channel().
This is a convenience function for deciding whether a timer supports a
particular capture/compare channel. It's necessary because of those
nuisance "general purpose" timers that only have a subset of the
channels.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-02 20:36:36 -04:00
Marti Bolivar 8c7d91af97 Sort the rcc_clk_id enumerators semi-alphabetically.
Only semi-alphabetically because peripherals are kept together (so the
UARTs sort as if they were USARTs). Advantages:

- It lets us play numeric comparison and lookup-table hacks, as we now
  have the property that the rcc_clk_ids for a given peripheral are a
  contiguous range of integers.

- It will hopefully let the compiler emit faster/smaller code for
  switches over a dev->clk_id.

- It's better intuitively.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-02 20:31:52 -04:00
Marti Bolivar ec5a2f8309 Oops; don't break the build on F1.
That was dumb.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-02 19:39:47 -04:00
Marti Bolivar b07c06d3e3 libmaple/adc.h: Fixup for Doxygen.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-01 16:36:20 -04:00
Marti Bolivar feae1d4478 libmaple/stm32.h: Add STM32_TIMER_MASK, STM32_HAVE_TIMER.
Feature-test macros for dealing with the fact that timer support has
holes. STM32_TIMER_MASK is a bitmask where bit n is set when TIMERn is
present. STM32_HAVE_TIMER(n) just tests whether bit n is set in
STM32_TIMER_MASK.

This is necessary because e.g. the STM32F100RB has timers 1-4, 6, 7,
and 15-17.  Because of this, the usual STM32_NR_whatever won't work,
and we use a bitmask instead.

For F1 performance line (F103s), STM32_TIMER_MASK can be derived from
the density. For F1 value line, I'm not as sure, so just add it for
the single MCU we support (the STM32F100RB). Same story for F2: add it
for the STM32F207IC. We can fix this up later if necessary.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-01 03:05:56 -04:00
Marti Bolivar 9a2ed4a661 stm32f2/usart.c: Change some FIXMEs to TODOs.
I think these are probably unchanged, but we need to make sure.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-01 01:29:54 -04:00
Marti Bolivar d2c4bd6564 Bring back HardwareSerial.
To make this happen, we need to have <board/board.h> tell us whether
or not it's got each of the USARTs. Do that with BOARD_HAVE_USARTn,
for n = 1,...,6. This lets us define HardwareSerial instances only
when appropriate, and gets rid of some board-specific hacks we'd
accumulated.

The new <libmaple/usart.h> now has a convenience function for
determining the bus rate by using the appropriate STM32_PCLKx macro,
so we can shave a uint32 per instance, which is nice given that
they're all going to be in memory. This changes the constructor
arguments, but the API only specifies the semantics of the predefined
instances, so this is still backwards-compatible. (We should look into
storing the instances in Flash -- they don't change, after all.)

We don't actually need struct usart_dev's definition in
HardwareSerial.h, so replace it with a forward declaration and include
<libmaple/usart.h> it in HardwareSerial.cpp instead.

Assert some copyrights.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-01 01:28:51 -04:00
Marti Bolivar 714569afdb stm32f2/gpio.c: Fix some bugs.
Make gpioh.regs actually point to GPIOH_BASE. Properly AND out flag
bits in gpio_set_modef().

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 18:44:26 -04:00
Marti Bolivar 3e6269316d <libmaple/gpio.h>: Fix gpio_write_bit().
It's exactly wrong -- val=0 makes the pin high, and val=1 makes it
low.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 18:43:18 -04:00
Marti Bolivar 766cda51fa libmaple/usart_private.c: Add missing include.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:41 -04:00
Marti Bolivar 47b17f5b98 STM32F1: Fix nvic_irq_disable_all() on some MCUs.
The current implementation only disables the first 64 IRQ lines. This
covers all the chips we currently support, but it'll be a nasty
surprise if anyone decides to add e.g. connectivity line MCUs (which
have more IRQs) in the future.  We already have the infrastructure to
fix it in a clean way, so we might as well do it now.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:18 -04:00
Marti Bolivar 0bc34d060c nvic.h: Doxygen: nvic_irq_num is target dependent.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:18 -04:00
Marti Bolivar fc3fb928fa libmaple/nvic.h: Doxygen tweak.s
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:18 -04:00
Marti Bolivar 1fb5934180 libmaple/nvic.h: Fix typo.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:18 -04:00
Marti Bolivar daee14b0b6 stm32f1/rcc.c: Move Doyxgen.
This is a workaround for Breathe.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:17 -04:00
Marti Bolivar 94f362e925 series/rcc.h: Lose BIT().
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:17 -04:00
Marti Bolivar ef217b7434 libmaple/rcc.c: Fix typo.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:17 -04:00
Marti Bolivar 8f8ab2e354 libmaple/rcc.h: Doxygen.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:17 -04:00
Marti Bolivar 1cf0366934 stm32f2/rcc.h: Remove a TODO.
That never worked out.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:17 -04:00
Marti Bolivar 722cf3e90c stm32f2/rcc.h: Add FIXME for rcc_rtc_divider.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:17 -04:00
Marti Bolivar b2b9a2ba87 stm32f2/rcc.h: Fix typo.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:17 -04:00
Marti Bolivar 518b5f0b4b stm32f1/rcc.h: Add a FIXME.
Having a separate struct is stupid.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:17 -04:00
Marti Bolivar 6d1ebe4a67 RCC: Doxygen
Various changes to Doxygen structure, to help leaflabs-docs make sense
of everything.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:17 -04:00
Marti Bolivar 5108a85dfd rcc.c: Fix typo.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:17 -04:00
Marti Bolivar 019d5af520 libmaple/rcc.h: Doxygen workarounds.
We need the arguments to be the same name everywhere, or
Breathe/Doxygen get confused.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:17 -04:00
Marti Bolivar d3369b63f9 libmaple/fsmc.h: Better Doxygen for memory bank bases.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:17 -04:00
Marti Bolivar c02e5775f3 libmaple/fsmc.h: Don't use BIT().
As fsmc.h doesn't include util.h or libmaple.h, these usages are
actually in error.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:17 -04:00
Marti Bolivar 963a5a35b0 stm32f2/fsmc.c: Cosmetics.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:17 -04:00
Marti Bolivar bd4f64b368 libmaple/iwdg.h: Remove BIT() usages.
This cleans up another unnecessary <libmaple/util.h> dependency.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:17 -04:00
Marti Bolivar f20568393e Don't try to build some libmaple files.
We can't do these on F2 right now.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:17 -04:00
Marti Bolivar f5f2fd2e75 Lose <libmaple/util.h> dependency in series/flash.h headers.
Switch from BIT(...) to (1U << ...).

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-09 17:56:35 -04:00
Marti Bolivar 2ed4c00c74 flash.h: Doxygen.
Document FLASH_BASE once. This is due to restrictions in the
documentation build system.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-09 17:53:45 -04:00
Marti Bolivar 2544e8f212 Change __DOXYGEN_PREDEFINED_HACK to __DOXYGEN__.
avr-gcc does it this way. Seems ok to me.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-09 15:09:52 -04:00
Marti Bolivar 9ff00606cf Make usart_irq() __always_inline.
Compiling with -Os can prevent this from inlining, and it's an IRQ
handler, so the space is worth spending.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-08 16:28:05 -04:00
Marti Bolivar d904623715 Mark Doxygen for Flash register maps as series-specific.
This will let help us verify that we got the right thing when we pull
it out of of Doxygen XML for the official HTML documentation.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-08 16:26:39 -04:00
Marti Bolivar 3a30b3329f libmaple/util.h: Doxygen cosmetics.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-08 16:25:32 -04:00
Marti Bolivar e824cc5308 libmaple/flash.h: Doxygen for flash_enable_features().
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-08 16:24:42 -04:00
Marti Bolivar 7651d09560 libmaple/flash.h: Deprecate flash_enable_prefetch().
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-08 16:24:16 -04:00
Marti Bolivar 68eb47d7a7 libmaple/flash.c: Update Doxygen for flash_set_latency().
Update for STM32F2 support.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-08 16:23:45 -04:00
Marti Bolivar 306e19cb9f Fix a bunch of Doxygen file-level comments.
Fix @file in many places. Also fix up the descriptions where it's
appropriate. This standardizes the @file formatting across the library
to explicitly include any parent directories up to the repository
root.

Besides being nice, this will hopefully let us manage Doxygen's XML
output so as to make extracting series-specific pieces via Breathe in
the leaflabs-docs repo possible.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-08 16:22:41 -04:00
Marti Bolivar 06dace8e01 libmaple/flash.h: Fix Doxygen @file
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-08 15:05:01 -04:00
Marti Bolivar fc214a6266 libmaple/util.h: Doxygen fixups.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-08 14:19:01 -04:00
Marti Bolivar df0cb433c1 ring_buffer.h: Fix Doxygen @file.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-08 13:10:00 -04:00
Marti Bolivar d078c7fbc1 stm32f1: stm32.h: Tweak STM32_F1_LINE_xxx for mnemonic value.
Change the values of the STM32_F1_LINE_xxx macros to match the part
number better (so performance line, or F103s, now have
STM32_F1_LINE_PERFORMANCE==3, F100s have STM32_F1_LINE_VALUE==0,
etc.). This will hopefully make debugging or error checking easier for
someone at some point.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-08 11:47:50 -04:00
Marti Bolivar 483698e274 stm32f1: stm32.h: Doxygen.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-08 11:44:55 -04:00
Marti Bolivar f2c4176478 libmaple/stm32.h: Doxygen.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-08 11:41:03 -04:00
Marti Bolivar 397fbe3895 stm32f1: stm32.h: Cosmetics.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-08 11:40:46 -04:00
Marti Bolivar 6249d996b1 stm32f1: stm32.h: Add Doxygen comments.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-08 11:39:47 -04:00
Marti Bolivar d7e04595a5 stm32f1: stm32.h: Add hooks for USB access line.
There are five F1 lines in total. The necessary infrastructure for USB
access line (STM32F102 MCUs) support is missing, so add it.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-08 11:39:10 -04:00
Marti Bolivar 92ec2d47f4 stm32f1: stm32.h: Fix wrong comment.
We've got some value line values now.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-08 11:31:37 -04:00
Marti Bolivar b2416cb050 libmaple/bkp.h: Tweak for STM32F1 XL-density.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-07 01:53:34 -04:00
Marti Bolivar 65f70ea102 adc: Add missing "static" on adc_dev adc3.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-06 21:26:18 -04:00
Marti Bolivar bad7e605b5 Fix wrong comment in libmaple/rules.mk.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-03 21:50:02 -04:00
Marti Bolivar 0f36bb2acd libmaple/adc.h: Cosmetics.
Add "extern" to mark portable interface routines that are implemented
individually by each series.

Move some code around.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-03 15:32:46 -04:00
Marti Bolivar 9108a9d807 stm32f1/adc.h: Add missing includes.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-03 15:21:57 -04:00
Marti Bolivar 9f402f46f6 stm32f1/adc.c: Cosmetics.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-03 15:20:02 -04:00
Marti Bolivar 423995d58d STM32F1: adc: Tweaks for XL-density MCUs.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-03 15:19:13 -04:00
Marti Bolivar d10b5a3efa stm32f1: Resurrect DMA support. (sets up breaking change)
Breaking change set up: struct dma_handler_config is no longer part of
the public API in <libmaple/dma.h>. User code which was touching
these was always mistaken; it should be using dma_attach_interrupt()
or dma_detach_interrupt() instead.

Other than that, just move the nonportable bits in <libmaple/dma.h>
and libmaple/dma.c to the appropriate places under
libmaple/stm32f1/. (Ouch. This is almost everything.) Patch the
(new) STM32F1 <series/dma.h> here and there to make everything
compile; this is mostly limited to forward-declaring struct dma_dev
and providing a hack _dma_dev_regs() declaration so inline functions
in the series header can still access a device's registers.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-03 14:09:05 -04:00
Anton Eltchaninov 2fb91678e0 STM32VLDiscovery support files
Signed-off-by: Anton Eltchaninov <anton.eltchaninov@gmail.com>
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-03 14:09:05 -04:00
Marti Bolivar 50210b33f8 libmaple/stm32.h: Copyrights and cosmetics.
Fix copyright. Fix Doxygen @file. Update file-level documentation,
given this file's increased importance as an abstraction for porting
between series.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-03 14:09:05 -04:00
Marti Bolivar 56d7bac320 libmaple/dma.h: Fix Doxygen @file.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-26 15:50:18 -04:00
Marti Bolivar 53a51ccf05 stm32.h: Various updates, mostly to help STM32F1 line support.
Add STM32_HAVE_USB feature test macro requirement for
<series/stm32.h>. This will let us test if we've got a USB peripheral.
wirish/stm32f1/boards_setup.cpp is set up to use this when turning on
USB CDC ACM support at init() time.

Rework the STM32F1 <series/stm32.h> to make it easier to support the
various lines that subdivide that series. We don't really support
anything besides performance line yet, but there's been enough
enthusiasm for value and connectivity line support in the past that
these hooks seem worth adding. This means adding an STM32_F1_LINE
macro and STM32_F1_LINE_[PERFORMANCE,VALUE,ACCESS,CONNECTIVITY] macros
for values that STM32_F1_LINE can take, and generalizing the rest of
the file to begin taking this into account. Some TODOs remain, but
filling these in is the responsibility of future libmaple porting
efforts.

One pleasant consequence of the F1 stm32.h rework is that the build
system no longer has to tell us what density of F103 we're building
for, so remove that from the relevant support/make/board-includes/
files.

Add some tweaks to <libmaple/stm32.h> and the STM32F2 stm32.h header
to make sure this went through properly, and continues to go through
properly in the future.
2012-04-24 05:01:28 -04:00
Marti Bolivar 44237e7b23 stm32f1: stm32.h: Fix comment typo. 2012-04-24 03:20:18 -04:00
Marti Bolivar 387baea3d6 stm32f1: stm32.h: Put MCU section first, allow overrides.
Put the section defining MCU-specific values before the other
sections. Surround the density-specific defines with #ifndef/#endif
pairs. This allows any of the settings in the STM32F1 stm32.h to be
overridden on a per-MCU basis. That's hopefully useful to e.g. people
porting libmaple to STM32F100 MCUs, which have slower clocks.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-23 13:30:07 -04:00
Marti Bolivar bddf33a448 libmaple/i2c.h: Rearrange i2c_dev members to improve packing.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:57 -04:00
Marti Bolivar ed44ded739 stm32f2/gpio.h: Cosmetics.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:57 -04:00
Marti Bolivar aae7c31b43 libmaple/stm32f1/spi.c: cosmetics.
Fix whitespace, move some definitions around.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:57 -04:00
Marti Bolivar fb13a241b8 libmaple/spi: Fixups, move nonportable bits into libmaple/stm32f1.
Standard family support refactoring: add STM32F1 series spi.h, spi.c,
and move anything that won't port to STM32F2 there.

As part of a general effort to be cleaner, remove the dependency on
libmaple/util.h from libmaple/spi.h by not using BIT(). Also forward
declare struct gpio_dev for spi_gpio_cfg() to remove that include.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:57 -04:00
Marti Bolivar 1ea6eb8971 libmaple/spi: Fix boilerplate.
Update Doxygen file headers and license copyright dates.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:57 -04:00
Marti Bolivar 6715377e27 STM32F2: Add timer support.
Standard series peripheral support patch, containing STM32F2 series
timer.h and timer.c.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:57 -04:00
Marti Bolivar 75421efa8a stm32f2/nvic.h: Add fake NVIC_TIMER6 irq number.
This is necessary to make some timer code portable, but I'm not sure
it's a good idea.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:57 -04:00
Marti Bolivar 8530a332ac libmaple/rcc.h: Fix Doxygen file header.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:57 -04:00
Marti Bolivar cd61bfbaf0 stm32f2/rcc.h: Fix Doxygen file header.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:57 -04:00
Marti Bolivar cbe37fa979 STM32F1: Add support for timers 9 through 14.
This applies to XL-density STM32F1 devices.

In stm32f1/timer.c, add timer_dev's for the new timers, using the
timer_private API. These definitions are conditionally compiled based
on the target density to avoid wasting space on smaller MCUs. Also add
calls to the appropriate timer_private.h dispatch routines within the
IRQ handlers for these timers. We need to change the IRQ handler names
to reflect this eventually, but put that off for now, as it could
break backwards compatibility in some exotic situations where the user
refers to the libmaple IRQ handlers directly.

In stm32f1/timer.h, add register map base pointers and device
declarations for the new timers. timer_dev* declarations are compiled
in only when the target MCU supports them, in keeping with the above
stm32f1/timer.c changes.

In libmaple/timer.c, update the (static) IRQ enable routines to
account for the additional timers. This adds some code that's
unnecessary on smaller STM32F1s, but it's minimal (40 extra bytes on
my machine), so portability and readability win out.

Size change, using GCC version "(Sourcery G++ Lite 2011.03-42) 4.5.2":

Before:

   text	   data	    bss	    dec	    hex	filename
    615	      0	      0	    615	    267	build/home/mbolivar/leaf/libmaple/libmaple/timer.o

After:

   text	   data	    bss	    dec	    hex	filename
    655	      0	      0	    655	    28f	build/home/mbolivar/leaf/libmaple/libmaple/timer.o

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:57 -04:00
Marti Bolivar c8915d3c91 libmaple/timer_private.h: Update to support TIM9-TIM14.
Add DECLARE_RESTRICTED_GENERAL_TIMER(), for declaring general-purpose
timers with limited interrupt support -- that is, for declaring timers
9 through 14. This helps avoid wasting space on pointers to user
handlers for interrupts that don't exist.

Add dispatch_tim_9_12() and dispatch_tim_10_11_13_14(), which are
special purpose dispatch routines for these "restricted" general
purpose timers, which only try to dispatch interrupts supported by
these timers.

Change dispatch_single_irq() to check the logical and of the DIER and
SR registers for the timer whose interrupt it's dispatching. This is
necessary due to increased muxing on the timer IRQ lines caused by the
new timers. See the comment in the patch for more details. This does
add overhead on medium- and high-density STM32F1s, where the extra
check is unnecessary, but it doesn't change dispatch_single_irq()'s
semantics, and keeps the implementation simple, so we'll live with it.

These changes will also work on F2 (and F4 AFAIK), which is why
they're part of the global private timer API, as opposed to
libmaple/stm32f1/timer.c.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:57 -04:00
Marti Bolivar 02545cab4d libmaple/timer_private.h: Add more explanatory comments.
Hopefully these will be helpful when adding timer support for
additional series in the future.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:56 -04:00
Marti Bolivar 16f81ef445 stm32f1/nvic.h: Add nvic_irq_num's for XL-density timers; Doxygen fixup.
This is a backwards-compatible change, but it deprecates some existing
functionality.

XL density STM32F1 devices have additional timers 9 through 14. These
share NVIC lines with timers 1 and 8. This scheme is also used on
e.g. STM32F2, so the corresponding nvic_irq_num enumerators on that
series have names like "NVIC_TIMER1_BRK_TIMER9" instead of
"NVIC_TIMER1_BRK". For portability (and XL-density support), it makes
sense to add these enumerators to the F1 version of nvic_irq_num,
which we do here.

For backwards compatibility, we keep the old enumerators (like
NVIC_TIMER1_BRK) around as aliases to the new ones (like
NVIC_TIMER1_BRK_TIMER9). These old enumerators are now deprecated.

Also fix up the Doxygen @file header.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:56 -04:00
Marti Bolivar 4b4de07958 stm32f2/nvic.h: Fix Doxygen @file directive.
This lets Doxygen pick it up.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:56 -04:00
Marti Bolivar 4c4d704956 stm32f2/rcc: Fix timer rcc_clk_id enumerators.
The timer enumerators are different tokens on F2 than they are on F1.
This is wrong (breaks portability), so fix it, and update the F2
rcc_dev_info table to match.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:56 -04:00
Marti Bolivar dc9a918288 stm32f1/timer.h: Whitespace tweaks.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:56 -04:00
Marti Bolivar 2dd98d25b4 libmaple/timer.h: Minor tweaks.
Comments etc.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:56 -04:00
Marti Bolivar d7b930d055 timer: Fixes, rip out nonportable bits.
Fix copy-paste errors in, and add missing, register bit
definitions. For copy-paste errors that would result in source
incompatibilities with past releases, add some legacy defines.

Add series header and C file for STM32F1 which fills in the missing
API. Much of the F1 timer.c would be repeated on F2, so also add
timer_private.h to hold these.

Support for timers 9 through 14 is still missing.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:56 -04:00
Marti Bolivar 6e2a65e7df Don't conditionally compile rcc_clk_id or nvic_irq_num enumerators.
Whether or not a given peripheral is present on an F1 series MCU
doesn't matter. It doesn't take up any extra space to include these
enumerators, and it's convenient to have them defined so portable
libmaple routines can safely refer to them. This can prevent the need
for special series-specific versions of some functions.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:56 -04:00
Marti Bolivar b545d97c01 libmaple/libmaple_types.h: Add __always_inline.
We need this to ensure inlining when compiled with -Os.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:56 -04:00
Marti Bolivar e8d6ba0cdd libmaple/timer.h: Fixups.
Fix include guard define name, update copyright, fix Doxygen @file.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:56 -04:00
Marti Bolivar b370738ee0 libmaple/dac.h: Fixups.
Assert LeafLabs copyright; fix Doxygen @file, and add missing include.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:56 -04:00
Marti Bolivar 59a7811d05 Deprecate rcc_clk_init().
This function has been with us from the earliest days of libmaple.
It's showing its age, as the API it presents is tied to the
STM32F1. Deprecate it, and provide instructions for how to use newer,
more portable APIs. The new way is more verbose, but we can always add
a portable "just set up the PLL, dammit" convenience function later (a
nice candidate is to extract an interface from setup_clocks() in
boards.cpp).

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:56 -04:00
Marti Bolivar a949744d3c Resurrect ADC support.
Standard refactoring: add series headers for F1 and F2, along with
series adc.c files. There are some issues relating to adc_extsel_event
to hammer out later, but this will do for now.

We also add some new portability interfaces to libmaple/adc.h in order
for Wirish to use the same code to initialize the ADCs at init() time.

As usual, F1 is untested.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:56 -04:00
Marti Bolivar 5f81900107 libmaple/rules.mk: Cosmetics.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:55 -04:00
Marti Bolivar 4dd092d705 Resurrect IWDG support.
This peripheral is identical on F1 and F2.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:55 -04:00
Marti Bolivar 88dc7e263a Resurrect PWR support for F1 and F2.
Just add the missing register bit definitions in new series headers.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:55 -04:00
Marti Bolivar a6644bcec1 Clean up rules.mk files.
Alphabetize targets and remove continuation lines.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:55 -04:00
Marti Bolivar 95f3f3bb0d libmaple/pwr.h: Fix register bits (breaking change).
This is a backwards-incompatible change. It is necessary to fix an
error.

The register bit definitions are given as if they were masks, but
they're actually bit numbers. E.g., PWR_CR_DBP, which should be the
mask for DBP in the power control register PWR_CR, is actually the
number of the bit that should be masked.

Fix this by adding _BIT to the definitions and adding proper
masks. Also add a mask for the PVD level selection bits in
PWR_CSR. Don't add any mask values for particular voltages selected as
these are not portable.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:55 -04:00
Marti Bolivar 918b98426c [UNTESTED] Resurrect FSMC support.
fsmc_sram_init_gpios() is now series-specific, so move its existing
implementation to the F1 backend, and add libmaple/stm32f2/fsmc.c for
the F2 backend.

Delete libmaple/fsmc.c; it is now empty.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:55 -04:00
Marti Bolivar 9cf06a9795 fsmc.h: Use STM32_HAVE_FSMC feature-test macro.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:55 -04:00
Marti Bolivar 5da6d57717 stm32.h: Add STM32_HAVE_FSMC.
This is a feature test macro for the flexible static memory
controller (FSMC) peripheral.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:55 -04:00
Marti Bolivar e59a7442a3 [FIXME] Resurrected, shinier USART support.
FIXME:
- Test F1 support
- Solve problem of duplicated bytes being TXed unless delay is
  inserted after configuration but before first bytes are TXed.

Rip out nonportable bits from top-level interfaces. The USART register
maps are basically the same between F1 and F2, so leave these, but add
register bit definitions which had name changes to the libmaple header
to avoid needless repetition. There are also a few new bits in the F2
USART registers; add definitions for these in the F2 USART header. Add
Doxygen comments for all USART bit definitions.

Deprecate struct usart_dev's max_baud field. This is just bloat that
doesn't bring us much real benefit.

Add new series-specific USART files for F1 and F2:

- libmaple/stm32f[1,2]/usart.c
- libmaple/stm32f[1,2]/include/series/usart.h

These are standard series-specific files, providing register map base
pointers, defining devices, implementing nonportable routines, etc.

We need a portable way to configure the USART GPIOs. To this end, add
usart_async_gpio_cfg() to the top-level USART interface. This function
is implemented in new F1 and F2 USART backends to take the appropriate
action to configure the RX and TX pins for asynchronous full duplex
mode.

USART baud rate calculation is done differently on the different
series. Keep the usart_set_baud_rate() declaration in the top-level
USART header, but move the implementations into the series-specific
usart.c files.

In usart_set_baud_rate(), allow for deriving clock_speed automatically
by letting user tell us to figure out the peripheral clock speed by
mapping the device's rcc_clk_id onto an STM32_PCLK[1,2] value. This
preserves flexibility for users with non-default clock configurations,
but makes things easier on everyone else.

Add private USART files for portable private USART routines:

- libmaple/usart_private.h
- libmaple/usart_private.c

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:55 -04:00
Marti Bolivar 4a88656774 stm32f2: Improve GPIO alternate function support.
Add GPIO_AFRL and GPIO_AFRH bit definitions; these seem to have been
overlooked. Add enum gpio_af to give labels to the various
functions. Add gpio_set_af() convenience routine for configuring a
GPIO's alternate function.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:55 -04:00
Marti Bolivar 63de87bd60 rcc_reconfigure_pll(): Assert that the PLL is disabled.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:55 -04:00
Marti Bolivar 454aab10af RCC: Add rcc_is_clk_on().
This is a convenience function for checking if a clock line is on.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:54 -04:00
Marti Bolivar 2240b54dfa Style change to libmaple/rules.mk.
New style makes for cleaner diffs.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:54 -04:00
Marti Bolivar 53fcafdedf stm32.h: Cleanups.
Fix include guard name. Remove unused STM32_FLASH_WAIT_STATES (which
was superseded by FLASH_SAFE_WAIT_STATES).

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:54 -04:00
Marti Bolivar a0e1657456 Add __weak to <libmaple/libmaple_types.h>.
This is just an alias for __attribute__((weak)).

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:54 -04:00
Marti Bolivar 8513d995ed RCC: Add new mechanism for configuring the main PLL.
The new style for configuring the PLL is to initialize
a (series-specific) struct rcc_pll_cfg, and pass a pointer to it to
rcc_configure_pll(). After that's done, you can use
rcc_turn_on_clk(RCC_CLK_PLL) to turn on the main PLL, and busy-wait
until rcc_is_clk_ready(RCC_CLK_PLL) is true to make sure the new
configuration took effect.

- libmaple/rcc.h:

  -- Add struct rcc_pll_cfg, which specifies a PLL configuration. This
     specifies a PLL source and a void pointer to series-specific PLL
     configuration data.

  -- Add rcc_configure_pll(), which takes a pointer to struct
     rcc_pll_cfg, and configures the main PLL. It's up to each series
     to define this function.

- stm32f1/rcc.h: Add struct stm32f1_rcc_pll_data, to store F1-specific
  PLL configuration state.

- stm32f1/rcc.c: Add an implementation for rcc_configure_pll().

- stm32f2/rcc.h: Add struct stm32f2_rcc_pll_data, to store F2-specific
  PLL configuration data.

- stm32f2/rcc.c: Add an implementation for rcc_configure_pll().

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:54 -04:00
Marti Bolivar 05212074eb stm32f1/rcc.h: Deprecate rcc_clk_init().
We're going to replace this with a more portable mechanism.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:54 -04:00
Marti Bolivar 8af1ff3f56 libmaple/rcc.h: Add rcc_enable_css(), rcc_disable_css().
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:54 -04:00
Marti Bolivar ec6dabfde7 libmaple_types.h: Add __deprecated.
This is a define for __attribute__((deprecated)).

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:54 -04:00
Marti Bolivar f20a281077 RCC: Clean up and sanitize interfaces across F1, F2 series.
Additions:

- rcc_switch_sysclk():

  For changing the clock used as SYSCLK's source.

- enum rcc_clk:

  One for each system and secondary clock source (e.g. HSE,
  LSE). These are defined on a per-series basis in each of the
  <series/rcc.h>.

- rcc_turn_on_clk(),
  rcc_turn_off_clk(),
  rcc_is_clk_ready():

  For turning on system and secondary clock sources, and checking
  whether or not they're ready. Uses enum rcc_clk.

Removals:

- rcc_clk_init(): There's no way to port this to F2. Move it to the F1
  header. This also means we can remove the empty implementation and
  enum rcc_pll_multiplier from the F2 RCC header, where it doesn't
  make any sense.

Also fix up some includes, and rewrite rcc_clk_init() in terms of the
new clock source management functions.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:54 -04:00
Marti Bolivar 32443a2222 Clean up Flash interface; add flash_enable_features().
Make a single function, flash_enable_features(), to control the access
characteristics of Flash memory (i.e. to write to the non-latency bits
of ACR).

In so doing, make everybody pretend to allow instruction and data
caching. On STM32F1, trying to turn these on simply has no
effect. This allows unconditionally trying to turn them on, which will
simplify users' lives.

This has the ancillary benefit of making the stm32f2- and
stm32f1-specific flash.c files unnecessary; delete these.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:54 -04:00
Marti Bolivar 4a4a2dd035 STM32F2 Flash support.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:54 -04:00
Marti Bolivar 8643191193 stm32f2/stm32.h: Add support for STM32F207IG.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:53 -04:00
Marti Bolivar 5447cc100c [UNDO] Rip out a bunch of F1-only bits from libmaple proper
We'll need to bring this functionality back online piecemeal as we add
F2 support.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:53 -04:00
Marti Bolivar f3f82bc87d Initial STM32F2 series/stm32.h.
This still has some FIXMEs, but it's enough to get going.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:53 -04:00
Marti Bolivar 52238ad3f5 Initial STM32F2 GPIO support.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:53 -04:00
Marti Bolivar f3efe9039e Initial STM32F2 RCC support.
Largely untested.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:53 -04:00
Marti Bolivar 9696a3b383 libmaple_types.h: Add offsetof().
Rather than rely on newlib's stddef.h, define our own offsetof() in
terms of GCC's __builtin_offsetof(). Don't override an existing
offsetof() definition, in case the user already has one they prefer.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:53 -04:00
Marti Bolivar 9e8bc1bd40 STM32F2 NVIC support.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:53 -04:00
Marti Bolivar ae88169058 STM32F2: Add vector table and weak ISR definitions.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:53 -04:00
Marti Bolivar ec601e0e23 Add skeleton libmaple/stm32f2/rules.mk.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:53 -04:00