is there something like
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
...
}
we had on avr or spin_lock_irqsave/spin_unlock_irqrestore calls in linux kernel?
Explore... Chat... Share...
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
...
}
Necromant wrote:Is there a proper way to make an atomic section to be 100% sure no interrupt kicks in during it?
static inline unsigned long arch_local_irq_save(void)
{
unsigned long flags;
asm volatile("rsil %0, 1"
: "=a" (flags) :: "memory");
return flags;
}
static inline void arch_local_irq_restore(unsigned long flags)
{
asm volatile("wsr %0, ps; rsync"
:: "a" (flags) : "memory");
}
static volatile uint16_t counter = 0;
void interruptRoutine()
{
counter++;
}
void setup(void)
{
attachInterrupt(5, interruptRoutine, FALLING);
}
void loop(void)
{
static uint16_t counterTemp = 0;
static uint16_t callCounter = 0;
if(callCounter++ == 10)
{
callCounter = 0;
// These two lines should probably be atomic
powerCounterTemp = powerCounter;
powerCounter = 0;
// Do something with powerCounterTemp...
}
}
It takes about 20-25 seconds for home assistant c[…]
I tried to upgrade tof my sonoff basic R2 with the[…]
a problem Perhaps you want to define "Probl[…]
Rebooting your router will not give you a faster I[…]
There are no other notifications from esptool.py i[…]
Using the Arduino IDE, you'll learn how to set up […]
In this project, you will post to Twitter using an[…]
In this project, we will build a water level contr[…]
I guess I'm late, but I had the same problem and f[…]
Last night I received my first D1 Minis for a lear[…]
Although I am aware that this is an old post, I fe[…]