In function 'void setup()':
error: 'digitalPinToInterrupt' was not declared in this scope
attachInterrupt ( digitalPinToInterrupt ( PulseTimeIrqPin ), InterruptPulseTime, PulseTrigger ) ;
inline unsigned char digitalPinToInterrupt(unsigned char Interrupt_pin) { return Interrupt_pin; } //This isn't included in the stm32duino libs (yet)
#define portOutputRegister(port) (volatile byte *)( &(port->regs->ODR) ) //These are defined in STM32F1/variants/generic_stm32f103c/variant.h but return a non byte* value
#define portInputRegister(port) (volatile byte *)( &(port->regs->IDR) ) //These are defined in STM32F1/variants/generic_stm32f103c/variant.h but return a non byte* valueI tried the code you suggested:
inline unsigned char digitalPinToInterrupt(unsigned char Interrupt_pin) { return Interrupt_pin; } //This isn't included in the stm32duino libs (yet)
#define portOutputRegister(port) (volatile byte *)( &(port->regs->ODR) ) //These are defined in STM32F1/variants/generic_stm32f103c/variant.h but return a non byte* value
#define portInputRegister(port) (volatile byte *)( &(port->regs->IDR) ) //These are defined in STM32F1/variants/generic_stm32f103c/variant.h but return a non byte* value
#define LED 13 // Arduino
#define IrqPin 7
#define Trigger RISING
volatile unsigned long MSCurrent ;
volatile int Detect ;
// Interrupt Routine
void InterruptTime()
{
MSCurrent = millis() ;
digitalWrite ( LED, HIGH ) ;
Detect = 1 ;
}
void setup ()
{
Serial.begin ( 115200 );
delay ( 250 ) ;
pinMode ( LED, OUTPUT ) ;
pinMode ( IrqPin, INPUT ) ;
attachInterrupt ( digitalPinToInterrupt ( IrqPin ), InterruptTime, Trigger ) ;
}
void loop()
{
if ( Detect == 1 )
{
detachInterrupt ( digitalPinToInterrupt ( IrqPin ) ) ;
Detect = 0 ;
delay ( 150 ) ;
digitalWrite ( LED, LOW ) ;
delay ( 1500 ) ;
attachInterrupt ( digitalPinToInterrupt ( IrqPin ), InterruptTime, Trigger ) ;
}
}
For the Arduino SAM (due) board its defined as
#define digitalPinToInterrupt(p) ((p) < NUM_DIGITAL_PINS ? (p) : -1)
Warning: set an EXTI on PA0 and PB0 will raised the same EXTI without way to know which GPIO port it is.
[fpiSTM – Tue Jun 20, 2017 6:43 am] –
For STM32, there is one EXTi per GPIO pin number. So, 16 EXTI (PX0 to Px15).
Warning: set an EXTI on PA0 and PB0 will raised the same EXTI without way to know which GPIO port it is.
Thanks Frederic
So apart from the problem of an Interrupt on the same pin mask on different ports, then this function should just return the pin number.
I’ve checked the Arduino API https://www.arduino.cc/en/Reference/AttachInterrupt and attachInterrupt does not return a value ![]()
So even if the core checked had an error because of PA0 and PB0 (or I presume PB1 and PC1 etc), then it could not be reported.
I just the core could just ASSERT if that happened, but I don’t know the “Arduino” way to handle this
Really we need an API change so that attachInterrupt can return bool, but Arduino are not usually happy to change their API
The question is “Is it required to handle this check?”
If a user attach interrupt twice on pin number ‘x’ with a different GPIO port PYx, I think irq handler x will be called only one time (tbc).
So its probably not worth even checking
[keypunch – Tue Jun 20, 2017 4:51 am] –
Vitor,I tried the code you suggested:
…
Is this the expected result?Regards,
John L. Males
Toronto, Ontario
Canada
20 June 2017 00:51 EDT
20 June 2017 00:54 EDT Added sketch code with suggested code additions.
Yes, it give those warnings but works here, did yours worked?
[RogerClark – Tue Jun 20, 2017 7:08 am] –[fpiSTM – Tue Jun 20, 2017 6:43 am] –
For STM32, there is one EXTi per GPIO pin number. So, 16 EXTI (PX0 to Px15).
Warning: set an EXTI on PA0 and PB0 will raised the same EXTI without way to know which GPIO port it is.…
Really we need an API change so that attachInterrupt can return bool, but Arduino are not usually happy to change their API
Did you looked at STAR repo? IMAO they should have it working for their STM board
#define digitalPinToInterrupt(pin) (pin)



