- OSAL
- Overview
- Summary
- Files
- Data Structures
- Macros
- Typedefs
- Enumerations
- Functions
- Details
- Macro Definition Documentation
- OSAL_READB
- OSAL_READL
- OSAL_READW
- OSAL_WRITEB
- OSAL_WRITEL
- OSAL_WRITEW
- Enumeration Type Documentation
- OSAL_IRQ_TRIGGER_MODE
- OSAL_THREAD_PRIORITY
- Function Documentation
- OsalAtomicDec()
- OsalAtomicInc()
- OsalAtomicRead()
- OsalAtomicSet()
- OsalClearBit()
- OsalDiffTime()
- OsalDisableIrq()
- OsalEnableIrq()
- OsalFileClose()
- OsalFileLseek()
- OsalFileOpen()
- OsalFileRead()
- OsalFileWrite()
- OsalGetSysTimeMs()
- OsalGetTime()
- OsalIoRemap()
- OsalIoUnmap()
- OsalMDelay()
- OsalMemAlloc()
- OsalMemAllocAlign()
- OsalMemCalloc()
- OsalMemFree()
- OsalMSleep()
- OsalMutexDestroy()
- OsalMutexInit()
- OsalMutexLock()
- OsalMutexTimedLock()
- OsalMutexUnlock()
- OsalReadFirmware()
- OsalRegisterIrq()
- OsalReleaseFirmware()
- OsalRequestFirmware()
- OsalSeekFirmware()
- OsalSemDestroy()
- OsalSemInit()
- OsalSemPost()
- OsalSemWait()
- OsalSleep()
- OsalSpinDestroy()
- OsalSpinInit()
- OsalSpinLock()
- OsalSpinLockIrq()
- OsalSpinLockIrqSave()
- OsalSpinUnlock()
- OsalSpinUnlockIrq()
- OsalSpinUnlockIrqRestore()
- OsalTestBit()
- OsalTestClearBit()
- OsalTestSetBit()
- OsalThreadCreate()
- OsalThreadDestroy()
- OsalThreadResume()
- OsalThreadStart()
- OsalThreadSuspend()
- OsalTimerCreate()
- OsalTimerDelete()
- OsalTimerSetTimeout()
- OsalTimerStartLoop()
- OsalTimerStartOnce()
- OsalUDelay()
- OsalUnregisterIrq()
OSAL
Overview
Defines the structures and interfaces for the Operating System Abstraction Layer (OSAL) module.
The OSAL module harmonizes OS interface differences and provides unified OS interfaces externally, including the memory management, thread, mutex, spinlock, semaphore, timer, file, interrupt, time, atomic, firmware, and I/O operation modules.
Since:
1.0
Version:
1.0
Summary
Files
Declares interrupt request (IRQ) interfaces and common IRQ trigger modes. |
|
Data Structures
Macros
OSAL_WRITEB(value, address) writeb(value, address) |
|
OSAL_WRITEW(value, address) writew(value, address) |
|
OSAL_WRITEL(value, address) writel(value, address) |
|
OSAL_READB(address) readb(address) |
|
OSAL_READW(address) readw(address) |
|
OSAL_READL(address) readl(address) |
|
OSAL_DECLARE_MUTEX (mutex) struct OsalMutex mutex |
|
OSAL_DECLARE_SEMAPHORE (sem) struct OsalSem sem |
|
OSAL_DECLARE_SPINLOCK (spinlock) OsalSpinlock spinlock |
|
OSAL_DECLARE_THREAD (thread) struct OsalThread thread |
|
OSAL_DECLARE_TIMER (timer) OsalTimer timer |
Typedefs
Enumerations
Functions
OsalAtomicRead (const OsalAtomic v) |
|
OsalAtomicSet (OsalAtomic v, int32_t counter) |
|
OsalTestBit (unsigned long nr, const volatile unsigned long addr) |
|
OsalTestSetBit (unsigned long nr, volatile unsigned long addr) |
Sets the value of a specified bit of the variable and returns the bit value before the setting. |
OsalTestClearBit (unsigned long nr, volatile unsigned long addr) |
Clears the value of a specified bit of the variable and returns the bit value before clearing. |
OsalClearBit (unsigned long nr, volatile unsigned long addr) |
|
OsalFileOpen (OsalFile file, const char path, int flags, uint32_t rights) |
|
OsalFileWrite (OsalFile file, const void string, uint32_t length) |
|
OsalFileClose (OsalFile file) |
|
OsalFileRead (OsalFile file, void buf, uint32_t length) |
|
OsalFileLseek (OsalFile file, off_t offset, int32_t whence) |
|
OsalRequestFirmware (struct OsalFirmware fw, const char fwName, void device) |
Requests a firmware file based on its name and device information. |
OsalSeekFirmware (struct OsalFirmware fw, uint32_t offset) |
|
OsalReadFirmware (struct OsalFirmware fw, struct OsalFwBlock block) |
|
OsalReleaseFirmware (struct OsalFirmware fw) |
|
OsalIoRemap (unsigned long phys_addr, unsigned long size) |
|
OsalIoUnmap (void addr) |
Unmaps an I/O virtual address associated with the physical address. |
OsalRegisterIrq (uint32_t irqId, uint32_t config, OsalIRQHandle handle, const char name, void dev) |
|
OsalUnregisterIrq (uint32_t irqId) |
|
OsalEnableIrq (uint32_t irqId) |
|
OsalDisableIrq (uint32_t irqId) |
|
OsalMemAlloc (size_t size) |
|
OsalMemCalloc (size_t size) |
Allocates memory of a specified size, and clears the allocated memory. |
OsalMemAllocAlign (size_t alignment, size_t size) |
Allocates memory of a specified size, and aligns the memory address on a given boundary. |
OsalMemFree (void mem) |
|
OsalMutexInit (struct OsalMutex mutex) |
|
OsalMutexDestroy (struct OsalMutex mutex) |
|
OsalMutexLock (struct OsalMutex mutex) |
|
OsalMutexTimedLock (struct OsalMutex mutex, uint32_t ms) |
|
OsalMutexUnlock (struct OsalMutex mutex) |
|
OsalSemInit (struct OsalSem sem, uint32_t value) |
|
OsalSemWait (struct OsalSem sem, uint32_t ms) |
|
OsalSemPost (struct OsalSem sem) |
|
OsalSemDestroy (struct OsalSem sem) |
|
OsalSpinInit (OsalSpinlock spinlock) |
|
OsalSpinDestroy (OsalSpinlock spinlock) |
|
OsalSpinLock (OsalSpinlock spinlock) |
|
OsalSpinUnlock (OsalSpinlock spinlock) |
|
OsalSpinLockIrq (OsalSpinlock spinlock) |
|
OsalSpinUnlockIrq (OsalSpinlock spinlock) |
|
OsalSpinLockIrqSave (OsalSpinlock spinlock, uint32_t flags) |
|
OsalSpinUnlockIrqRestore (OsalSpinlock spinlock, uint32_t flags) |
Releases a spinlock, enables the IRQ, and restores the saved IRQ status. |
OsalThreadCreate (struct OsalThread thread, OsalThreadEntry threadEntry, void entryPara) |
|
OsalThreadStart (struct OsalThread thread, const struct OsalThreadParam param) |
|
OsalThreadDestroy (struct OsalThread thread) |
|
OsalThreadSuspend (struct OsalThread thread) |
|
OsalThreadResume (struct OsalThread thread) |
|
OsalSleep (uint32_t sec) |
|
OsalMSleep (uint32_t ms) |
|
OsalDiffTime (const OsalTimespec start, const OsalTimespec end, OsalTimespec diff) |
|
OsalGetSysTimeMs (void) |
|
OsalMDelay (uint32_t ms) |
|
OsalUDelay (uint32_t us) |
|
OsalTimerCreate (OsalTimer timer, uint32_t interval, OsalTimerFunc func, uintptr_t arg) |
|
OsalTimerDelete (OsalTimer timer) |
|
OsalTimerStartOnce (OsalTimer timer) |
|
OsalTimerStartLoop (OsalTimer timer) |
|
OsalTimerSetTimeout (OsalTimer timer, uint32_t interval) |
Details
Macro Definition Documentation
OSAL_READB
#define OSAL_READB( address) readb(address)
Description:
Reads one byte of data from an I/O address space.
Parameters:
address | Indicates the address to read. |
Returns:
Returns the byte.
OSAL_READL
#define OSAL_READL( address) readl(address)
Description:
Reads an integer from an I/O address space.
Parameters:
address | Indicates the address to read. |
Returns:
Returns the integer.
OSAL_READW
#define OSAL_READW( address) readw(address)
Description:
Reads a short integer from an I/O address space.
Parameters:
address | Indicates the address to read. |
Returns:
Returns the short integer.
OSAL_WRITEB
#define OSAL_WRITEB( value, address ) writeb(value, address)
Description:
Writes one byte of data into an I/O address space.
Parameters:
value | Indicates the data to write. |
address | Indicates the address to write. |
OSAL_WRITEL
#define OSAL_WRITEL( value, address ) writel(value, address)
Description:
Writes an integer into an I/O address space.
Parameters:
value | Indicates the data to write. |
address | Indicates the address to write. |
OSAL_WRITEW
#define OSAL_WRITEW( value, address ) writew(value, address)
Description:
Writes a short integer into an I/O address space.
Parameters:
value | Indicates the data to write. |
address | Indicates the address to write. |
Enumeration Type Documentation
OSAL_IRQ_TRIGGER_MODE
enum [OSAL_IRQ_TRIGGER_MODE]($api-api-SmartVision-Devices-OSAL.md#ga78cd126b10424753db6f39f9b72ea124)
Description:
Enumerates interrupt trigger modes.
OSAL_IRQF_TRIGGER_NONE | |
OSAL_IRQF_TRIGGER_RISING | |
OSAL_IRQF_TRIGGER_FALLING | |
OSAL_IRQF_TRIGGER_HIGH | |
OSAL_IRQF_TRIGGER_LOW |
OSAL_THREAD_PRIORITY
enum [OSAL_THREAD_PRIORITY]($api-api-SmartVision-Devices-OSAL.md#gab8c099a9c39fdde73c74b3f7367be5d0)
Description:
Enumerates thread priorities.
OSAL_THREAD_PRI_LOW | |
OSAL_THREAD_PRI_DEFAULT | |
OSAL_THREAD_PRI_HIGH | |
OSAL_THREAD_PRI_HIGHEST |
Function Documentation
OsalAtomicDec()
void OsalAtomicDec ([OsalAtomic]($api-api-SmartVision-Devices-OsalAtomic.md) * v)
Description:
Decrements the counter of an atomic by 1.
Parameters:
v | Indicates the pointer to the atomic OsalAtomic. |
OsalAtomicInc()
void OsalAtomicInc ([OsalAtomic]($api-api-SmartVision-Devices-OsalAtomic.md) * v)
Description:
Increments the counter of an atomic by 1.
Parameters:
v | Indicates the pointer to the atomic OsalAtomic. |
OsalAtomicRead()
int32_t OsalAtomicRead (const [OsalAtomic]($api-api-SmartVision-Devices-OsalAtomic.md) * v)
Description:
Reads the counter of an atomic.
Parameters:
v | Indicates the pointer to the atomic OsalAtomic. |
Returns:
Returns the counter.
OsalAtomicSet()
void OsalAtomicSet ([OsalAtomic]($api-api-SmartVision-Devices-OsalAtomic.md) * v, int32_t counter )
Description:
Sets the counter for an atomic.
Parameters:
v | Indicates the pointer to the atomic OsalAtomic. |
counter | Indicates the counter to set. |
OsalClearBit()
void OsalClearBit (unsigned long nr, volatile unsigned long * addr )
Description:
Clears the value of a specified bit of the variable.
Parameters:
nr | Indicates the bit of the variable. The value ranges from 0 to 31. |
addr | Indicates the pointer to the variable. |
OsalDiffTime()
int32_t OsalDiffTime (const [OsalTimespec]($api-api-SmartVision-Devices-OsalTimespec.md) * start, const [OsalTimespec]($api-api-SmartVision-Devices-OsalTimespec.md) * end, [OsalTimespec]($api-api-SmartVision-Devices-OsalTimespec.md) * diff )
Description:
Obtains time difference.
Parameters:
start | Indicates the pointer to the start time OsalTimespec. |
end | Indicates the pointer to the end time OsalTimespec. |
diff | Indicates the pointer to the time difference OsalTimespec. |
Returns:
Returns a value listed below:
OsalDisableIrq()
int32_t OsalDisableIrq (uint32_t irqId)
Description:
Disables an IRQ.
Parameters:
irqId | Indicates the IRQ ID. |
Returns:
Returns a value listed below:
OsalEnableIrq()
int32_t OsalEnableIrq (uint32_t irqId)
Description:
Enables an IRQ.
Parameters:
irqId | Indicates the IRQ ID. |
Returns:
Returns a value listed below:
OsalFileClose()
void OsalFileClose ([OsalFile]($api-api-SmartVision-Devices-OsalFile.md) * file)
Description:
Closes a file.
Parameters:
file | Indicates the pointer to the file type OsalFile. |
OsalFileLseek()
off_t OsalFileLseek ([OsalFile]($api-api-SmartVision-Devices-OsalFile.md) * file, off_t offset, int32_t whence )
Description:
Sets the file read/write offset.
Parameters:
file | Indicates the pointer to the file type OsalFile. |
offset | Indicates the offset to set. |
whence | Indicates the position from which the offset is to set. For details, see OSAL_SEEK_SET. |
OsalFileOpen()
int32_t OsalFileOpen ([OsalFile]($api-api-SmartVision-Devices-OsalFile.md) * file, const char * path, int flags, uint32_t rights )
Description:
Opens a file.
Parameters:
file | Indicates the pointer to the file type OsalFile. |
path | Indicates the pointer to the name of the file to open. |
flags | Indicates the mode of opening the file. For details, see OSAL_O_RD_ONLY. |
rights | Indicates the permissions required for opening the file. For details, see OSAL_S_IREAD. |
Returns:
Returns a value listed below:
OsalFileRead()
ssize_t OsalFileRead ([OsalFile]($api-api-SmartVision-Devices-OsalFile.md) * file, void * buf, uint32_t length )
Description:
Reads a file.
Parameters:
file | Indicates the pointer to the file type OsalFile. |
buf | Indicates the pointer to the buffer for storing the content to read. |
length | Indicates the length of the content to read. |
Returns:
Returns a value listed below:
HDF_FAILURE HDF_STATUS |
|
HDF_ERR_INVALID_PARAM HDF_STATUS |
OsalFileWrite()
ssize_t OsalFileWrite ([OsalFile]($api-api-SmartVision-Devices-OsalFile.md) * file, const void * string, uint32_t length )
Description:
Writes a file.
Parameters:
file | Indicates the pointer to the file type OsalFile. |
string | Indicates the pointer to the content to write. |
length | Indicates the length of the content to write. |
Returns:
Returns a value listed below:
HDF_FAILURE HDF_STATUS |
|
HDF_ERR_INVALID_PARAM HDF_STATUS |
OsalGetSysTimeMs()
uint64_t OsalGetSysTimeMs (void )
Description:
Obtains the system time.
Returns:
Returns the system time, in milliseconds.
OsalGetTime()
int32_t OsalGetTime ([OsalTimespec]($api-api-SmartVision-Devices-OsalTimespec.md) * time)
Description:
Obtains the second and microsecond time.
Parameters:
time | Indicates the pointer to the time structure OsalTimespec. |
Returns:
Returns a value listed below:
OsalIoRemap()
static void* OsalIoRemap (unsigned long phys_addr, unsigned long size )
Description:
Remaps an I/O physical address to its virtual address.
Parameters:
phys_addr | Indicates the I/O physical address. |
size | Indicates the size of the physical address to remap. |
Returns:
Returns the virtual address.
OsalIoUnmap()
static void OsalIoUnmap (void * addr)
Description:
Unmaps an I/O virtual address associated with the physical address.
The virtual address is the one returned by calling OsalIoRemap.
Parameters:
addr | Indicates the pointer to the virtual address to unmap. |
OsalMDelay()
void OsalMDelay (uint32_t ms)
Description:
Describes thread delay, in milliseconds.
When a thread invokes this function, the CPU is not released. This function returns after waiting for milliseconds.
Parameters:
ms | Indicates the delay time, in milliseconds. |
OsalMemAlloc()
void* OsalMemAlloc (size_t size)
Description:
Allocates memory of a specified size.
Parameters:
size | Indicates the size of memory to allocate. |
Returns:
Returns the pointer to the allocated memory if the operation is successful; returns NULL otherwise.
OsalMemAllocAlign()
void* OsalMemAllocAlign (size_t alignment, size_t size )
Description:
Allocates memory of a specified size, and aligns the memory address on a given boundary.
Parameters:
alignment | Indicates the memory boundary alignment. The value must be a power of 2. |
size | Indicates the size of memory to allocate. |
Returns:
Returns the pointer to the allocated memory if the operation is successful; returns NULL otherwise.
OsalMemCalloc()
void* OsalMemCalloc (size_t size)
Description:
Allocates memory of a specified size, and clears the allocated memory.
Parameters:
size | Indicates the size of memory to allocate. |
Returns:
Returns the pointer to the allocated memory if the operation is successful; returns NULL otherwise.
OsalMemFree()
void OsalMemFree (void * mem)
Description:
Releases memory.
Parameters:
mem | Indicates the pointer to the memory to release. |
OsalMSleep()
void OsalMSleep (uint32_t ms)
Description:
Describes thread sleep, in milliseconds.
When a thread invokes this function, the CPU is released and the thread enters the sleep state.
Parameters:
ms | Indicates the sleep time, in milliseconds. |
OsalMutexDestroy()
int32_t OsalMutexDestroy (struct [OsalMutex]($api-api-SmartVision-Devices-OsalMutex.md) * mutex)
Description:
Destroys a mutex.
Parameters:
mutex | Indicates the pointer to the mutex OsalMutex. |
Returns:
Returns a value listed below:
OsalMutexInit()
int32_t OsalMutexInit (struct [OsalMutex]($api-api-SmartVision-Devices-OsalMutex.md) * mutex)
Description:
Initializes a mutex.
Parameters:
mutex | Indicates the pointer to the mutex OsalMutex. |
Returns:
Returns a value listed below:
Failed to invoke the system function to initialize the mutex. |
|
OsalMutexLock()
int32_t OsalMutexLock (struct [OsalMutex]($api-api-SmartVision-Devices-OsalMutex.md) * mutex)
Description:
Locks a mutex.
Parameters:
mutex | Indicates the pointer to the mutex OsalMutex. |
Returns:
Returns a value listed below:
OsalMutexTimedLock()
int32_t OsalMutexTimedLock (struct [OsalMutex]($api-api-SmartVision-Devices-OsalMutex.md) * mutex, uint32_t ms )
Description:
Locks a mutex with a specified timeout duration.
Parameters:
mutex | Indicates the pointer to the mutex OsalMutex. |
ms | Indicates the timeout duration, in milliseconds. |
Returns:
Returns a value listed below:
OsalMutexUnlock()
int32_t OsalMutexUnlock (struct [OsalMutex]($api-api-SmartVision-Devices-OsalMutex.md) * mutex)
Description:
Unlocks a mutex.
Parameters:
mutex | Indicates the pointer to the mutex OsalMutex. |
Returns:
Returns a value listed below:
OsalReadFirmware()
int32_t OsalReadFirmware (struct [OsalFirmware]($api-api-SmartVision-Devices-OsalFirmware.md) * fw, struct [OsalFwBlock]($api-api-SmartVision-Devices-OsalFwBlock.md) * block )
Description:
Releases a firmware file.
After the firmware file is read, this function is called to release the firmware file.
Parameters:
fw | Indicates the pointer to the firmware file OsalFirmware. |
Returns:
Returns a value listed below:
OsalRegisterIrq()
int32_t OsalRegisterIrq (uint32_t irqId, uint32_t config, [OsalIRQHandle]($api-api-SmartVision-Devices-OSAL.md#gab671a9e177f622a98af9ca1bd93198eb) handle, const char * name, void * dev )
Description:
Registers an IRQ.
Parameters:
irqId | Indicates the IRQ ID. |
config | Indicates the interrupt trigger mode. For details, see OSAL_IRQ_TRIGGER_MODE. |
handle | Indicates the interrupt processing function. |
name | Indicates the pointer to the device name for registering an IRQ. |
dev | Indicates the pointer to the parameter passed to the interrupt processing function. |
Returns:
Returns a value listed below:
OsalReleaseFirmware()
int32_t OsalReleaseFirmware (struct [OsalFirmware]($api-api-SmartVision-Devices-OsalFirmware.md) * fw)
Description:
Release firmware resource
Parameters:
fw Firmware parameter, see detail in OsalFirmware block Firmware data block, see detail in hdf_FWBlock |
Returns:
: true or false
OsalRequestFirmware()
int32_t OsalRequestFirmware (struct [OsalFirmware]($api-api-SmartVision-Devices-OsalFirmware.md) * fw, const char * fwName, void * device )
Description:
Requests a firmware file based on its name and device information.
Parameters:
fw | Indicates the pointer to the firmware file OsalFirmware, which cannot be empty. |
fwName | Indicates the pointer to the firmware file name, which cannot be empty. |
device | Indicates the pointer to the information about the device that requests the firmware file. |
Returns:
Returns a value listed below:
OsalSeekFirmware()
int32_t OsalSeekFirmware (struct [OsalFirmware]($api-api-SmartVision-Devices-OsalFirmware.md) * fw, uint32_t offset )
Description:
Reads a firmware file.
Parameters:
fw | Indicates the pointer to the firmware file OsalFirmware. |
block | Indicates the pointer to the firmware block to read. For details, see OsalFwBlock. |
Returns:
Returns a value listed below:
OsalSemDestroy()
int32_t OsalSemDestroy (struct [OsalSem]($api-api-SmartVision-Devices-OsalSem.md) * sem)
Description:
Destroys a semaphore.
Parameters:
sem | Indicates the pointer to the semaphore OsalSem. |
Returns:
Returns a value listed below:
Failed to invoke the system function to destroy the semaphore. |
|
OsalSemInit()
int32_t OsalSemInit (struct [OsalSem]($api-api-SmartVision-Devices-OsalSem.md) * sem, uint32_t value )
Description:
Initializes a semaphore.
Parameters:
sem | Indicates the pointer to the semaphore OsalSem. |
value | Indicates the initial value of the semaphore. |
Returns:
Returns a value listed below:
Failed to invoke the system function to initialize the semaphore. |
|
OsalSemPost()
int32_t OsalSemPost (struct [OsalSem]($api-api-SmartVision-Devices-OsalSem.md) * sem)
Description:
Releases a semaphore.
Parameters:
sem | Indicates the pointer to the semaphore OsalSem. |
Returns:
Returns a value listed below:
Failed to invoke the system function to release the semaphore. |
|
OsalSemWait()
int32_t OsalSemWait (struct [OsalSem]($api-api-SmartVision-Devices-OsalSem.md) * sem, uint32_t ms )
Description:
Waits for a semaphore.
Parameters:
sem | Indicates the pointer to the semaphore OsalSem. |
ms | Indicates the timeout interval. |
Returns:
Returns a value listed below:
Failed to invoke the system function to wait for the semaphore. |
|
OsalSleep()
void OsalSleep (uint32_t sec)
Description:
Describes thread sleep, in seconds.
When a thread invokes this function, the CPU is released and the thread enters the sleep state.
Parameters:
sec | Indicates the sleep time, in seconds. |
OsalSpinDestroy()
int32_t OsalSpinDestroy ([OsalSpinlock]($api-api-SmartVision-Devices-OsalSpinlock.md) * spinlock)
Description:
Destroys a spinlock.
Parameters:
spinlock | Indicates the pointer to the spinlock OsalSpinlock. |
Returns:
Returns a value listed below:
Failed to invoke the system function to destroy the spinlock. |
|
OsalSpinInit()
int32_t OsalSpinInit ([OsalSpinlock]($api-api-SmartVision-Devices-OsalSpinlock.md) * spinlock)
Description:
Initializes a spinlock.
Parameters:
spinlock | Indicates the pointer to the spinlock OsalSpinlock. |
Returns:
Returns a value listed below:
Failed to invoke the system function to initialize the spinlock. |
|
OsalSpinLock()
int32_t OsalSpinLock ([OsalSpinlock]($api-api-SmartVision-Devices-OsalSpinlock.md) * spinlock)
Description:
Obtains a spinlock.
Parameters:
spinlock | Indicates the pointer to the spinlock OsalSpinlock. |
Returns:
Returns a value listed below:
Failed to invoke the system function to obtain the spinlock. |
|
OsalSpinLockIrq()
int32_t OsalSpinLockIrq ([OsalSpinlock]($api-api-SmartVision-Devices-OsalSpinlock.md) * spinlock)
Description:
Obtains a spinlock and disables the IRQ.
Parameters:
spinlock | Indicates the pointer to the spinlock OsalSpinlock. |
Returns:
Returns a value listed below:
Failed to invoke the system function to obtain the spinlock. |
|
OsalSpinLockIrqSave()
int32_t OsalSpinLockIrqSave ([OsalSpinlock]($api-api-SmartVision-Devices-OsalSpinlock.md) * spinlock, uint32_t * flags )
Description:
Obtains a spinlock, disables the IRQ, and saves its status.
Parameters:
spinlock | Indicates the pointer to the spinlock OsalSpinlock. |
flags | Indicates the pointer to the status of the IRQ register. |
Returns:
Returns a value listed below:
Failed to invoke the system function to obtain the spinlock. |
|
OsalSpinUnlock()
int32_t OsalSpinUnlock ([OsalSpinlock]($api-api-SmartVision-Devices-OsalSpinlock.md) * spinlock)
Description:
Releases a spinlock.
Parameters:
spinlock | Indicates the pointer to the spinlock OsalSpinlock. |
Returns:
Returns a value listed below:
Failed to invoke the system function to release the spinlock. |
|
OsalSpinUnlockIrq()
int32_t OsalSpinUnlockIrq ([OsalSpinlock]($api-api-SmartVision-Devices-OsalSpinlock.md) * spinlock)
Description:
Releases a spinlock and enables the IRQ.
Parameters:
spinlock | Indicates the pointer to the spinlock OsalSpinlock. |
Returns:
Returns a value listed below:
Failed to invoke the system function to release the spinlock. |
|
OsalSpinUnlockIrqRestore()
int32_t OsalSpinUnlockIrqRestore ([OsalSpinlock]($api-api-SmartVision-Devices-OsalSpinlock.md) * spinlock, uint32_t * flags )
Description:
Releases a spinlock, enables the IRQ, and restores the saved IRQ status.
Parameters:
spinlock | Indicates the pointer to the spinlock OsalSpinlock. |
flags | Indicates the pointer to the value used to restore the IRQ register. |
Returns:
Returns a value listed below:
Failed to invoke the system function to release the spinlock. |
|
OsalTestBit()
int32_t OsalTestBit (unsigned long nr, const volatile unsigned long * addr )
Description:
Tests the value of a specified bit of a variable.
Parameters:
nr | Indicates the bit of the variable. The value ranges from 0 to 31. |
addr | Indicates the pointer to the variable. |
Returns:
Returns the bit value.
OsalTestClearBit()
int32_t OsalTestClearBit (unsigned long nr, volatile unsigned long * addr )
Description:
Clears the value of a specified bit of the variable and returns the bit value before clearing.
Parameters:
nr | Indicates the bit of the variable. The value ranges from 0 to 31. |
addr | Indicates the pointer to the variable. |
Returns:
Returns the bit value before the bit is cleared.
OsalTestSetBit()
int32_t OsalTestSetBit (unsigned long nr, volatile unsigned long * addr )
Description:
Sets the value of a specified bit of the variable and returns the bit value before the setting.
Parameters:
nr | Indicates the bit of the variable. The value ranges from 0 to 31. |
addr | Indicates the pointer to the variable. |
Returns:
Returns the bit value before the setting.
OsalThreadCreate()
int32_t OsalThreadCreate (struct [OsalThread]($api-api-SmartVision-Devices-OsalThread.md) * thread, [OsalThreadEntry]($api-api-SmartVision-Devices-OSAL.md#ga21ea0f87d53e65ec86a424c532d688d8) threadEntry, void * entryPara )
Description:
Creates a thread.
Parameters:
thread | Indicates the pointer to the thread OsalThread. |
threadEntry | Indicates the thread callback function OsalThreadEntry. |
entryPara | Indicates the pointer to the parameter passed to the thread callback function. |
Returns:
Returns a value listed below:
OsalThreadDestroy()
int32_t OsalThreadDestroy (struct [OsalThread]($api-api-SmartVision-Devices-OsalThread.md) * thread)
Description:
Destroys a thread.
Parameters:
thread | Indicates the pointer to the thread OsalThread. |
Returns:
Returns a value listed below:
OsalThreadResume()
int32_t OsalThreadResume (struct [OsalThread]($api-api-SmartVision-Devices-OsalThread.md) * thread)
Description:
Resumes a thread.
Parameters:
thread | Indicates the pointer to the thread OsalThread. |
Returns:
Returns a value listed below:
OsalThreadStart()
int32_t OsalThreadStart (struct [OsalThread]($api-api-SmartVision-Devices-OsalThread.md) * thread, const struct [OsalThreadParam]($api-api-SmartVision-Devices-OsalThreadParam.md) * param )
Description:
Starts a thread.
Parameters:
thread | Indicates the pointer to the thread OsalThread. |
param | Indicates the pointer to the parameter used to start a thread. For details, see OsalThreadParam. |
Returns:
Returns a value listed below:
OsalThreadSuspend()
int32_t OsalThreadSuspend (struct [OsalThread]($api-api-SmartVision-Devices-OsalThread.md) * thread)
Description:
Suspends a thread.
Parameters:
thread | Indicates the pointer to the thread OsalThread. |
Returns:
Returns a value listed below:
OsalTimerCreate()
int32_t OsalTimerCreate ([OsalTimer]($api-api-SmartVision-Devices-OsalTimer.md) * timer, uint32_t interval, [OsalTimerFunc]($api-api-SmartVision-Devices-OSAL.md#gaf3e7a12075b25df5971049d8cd77c25c) func, uintptr_t arg )
Description:
Creates a timer.
Parameters:
timer | Indicates the pointer to the timer OsalTimer. |
interval | Indicates the timer interval. |
func | Indicates the timer execution function OsalTimerFunc. |
arg | Indicates the argument passed to the timer execution function. |
Returns:
Returns a value listed below:
OsalTimerDelete()
int32_t OsalTimerDelete ([OsalTimer]($api-api-SmartVision-Devices-OsalTimer.md) * timer)
Description:
Deletes a timer.
Parameters:
timer | Indicates the pointer to the timer OsalTimer. |
Returns:
Returns a value listed below:
OsalTimerSetTimeout()
int32_t OsalTimerSetTimeout ([OsalTimer]($api-api-SmartVision-Devices-OsalTimer.md) * timer, uint32_t interval )
Description:
Sets the interval of a timer.
Parameters:
timer | Indicates the pointer to the timer OsalTimer. |
interval | Indicates the timer interval, in milliseconds. |
Returns:
Returns a value listed below:
OsalTimerStartLoop()
int32_t OsalTimerStartLoop ([OsalTimer]($api-api-SmartVision-Devices-OsalTimer.md) * timer)
Description:
Starts a periodic timer.
Parameters:
timer | Indicates the pointer to the timer OsalTimer. |
interval | Indicates the timer interval, in milliseconds. |
Returns:
Returns a value listed below:
OsalTimerStartOnce()
int32_t OsalTimerStartOnce ([OsalTimer]($api-api-SmartVision-Devices-OsalTimer.md) * timer)
Description:
Starts a timer.
Parameters:
timer | Indicates the pointer to the timer OsalTimer. |
Returns:
Returns a value listed below:
OsalUDelay()
void OsalUDelay (uint32_t us)
Description:
Describes thread delay, in microseconds.
When a thread invokes this function, the CPU is not released. This function returns after waiting for microseconds.
Parameters:
us | Indicates the delay time, in microseconds. |
OsalUnregisterIrq()
int32_t OsalUnregisterIrq (uint32_t irqId)
Description:
Unregisters an IRQ.
Parameters:
irqId | Indicates the IRQ ID. |
Returns:
Returns a value listed below: