Commit graph

116 commits

Author SHA1 Message Date
Marti Bolivar e58051ea46 examples/blinky.cpp: Use toggleLED() instead of digitalWrite().
Keep things simple.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2013-01-01 20:11:14 -05:00
Marti Bolivar d9f8b4f8c4 EXTI examples: whitespace fixups.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-09-03 18:28:48 -04:00
Aditya Gaddam f86cbffa46 "Changed tabs to spaces. Changed some braces placement to match existing examples
Signed-off-by: Aditya Gaddam <adityagaddam@gmail.com>"
2012-09-03 18:05:57 -04:00
Aditya Gaddam bd703d8a4b "Added two examples for using attachInterrupt. One shows the use of a global function. While the second shows the use of a static class method as the event handler. Both work on Maple REVC
Signed-off-by: Aditya Gaddam <adityagaddam@gmail.com>"
2012-09-03 17:58:04 -04:00
Marti Bolivar cac3fd3b96 test session: Add SerialUSB benchmark to 'U' command.
I'm currently measuring over 500 KB/sec with screen as my serial
monitor. If I don't display the output at all, I get over 600
KB/sec. Nice!

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-03 22:53:31 -04:00
Marti Bolivar 060a12e27a i2c-mcp4725-dac.cpp: Fix whitespace.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-22 15:07:08 -04:00
Marti Bolivar 4fd05bcdf9 Add I2C example for MCP4725 DAC.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-22 14:06:10 -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 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 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 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 1ee779dd4c examples/debug-dtrrts.cpp: Cosmetics.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-01 01:30:06 -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 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 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 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
Marti Bolivar 46782d312b test-fsmc.cpp: Fixup; wait for user input before running test. 2011-09-26 14:48:25 -04:00
Marti Bolivar 2ca5a89e55 test-fsmc.cpp: Switch to SerialUSB
This messes with timing a little, but makes it faster to test.  The
timing was never perfect anyway, due to incrementing count.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2011-09-26 14:39:30 -04:00
Marti Bolivar 20ba449984 test-session: Add test case for disabling USB.
This replaces the previously undocumented 'd' option, which tested the
pin mode INPUT_PULLDOWN.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2011-09-24 16:01:47 -04:00
Marti Bolivar 8b522ee8ed test-fsmc.cpp: Fix incorrect sram_end. 2011-09-12 14:56:19 -04:00
Marti Bolivar 4fe0c9ffda test-session.cpp: Fix 'd' command.
Actually read a character each time we ask for one.  Put pin 22 back
into OUTPUT mode when we're done.
2011-09-06 18:46:27 -04:00
Marti Bolivar ec7c6d2dbd test-spi-roundtrip.cpp: Remove redundant loop.
SerialUSB.read() is already blocking, so no sense looping on available().
2011-08-31 15:14:53 -04:00
Marti Bolivar 23f1f96bca test-session.cpp: Tweak output. 2011-08-31 15:00:37 -04:00
Marti Bolivar a38b67d2d5 test-session.cpp: Measure ADC noise sequentially.
Measure pins one at a time.
2011-08-31 13:06:07 -04:00
Marti Bolivar b4e37dcde1 test-session.cpp: Multiple ADC noise measurements by default.
Each call to measure_adc_noise() now does
N_ADC_NOISE_MEASUREMENTS (currently 40) samples, instead of just 1.
2011-08-31 13:06:07 -04:00
Marti Bolivar 46d51a687b test-session.cpp: Better analog noise readings.
Update measure_adc_noise() to actually use the Welford online
algorithm, instead of accumulating data in an array on the stack.
This allows us to increase the number of samples (to 1000).

Revised algorithm tested on host PC and compared (in Python) against
numpy with a list of 100 values in [0, 1) drawn using random.random().

Results (Python):

    >>> r = [random.random() for i in xrange(100)]
    >>> numpy.mean(r)
    0.50073064742634854
    >>> numpy.var(r)
    0.083726090293309297

Results (C++, x86 host PC):

     n: 100	mean: 0.500731	variance: 0.084572

