/* Atomic clear primitive. 
This routine provides the atomic clear operator. The value of 0 is atomically written at <target> and the previous value at <target> is returned. (Hence, atomic_clear(pAtomicVar) is equivalent to atomic_set(pAtomicVar, 0).) */
atomic_val_t atomic_clear(atomic_t *target)
/* Atomic clear primitive. 
This routine provides the atomic clear operator. The value of 0 is atomically written at <target> and the previous value at <target> is returned. (Hence, atomic_clear(pAtomicVar) is equivalent to atomic_set(pAtomicVar, 0).) */
atomic_val_t atomic_clear(atomic_t *target)
{
    unsigned int key;
    atomic_val_t ret;
    key = irq_lock();
    ret = *target;
    *target = 0;
    irq_unlock(key);
    return ret;
}