altos: Add EXTI_PIN_NOCONFIGURE to exti interface, use for MS5607
authorKeith Packard <keithp@keithp.com>
Mon, 20 May 2013 03:04:29 +0000 (20:04 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 20 May 2013 03:04:29 +0000 (20:04 -0700)
This asks the EXTI code to not mess with the pin configuration so that
the MS5607 driver can get interrupts on the MISO pin while still using
it for SPI.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/attiny/ao_exti.h
src/drivers/ao_ms5607.c
src/lpc/ao_exti.h
src/lpc/ao_exti_lpc.c
src/stm/ao_exti.h
src/stm/ao_exti_stm.c

index 2ea4f47d33421e112e5d0d0bfacdd5db7c62387f..85bb2fbabc939eb39b3ad0e31205f287668a6dff 100644 (file)
@@ -30,5 +30,6 @@ ao_exti_setup_port(uint8_t pin, uint8_t mode, void (*callback)(void));
 #define ao_exti_init()
 
 #define AO_EXTI_MODE_RISING    1
+#define AO_EXTI_PIN_NOCONFIGURE        0
 
 #endif /* _AO_EXTI_H_ */
index 0eece584888d3cabfe5b76f4443408468043c8b0..8f1dcbe1688b268c00d5f6b526a2cc8f9a62cd5e 100644 (file)
@@ -247,17 +247,9 @@ ao_ms5607_init(void)
         */
        ao_exti_setup(AO_MS5607_MISO_PORT,
                      AO_MS5607_MISO_PIN,
-                     AO_EXTI_MODE_RISING,
+                     AO_EXTI_MODE_RISING|
+                     AO_EXTI_PIN_NOCONFIGURE,
                      ao_ms5607_isr);
-
-#ifdef STM_MODER_ALTERNATE
-       /* Reset the pin from INPUT to ALTERNATE so that SPI works
-        * This needs an abstraction at some point...
-        */
-       stm_moder_set(AO_MS5607_MISO_PORT,
-                     AO_MS5607_MISO_PIN,
-                     STM_MODER_ALTERNATE);
-#endif
 }
 
 #endif
index cbe63eaae8c5c9a801af2d63d700a41cb94e3203..e8599eb436db9221e2e4aff7e77846e29d2ce64a 100644 (file)
@@ -25,6 +25,7 @@
 #define AO_EXTI_PRIORITY_LOW   16
 #define AO_EXTI_PRIORITY_MED   0
 #define AO_EXTI_PRIORITY_HIGH  32
+#define AO_EXTI_PIN_NOCONFIGURE        64
 
 void
 ao_exti_setup(uint8_t gpio, uint8_t pin, uint8_t mode, void (*callback)());
index ce98b4ad3e0dae3c771083dd2fc214009b183112..588cf58c5c7ee81688031002e31717ae5352423d 100644 (file)
@@ -91,6 +91,9 @@ ao_exti_setup (uint8_t port, uint8_t pin, uint8_t mode, void (*callback)(void))
        if (pint == LPC_NUM_PINT)
                ao_panic(AO_PANIC_EXTI);
 
+       if (!mode & AO_EXTI_PIN_NOCONFIGURE)
+               ao_enable_input(port, pin, mode);
+
        ao_arch_block_interrupts();
        mask = (1 << pint);
        ao_pint_inuse |= mask;
index 35b56b571582fd392201bf0172767ff9f53119ad..ebea224d03d48934507e3673d5d049ba9bc2324e 100644 (file)
@@ -25,6 +25,7 @@
 #define AO_EXTI_PRIORITY_LOW   16
 #define AO_EXTI_PRIORITY_MED   0
 #define AO_EXTI_PRIORITY_HIGH  32
+#define AO_EXTI_PIN_NOCONFIGURE        64
 
 void
 ao_exti_setup(struct stm_gpio *gpio, uint8_t pin, uint8_t mode, void (*callback)());
index 1361d0d4a8cb6caf0a41b3522c9ae49c53c71cf5..c1dcdf85303a84f0a7541023f7bca684fdaba037 100644 (file)
@@ -70,21 +70,23 @@ ao_exti_setup (struct stm_gpio *gpio, uint8_t pin, uint8_t mode, void (*callback
        /* configure gpio to interrupt routing */
        stm_exticr_set(gpio, pin);
 
-       /* configure pin as input, setting selected pull-up/down mode */
-       stm_moder_set(gpio, pin, STM_MODER_INPUT);
-       switch (mode & (AO_EXTI_MODE_PULL_UP|AO_EXTI_MODE_PULL_DOWN)) {
-       case 0:
-       default:
-               pupdr  = STM_PUPDR_NONE;
-               break;
-       case AO_EXTI_MODE_PULL_UP:
-               pupdr = STM_PUPDR_PULL_UP;
-               break;
-       case AO_EXTI_MODE_PULL_DOWN:
-               pupdr = STM_PUPDR_PULL_DOWN;
-               break;
+       if (!(mode & AO_EXTI_PIN_NOCONFIGURE)) {
+               /* configure pin as input, setting selected pull-up/down mode */
+               stm_moder_set(gpio, pin, STM_MODER_INPUT);
+               switch (mode & (AO_EXTI_MODE_PULL_UP|AO_EXTI_MODE_PULL_DOWN)) {
+               case 0:
+               default:
+                       pupdr  = STM_PUPDR_NONE;
+                       break;
+               case AO_EXTI_MODE_PULL_UP:
+                       pupdr = STM_PUPDR_PULL_UP;
+                       break;
+               case AO_EXTI_MODE_PULL_DOWN:
+                       pupdr = STM_PUPDR_PULL_DOWN;
+                       break;
+               }
+               stm_pupdr_set(gpio, pin, pupdr);
        }
-       stm_pupdr_set(gpio, pin, pupdr);
 
        /* Set interrupt mask and rising/falling mode */
        stm_exti.imr &= ~mask;