RUI3 (RAK Unified Interface 3) - RAK4631
Interrupts

Functions

void interrupts (void)
 
void noInterrupts (void)
 
void attachInterrupt (uint32_t pin, void(*userFunc)(void), int mode)
 
void detachInterrupt (uint32_t pin)
 
void yield (void)
 

Detailed Description

Function Documentation

◆ interrupts()

void interrupts ( void  )
Description
Re-enables interrupts (after they’ve been disabled by noInterrupts()
Syntax
interrupts();
Returns
void
Example
void setup() {
}

void loop() {
  noInterrupts();
  // critical, time-sensitive code here
  interrupts();
  // other code here
}

◆ noInterrupts()

void noInterrupts ( void  )
Description
Disables interrupts (you can re-enable them with interrupts())
Syntax
noInterrupts();
Returns
void
Example
void setup() {
}

void loop() {
  noInterrupts();
  // critical, time-sensitive code here
  interrupts();
  // other code here
}

◆ attachInterrupt()

void attachInterrupt ( uint32_t  pin,
void(*)(void)  userFunc,
int  mode 
)
Description
Digital Pins With Interrupts
Syntax
attachInterrupt(pin, ISR, mode);
See also
https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/
Parameters
pinthe number of the interrupt
ISRthe ISR to call when the interrupt occurs; this function must take no parameters and return nothing. This function is sometimes referred to as an interrupt service routine
modedefines when the interrupt should be triggered(LOW,CHANGE,RISING,FALLING)
Returns
void
Example
uint8_t ledPin = 36;
uint8_t interruptPin = 13;
volatile byte state = LOW;
long startTime = 0;

void blink()
{
    state = !state;
}

void setup()
{
    pinMode(ledPin, OUTPUT);
    pinMode(interruptPin, INPUT_PULLUP);
    attachInterrupt(interruptPin, blink, CHANGE);
    startTime = millis();
}

void loop()
{
    //After 20sec will disable ISR for pin13
    if(millis() - startTime >= 20*1000)
        detachInterrupt(13);
   
    digitalWrite(ledPin, state);
}

◆ detachInterrupt()

void detachInterrupt ( uint32_t  pin)
Description
Turns off the given interrupt
Syntax
detachInterrupt(pin);
Parameters
pinthe number of the interrupt to disable
Returns
void
Example
uint8_t ledPin = 36;
uint8_t interruptPin = 13;
volatile byte state = LOW;
long startTime = 0;

void blink()
{
    state = !state;
}

void setup()
{
    pinMode(ledPin, OUTPUT);
    pinMode(interruptPin, INPUT_PULLUP);
    attachInterrupt(interruptPin, blink, CHANGE);
    startTime = millis();
}

void loop()
{
    //After 20sec will disable ISR for pin13
    if(millis() - startTime >= 20*1000)
        detachInterrupt(13);
   
    digitalWrite(ledPin, state);
}

◆ yield()

void yield ( void  )