v0.5.0 #19

Merged
klassents merged 310 commits from v0.5.0 into main 2025-04-28 07:06:11 +03:00
3 changed files with 13 additions and 2 deletions
Showing only changes of commit 002762bf80 - Show all commits

View File

@ -6,6 +6,9 @@
#include "WInterrupts.h"
#include "wiring_LL.h"
// interrupts are enabled by default after setup()
static bool intIsEnabled = true;
typedef void (*voidFuncPtr)(void);
// empty irq handler
@ -18,14 +21,20 @@ static void nothing(void)
void interrupts(void)
{
GLOBAL_IRQ_ENABLE();
intIsEnabled = true;
}
// disable global interrupts
void noInterrupts(void)
{
GLOBAL_IRQ_DISABLE();
intIsEnabled = false;
}
bool isInterruptsEnabled(void)
{
return intIsEnabled;
}
// we can provide no more than 8 interrupts on gpio at the same time
static volatile voidFuncPtr intFunc[EXTERNAL_INTERRUPTS_QTY] =
{

View File

@ -6,10 +6,12 @@ extern "C" {
#endif
#include <stdint.h>
#include "stdbool.h"
// enable/disable interrupts
void interrupts(void);
void noInterrupts(void);
bool isInterruptsEnabled(void);
// attach/detach interrupt to pin
void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode);

View File

@ -25,8 +25,8 @@ extern "C" void SystemInit(void)
// called after setup()
void post_init(void)
{
// enable global interrupts by default
interrupts();
if(isInterruptsEnabled()) // if user has called noInterrupts() in setup(), this value is false
interrupts(); // enable global interrupts
}
// --------------------- other --------------------- //