Commit graph

29 commits

Author SHA1 Message Date
Marti Bolivar e45697a65f exti.c: Use exti_num enumerators instead of magic values.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-09-03 18:31:50 -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
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 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 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 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 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 b2d244dd6a exti.c: Doxygen improvements. 2011-08-22 23:29:58 -04:00
Marti Bolivar c075041100 exti.c: Optimize multiplexed IRQ handlers.
Rewrite existing IRQ handlers in terms of new functions
dispatch_single_exti() and dispatch_extis().  dispatch_single_exti()
handles EXTIs which have a dedicated IRQ line, and thus doesn't have
to check EXTI_PR; it is mostly equivalent to the (now removed)
handle_exti().  dispatch_extis() handles multiple EXTIs sharing an IRQ
line.  Using dispatch_extis() instead of calling handle_exti()
multiple times avoids unnecessary I/O to the (volatile) EXTI_BASE->PR
register.

These changes are in the flavor of the timer IRQ optimizations
performed in f5016b15be.
2011-08-03 17:34:03 -04:00
Marti Bolivar 487a60946d exti.c: Cleanups. 2011-08-03 17:34:03 -04:00
Marti Bolivar aee5bceb0f exti.c: Remove enable_irq() and maybe_disable_irq().
These functions incorrectly replicate functionality that is already
accomplished by manipulating EXTI_IMR directly.
2011-08-03 17:34:03 -04:00
Marti Bolivar 5a7ad93ab2 exti.c: Clean up some bit-banding usages. 2011-08-03 17:34:03 -04:00
Marti Bolivar f5935ef477 exti.c: Cleanups.
Add new handle_exti() instead of calling clear_pending() and
dispatch_handler() each time.
2011-08-03 17:34:03 -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 4ba238a7bd Renaming some nvic_irq_num enumerators for better readability. 2011-04-07 15:04:06 -04:00
Perry Hung 323627d367 Fix compiler errors after reverting broken commit. 2011-03-21 02:27:45 -04:00
Perry Hung eae720021d Revert "RCC refactor, bugfixes"
This reverts commit e4807a5010.
2011-03-21 02:25:23 -04:00
Marti Bolivar e4807a5010 RCC refactor, bugfixes 2011-03-12 23:28:53 -05:00
Marti Bolivar 7c5c5bb118 [WIP] GPIO refactor: seems ok, ready for review 2011-03-11 16:24:44 -05:00
Perry Hung 43d6921658 Refactor linker scripts. Rename irq and exception handlers.
Add common linker scripts for ram and rom. Add medium and high density
libraries for libcs3.
2011-02-27 15:56:40 -05:00
Marti Bolivar 2e7fa60e43 nvic bugfix; removed unnecessary volatile usage 2011-01-31 00:19:36 -05:00
Marti Bolivar f1b64e707d [WIP] Code review picked up some bugs/issues. 2011-01-26 22:05:41 -05:00
Marti Bolivar 8e973f3d1e Changed nzmichaelh's initial DMA interface to be more flexible.
Some bugfixes in the external interrupt code were found along the way.
Defines for nonexistent registers removed from nvic interface.
2010-12-30 02:40:16 -05:00
Marti Bolivar 753f89de35 whitespace cleanups 2010-09-27 00:40:44 -04:00
Perry Hung c13e850abe Enable external interrupts on all Maple GPIOs.
Extend the wirish attachInterrupt() and detachInterrupt() interface to
work with all GPIOs.

Note: The STM32 external interrupt lines are multiplexed between GPIO
ports. While any GPIO can be used as an external interrupt, not all of
them can be used at the same time. Each EXTI[n] line selects between
PA[n], PB[n], PC[n], etc. For example, line EXTI5 can be used with STM32
pins PA5, PB5, or PC5, but not all at the same time. See table:

EXTI Line       Maple Pin       STM32 Pin
  0             D2              PA0
  0             D27             PB0
  0             D15             PC0
  1             D3              PA1
  1             D28             PB1
  1             D16             PC1
  2             D1              PA2
  2             D17             PC2
  2             D25             PD2
  3             D0              PA3
  3             D18             PC3
  4             D10             PA4
  4             D19             PC4
  5             D13             PA5
  5             D4              PB5
  5             D20             PC5
  6             D12             PA6
  6             D5              PB6
  6             D35             PC6
  7             D11             PA7
  7             D9              PB7
  7             D36             PC7
  8             D6              PA8
  8             D14             PB8
  8             D37             PC8
  9             D7              PA9
  9             D24             PB9
  9             D38             PC9 (BUT)
 10             D8              PA10
 10             D29             PB10
 10             D26             PC10
 11             D30             PB11
 12             D31             PB12
 13             D32             PB13
 13             D21             PC13
 14             D33             PB14
 14             D22             PC14
 15             D34             PB15
 15             D23             PC15
2010-09-22 03:17:45 -04:00
Perry Hung 87c85a6449 Licensing: Relicensed libmaple under the MIT License.
Relicensed the bulk of libmaple under the more permissive MIT License,
from GPLv3. Files that were largely or entirely derived from
the Arduino, STM, or Lanchon retain their original licenses.
2010-03-31 22:43:27 -04:00
Perry Hung 25c7ba0ed7 Removed inttypes.h
Removed inttypes.h from libmaple. Will have another pass through to use
the standard libmaple types, but will come in another commit.
2010-03-31 21:29:29 -04:00
bnewbold 1d3861ef93 Major hierarchy reorganization; see README.
copy-to-ide and Makefile updated to conform; .gitignore added;
LICENSE added
2010-03-31 09:43:10 +08:00
Renamed from src/lib/exti.c (Browse further)