mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
21 lines
335 B
C
21 lines
335 B
C
|
#include <atomic.h>
|
||
|
#include <cpu.h>
|
||
|
#include "debug.h"
|
||
|
|
||
|
unsigned int atomic_set_return(unsigned int* val, unsigned int set)
|
||
|
{
|
||
|
unsigned int old_val;
|
||
|
unsigned int old_state;
|
||
|
|
||
|
DEBUG("atomic_set_return\n");
|
||
|
|
||
|
old_state = disableIRQ();
|
||
|
|
||
|
old_val = *val;
|
||
|
*val = set;
|
||
|
|
||
|
restoreIRQ(old_state);
|
||
|
|
||
|
return old_val;
|
||
|
}
|