Commit graph

1184 commits

Author SHA1 Message Date
Marti Bolivar ec40c9ddc9 <libmaple/i2c.h>: Cosmetics.
Put CCR definitions after SR2, to keep them in register map order.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-22 14:06:09 -04:00
Marti Bolivar 2e32d86142 <libmaple/i2c.h>: Cosmetics.
Reorder register bit definitions by descending bit number, for
consistency with the rest of the library.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-22 14:06:09 -04:00
Marti Bolivar 38fdbf8d10 <libmaple/i2c.h>: Add missing register bit defns.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-22 14:06:09 -04:00
Marti Bolivar 74f4437188 libmaple/i2c.h: Assert LeafLabs copyright.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-22 14:06:09 -04:00
Marti Bolivar 4efec065ff Fix I2C_CR2_FREQ bit definition.
The existing value clobbers the entire register.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-22 14:06:09 -04:00
Marti Bolivar aac8e2ba2c libmaple/i2c.h: Cosmetics.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-22 14:06:09 -04:00
Marti Bolivar 2031b7a50a libmaple/i2c.h: Don't use BIT().
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-22 14:06:09 -04:00
Marti Bolivar f7826ab473 <libmaple/dma.h>: Assert LeafLabs copyright.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-21 23:17:24 -04:00
Marti Bolivar e0a2e9a5ce Port test-usart-dma.cpp for STM32F2.
Too ugly? Meh.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-15 17:41:37 -04:00
Marti Bolivar 26cf9b2209 Implement DMA tube API on STM32F2.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-15 17:41:37 -04:00
Marti Bolivar 8c71808212 Port test-usart-dma.cpp to use tube API.
This is straightforward. Do it in a verbose style with lots of
comments, so we can use this patch as an example for how to port
existing DMA code.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-15 17:41:37 -04:00
Marti Bolivar 205f3f7eb7 Implement DMA tube API on STM32F1.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-15 17:41:37 -04:00
Marti Bolivar 2026ef2c36 DMA: prep for F2 with new "tube" API.
To prepare for STM32F2/F4 DMA support, introduce a new libmaple DMA
API, and move some code around to make priority level and interrupt
handling more generic.

The new API is based on a new set of types (dma_tube, struct
dma_tube_reg_map, enum dma_request_src, enum dma_cfg_flags, and struct
dma_tube_config).

