Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions core/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ typedef uint8_t byte;
#define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ((x)*(x)) /* x^2 */

/* define interrupts and noInterrupts */
#define interrupts()
#define noInterrupts()

#ifdef F_CPU
#define clockCyclesPerMicrosecond() (F_CPU / 1000000L)
#define clockCyclesToMicroseconds(a) ((a) / clockCyclesPerMicrosecond())
Expand Down Expand Up @@ -186,6 +182,7 @@ void noTone(uint8_t _pin);

#include "WCharacter.h"
#include "WString.h"
#include "WInterrupts.h"
#include "HardwareSerial.h"
#ifdef RTDUINO_USING_USBSERIAL
#include "USBSerial.h"
Expand Down
36 changes: 36 additions & 0 deletions core/WInterrupts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2021-2022, RTduino Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-01-07 Meco Man first version
*/

#ifndef WInterrupts_h
#define WInterrupts_h

#include <rthw.h>

class rtduino_noInterrupts
{
private:
rt_base_t rtduino_interrupt_nesting;

public:
rtduino_noInterrupts()
{
rtduino_interrupt_nesting = rt_hw_interrupt_disable();
}

~rtduino_noInterrupts()
{
rt_hw_interrupt_enable(rtduino_interrupt_nesting);
}
};

#define noInterrupts() rtduino_noInterrupts *rtduino_noInterrupts_obj = new rtduino_noInterrupts()
#define interrupts() delete rtduino_noInterrupts_obj

#endif /* WInterrupts_h */