Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

digitalPinToInterrupt seems not to be defined for chipKIT MAX32 #406

Open
pgunzelmann opened this issue May 19, 2018 · 8 comments
Open

digitalPinToInterrupt seems not to be defined for chipKIT MAX32 #406

pgunzelmann opened this issue May 19, 2018 · 8 comments

Comments

@pgunzelmann
Copy link

Using the sketc:
void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:
digitalPinToInterrupt(3);
}
works for Mega 2560 but if i switch to chipKIT MAX32 following error occur:

C:\Users\ENTWPIC\AppData\Local\Temp\arduino_modified_sketch_234261\libeval.ino: In function 'void loop()':

libeval:11: error: 'digitalPinToInterrupt' was not declared in this scope

digitalPinToInterrupt(3);

                    ^

exit status 255
'digitalPinToInterrupt' was not declared in this scope

@pgunzelmann
Copy link
Author

I expect its because digitalPinToInterrupt is not defined at
chipKIT-core/pic32/variants/Max32/Board_Defs.h

@majenkotech
Copy link
Member

It is actually a functionality that is lacking from the core completely, and is something that crossed my mind last night whilst putting together a board configuration for a new board - we really need to implement digitalPinToInterrupt in the core.

@majenkotech
Copy link
Member

As it is most board definitions have defines for PIN_INTx to kind of map the other way (select an interrupt number and you can know the pin number from that), but it's not ideal.

@majenkotech
Copy link
Member

Implementing it in the core is a simple one-liner. However then doing the board-level work is going to be an onerous task. I have done it in testing for the MAX32:

void setup() {
	Serial.begin(115200);

	for (int i = 0; i < NUM_DIGITAL_PINS; i++) {
        if (digitalPinToInterrupt(i) != NOT_INT_PIN) {
    		Serial.printf("Pin %d has interrupt number %d\r\n", i, digitalPinToInterrupt(i));
        }
    }
}

void loop() {
}

now gives:

Pin 2 has interrupt number 1                                         
Pin 3 has interrupt number 0                                         
Pin 7 has interrupt number 2                                         
Pin 20 has interrupt number 4                                        
Pin 21 has interrupt number 3  

but I need to now go through each and every board and implement it. Boards that don't have it implemented will return NOT_INT_PIN (i.e., 0xFF) for every pin. Looks like I have a fun weekend ahead of me.

@majenkotech
Copy link
Member

Actually, I may have come up with a better, more generic, method of implementing it that uses the PIN_INTx definitions. Something that can be dropped in the core and, if needed, overridden by a board.

@majenkotech
Copy link
Member

Generically fixed in #407 - individual boards may need tweaks after testing.

@JacobChrist
Copy link
Member

JacobChrist commented May 19, 2018 via email

@majenkotech
Copy link
Member

majenkotech commented May 19, 2018

I just found the exact same code written by someone else in some of the board definitions (great minds... ;) ) - so I have removed it to prevent redefinition warnings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@JacobChrist @majenkotech @pgunzelmann and others