Commit graph

28 commits

Author SHA1 Message Date
Marti Bolivar c5dfc108e6 Merge branch 'callback_interrupt_handlers' 2012-09-03 18:29:45 -04:00
Marti Bolivar ef280366bc Whitespace fixups to EXTI files.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-09-03 18:27:18 -04:00
Aditya Gaddam e77b2b7f46 "Callback versions of functions now take voidArgumentFuncPtr. We can probably use voidFuncPtr instead, but this way people can see that the function expects something different. Existing functions haven't changed in signature.
Signed-off-by: Aditya Gaddam <adityagaddam@gmail.com>"
2012-09-02 11:04:01 -04:00
Marti Bolivar 9992325cef Include <stdint.h> from wirish.h.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-31 16:12:28 -04:00
Aditya Gaddam f6f2601213 "Added ability to set callbacks for interrupts that get an argument. This argument can be the instance that needs to handle the interrupt, or just a random argument you might find useful later. Suggestions from mbolivar and iperry from pull53 on libmaple were taken into account.
Signed-off-by: Aditya Gaddam <adityagaddam@gmail.com>"
2012-08-31 14:19:57 -04:00
Marti Bolivar 853d0b1a5a HardwareSPI: move warning into .cpp from header.
This causes the warning to be emitted at most once. As is, it can be
emitted each time HardwareSPI.h is included, which is annoying.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-27 16:50:57 -04:00
Marti Bolivar a3a49c3ea9 Make PRIMASK set/clear functions __always_inline.
This is just to ensure that -Os doesn't prevent these from getting
inlined.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-14 11:35:01 -04:00
Marti Bolivar c3a8dfd1ca wirish/ext_interrupts.h: Doxygen
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-14 11:32:47 -04:00
Marti Bolivar 5675fb0d73 Clean up micros().
Don't leave US_PER_MS user-visible. Remove an unnecessary variable.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-27 14:04:10 -04:00
Marti Bolivar 12aecf584e STM32F1: Bring back HardwareSPI.
We're going to merge into master without F2 support for this.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-26 18:13:12 -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 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 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 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 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 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
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 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 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 87ce0f6c58 [FIXME] Resurrect boards.cpp for F2 and F1.
FIXME:

- F1 support currently appears to be failing in start_c.c, for some
  unknown reason. This will need to get sorted out later.

Add a new wirish namespace, and a sub-namespace wirish::priv::. Put a
bunch of board setup routines in this namespace, and declare them in
new wirish/boards_private.h. boards.cpp uses this to perform
initialization tasks in a portable way, with two new boards_setup.cpp
files under wirish/stm32f1 and wirish/stm32f2 handling the
series-specific details.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:54 -04:00
Marti Bolivar 954f9e5065 Move public headers to include directories; related cleanups.
Move libmaple/*.h to (new) libmaple/include/libmaple/. The new
accepted way to include a libmaple header foo.h is with:

    #include <libmaple/foo.h>

This is more polite in terms of the include namespace. It also allows
us to e.g. implement the Arduino SPI library at all (which has header
SPI.h; providing it was previously impossible on case-insensitive
filesystems due to libmaple's spi.h).

Similarly for Wirish.

The old include style (#include "header.h") is now deprecated.

libmaple/*.h:

- Change include guard #defines from _FOO_H_ to _LIBMAPLE_FOO_H_.
- Add license headers where they're missing
- Add conditional extern "C" { ... } blocks where they're missing
  (they aren't always necessary, but we might was well do it against
  the future, while we're at it.).
- Change includes from #include "foo.h" to #include <libmaple/foo.h>.
- Move includes after extern "C".
- Remove extra trailing newlines

Note that this doesn't include the headers under libmaple/usb/ or
libmaple/usb/usb_lib. These will get fixed later.

libmaple/*.c:

- Change includes from #include "foo.h" to #include <libmaple/foo.h>.

Makefile:

- Add I$(LIBMAPLE_PATH)/include/libmaple to GLOBAL_FLAGS.  This allows
  for users (including Wirish) to migrate their code, but should go
  away ASAP, since it slows down compilation.

Wirish:

- Move wirish/**/*.h to (new) wirish/include/wirish/.  This ignores
  the USB headers, which, as usual, are getting handled after
  everything else.

- Similarly generify wirish/boards/ structure. For each supported
  board "foo", move wirish/boards/foo.h and wirish/boards/foo.cpp to
  wirish/boards/foo/include/board/board.h and
  wirish/boards/foo/board.cpp, respectively. Also remove the #ifdef
  hacks around the .cpp files.

- wirish/rules.mk: put wirish/boards/foo/include in the include path
  (and add wirish/boards/foo/board.cpp to the list of sources to be
  compiled). This allows saying:

      #include <board/board.h>

  instead of the hack currently in place. We can allow the user to
  override this setting later to make adding custom board definitions
  easier.

- Disable -Werror in libmaple/rules.mk, as the current USB warnings
  don't let the olimex_stm32_h103 board compile. We can re-enable
  -Werror once we've moved the board-specific bits out of libmaple
  proper.

libraries, examples:

- Update includes accordingly.
- Miscellaneous cosmetic fixups.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:50 -04:00