2010-09-27 06:40:44 +02:00
|
|
|
/******************************************************************************
|
2010-04-01 04:22:29 +02:00
|
|
|
* The MIT License
|
2009-12-19 11:53:07 +01:00
|
|
|
*
|
2010-04-01 04:22:29 +02:00
|
|
|
* Copyright (c) 2010 Perry Hung.
|
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-04 02:30:13 +02:00
|
|
|
* Copyright (c) 2011, 2012 LeafLabs, LLC.
|
2009-12-19 11:53:07 +01:00
|
|
|
*
|
2011-06-07 20:44:39 +02:00
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
* files (the "Software"), to deal in the Software without
|
|
|
|
* restriction, including without limitation the rights to use, copy,
|
|
|
|
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
* of the Software, and to permit persons to whom the Software is
|
2010-04-01 04:22:29 +02:00
|
|
|
* furnished to do so, subject to the following conditions:
|
2009-12-19 11:53:07 +01:00
|
|
|
*
|
2011-06-07 20:44:39 +02:00
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
2009-12-19 11:53:07 +01:00
|
|
|
*
|
2011-06-07 20:44:39 +02:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
2010-09-27 06:40:44 +02:00
|
|
|
*****************************************************************************/
|
2010-04-01 04:22:29 +02:00
|
|
|
|
2009-12-19 11:53:07 +01:00
|
|
|
/**
|
2012-05-08 22:22:41 +02:00
|
|
|
* @file libmaple/exti.c
|
2010-09-27 06:40:44 +02:00
|
|
|
* @brief External interrupt control routines
|
2009-12-19 11:53:07 +01:00
|
|
|
*/
|
|
|
|
|
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>
2011-11-15 18:45:43 +01:00
|
|
|
#include <libmaple/exti.h>
|
|
|
|
#include <libmaple/libmaple.h>
|
|
|
|
#include <libmaple/nvic.h>
|
|
|
|
#include <libmaple/bitband.h>
|
2009-12-17 03:37:07 +01:00
|
|
|
|
2011-08-03 19:42:30 +02:00
|
|
|
static inline void dispatch_single_exti(uint32 exti_num);
|
|
|
|
static inline void dispatch_extis(uint32 start, uint32 stop);
|
2011-08-03 18:41:06 +02:00
|
|
|
|
2011-03-07 19:11:54 +01:00
|
|
|
/*
|
|
|
|
* Internal state
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct exti_channel {
|
2012-08-31 20:19:57 +02:00
|
|
|
void (*handler)(void *);
|
|
|
|
void *arg;
|
2011-03-07 19:11:54 +01:00
|
|
|
} exti_channel;
|
2010-09-22 09:17:45 +02:00
|
|
|
|
2011-03-07 19:11:54 +01:00
|
|
|
static exti_channel exti_channels[] = {
|
2012-08-31 20:19:57 +02:00
|
|
|
{ .handler = NULL, .arg = NULL }, // EXTI0
|
|
|
|
{ .handler = NULL, .arg = NULL }, // EXTI1
|
|
|
|
{ .handler = NULL, .arg = NULL }, // EXTI2
|
|
|
|
{ .handler = NULL, .arg = NULL }, // EXTI3
|
|
|
|
{ .handler = NULL, .arg = NULL }, // EXTI4
|
|
|
|
{ .handler = NULL, .arg = NULL }, // EXTI5
|
|
|
|
{ .handler = NULL, .arg = NULL }, // EXTI6
|
|
|
|
{ .handler = NULL, .arg = NULL }, // EXTI7
|
|
|
|
{ .handler = NULL, .arg = NULL }, // EXTI8
|
|
|
|
{ .handler = NULL, .arg = NULL }, // EXTI9
|
|
|
|
{ .handler = NULL, .arg = NULL }, // EXTI10
|
|
|
|
{ .handler = NULL, .arg = NULL }, // EXTI11
|
|
|
|
{ .handler = NULL, .arg = NULL }, // EXTI12
|
|
|
|
{ .handler = NULL, .arg = NULL }, // EXTI13
|
|
|
|
{ .handler = NULL, .arg = NULL }, // EXTI14
|
|
|
|
{ .handler = NULL, .arg = NULL }, // EXTI15
|
2010-09-22 09:17:45 +02:00
|
|
|
};
|
2009-12-17 03:37:07 +01:00
|
|
|
|
2011-03-07 19:11:54 +01:00
|
|
|
/*
|
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-04 02:30:13 +02:00
|
|
|
* Portable routines
|
2011-03-07 19:11:54 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Register a handler to run upon external interrupt.
|
|
|
|
*
|
|
|
|
* This function assumes that the interrupt request corresponding to
|
|
|
|
* the given external interrupt is masked.
|
|
|
|
*
|
|
|
|
* @param num External interrupt line number.
|
|
|
|
* @param port Port to use as source input for external interrupt.
|
|
|
|
* @param handler Function handler to execute when interrupt is triggered.
|
|
|
|
* @param mode Type of transition to trigger on, one of:
|
|
|
|
* EXTI_RISING, EXTI_FALLING, EXTI_RISING_FALLING.
|
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-04 02:30:13 +02:00
|
|
|
* @see exti_num
|
|
|
|
* @see exti_cfg
|
2011-08-23 00:13:49 +02:00
|
|
|
* @see voidFuncPtr
|
2011-03-07 19:11:54 +01:00
|
|
|
* @see exti_trigger_mode
|
|
|
|
*/
|
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-04 02:30:13 +02:00
|
|
|
void exti_attach_interrupt(exti_num num,
|
|
|
|
exti_cfg port,
|
2011-03-07 19:11:54 +01:00
|
|
|
voidFuncPtr handler,
|
|
|
|
exti_trigger_mode mode) {
|
2012-08-31 20:19:57 +02:00
|
|
|
// Call callback version with arg being null
|
2012-09-02 17:04:01 +02:00
|
|
|
exti_attach_callback(num, port, (voidArgumentFuncPtr)handler, NULL, mode);
|
2012-08-31 20:19:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Register a handler with an argument to run upon external interrupt.
|
|
|
|
*
|
|
|
|
* This function assumes that the interrupt request corresponding to
|
|
|
|
* the given external interrupt is masked.
|
|
|
|
*
|
|
|
|
* @param num External interrupt line number.
|
|
|
|
* @param port Port to use as source input for external interrupt.
|
|
|
|
* @param handler Function handler to execute when interrupt is triggered.
|
|
|
|
* @param arg Argument to pass to the interrupt handler.
|
|
|
|
* @param mode Type of transition to trigger on, one of:
|
|
|
|
* EXTI_RISING, EXTI_FALLING, EXTI_RISING_FALLING.
|
|
|
|
* @see exti_num
|
|
|
|
* @see exti_cfg
|
|
|
|
* @see voidFuncPtr
|
|
|
|
* @see exti_trigger_mode
|
|
|
|
*/
|
|
|
|
void exti_attach_callback(exti_num num,
|
|
|
|
exti_cfg port,
|
2012-09-02 17:04:01 +02:00
|
|
|
voidArgumentFuncPtr handler,
|
2012-08-31 20:19:57 +02:00
|
|
|
void *arg,
|
|
|
|
exti_trigger_mode mode) {
|
2011-03-07 19:11:54 +01:00
|
|
|
ASSERT(handler);
|
2009-12-17 03:37:07 +01:00
|
|
|
|
2011-03-07 19:11:54 +01:00
|
|
|
/* Register the handler */
|
2012-09-02 17:04:01 +02:00
|
|
|
exti_channels[num].handler = handler;
|
2012-08-31 20:19:57 +02:00
|
|
|
exti_channels[num].arg = arg;
|
2011-03-07 19:11:54 +01:00
|
|
|
|
|
|
|
/* Set trigger mode */
|
|
|
|
switch (mode) {
|
|
|
|
case EXTI_RISING:
|
2011-08-03 18:27:18 +02:00
|
|
|
bb_peri_set_bit(&EXTI_BASE->RTSR, num, 1);
|
2011-03-07 19:11:54 +01:00
|
|
|
break;
|
|
|
|
case EXTI_FALLING:
|
2011-08-03 18:27:18 +02:00
|
|
|
bb_peri_set_bit(&EXTI_BASE->FTSR, num, 1);
|
2011-03-07 19:11:54 +01:00
|
|
|
break;
|
|
|
|
case EXTI_RISING_FALLING:
|
2011-08-03 18:27:18 +02:00
|
|
|
bb_peri_set_bit(&EXTI_BASE->RTSR, num, 1);
|
|
|
|
bb_peri_set_bit(&EXTI_BASE->FTSR, num, 1);
|
2011-03-07 19:11:54 +01:00
|
|
|
break;
|
2010-09-22 09:17:45 +02:00
|
|
|
}
|
2011-03-07 19:11:54 +01:00
|
|
|
|
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-04 02:30:13 +02:00
|
|
|
/* Use the chip-specific exti_select() to map num to port */
|
|
|
|
exti_select(num, port);
|
2011-03-07 19:11:54 +01:00
|
|
|
|
|
|
|
/* Unmask external interrupt request */
|
2011-08-03 18:27:18 +02:00
|
|
|
bb_peri_set_bit(&EXTI_BASE->IMR, num, 1);
|
2011-03-07 19:11:54 +01:00
|
|
|
|
|
|
|
/* Enable the interrupt line */
|
2012-08-31 20:19:57 +02:00
|
|
|
switch(num)
|
|
|
|
{
|
2012-09-04 00:31:50 +02:00
|
|
|
case EXTI0:
|
2012-08-31 20:19:57 +02:00
|
|
|
nvic_irq_enable(NVIC_EXTI0);
|
|
|
|
break;
|
2012-09-04 00:31:50 +02:00
|
|
|
case EXTI1:
|
2012-08-31 20:19:57 +02:00
|
|
|
nvic_irq_enable(NVIC_EXTI1);
|
|
|
|
break;
|
2012-09-04 00:31:50 +02:00
|
|
|
case EXTI2:
|
2012-08-31 20:19:57 +02:00
|
|
|
nvic_irq_enable(NVIC_EXTI2);
|
|
|
|
break;
|
2012-09-04 00:31:50 +02:00
|
|
|
case EXTI3:
|
2012-08-31 20:19:57 +02:00
|
|
|
nvic_irq_enable(NVIC_EXTI3);
|
|
|
|
break;
|
2012-09-04 00:31:50 +02:00
|
|
|
case EXTI4:
|
2012-08-31 20:19:57 +02:00
|
|
|
nvic_irq_enable(NVIC_EXTI4);
|
|
|
|
break;
|
2012-09-04 00:31:50 +02:00
|
|
|
case EXTI5:
|
|
|
|
case EXTI6:
|
|
|
|
case EXTI7:
|
|
|
|
case EXTI8:
|
|
|
|
case EXTI9:
|
2012-08-31 20:19:57 +02:00
|
|
|
nvic_irq_enable(NVIC_EXTI_9_5);
|
|
|
|
break;
|
2012-09-04 00:31:50 +02:00
|
|
|
case EXTI10:
|
|
|
|
case EXTI11:
|
|
|
|
case EXTI12:
|
|
|
|
case EXTI13:
|
|
|
|
case EXTI14:
|
|
|
|
case EXTI15:
|
2012-08-31 20:19:57 +02:00
|
|
|
nvic_irq_enable(NVIC_EXTI_15_10);
|
|
|
|
break;
|
|
|
|
}
|
2011-03-07 19:11:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Unregister an external interrupt handler
|
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-04 02:30:13 +02:00
|
|
|
* @param num External interrupt line to disable.
|
|
|
|
* @see exti_num
|
2011-03-07 19:11:54 +01:00
|
|
|
*/
|
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-04 02:30:13 +02:00
|
|
|
void exti_detach_interrupt(exti_num num) {
|
2011-03-07 19:11:54 +01:00
|
|
|
/* First, mask the interrupt request */
|
2011-08-03 18:27:18 +02:00
|
|
|
bb_peri_set_bit(&EXTI_BASE->IMR, num, 0);
|
2011-03-07 19:11:54 +01:00
|
|
|
|
|
|
|
/* Then, clear the trigger selection registers */
|
2011-08-03 18:27:18 +02:00
|
|
|
bb_peri_set_bit(&EXTI_BASE->FTSR, num, 0);
|
|
|
|
bb_peri_set_bit(&EXTI_BASE->RTSR, num, 0);
|
2011-03-07 19:11:54 +01:00
|
|
|
|
|
|
|
/* Finally, unregister the user's handler */
|
|
|
|
exti_channels[num].handler = NULL;
|
2012-08-31 20:19:57 +02:00
|
|
|
exti_channels[num].arg = NULL;
|
2010-09-22 09:17:45 +02:00
|
|
|
}
|
|
|
|
|
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-04 02:30:13 +02:00
|
|
|
/*
|
|
|
|
* Private routines
|
|
|
|
*/
|
|
|
|
|
|
|
|
void exti_do_select(__io uint32 *exti_cr, exti_num num, exti_cfg port) {
|
|
|
|
uint32 shift = 4 * (num % 4);
|
|
|
|
uint32 cr = *exti_cr;
|
|
|
|
cr &= ~(0xF << shift);
|
|
|
|
cr |= port << shift;
|
|
|
|
*exti_cr = cr;
|
|
|
|
}
|
|
|
|
|
2011-03-07 19:11:54 +01:00
|
|
|
/*
|
|
|
|
* Interrupt handlers
|
|
|
|
*/
|
|
|
|
|
2011-02-27 21:49:51 +01:00
|
|
|
void __irq_exti0(void) {
|
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-04 02:30:13 +02:00
|
|
|
dispatch_single_exti(EXTI0);
|
2009-12-17 03:37:07 +01:00
|
|
|
}
|
|
|
|
|
2011-02-27 21:49:51 +01:00
|
|
|
void __irq_exti1(void) {
|
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-04 02:30:13 +02:00
|
|
|
dispatch_single_exti(EXTI1);
|
2009-12-17 03:37:07 +01:00
|
|
|
}
|
|
|
|
|
2011-02-27 21:49:51 +01:00
|
|
|
void __irq_exti2(void) {
|
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-04 02:30:13 +02:00
|
|
|
dispatch_single_exti(EXTI2);
|
2009-12-17 03:37:07 +01:00
|
|
|
}
|
|
|
|
|
2011-02-27 21:49:51 +01:00
|
|
|
void __irq_exti3(void) {
|
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-04 02:30:13 +02:00
|
|
|
dispatch_single_exti(EXTI3);
|
2009-12-17 03:37:07 +01:00
|
|
|
}
|
|
|
|
|
2011-02-27 21:49:51 +01:00
|
|
|
void __irq_exti4(void) {
|
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-04 02:30:13 +02:00
|
|
|
dispatch_single_exti(EXTI4);
|
2009-12-17 03:37:07 +01:00
|
|
|
}
|
|
|
|
|
2011-02-27 21:49:51 +01:00
|
|
|
void __irq_exti9_5(void) {
|
2011-08-03 19:42:30 +02:00
|
|
|
dispatch_extis(5, 9);
|
2009-12-17 03:37:07 +01:00
|
|
|
}
|
|
|
|
|
2011-02-27 21:49:51 +01:00
|
|
|
void __irq_exti15_10(void) {
|
2011-08-03 19:42:30 +02:00
|
|
|
dispatch_extis(10, 15);
|
2009-12-17 03:37:07 +01:00
|
|
|
}
|
|
|
|
|
2011-03-07 19:11:54 +01:00
|
|
|
/*
|
|
|
|
* Auxiliary functions
|
2010-09-22 09:17:45 +02:00
|
|
|
*/
|
2009-12-17 03:37:07 +01:00
|
|
|
|
2011-08-03 19:42:30 +02:00
|
|
|
/* Clear the pending bits for EXTIs whose bits are set in exti_msk.
|
|
|
|
*
|
|
|
|
* If a pending bit is cleared as the last instruction in an ISR, it
|
|
|
|
* won't actually be cleared in time and the ISR will fire again. To
|
|
|
|
* compensate, this function NOPs for 2 cycles after clearing the
|
|
|
|
* pending bits to ensure it takes effect. */
|
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-04 02:30:13 +02:00
|
|
|
static __always_inline void clear_pending_msk(uint32 exti_msk) {
|
2011-08-03 19:42:30 +02:00
|
|
|
EXTI_BASE->PR = exti_msk;
|
2011-03-07 19:11:54 +01:00
|
|
|
asm volatile("nop");
|
|
|
|
asm volatile("nop");
|
|
|
|
}
|
2009-12-17 03:37:07 +01:00
|
|
|
|
2011-08-03 19:42:30 +02:00
|
|
|
/* This dispatch routine is for non-multiplexed EXTI lines only; i.e.,
|
|
|
|
* it doesn't check EXTI_PR. */
|
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-04 02:30:13 +02:00
|
|
|
static __always_inline void dispatch_single_exti(uint32 exti) {
|
2012-08-31 20:19:57 +02:00
|
|
|
voidArgumentFuncPtr handler = exti_channels[exti].handler;
|
2011-08-03 19:42:30 +02:00
|
|
|
|
|
|
|
if (!handler) {
|
|
|
|
return;
|
2009-12-17 03:37:07 +01:00
|
|
|
}
|
2011-08-03 19:42:30 +02:00
|
|
|
|
2012-08-31 20:19:57 +02:00
|
|
|
handler(exti_channels[exti].arg);
|
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-04 02:30:13 +02:00
|
|
|
clear_pending_msk(1U << exti);
|
2009-12-17 03:37:07 +01:00
|
|
|
}
|
|
|
|
|
2011-08-03 19:42:30 +02:00
|
|
|
/* Dispatch routine for EXTIs which share an IRQ. */
|
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-04 02:30:13 +02:00
|
|
|
static __always_inline void dispatch_extis(uint32 start, uint32 stop) {
|
2011-08-03 19:42:30 +02:00
|
|
|
uint32 pr = EXTI_BASE->PR;
|
|
|
|
uint32 handled_msk = 0;
|
|
|
|
uint32 exti;
|
|
|
|
|
|
|
|
/* Dispatch user handlers for pending EXTIs. */
|
|
|
|
for (exti = start; exti <= stop; exti++) {
|
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-04 02:30:13 +02:00
|
|
|
uint32 eb = (1U << exti);
|
2011-08-03 19:42:30 +02:00
|
|
|
if (pr & eb) {
|
2012-08-31 20:19:57 +02:00
|
|
|
voidArgumentFuncPtr handler = exti_channels[exti].handler;
|
2011-08-03 19:42:30 +02:00
|
|
|
if (handler) {
|
2012-08-31 20:19:57 +02:00
|
|
|
handler(exti_channels[exti].arg);
|
2011-08-03 19:42:30 +02:00
|
|
|
handled_msk |= eb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear the pending bits for handled EXTIs. */
|
|
|
|
clear_pending_msk(handled_msk);
|
2011-08-03 18:24:38 +02:00
|
|
|
}
|