Commit graph

39 commits

Author SHA1 Message Date
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 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 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 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 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 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 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 d63748b858 Trivial test-session.cpp bugfix 2011-04-27 17:38:33 -04:00
Marti Bolivar d5097adadf RET6 fixes 2011-04-27 15:33:06 -04:00
Marti Bolivar 2f07cb6f6c Better debug port support.
- gpio.h: afio_mapr_swj_config() renamed afio_cfg_debug_ports()

- [new] wirish_debug.h: disableDebugPorts(), enableDebugPorts()

- Maple, Maple Native, and Maple RET6 PIN_MAPs are now larger by 5,
  have mappings for the extra JTAG/SW pins.

  Documentation was updated appropriately.
2011-04-25 22:03:25 -04:00
Marti Bolivar bdf3258521 Minor test-session.cpp fixup 2011-04-25 17:58:37 -04:00
Marti Bolivar e1a5d8edaf Resolving some FIXMEs. 2011-04-11 20:45:47 -04:00
Marti Bolivar 587ac2c077 Adding button test to examples/test-session.cpp. 2011-04-11 12:32:09 -04:00
Marti Bolivar f6f9a11227 USART refactor. 2011-04-07 13:18:36 -04:00
Marti Bolivar 6cf3178996 Board-specific values; corresponding QA test generalizations.
Various board-specific #defines and arrays of pins added.

For the changelog (some of this information predates this commit):

* wirish/boards.h now declares the following arrays of pin numbers:

      * boardPWMPins - PWM-capable pins
      * boardADCPins - ADC-capable pins
      * boardUsedPins - pins already in use, e.g. BOARD_BUTTON_PIN

  It also declares a bool boardUsesPin(uint8 pin) function for
  convenient testing of whether a pin is in use.

