Commit graph

262 commits

Author SHA1 Message Date
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 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 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 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 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 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 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 41e899108a Bring back analogRead().
Yay, it just worked! Still, while we're here, touch up the make-up on
wirish_analog.cpp.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-01 02:04:59 -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 0762f471dd Bring back wirish/wirish_math.cpp.
This is portable.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 19:20:01 -04:00
Marti Bolivar 01c9cbe65c wirish/rules.mk: Cosmetics.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 19:19:25 -04:00
Marti Bolivar de71973685 Bring back wirish/Print.cpp.
The only nonportable parts of this file are based on the assumption
that we're on ILP32.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 19:14:40 -04:00
Marti Bolivar 819a2404ca Assert LeafLabs copyright in wirish/Print.cpp.
This should get replaced with a clean-room MIT licensed version, but
pieces of it are ours (notably the bugfixes to the floating point
printing routines), so might as well do the copyright thing.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 18:55:44 -04:00
Marti Bolivar 4b0b4c06d6 Replace shiftOut(), also fixing a possible bug.
The current shiftOut() is borrowed from Arduino, and is in an LGPL
file. Replace that file with a new MIT-licensed version containing a
new implementation.

The new version brings the clock line LOW before starting, to make
sure that the first pulse is detected if the clock line was previously
HIGH.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 18:47:39 -04:00
Marti Bolivar 9d8a2d7d0e examples/blinky.cpp works on F2.
Only OUTPUT mode is tested; any other modes might work, but no
guarantees.

Bring back:

- wirish/wirish_digital.cpp
- wirish/cxxabi-compat.cpp
- wirish/wirish_time.cpp

Add new:

- wirish/stm32f1/wirish_digital.cpp
- wirish/stm32f2/wirish_digital.cpp

Move pinMode() from wirish/wirish_digital.cpp into the file by the
same basename in wirish/stm32f1. This implementation is tied to
F1. Add an F2 implementation in wirish/stm32f2/wirish_digital.cpp.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:41 -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 98653a7761 wirish: Build board.cpp.
There's enough infrastructure for a basic board.cpp on STM32F2, so we
might as well bring this back.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:18 -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
Anton Eltchaninov 2fb91678e0 STM32VLDiscovery support files
Signed-off-by: Anton Eltchaninov <anton.eltchaninov@gmail.com>
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-03 14:09:05 -04:00
Marti Bolivar 53a51ccf05 stm32.h: Various updates, mostly to help STM32F1 line support.
Add STM32_HAVE_USB feature test macro requirement for
<series/stm32.h>. This will let us test if we've got a USB peripheral.
wirish/stm32f1/boards_setup.cpp is set up to use this when turning on
USB CDC ACM support at init() time.

Rework the STM32F1 <series/stm32.h> to make it easier to support the
various lines that subdivide that series. We don't really support
anything besides performance line yet, but there's been enough
enthusiasm for value and connectivity line support in the past that
these hooks seem worth adding. This means adding an STM32_F1_LINE
macro and STM32_F1_LINE_[PERFORMANCE,VALUE,ACCESS,CONNECTIVITY] macros
for values that STM32_F1_LINE can take, and generalizing the rest of
the file to begin taking this into account. Some TODOs remain, but
filling these in is the responsibility of future libmaple porting
efforts.

One pleasant consequence of the F1 stm32.h rework is that the build
system no longer has to tell us what density of F103 we're building
for, so remove that from the relevant support/make/board-includes/
files.

Add some tweaks to <libmaple/stm32.h> and the STM32F2 stm32.h header
to make sure this went through properly, and continues to go through
properly in the future.
2012-04-24 05:01:28 -04:00
Marti Bolivar 645ab9108a stm32f1 boards_setup.cpp: Allow overriding the PLL multiplier.
Allow <board/board.h> to override the PLL multiplier by defining
BOARD_RCC_PLLMUL. This should be useful for e.g. value line MCUs,
which have slower clocks. It's also probably useful for people who
have external oscillators different from the 8 MHz ones we use on all
of our boards.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-23 13:45:15 -04:00
Marti Bolivar a949744d3c Resurrect ADC support.
Standard refactoring: add series headers for F1 and F2, along with
series adc.c files. There are some issues relating to adc_extsel_event
to hammer out later, but this will do for now.

