Commit graph

1184 commits

Author SHA1 Message Date
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 86ad3d57f2 Doxyfile: Allow group documentation.
This change allows us to document several members of a group with one
Doxygen comment. It's not clear how well this will work out in practice.

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 08531fb561 Move notes/dma.txt to notes/dma-stm32f1.txt.
This information is all STM32F1 only.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-26 15:50:18 -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 645ab9108a stm32f1 boards_setup.cpp: Allow overriding the PLL multiplier.
Allow <board/board.h> to override the PLL multiplier by defining
BOARD_RCC_PLLMUL. This should be useful for e.g. value line MCUs,
which have slower clocks. It's also probably useful for people who
have external oscillators different from the 8 MHz ones we use on all
of our boards.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-23 13:45:15 -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 d49d4dc630 Update examples/test.timers.cpp.
Currently passing on STM32F2.

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