* wirish/boards/*.h now define:

      * BOARD_USART1_TX_PIN
      * BOARD_USART1_RX_PIN
      * BOARD_USART2_TX_PIN
      * BOARD_USART2_RX_PIN
      * BOARD_USART3_TX_PIN
      * BOARD_USART3_RX_PIN
      * BOARD_NR_GPIO_PINS (renamed from NR_GPIO_PINS)
      * BOARD_NR_USARTS (renamed from NR_USARTS)
      * BOARD_NR_PWM_PINS
      * BOARD_NR_ADC_PINS
      * BOARD_NR_USED_PINS

* wirish/boards/maple_native.h now defines:

      * BOARD_UART4_TX_PIN
      * BOARD_UART4_RX_PIN
      * BOARD_UART5_TX_PIN
      * BOARD_UART5_RX_PIN

  (Unfortunately, wirish/boards/maple_RET6.h cannot, since at least
  one of the UART4/UART5 pins are used already; this will require layout
  changes for a wide-release Maple form factor RET6 board).

* wirish/boards/*.cpp all include the corresponding array definitions.
  They all live in flash by default, thanks to the new __FLASH__ macro
  in wirish/wirish_types.h, which is a synonym for the existing __attr_flash
  #define in libmaple/libmaple_types.h.

The documentation was updated to include this information.  It also
gained various FIXME/TODO comments related to its generalization
across boards.

The quality assurance-related examples (examples/qa-slave-shield.cpp
and examples/test-session.cpp) now make heavy use of board-specific
values to ensure portability.
2011-03-30 07:19:13 -04:00
Marti Bolivar c5e16e9625 Final stm32_pin_info design candidate; ADC3 support on Native.
Added an adc_dev to struct stm32_pin_info.  This was necessary to add
support for the channels on the Native which are only connected to
ADC3, but it does add a bunch of NULLs to the PIN_MAPs.

I don't think any other peripherals need representation on a per-pin
basis.  Each peripheral library will be responsible for keeping track
of related GPIO ports and bits, and we can throw #defines in to
boards/*.h for other things (e.g. BOARD_SPI1_MISO_PIN).

Fleshed out the ADC refactor and brought it more in keeping with the
new design as it evolves.

A couple of other tweaks.  Notably: waitForButtonPress() now takes a
default argument meaning "wait forever".

Removed Maple-specific documentation from core functions in io.h; this
information will need to go into the individual board docs files.
2011-03-25 20:09:30 -04:00
Marti Bolivar 9d2b4e574c Adding /wirish/boards/ for easier porting; shrank PIN_MAPs.
/wirish/boards/ contains xxx.h and xxx.cpp (for xxx=maple,
maple_native, maple_mini, maple_RET6).  The headers contain the
board-specific #defines that used to live in boards.h (except
BOARD_INIT, which was removed).  The CPP files contain the PIN_MAP
definitions that used to live in boards.cpp, and a proper boardInit()
function to replace the old BOARD_INIT macro.  This will make it
easier to add new boards in the future.

struct PinMapping was renamed struct stm32_pin_info, and was moved
into a new wirish_types.h.  Its external interrupt field was moved
into struct gpio_dev, which saves memory by storing an afio_exti_port
per port, rather than one per pin.  Also rearranged the stm32_pin_info
fields to improve packing.  Maple's PIN_MAP is now down to below 500
bytes.
2011-03-24 17:31:47 -04:00
Marti Bolivar 296b1188bf Initial timer refactor.
Basic PWM works.  Had some problems in testing that might be due to
USART bugs.

HardwareTimer has been removed from the build for now; I will
re-implement it in terms of the new libmaple API, but consider it
deprecated.  Let's come up with something better.

Servo is implemented in terms of HardwareTimer, so it also has been
temporarily removed from the build.

pwmWrite() likely got a little bit less inefficient due to
indirection, but the PIN_MAPs shrank by a pointer per PinMapping.
2011-03-24 07:25:14 -04:00
Marti Bolivar 580f0b6965 Maple RET6 edition support 2011-03-16 17:56:54 -04:00
Marti Bolivar 7c5c5bb118 [WIP] GPIO refactor: seems ok, ready for review 2011-03-11 16:24:44 -05:00
Marti Bolivar d6ef63b471 Cleaned out libmaple.h; this had wide-ranging implications.
Many of the #defines in libmaple.h were board-specific, not
MCU-specific.  Most of these were only used by code under
libmaple/usb/.  These were moved into usb_config.h, and are clearly
marked as being terrible hacks.  I'm going to treat the USB stack as a
black box that we'll deal with later.

Further, instead of having a variety of #defines like "How many USARTS
do I have?", we decide that based on the density of the chip.  This is
determined by testing for STM32_MEDIUM_DENSITY or STM32_HIGH_DENSITY
defines.  libmaple currently doesn't support low-density chips, so
that suffices.  The Makefile will set these automatically based on the
MCU.

Other offending #defines are ERROR_LED_PORT and ERROR_LED_PIN; these
were made optional, but they're set in the Makefile as a hack to keep
things working.
2011-02-27 11:42:56 -05:00
Perry Hung d9287cdd42 workaround to compile test-session.cpp 2011-02-27 02:55:43 -05:00
Marti Bolivar 0713c12711 Function examples/test-session.cpp on Native 2011-02-10 17:50:26 -05:00
Marti Bolivar 0632cab102 Ported examples/test-session.cpp to work on Mini 2011-01-30 21:48:54 -05:00
bnewbold 16b4c1fce5 fixed Serial crash bug 2010-09-05 21:43:06 -04:00
bnewbold 1e3e0862bb simplified example headers 2010-08-31 17:45:26 -04:00
Perry Hung 2dd4b9db68 Call init() before static constructors
Commit 70a18f96b6 forces init() to be
called before any statically allocated object constructors for the IDE.

This adds the change to the examples for users not using the IDE.
2010-06-25 21:47:27 -04:00
bnewbold cabb71f942 fixed QA test (pulldown) 2010-06-16 13:17:18 -04:00
bnewbold 6e5326e0dd new QA testing modes 2010-06-15 22:19:10 -04:00
bnewbold c8cee2368c test session serial fix 2010-06-07 14:46:48 -04:00
bnewbold 7ef5c1f749 fixed example 2010-06-05 21:57:56 -04:00
bnewbold 767bf60238 example updates... 2010-06-04 20:01:34 -04:00
Perry Hung 88d4b095e4 Preliminary wirish USBSerial implementation.
-updated examples
-removed HardwareUSB
-cleaned up a handful of includes
2010-06-04 00:43:21 -04:00
bnewbold fb3f98d165 finish cxxabi-compat refactor
perry forgot to add/edit these...
2010-04-29 07:13:16 -04:00
bnewbold b9fba8a471 updated test-session with new banner art etc 2010-04-27 18:49:57 -04:00
bnewbold e9eda8f74c mostly complete new interactive hardware testing program 2010-04-21 01:36:53 -04:00