Page 1 of 1

How to get two pins into EXTI config?

Posted: Wed Sep 19, 2012 7:25 pm
by tuxscreen
Hi,

how do I configure the EXTD1 driver, to get callbacks for two pins, one on PORTA, the other one on PORTD (on a STM32F407 controller) ?

One Pin was easy...

static const EXTConfig extcfg = {
{
{EXT_CH_MODE_DISABLED, NULL}, // PA0
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL}, // PA5
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART, ext_pps}, // PA8
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL}
},
EXT_MODE_EXTI(0, 0, 0, 0, 0, 0, 0, 0,
EXT_MODE_GPIOA,
0, 0, 0, 0, 0, 0, 0)
};

Thanks in advance

Marc

Re: How to get two pins into EXTI config?

Posted: Wed Sep 19, 2012 7:28 pm
by Giovanni
Hi,

You have to specify the callback replacing the various NULLs and the port as parameter of EXT_MODE_EXTI(), the first parameter is the port of EXTI0 the last is the port of EXTI15.

Giovanni

Re: How to get two pins into EXTI config?

Posted: Wed Sep 19, 2012 7:35 pm
by tuxscreen
Hmm,

ok, you mean, that this should work?

static const EXTConfig extcfg = {
{
{EXT_CH_MODE_DISABLED, NULL}, // PA0
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL}, // PA5
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART, ext_pps}, // PA8
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART, ext_pps2}, // PD10
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL}
},
EXT_MODE_EXTI(0, 0, 0, 0, 0, 0, 0, 0,
EXT_MODE_GPIOA,
0,
EXT_MODE_GPIOD, 0, 0, 0, 0, 0)
};


?

Re: How to get two pins into EXTI config?

Posted: Wed Sep 19, 2012 7:53 pm
by Giovanni
Yes, it should work.

Note, that in 2.5.0 the structure changed, so the initialization is a bit different, just in case you plan to update.

Giovanni

Re: How to get two pins into EXTI config?

Posted: Wed Sep 19, 2012 8:09 pm
by tuxscreen
ok, then I have the problem...

as you know, I use the new I2S Driver, and for that I switched to the SVN version

whats different?

TIA
Marc

Re: How to get two pins into EXTI config?

Posted: Wed Sep 19, 2012 8:24 pm
by Giovanni
Look at the examples under ./testhal. EXT_MODE_EXTI no more exists, the port is ORed to the mode field, it is much simpler than the old version.

Edit, example:

Code: Select all

static const EXTConfig extcfg = {
  {
    {EXT_CH_MODE_BOTH_EDGES | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOA, extcb1},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL}
  }
};


Giovanni

Re: How to get two pins into EXTI config?

Posted: Wed Sep 19, 2012 8:31 pm
by tuxscreen
OK, I don't wonder why it worked only for the PortA its define is 0x00 :-)...
This should be better, right?

static const EXTConfig extcfg = {
{
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_BOTH_EDGES | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOA, ext_pps},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_BOTH_EDGES | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOD, ext_pps2},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL}
}
};

Re: How to get two pins into EXTI config?

Posted: Wed Sep 19, 2012 8:32 pm
by tuxscreen
Thanks Giovanni,

works like a charm...

Re: How to get two pins into EXTI config?

Posted: Wed Sep 19, 2012 8:50 pm
by Giovanni
Yes, I assumed you were using the stable version because the code you posted.

Giovanni