SemiDrive SSDK Appication Program Interface PTG3.0
Functions
sdrv_semag.h File Reference
#include <sdrv_common.h>
#include <types.h>

Go to the source code of this file.

Functions

status_t sdrv_semag_trylock (uint32_t gate_idx)
 
status_t sdrv_semag_lock (uint32_t gate_idx)
 
status_t sdrv_semag_unlock (uint32_t gate_idx)
 
int32_t sdrv_semag_get_lock_proc (uint32_t gate_idx)
 
status_t sdrv_semag_reset_all_gate (void)
 
status_t sdrv_semag_enable_gate_notify_interrupt (uint32_t mask)
 
status_t sdrv_semag_disable_gate_notify_interrupt (uint32_t mask)
 
uint32_t sdrv_semag_get_notify_status (void)
 
status_t sdrv_semag_clear_notify_status (uint32_t mask)
 

Detailed Description

User should initialize mbox module before using semag driver.

Macro Definition Documentation

◆ SDRV_SEMAG_NUM

#define SDRV_SEMAG_NUM   (32UL)

◆ SDRV_SEMAG_PROCESSOR_NUM

#define SDRV_SEMAG_PROCESSOR_NUM   (8UL)

Function Documentation

◆ sdrv_semag_clear_notify_status()

status_t sdrv_semag_clear_notify_status ( uint32_t  mask)

Clear the gate notification interrupt status.

This function clear SEMAG gate IRQ notifications.

Parameters
[in]maskMask of the gate index, for example: (1<<0U) | (1<<1U) means gate 0 and gate 1.
Returns
SDRV_STATUS_OK Clear the notify interrupt status of the semag gate successfully.

◆ sdrv_semag_disable_gate_notify_interrupt()

status_t sdrv_semag_disable_gate_notify_interrupt ( uint32_t  mask)

Disable the gate notification interrupt.

Gate notification provides such feature, when interrupt is enabled, then core tried to lock the gate and failed, it could get notification when the gate is idle.

Parameters
[in]maskMask of the gate index, for example: (1<<0U) | (1<<1U) means gate 0 and gate 1.
Returns
SDRV_STATUS_OK Disable the notify interrupt of the semag gate successfully.

◆ sdrv_semag_enable_gate_notify_interrupt()

status_t sdrv_semag_enable_gate_notify_interrupt ( uint32_t  mask)

Enable the gate notification interrupt.

Gate notification provides such feature, when interrupt is enabled, then core tried to lock the gate and failed, it could get notification when the gate is idle.

Parameters
[in]maskMask of the gate index, for example: (1<<0U) | (1<<1U) means gate 0 and gate 1.
Returns
SDRV_STATUS_OK Enable the notify interrupt of the semag gate successfully.

◆ sdrv_semag_get_lock_proc()

int32_t sdrv_semag_get_lock_proc ( uint32_t  gate_idx)

Gets the status of the SEMAG gate.

This function checks the lock status of a specific SEMAG gate.

Parameters
[in]gate_idxGate number to check lock status.
Returns
Return -1 if the gate is unlocked, otherwise return the processor number which has locked the gate.

◆ sdrv_semag_get_notify_status()

uint32_t sdrv_semag_get_notify_status ( void  )

Get the gate notification flags.

Gate notification provides such feature, when interrupt is enabled, then core tried to lock the gate and failed, it could get notification when the gate is idle.

Returns
Mask of the gate index, for example: (1<<0U) | (1<<1U) means gate 0 and gate 1 flags are pending.

◆ sdrv_semag_lock()

status_t sdrv_semag_lock ( uint32_t  gate_idx)

Locks the SEMAG gate.

This function locks the specific SEMAG gate. If the gate has been locked by other processors, this function waits until it is unlocked and then lock it.

Parameters
[in]gate_idxGate number to lock.
Returns
SDRV_STATUS_INVALID_PARAM The gate id is unvalid. SDRV_STATUS_OK Lock the semag gate successfully.

◆ sdrv_semag_reset_all_gate()

status_t sdrv_semag_reset_all_gate ( void  )

Resets all SEMAG gates to an unlocked status.

This function resets all SEMAG gate to an unlocked status, it will only unlock gates which locked by itself, can't reset gates which locked by other processors.

Returns
SDRV_STATUS_OK Reset all semag gates successfully.

◆ sdrv_semag_trylock()

status_t sdrv_semag_trylock ( uint32_t  gate_idx)

Tries to lock the SEMAG gate.

This function tries to lock the specific SEMAG gate. If the gate has been locked by another processor, this function returns an error code.

Parameters
[in]gate_idxGate number to lock.
Returns
SDRV_STATUS_INVALID_PARAM The gate id is unvalid. SDRV_STATUS_FAIL Semag gate has been locked by another processor. SDRV_STATUS_OK Lock the semag gate successfully.

◆ sdrv_semag_unlock()

status_t sdrv_semag_unlock ( uint32_t  gate_idx)

Unlocks the SEMAG gate.

This function unlocks the specific SEMAG gate. It only writes unlock value to the SEMAG gate register. However, it does not check whether the SEMAG gate is locked by the current processor or not. As a result, if the SEMAG gate is not locked by the current processor, this function has no effect.

Parameters
[in]gate_idxGate number to unlock.
Returns
SDRV_STATUS_OK Unlock the semag gate successfully.