# osal\_spinlock.h ## **Overview** **Related Modules:** [OSAL](OSAL.md) **Description:** Declares spinlock types and interfaces. This file provides the interfaces for initializing, destroying, obtaining, and releasing a spinlock, the interfaces for obtaining a spinlock and disabling the interrupt request \(IRQ\), releasing a spinlock and enabling the IRQ, obtaining a spinlock, disabling the IRQ, and saving its status, and releasing a spinlock, enabling the IRQ, and restoring the saved IRQ status. The spinlock needs to be destroyed when it is no longer used. **Since:** 1.0 **Version:** 1.0 ## **Summary** ## Data Structures

Data Structure Name

Description

OsalSpinlock

Describes a spinlock.

## Macros

Macro Name and Value

Description

OSAL_DECLARE_SPINLOCK(spinlock)   OsalSpinlock spinlock

Defines a spinlock.

## Functions

Function Name

Description

OsalSpinInit (OsalSpinlock *spinlock)

int32_t 

Initializes a spinlock.

OsalSpinDestroy (OsalSpinlock *spinlock)

int32_t 

Destroys a spinlock.

OsalSpinLock (OsalSpinlock *spinlock)

int32_t 

Obtains a spinlock.

OsalSpinUnlock (OsalSpinlock *spinlock)

int32_t 

Releases a spinlock.

OsalSpinLockIrq (OsalSpinlock *spinlock)

int32_t 

Obtains a spinlock and disables the IRQ.

OsalSpinUnlockIrq (OsalSpinlock *spinlock)

int32_t 

Releases a spinlock and enables the IRQ.

OsalSpinLockIrqSave (OsalSpinlock *spinlock, uint32_t *flags)

int32_t 

Obtains a spinlock, disables the IRQ, and saves its status.

OsalSpinUnlockIrqRestore (OsalSpinlock *spinlock, uint32_t *flags)

int32_t 

Releases a spinlock, enables the IRQ, and restores the saved IRQ status.