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>
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>
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>
libmaple/timer.h: Minor tweaks.

Comments etc.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
stm32f1/timer.h: Whitespace tweaks.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
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>
stm32f2/nvic.h: Fix Doxygen @file directive.

This lets Doxygen pick it up.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
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>
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>
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>
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>
stm32f2/rcc.h: Fix Doxygen file header.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
libmaple/rcc.h: Fix Doxygen file header.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
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>
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>
Update examples/test.timers.cpp.

Currently passing on STM32F2.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>