How to get two pins into EXTI config?

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
tuxscreen
Posts: 14
Joined: Wed May 02, 2012 4:53 pm

How to get two pins into EXTI config?

Post 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
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: How to get two pins into EXTI config?

Post 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
tuxscreen
Posts: 14
Joined: Wed May 02, 2012 4:53 pm

Re: How to get two pins into EXTI config?

Post 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)
};


?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: How to get two pins into EXTI config?

Post 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
tuxscreen
Posts: 14
Joined: Wed May 02, 2012 4:53 pm

Re: How to get two pins into EXTI config?

Post 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
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: How to get two pins into EXTI config?

Post 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
tuxscreen
Posts: 14
Joined: Wed May 02, 2012 4:53 pm

Re: How to get two pins into EXTI config?

Post 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}
}
};
tuxscreen
Posts: 14
Joined: Wed May 02, 2012 4:53 pm

Re: How to get two pins into EXTI config?

Post by tuxscreen »

Thanks Giovanni,

works like a charm...
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: How to get two pins into EXTI config?

Post by Giovanni »

Yes, I assumed you were using the stable version because the code you posted.

Giovanni
Post Reply