arduino / arduino/ArduinoCore-API

Should SPI `attachInterrupt()` and `detachInterrupt()` be removed?

Open
#183 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
306
Forks
150
PR merge metrics
No merged PRs in 30d

Description

It looks like these methos are only used in the AVR ports, and even then they indicate that they should not be used.

[ArduinoCore-avr/libraries/SPI/src/SPI.h#L306-L310](https://github.com/arduino/ArduinoCore-avr/blob/42fa4a1ea1b1b11d1cc0a60298e529d37f9d14bd/libraries/SPI/src/SPI.h#L306-L310)
[ArduinoCore-megaavr/libraries/SPI/src/SPI.h#L183-L187](https://github.com/arduino/ArduinoCore-megaavr/blob/01b56951ed2a8acfa7a4efc4e9a2687f626641d1/libraries/SPI/src/SPI.h#L183-L187)
```cpp
// These undocumented functions should not be used. SPI.transfer()
// polls the hardware flag which is automatically cleared as the
// AVR responds to SPI's interrupt
inline static void attachInterrupt() { SPCR |= _BV(SPIE); }
inline static void detachInterrupt() { SPCR &= ~_BV(SPIE); }
```

Other cores do nothing or even do not implement it:
- [ArduinoCore-samd/libraries/SPI/SPI.cpp#L267-L273](https://github.com/arduino/ArduinoCore-samd/blob/26f2d480e1f8934c8e225f4171076e2e3be0a949/libraries/SPI/SPI.cpp#L267-L273)
- [ArduinoCore-mbed/libraries/SPI/SPI.cpp#L90-L96](https://github.com/arduino/ArduinoCore-mbed/blob/8593ab99713c662060cd02ca95c3ef25b2fd1bce/libraries/SPI/SPI.cpp#L90-L96)
- [ArduinoCore-arc32/libraries/SPI/src/SPI.h](https://github.com/arduino/ArduinoCore-arc32/blob/9f2e5e1404649026c057a4128308cb20c413b021/libraries/SPI/src/SPI.h)
- [ArduinoCore-sam/libraries/SPI/src/SPI.cpp](https://github.com/arduino/ArduinoCore-sam/blob/790ff2c852bf159787a9966bddee4d9f55352d15/libraries/SPI/src/SPI.cpp)

When are these methods meant to be used by Arduino users or ArduinoCore developers?

Contributor guide

No contributing guide indexed for this repository

Research direction

Compare the SPI declarations and implementations linked for ArduinoCore-avr, megaavr, samd, mbed, arc32, and sam. Start by checking how attachInterrupt() and detachInterrupt() are defined or omitted across those cores and whether the API contract explains their purpose. Done means reaching a documented decision on their supported status and identifying the affected core files.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api, embedded-iot
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.