We also add some new portability interfaces to libmaple/adc.h in order
for Wirish to use the same code to initialize the ADCs at init() time.

As usual, F1 is untested.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:56 -04:00
Marti Bolivar d88a209870 wirish/boards.cpp: Use __weak instead of GCC attribute.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:54 -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 9ee66ebd61 [WIP] boards: Add st_stm3220g_eval.
This supports ST's STM3220G-EVAL, the standard "kitchen-sink"
evaluation board for the STM32F2 series.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:54 -04:00
Marti Bolivar 358a355914 [UNDO] Rip out everything but libmaple and Wirish startup code.
We'll need to bring all this functionality back online piecemeal as we
add F2 support.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:53 -04:00
Marti Bolivar dec3e3ad88 boards.cpp: Remove implementation details from Doxygen comments.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:52 -04:00
Marti Bolivar 7bd3af832d wirish/boards.cpp: Use FLASH_SAFE_WAIT_STATES.
Do this instead of hard-coding a number of wait states to use in
setupFlash(), which is called by init(). This helps future-proof.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:52 -04:00
Marti Bolivar 04760fa17b Make USB its own submodule.
Add libmaple/usb/rules.mk, which compiles the USB FS device firmware
submodule. Move the logic for compiling the USB stack from
libmaple/rules.mk into libmaple/usb/rules.mk.

Move libmaple/usb/usb_cdacm.h to libmaple/include/libmaple/. Its API
is sufficiently general that we'll be able to port it over to USB
OTG (either FS or HS) eventually, and that lets us include it from
Wirish using the new style for libmaple headers.

