sparkfun / Arduino_Apollo3

Arduino core to support the Apollo3 microcontroller from Ambiq Micro
83 stars 37 forks source link

Missing `noInterrupts()` and `interrupts()` functions #431

Closed santaimpersonator closed 2 years ago

santaimpersonator commented 2 years ago

It appears that the Apollo3 Arduino core doesn't implement these Arduino functions:

I believe that enabling and disabling the interrupts were handled by these functions

in the Apollo3 Mbed OS platform in these files (location varies by branch):

I saw an old issue that got pulled, where @oclyke mentioned noInterrupts() being used; also, there was an example for the PDM microphone calling those functions. However, I think that the noInterrupts() and interrupts() functions were removed at a later point (probably by accident).


I found the issue when I was trying to get the LoRaWAN Arduino library working with the Artemis MicroMod processor board. However, I ran into compiler issues for noInterrupts() and interrupts() in the library at these lines:

I was able to work around the issue by throwing an ifdef to avoid compiling those functions, since the disabling of the interrupts in the library seemed mostly critical for AVR boards (from what I could tell).

void hal_disableIRQs () {
    #if !defined(ARDUINO_APOLLO3_SFE_ARTEMIS_MM_PB)
        noInterrupts();
    #endif // !defined(ARDUINO_APOLLO3_SFE_ARTEMIS_MM_PB)

    irqlevel++;
}

void hal_enableIRQs () {
    if(--irqlevel == 0) {
        #if !defined(ARDUINO_APOLLO3_SFE_ARTEMIS_MM_PB)
            interrupts();
        #endif // !defined(ARDUINO_APOLLO3_SFE_ARTEMIS_MM_PB)
wemaxon commented 2 years ago

I had the exact same problem, which I solved too by commenting out both function calls. In the example provided by SparkFun the calls are removed as well. I still have some timing issues when trying to receive LoRa frames. I am using the LacunaSpace BasicMAC Library with the SparkFun LoRa Thing Plus explorable.

Wenn0101 commented 2 years ago

Fix is in dev and scheduled for release 2.2.1