The central abstraction is the dma_tube type. STM32F2/F4 use DMA
streams to control dataflow, and STM32F1 uses channels. dma_tube
stands for whichever is appropriate for the current target. Dealing
with tubes allows for configuring and using DMA with opaque tube
values in the same source, instead of (as with ST's firmware)
requiring two separate codebases.

The new API is also more user-friendly, as it doesn't require knowing
which DMA address registers to set and which configuration register
flags go along with them. It now suffices to specify the source and
destination for the DMA transfer, along with their sizes. This avoids
confusion (e.g. for memory-to-memory transfers, data flows from the
peripheral address register to the memory register, which might be
surprising on F2, which has two memory address registers).

The old API (based on enum dma_mode_flags and dma_setup_transfer()) is
still available on F1, but deprecate it.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-15 17:41:34 -04:00
Marti Bolivar 7451d1d262 Makefile: cosmetics.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-15 15:58:10 -04:00
Gaute Hope 43b5259cae Xlinker + Xassembler flags to Makefile
These flags were needed to have the Makefile working with
arm-none-eabi-g++ (Sourcery CodeBench Lite 2011.09-69) 4.6.1.

Signed-off-by: Gaute Hope <eg@gaute.vetsj.com>
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-15 15:57:16 -04:00
Marti Bolivar be75a466b7 Tweak build system to allow out-of-tree projects.
It's very annoying to have to build libmaple projects in-tree. Users
are just copying the repository everywhere. That's stupid. So I made this:

https://github.com/mbolivar/example-libmaple-project

It needs these patches to work.

Add a header and footer for rules.mk files, so we can change them
around and things will continue to work for the users, who just
include them.

In Makefile, add USER_MODULES to LIBMAPLE_MODULES if it's
nonempty. This is the hook you use to get your code compiled and
linked correctly.

Hack build-targets.mk for stupid reasons I hope to fix later. For now,
you'll need an empty main.cpp in BOTH the libmaple directory and your
directory if you want things to work the way you'd expect.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-14 23:43:48 -04:00
Marti Bolivar b8f61070b0 test-usart-dma.cpp: tweaks.
Touch up comments, change some function names, and don't set something
to zero which already is.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-13 14:41:31 -04:00
Marti Bolivar 875a974ed1 examples/test-usart-dma.cpp: Use HardwareSerial::c_dev().
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-13 12:54:35 -04:00
Marti Bolivar 6ca023a07a examples/test-usart-dma.cpp: Cleanups and comments.
Someone pointed to this example on the DMA page in the wiki, so it's
probably worth making it more clear what's going on. Remove unused
code, add comments, and move things around for better exposition.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-13 12:54:35 -04:00
Marti Bolivar bf2600871e HardwareTimer: add a c_dev().
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-13 11:54:42 -04:00
Marti Bolivar 707b552a65 HardwareSPI: add a c_dev().
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-13 11:54:42 -04:00
Marti Bolivar 13a0db8f74 HardwareSerial: Add c_dev() accessor for instance's usart_dev*.
This is analagous to std::string::c_str().

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-13 11:54:20 -04:00
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 e3fc4cd14d Typo fix.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-12 16:03:17 -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 fece8e83b0 Add .gdbinit to .gitignore.
Everyone wants their own .gdbinit; it's stupid to put one into the
repository top-level.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-12 15:35:24 -04:00
Marti Bolivar 4d46c18597 Remove .gdbinit.
This has gone unmaintained for long enough.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-12 15:34:48 -04:00
Marti Bolivar bcad639ff9 maple: board.cpp: More comments.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-08 18:46:25 -04:00
Marti Bolivar 93eb9368db Bring back <wirish/wirish_debug.h>.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-08 18:34:33 -04:00
Marti Bolivar a58d1275c6 maple: board.h: More comments, remove SYSTICK_RELOAD_VAL.
We derive SYSTICK_RELOAD_VAL from CYCLES_PER_MICROSECOND now, so let's
hide it for expert use.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-08 18:21:02 -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 14ce7ffcca wirish/syscalls.c: Assert LeafLabs copyright.
_sbrk() is new in 2011, and there've been changes in 2012.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 19:15:05 -04:00
Marti Bolivar f370db157f wirish/syscalls.c: Weaken I/O related function defs.
For overriding.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 19:15:05 -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 d2f30040f8 Makefile: fix cscope target.
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 b36b63f5d0 Makefile: help target pointers for multiple source files.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 04:15:44 -04:00
Marti Bolivar 37ae8e4308 README: remove mention of support/openocd/.
This is now in contrib/.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 03:55:33 -04:00
Marti Bolivar efe5f02e41 Rework linker scripts.
Having separate linker scripts for all the boards is a bad idea. Most
boards really only need to specify MEMORY and the appropriate
REGION_ALIASES() so that support/ld/common.inc can do its work. Not
having infrastructure for this leads to duplication -- viz. the Maple
Mini linker scripts are identical to the Maple's, and the
olimex_stm32_h103 linker directory is just a symlink to
Maple's. Clearly, the current structure is wrong.

To fix it, instead of having per-board subdirectories of support/ld/,
add per-MEMORY subdirectories of (new) support/ld/stm32/mem/. The
per-board .mk files under support/mk/board-includes/ now reference
these directly, and target-config.mk and the Makefile handle this
appropriately. We move some other stuff around in target-config.mk to
make this all more convenient, and even allow more overriding of the
libmaple defaults on a per-board basis. Custom board hacks will be
easier now.

Unfortunately, lots of duplication under support/ld/stm32/mem/ is
necessary, as the LENGTH attribute in a MEMORY region specification
doesn't support arithmetic expressions, and ld doesn't seem to have
any way to specify MEMORY at the command line (why?!). If we find a
better way than this, we should do it.

If a board (e.g. Maple Native) _does_ really need special
memory-related configuration, you can always put a per-board
subdirectory of support/ld/stm32/mem. We do this here to configure the
heap.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 03:44:31 -04:00
Marti Bolivar 0d8f8e058d Move OpenOCD stuff into contrib/.
This has gone unmaintained for long enough.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 03:40:11 -04:00
Marti Bolivar 131e98ab67 Makefile: make help target more helpful.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 03:40:11 -04:00