So this algorithm for variance has some inaccuracies, but it appears
to be good to a couple of significant figures.
2011-08-31 13:06:07 -04:00
Marti Bolivar 3cf6035852 fsmc-stress-test.cpp: Eliminating unnecessary variable. 2011-08-31 13:06:07 -04:00
Marti Bolivar 98af868b0d fsmc-stress-test.cpp: Convert to SerialUSB, don't print so much. 2011-08-31 13:03:30 -04:00
Marti Bolivar 4de92fe0d5 test-session.cpp: Tweak output.
Print input as if it were an ASCII character, not a number.
2011-08-30 18:37:01 -04:00
Marti Bolivar 8b3eedadc0 test-fsmc.cpp: Tweak output. 2011-08-30 18:22:07 -04:00
Marti Bolivar ed267cccec fsmc-stress-test.cpp: Eliminating unnecessary variable. 2011-08-30 15:47:28 -04:00
Marti Bolivar 1c0f039ad2 fsmc-stress-test.cpp: Eliminate unused variable. 2011-08-30 15:43:29 -04:00
Marti Bolivar 57c0cead0b fsmc-stress-test.cpp: Halt on error, print "all's well" message less often. 2011-08-30 15:16:58 -04:00
Marti Bolivar 60081f727f fsmc-stress-test.cpp: Convert to SerialUSB, don't print so much. 2011-08-30 15:16:58 -04:00
Marti Bolivar 9192b2a954 Whitespace tweak. 2011-08-18 13:41:13 -04:00
Marti Bolivar 0f9449fe8f freertos-blinky.cpp: Remove executable bit. 2011-08-18 13:38:22 -04:00
Marti Bolivar eea48f14b6 examples/mini-exti-test.cpp: Comment fix. 2011-08-03 18:17:15 -04:00
Marti Bolivar eabbcaa3dd Add examples/mini-exti-test.cpp.
Nonportable (Maple Mini only) test of external interrupt
functionality.  When wired properly, this triggers various EXTI lines
simultaneously, keeping track of the number of times each handler is
invoked.
2011-08-03 17:07:53 -04:00
Marti Bolivar 9b29c61fbe test-usart-dma.cpp: Change mistaken "__io" -> "volatile" 2011-07-06 11:04:37 -04:00
Marti Bolivar 55ec285642 Make FreeRTOS changes comply with the coding standard.
Don't modify the core FreeRTOS code; only change source that's
specific to libmaple.
2011-06-24 14:37:54 -04:00
Nis Sarup 496875dc83 FreeRTOS: Added FreeRTOS 7.0.1, including hook in libmaple/systick.c and example blinky. 2011-06-21 17:02:06 +02:00
Marti Bolivar c1a7fa7aad test-usart-dma.cpp: Update to demo working DMA interrupts. 2011-06-20 15:22:03 -04:00
Marti Bolivar b078de0361 Update test-print.cpp to exercise new behavior.
Changes make sure that base arithmetic applies correctly for various
integral types, and that floating point numbers can be printed at
various precisions.
2011-06-08 16:39:45 -04:00
Marti Bolivar 450e1c6e17 Keep it 80-column clean.
Go through overlong source code lines and convert as many of them as
appropriate to be 80-column clean.  This mostly affects license
headers.  Overlong lines are determined by running following from the
libmaple base directory:

$ ack-grep --nocolor --nogroup --cpp --cc --ignore-dir=usb -- '.{80}'

Note that this excludes libmaple's usb subdirectory, which is still
full of ST code that doesn't follow the libmaple source code
guidelines.

Contents of ~/.ackrc (these won't matter, but are included for
completeness):

--ignore-dir=docs
--ignore-dir=build
--type-set
ld=.ld
--type-set
rst=.rst
--type-set
txt=.txt
--type-set
mk=.mk
2011-06-07 14:44:39 -04:00
Marti Bolivar ff5ae825d6 Converting all files to UNIX newlines.
Committing the results of running the following on the libmaple root
directory:

$ fromdos `grep --exclude-dir='[.]git' -Ilsr $'\r$' .`
2011-05-10 16:41:37 -04:00
Marti Bolivar c8a512e310 Updating VGA examples for use with new timer API. 2011-05-06 20:11:48 -04:00
Marti Bolivar 07357000ee Changing integration date of function in examples/test-timer.cpp.
It would be nice to have something like a timer_set_period() in
libmaple proper that takes the period and the clock rate as
parameters, much the same as usart_set_baud_rate() does.  No time for
that now, though, so punt to 0.1.0.
2011-05-05 02:39:37 -04:00
Marti Bolivar d77842668d examples/test-spi-roundtrip.cpp now uses SerialUSB instead of Serial2. 2011-05-04 17:24:47 -04:00