Commit graph

1184 commits

Author SHA1 Message Date
Marti Bolivar faf2815863 Makefile: add list-boards target.
As the number of boards increases, it's less practical to keep a list
of them in the help target output (notice also that some have been
forgotten). This target can't get out of date unless we change how the
board-includes/ directory works.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 03:40:08 -04:00
Marti Bolivar e652fe6e58 maple/board.cpp: Demo weakness of boardInit().
This shows people what to do to write boardInit(), but also how to
save work if they don't need it.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 03:38:30 -04:00
Marti Bolivar eb0dcd048f maple/board.cpp: Use PMAP_ROW().
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 03:38:30 -04:00
Marti Bolivar d44225c4bb board_private.h: Add PMAP_ROW() convenience macro.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 03:38:30 -04:00
Marti Bolivar c1771ff616 maple/board.cpp: Add more explanatory comments.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 03:38:30 -04:00
Marti Bolivar 9a081c2d52 isButtonPressed(): Take a pin and pressedLevel argument.
This allows dealing with push-buttons on pins other than
BOARD_BUTTON_PIN.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 03:38:30 -04:00
Marti Bolivar 8266812149 <wirish/boards.h>: Add BOARD_BUTTON_PRESSED_LEVEL.
This allows boards to override the logic level of a pressed
button. All Maple boards have a pressed button read HIGH, but if the
opposite convention is used, isButtonPressed() will infinite loop.

Make isButtonPressed() respect this setting.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 03:38:30 -04:00
Marti Bolivar 0986300f42 wirish/boards.h: Optionally derive SYSTICK_RELOAD_VAL.
It's stupid to make everyone keep this around.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 03:38:29 -04:00
Marti Bolivar 4e20383ff5 STM32F2: Allow boards to override PLL configuration.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 03:38:29 -04:00
Marti Bolivar 31a3db609f Makefile: move the fake VID/PID, to hide our shame.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 03:38:29 -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 4f4b601504 HardwareSerial.cpp: Fix "#warn" -> "#warning".
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 03:38:29 -04:00
Marti Bolivar cc28a31a5b wirish: Weaken boards_private.h definitions.
This lets users override them conveniently if our decisions don't
suit.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 03:38:29 -04:00
Marti Bolivar dbe91ade96 Provide wirish::priv::series_init() on F1.
This lets us remove the weak definition in boards.cpp.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 03:38:29 -04:00
Marti Bolivar 4d6905d298 Remove a completed FIXME comment.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-07 03:38:28 -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 c2a5783312 STM32F2: Turn on SYSCFG I/O compensation during init().
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 1b37ca32f4 wirish/ext_interrupts.cpp: Doxygen, copyright.
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 34c238a768 Add BOARD_HAVE_SERIALUSB.
Feature-test for SerialUSB support.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-03 22:40:39 -04:00
Marti Bolivar 0728f3e903 <wirish/boards.h>: Add feature test macros for SPI.
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 69974121c0 Typo fix.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-03 02:15:57 -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 07dc3d1753 STM32F2: fix pinMode() for PWM, PWM_OPEN_DRAIN.
Make it so the call to gpio_set_modef() actually happens.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-03 00:04:01 -04:00
Marti Bolivar dc52c7d071 HardwareTimer.cpp: cosmetics.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-03 00:04:01 -04:00
Marti Bolivar 16a8af75de HardwareTimer::setPeriod(): Don't use floating point.
I can't believe we've been shipping this for so long.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-03 00:04:01 -04:00
Marti Bolivar cdac411356 HardwareTimer.cpp: save some space with an rcc_clk_id hack.
Since rcc_clk_ids for a peripheral now form a contiguous range by
peripheral number, we can infer the rcc_clk_id for a timer given its
number (e.g., can calculate RCC_TIMER2 given timerNum == 2). This lets
us use timer_foreach() to avoid keeping a table of available timers in
HardwareTimer.cpp.

The implementation is hackish, but can be fixed up later if need be.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-03 00:03:11 -04:00
Marti Bolivar 979483ba79 Bring back/tweak pwmWrite().
Works on F1, doesn't on F2. Will figure that out next.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-02 21:15:17 -04:00
Marti Bolivar 1e7ca13f83 boards.cpp: Improve the comments.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-02 21:13:52 -04:00
Marti Bolivar 6c52b7e870 Bring timer initialization back to init().
Turns out the F1 code was pretty portable after all, so take it from
the F1 boards_setup.cpp and stick it back into boards.cpp. The only
change needed was to add a call to the newly-minted
timer_has_cc_channel() (and this is necessary on F103 XL-density,
anyway).

Also assert LeafLabs copyright in boards.cpp. We really need to do
this throughout the library; it's basically been rewritten since
Perry.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-02 21:04:13 -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 a504da225d Preprocessor-fu to derive BOARD_HAVE_USARTn from <board/board.h>.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-01 17:26:03 -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 be0a29c90f <wirish/HardwareTimer.h> cosmetics.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-01 03:27:23 -04:00
Marti Bolivar 93e3d0e9d2 Bring back HardwareTimer.
Untested, but the timers work on F2 (see exampes/test-timers.cpp), so
I'm hoping this is mostly OK. Note that there's an issue with TIMER2
and TIMER5 on F2: these timers have 32-bit counters, and the
HardwareTimer methods are all based on uint16 (like on F1).

I'm sorely tempted to keep this as-is; exposing the extra bits is just
extra documentation, and the HardwareTimer interface is already way
too complicated. The interface should still _work_; it just hides the
fact that you're missing out on the extra bits for some of the timers.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-01 03:27:05 -04:00