Commit graph

1184 commits

Author SHA1 Message Date
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 41e899108a Bring back analogRead().
Yay, it just worked! Still, while we're here, touch up the make-up on
wirish_analog.cpp.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-01 02:04:59 -04:00
Marti Bolivar 1ee779dd4c examples/debug-dtrrts.cpp: Cosmetics.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-01 01:30:06 -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 93a2a86a02 Add examples/serial-echo.cpp.
Serial1 writes back what it receives.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-01 01:29:23 -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 0762f471dd Bring back wirish/wirish_math.cpp.
This is portable.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 19:20:01 -04:00
Marti Bolivar 01c9cbe65c wirish/rules.mk: Cosmetics.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 19:19:25 -04:00
Marti Bolivar de71973685 Bring back wirish/Print.cpp.
The only nonportable parts of this file are based on the assumption
that we're on ILP32.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 19:14:40 -04:00
Marti Bolivar 819a2404ca Assert LeafLabs copyright in wirish/Print.cpp.
This should get replaced with a clean-room MIT licensed version, but
pieces of it are ours (notably the bugfixes to the floating point
printing routines), so might as well do the copyright thing.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 18:55:44 -04:00
Marti Bolivar 4b0b4c06d6 Replace shiftOut(), also fixing a possible bug.
The current shiftOut() is borrowed from Arduino, and is in an LGPL
file. Replace that file with a new MIT-licensed version containing a
new implementation.

The new version brings the clock line LOW before starting, to make
sure that the first pulse is detected if the clock line was previously
HIGH.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 18:47:39 -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 9d8a2d7d0e examples/blinky.cpp works on F2.
Only OUTPUT mode is tested; any other modes might work, but no
guarantees.

Bring back:

- wirish/wirish_digital.cpp
- wirish/cxxabi-compat.cpp
- wirish/wirish_time.cpp

Add new:

- wirish/stm32f1/wirish_digital.cpp
- wirish/stm32f2/wirish_digital.cpp

Move pinMode() from wirish/wirish_digital.cpp into the file by the
same basename in wirish/stm32f1. This implementation is tied to
F1. Add an F2 implementation in wirish/stm32f2/wirish_digital.cpp.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:41 -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 eccd34be46 <wirish/wirish.h>: Don't include some files.
These don't work on F2, so leave them out for now.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:37 -04:00
Marti Bolivar 98653a7761 wirish: Build board.cpp.
There's enough infrastructure for a basic board.cpp on STM32F2, so we
might as well bring this back.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:18 -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 3fa7a509c4 Doxyfile: Add to PREDEFINED to cover libmaple_types.h.
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 123f0549e0 Doxygen: add the Evil Mangler.
Whenever Doxygen is running on a series header, make it run an awk
script, the Evil Mangler, that pretends the file is enclosed in an
appropriate namespace declaration for the series target.

Doxygen chokes if two structs have the same name. This is a problem
for the series headers, which commonly have data structures with the
same name.  However, if those structs are in different namespaces,
Doxygen has no problems.  We obviously can't use namespaces in C
headers, so use FILTER_PATTERNS to trick Doxygen into thinking they're
there.

Ugly, but I can't think of a better way to handle this.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-10 15:48:48 -04:00
Marti Bolivar ca9fe5fd8a Fix .gitignore so it doesn't filter out support/doxygen/.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-10 15:26:06 -04:00
Marti Bolivar aa9db0f9cf Doxyfile: Disable TYPEDEF_HIDES_STRUCT to work around Breathe issues.
This works around a problem we're having getting the XML for the
series headers into a form that we can work with in leaflabs-docs.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-10 13:20:03 -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 6d07ac5ec3 Shut up, doxygen.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-09 15:00:45 -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