Fix the includes for public libmaple headers within libmaple/usb.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:51 -04:00
Marti Bolivar 4b826727d0 Move wirish/comm/*.cpp into wirish.
The wirish/comm/ directory is stupid.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:50 -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 3a80d1282b Fix linking and C runtime initialization on F1.
Reorder the .data and .rodata sections in common.inc. This seems
necessary to get the linker to place the data ROM disk and the pointer
to it in the right places.

Switch from long long to int in start_c.c. I have no idea why this
helps, but it does. F1 will crash if you don't do this. It will
probably slow things down unnecessarily on F2, but I don't care.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:50 -04:00
Marti Bolivar b74d28406b Cosmetics.
Convert wirish/start.S and wirish/start_c.c to libmaple coding
conventions.

Whitespace and brace insertion changes only.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:52:17 -04:00
Marti Bolivar d70098ba26 Remove "CS3" prefix from libmaple symbol names.
We're no longer even marginally compatible with CS3, so it's
inappropriate to use that prefix in our names.

Rename:
    __cs3_stm32_vector_table -> __stm32_vector_table.
    __cs3_stack              -> __msp_init
    __cs3_reset              -> __exc_reset
    __cs3_start_c            -> start_c

Also add an MIT license header and assert LeafLabs copyright over
wirish/start.S and wirish/start_c.c.  These files are modified from
the original CodeSourcery versions, which were distributed under a
license that permits modifications to be distributed under a different
copyright and licensing terms than the originals.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:52:17 -04:00
Marti Bolivar 926710d872 Remove CS3-style initialization.
Remove libcs3-related bits from support/ld. Break them out into
libmaple proper and Wirish as appropriate: vector table definition and
ISR declarations go into libmaple proper, and startup code goes into
Wirish. Vector table symbols are included into common.inc from an
STM32 family-specific directory under support/ld/stm32.

This is a combination of 5 commits. Individual commit messages follow:

libcs3_stm32_src: Don't depend on cs3.h.

So we can use the existing toolchain.

Move ISR decls/vector table into libmaple proper.

This allows us to configure the vector table on a per-family basis.

- Move
        support/ld/libcs3_stm32_src/stm32_isrs.S
                                    stm32_vector_table.S
  to
        libmaple/stm32f1/isrs_performance.S
                         vector_table_performance.S,
  respectively.

  The directory libmaple/stm32f1/ is intended to hold all
  STM32F1-specific code within libmaple. Obviously, there's a lot of
  work to do before this becomes true.

- support/ld/libcs3_stm32_src/Makefile: Don't try to compile
  stm32_isrs.S and stm32_vector_table.S anymore.

- Add libmaple/stm32f1/rules.mk to include these new files in the
  standard libmaple build.

- support/make/target-config.mk: Add LIBMAPLE_MODULE_FAMILY, which
  selects a directory to use as a family-specific libmaple
  submodule.

- Makefile: Add LIBMAPLE_MODULE_FAMILY to LIBMAPLE_MODULES.

Remove support/ld/libcs3_stm32_src and derived object files.

From support/ld/libcs3_stm32_src, move start.S and start_c.c into
Wirish. Modify wirish/rules.mk accordingly.

Delete support/ld/libcs3_stm32_*_density.a. These are no longer
necessary, as the relevant objects are included in the standard Wirish
build. Remove the GROUP statements from the board linker scripts
accordingly.

Remove SEARCH_DIR(.) from common.inc; it's no longer necessary. Also
fix up some comments that are now out of date.

wirish/start_c.c: Don't use CS3-style memory initialization.

Switch memory initialization to a simpler style of initializing .data
if necessary, then zeroing .bss. Initializing .data is only necessary
during Flash builds, since during RAM builds, LOADADDR(.data) ==
ADDR(.data).

This makes libmaple completely incompatible with the CS3 startup
sequence. Subsequent commits will clean up the namespace to reflect
that fact.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:52:17 -04:00
Marti Bolivar 9be44ebd86 USB: API cleanups.
Modify usb.h functions (changing their names in some cases) to also
take a usblib_dev* argument, to fit in better with the rest of
libmaple.

Store an rcc_clk_id in struct usblib_dev for the same reason.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2011-10-21 18:13:05 -04:00
Marti Bolivar f7e384a5ea Fix micros() bug.
Thanks to ala42 for the fix.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2011-10-20 23:05:33 -04:00
Marti Bolivar ad33982885 wirish: Clean up includes; other fixups.
Clean up various core files' includes to fit this pattern:

- Header files include what they use.
- CPP files include their header first
- Include order is libmaple proper headers, then wirish
  headers (modulo CPP rule above).

wirish.h: Move HIGH and LOW to io.h, and the boolean and byte typedefs
into wirish_types.h. These don't belong in wirish.h.

Add include guards to wirish_debug.h. Oops.

wirish_digital.cpp: Use standard bool instead of "boolean".

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2011-10-18 15:12:21 -04:00
Marti Bolivar 494f05b236 usb: Disentangle CDC ACM functionality.
Add new usb_cdcacm.h, which provides the virtual serial port API.
This file (and new usb_cdcacm.c) consolidate the VCOM support, which
was previously distributed through descriptors.[hc], usb.[hc],
usb_callbacks.[hc], and usb_config.h.

Add usb_init_usblib() to usb.h, as a way of initializing the USB
peripheral in terms of the data structures required by usb_lib.  This
is used by the new usb_cdcacm_enable().

Create new usb_lib_globals.h, with declarations for the usb_lib global
state which is most used throughout the rest of the libmaple USB stack.

Remove descriptors.c and usb_callbacks.[hc]; they are no longer
necessary.

Update the USB README accordingly.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2011-10-18 13:30:18 -04:00
Marti Bolivar 17e67dff76 usb: Cleanups and renames.
Rename setupUSB() and disableUSB() to usb_cdcacm_enable() and
usb_cdcacm_disable(), respectively.

Remove usbSendHello(). This shouldn't exist.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2011-10-18 13:30:17 -04:00
Marti Bolivar 545aae4459 usb: Move some board-specific configuration to Wirish.
Create new BOARD_USB_DISC_DEV and BOARD_USB_DISC_BIT board-specific
values.  Use these as arguments to setupUSB() and disableUSB().  This
helps make the USB stack more generic, and goes towards the resolution
of an important FIXME.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2011-10-18 13:30:17 -04:00
David Kiliani 1873871aea Add support for the Olimex STM32 H103 board.
Pin layout and header files for the STM32 H103 prototype board from
Olimex featuring an STM32F103RBT6 chip. This commit contains all
necessary changes to compile with BOARD=olimex_stm32_h103.

Signed-off-by: David Kiliani <mail@davidkiliani.de>
2011-09-27 16:44:53 -04:00
Marti Bolivar 0697f5d0d6 maple_native.cpp: Cosmetics.
Stick FSMC_BCR_MTYP_SRAM among the bitfields assigned to the BCR
write.  Technically not necessary (SRAM is the default after reset),
but good for readability and future-proofing.
2011-09-12 21:29:50 -04:00
Marti Bolivar 626e4e06f0 Maple Native: Fix BOARD_NR_USED_PINS, boardUsedPins. 2011-09-09 15:33:11 -04:00
Marti Bolivar aad2377ae3 Update outdated stm32.h usages.
stm32.h has been updated to prefix its definitions.  Update the rest
of libmaple to take this into account.
2011-09-07 23:34:23 -04:00
Marti Bolivar 4a98ddaccb wirish/boards: Move includes into .cpp files.
The headers just #define some numbers, so there's no need for them to
be including libmaple headers.
2011-09-01 09:38:39 -04:00
Marti Bolivar d349f7cd6b maple_native.cpp: Add FSMC FIXME to resolve for 0.0.12. 2011-09-01 09:35:11 -04:00
Marti Bolivar 1769ba3a05 maple-native.cpp: Comment tweak.
First in what is sure to be a long series of efforts in educating
people that you can have GPIOs 56--100 or the SRAM chip, but not both.
2011-08-31 15:32:29 -04:00
Marti Bolivar 15b9adcf66 maple_native.cpp: mark initSRAMChip() static. 2011-08-31 15:00:54 -04:00
Marti Bolivar d055e99a9f maple_native.h: Fix USART pins.
These apparently didn't get updated from an earlier prototype's
values.
2011-08-30 18:16:00 -04:00
Marti Bolivar b1b71c5e09 HardwareSerial.h: Remove documentation TODO.
It's difficult to document HardwareSerial's interface fully in
HardwareSerial.h, since most of the methods people care about are
inherited from Print, anyway.  Stick with documenting this interface
by hand for the foreseeable future.
2011-08-16 06:13:48 -04:00
Marti Bolivar 8a3aa2a29b HardwareSerial.cpp: Respect PCLK1 and PCLK2. 2011-08-16 06:13:48 -04:00
Marti Bolivar fcb4afcd50 HardwareSerial: Add pin accessors. 2011-08-16 06:13:48 -04:00
Marti Bolivar 96c474d94b HardwareSerial: trivial code reordering 2011-08-16 06:13:48 -04:00
Marti Bolivar 5710942d83 HardwareSPI.cpp: minor HardwareSPI::send() cleanup. 2011-08-16 06:13:48 -04:00
Marti Bolivar e1c0b0cfee HardwareSPI: Add pin accessors. 2011-08-16 06:13:41 -04:00
Marti Bolivar ab8d721c05 HardwareTimer.cpp: fix HardwareTimer::setPeriod() 2011-06-14 16:35:10 -04:00
Marti Bolivar f36a1d9849 Remove reST documentation, attendant updates.
The documentation covers topics not specifically relevant to libmaple,
so it doesn't make sense for it to be part of the libmaple source
distribution.

Delete the docs/ tree, and prepare libmaple for use with the new
leaflabs-docs repo, which will contain the docs from now on.

* README: update to reflect this change

* support/doxygen/Doxyfile: This is the old docs/Doxyfile

* Makefile: Add a doxygen target

* wirish/comm/HardwareSerial.h: fix reference to docs/.  The comment
  informing maintainers that the HardwareSerial interface is
  documented by hand refers to the docs/ tree, which no longer exists.
  Update it to refer to the separate leaflabs-docs repository.

* support/scripts/copy-to-ide: No longer build the documentation
2011-06-11 20:05:33 -04:00
Marti Bolivar 5c847fda31 Update Print to match Arduino master.
Add base argument to integral Print methods, defaulting to DEC so as
not to break backwards compatibility.  Add precision argument to
floating-point Print methods.

These changes increase compatibility with the Arduino Print
implementation.
2011-06-08 16:39:04 -04:00
Marti Bolivar 5ceb99bc29 Revert "Add wiring_limits.h"
This reverts commit f960c41b1a.

Wait until the Wiring spec is complete to merge this into master.
2011-06-07 16:51:40 -04:00
Marti Bolivar f960c41b1a Add wiring_limits.h
This file is analogous to the standard C header <limits.h>.  It
defines various constants within the Wiring language that we consider
to be implementation-defined.  The current version is a work in
progress; more constants may be added as time goes on.

The member constants defined in wiring_limits.h are currently limited
to the core Wiring language.  They do not include
implementation-defined values which pertain to the standard Wiring
libraries.
2011-06-07 15:37:27 -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 9d9275e7a0 Docs: Fix several board-specific values.
Ugh.

Fix BOARD_NR_ADC_PINS and boardADCPins on Maple, Maple Mini, and Maple
RET6 Edition:

Maple and Maple RET6 Ed. don't have ADC on pin 3.  Seems likely that
the error was due to AIN being missing on the silkscreen.  They also
have ADC on pin 13.  This is not really true due to the voltage drop
across the built-in LED.

Maple Mini really should not include BOARD_LED_PIN among its ADC pins,
since it's not broken out to a header.

Fix BOARD_NR_PWM_PINS and boardPWMPins on Maple and RET6 Ed:

Both boards falsely include pin 25 as a PWM pin.  Maple RET6 Edition
also lacks some PWM pins.

Fix BOARD_NR_SPI on Maple RET6 Edition:

SPI3 uses PB4, which is unusable since it's tied to NRST.  This means
that SPI3 is not available on the RET6 edition.  Decreasing
BOARD_NR_SPI to 2 to accomodate this.  Leave the BOARD_SPI3_*_PIN
defines intact so as not to further clutter the rest of the library
with RET6-specific wrinkles.
2011-05-26 02:42:07 -04:00
Marti Bolivar e3dfbf4b5b Getting rid of the last 0.0.10 TODO.
We should be good to go.
2011-05-23 10:18:39 -04:00
Marti Bolivar 3b9cc70fb2 HardwareSerial.h: adding documentation TODO for 0.1.0 2011-05-20 15:21:59 -04:00
Marti Bolivar cd723c2f0e adc.c: adc_init() doesn't set the RCC's ADC prescaler.
You have to call rcc_set_prescaler() yourself now.  adc_init() never
should have been doing that anyway.
2011-05-19 18:45:45 -04:00
Marti Bolivar 7444fc5a7a Punting the fix of Maple Native's boardUsedPins to 0.0.12. 2011-05-19 15:03:21 -04:00
Marti Bolivar f92d5f4865 Fixing HardwareSPI.h mistake for non-LeafLabs boards.
"#warn" -> "#warning"; oops.
2011-05-12 04:37:30 -04:00
Perry Hung 914db021c3 i2c: Various fixes, extensions, documentation.
-Fix clock calculations for fast-mode support
-Add I2C_REMAP option to remap i2c1 (untested)
-Add I2C_BUS_RESET option to reset bus on initialization
-Add optional timeout parameter
-Doxygen comments
-Various cleanup

10-bit slave addressing is untested until I have a device that speaks
such.
2011-05-12 04:07:33 -04:00
Marti Bolivar f3d44dfa4e Adding SPI3 definitions for Maple RET6 Edition. 2011-05-11 13:23:30 -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 a20c3966b5 Putting updated HardwareTimer back into the build.
HardwareTimer was removed from the build when the timer refactor was
done; this redoes it in terms of the new timer.h interface.  A variety
of conflicting or badly designed bits were deprecated or removed.

I'm still not satisfied with this interface, as it's going to make
life difficult moving forward to high-density chips, where the
addition of basic timers means that the capture/compare methods won't
apply in some cases.  However, we need to get 0.0.10 out the door, so
it'll have to do for now.

The docs are up to date, and contain a warning that the Wirish API
isn't stable and a recommendation to use libmaple proper.
2011-05-06 19:30:49 -04:00
Marti Bolivar 194084baed Renaming "enum ExtIntTriggerMode_" -> "enum ExtIntTriggerMode".
Done for consistency the rest of the source.  Doesn't affect any
documented features.
2011-05-05 15:38:58 -04:00
Marti Bolivar 6c427d285f SPI fixups.
Initial post-review changes based on thread here:

77f707d7b8 (comments)
2011-05-04 17:23:54 -04:00
Marti Bolivar 5cf58d39d4 Maple Mini pin map fix.
Thanks, Xavier!
2011-05-04 13:36:52 -04:00
Marti Bolivar bc745cd913 Making micros() counter underrun safe.
Thanks, ala42!
2011-05-04 13:31:53 -04:00
Marti Bolivar e7d5f4c167 SerialUSB fixups. 2011-05-04 13:31:53 -04:00
Marti Bolivar 837e649dba Fixing USBSerial::read(void*, uint32). 2011-05-04 13:31:53 -04:00
Marti Bolivar c436ffa1bb Native and FSMC cleanups.
Got rid of native_sram.h (and native_sram.cpp), and pushed their
functionality into maple_native.cpp.  Fixed includes in maple_native.h.

Fixed includes in fsmc.h.
2011-05-04 13:29:55 -04:00
Marti Bolivar 77f707d7b8 SPI refactor.
Still a polling driver, but the libmaple proper interface exposes
enough that users enable the various interrupts and define their own
IRQ handlers if they feel like it.

Wirish HardwareSPI interface was largely redone; it's more like the
Arduino implementation now, although there are some differences when I
didn't like their API.  The old methods are still there, but are
deprecated and slated for deletion in 0.1.0.

New board-specific values: BOARD_NR_SPI, BOARD_SPIx_NSS_PIN,
BOARD_SPIx_MOSI_PIN, BOARD_SPIx_MISO_PIN, and BOARD_SPIx_SCK_PIN, for
x from 1 to BOARD_NR_SPI.

Documentation was updated appropriately.
2011-04-28 14:23:30 -04:00
Marti Bolivar d4552d602c maple_native.cpp updates/fixes. 2011-04-27 17:38:55 -04:00
Marti Bolivar d5097adadf RET6 fixes 2011-04-27 15:33:06 -04:00
Marti Bolivar 95d1f62997 Removing Maple-specific values from WirinPinMode doxygen comment.
Comment changes only.
2011-04-26 03:27:33 -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 842096ba35 Minor Print cleanups. 2011-04-25 18:02:10 -04:00
Marti Bolivar 61ac368578 Updating Maple Native pins for prototype C. 2011-04-13 15:49:05 -04:00
Marti Bolivar f72d2948a8 Compromise Print implementation.
The users really hated the code size requirements for an snprintf()-based
Print implementation, but I really hated how bad the old implementation was.

Revised version fixes bugs related to printing 64-bit values and has some
improved behavior when it comes to printing doubles.  Now, instead of
happily printing garbage values when large doubles are printed, we try
printing "<large double>" or "-<large double>" (depending on sign) when
the argument is too big for the old strategy to accommodate.
2011-04-12 17:44:27 -04:00