Functions are used in the driver.
◆ Cy_IPC_Sema_Init()
This function initializes the semaphores subsystem.
The user must create an array of unsigned 32-bit words to hold the semaphore bits. The number of semaphores will be the size of the array * 32. The total semaphores count will always be a multiple of 32.
- Note
- In a multi-CPU system this init function should be called with all initialized parameters on one CPU only to provide a pointer to SRAM that can be shared between all the CPUs in the system that will use semaphores. On other CPUs user must specify the IPC semaphores channel and pass 0 / NULL to count and memPtr parameters correspondingly.
CM7 cores in CAT1C devices support Data Cache. Data Cache line is 32 bytes. User needs to make sure that the memPtr pointer passed to the Cy_IPC_Sema_Init function points to 32 byte aligned array of words that contain the semaphore data. User can use CY_ALIGN(32) macro for 32 byte alignment.
- Parameters
-
ipcChannel | The IPC channel number used for semaphores |
count | The maximum number of semaphores to be supported (multiple of 32). |
memPtr | This points to the array of (count/32) words that contain the semaphore data. |
- Returns
- Status of the operation
- Return values
-
CY_IPC_SEMA_SUCCESS | Successfully initialized |
CY_IPC_SEMA_BAD_PARAM | Memory pointer is NULL and count is not zero, or count not multiple of 32 |
CY_IPC_SEMA_ERROR_LOCKED | Could not acquire semaphores IPC channel |
- Function Usage
#ifndef MY_IPC_CHAN_INDEX
#define MY_IPC_CHAN_INDEX (8UL)
#endif
#if (CY_CPU_CORTEX_M0P)
uint32_t mySemaData;
{
}
#else
{
}
#endif
◆ Cy_IPC_Sema_InitExt()
This function initializes the semaphores subsystem.
The user must create an array of unsigned 32-bit words to hold the semaphore bits. The number of semaphores will be the size of the array * 32. The total semaphores count will always be a multiple of 32.
- Note
- In a multi-CPU system this init function should be called with all initialized parameters on one CPU only to provide a pointer to SRAM that can be shared between all the CPUs in the system that will use semaphores. On other CPUs user must specify the IPC semaphores channel and pass 0 / NULL to count and memPtr parameters correspondingly.
- Parameters
-
ipcChannel | The IPC channel number used for semaphores |
ipcSema | This is configuration structure of the IPC semaphore. See cy_stc_ipc_sema_t. |
- Returns
- Status of the operation
- Return values
-
CY_IPC_SEMA_SUCCESS | Successfully initialized |
CY_IPC_SEMA_BAD_PARAM | Memory pointer is NULL and count is not zero, or count not multiple of 32 |
CY_IPC_SEMA_ERROR_LOCKED | Could not acquire semaphores IPC channel |
◆ Cy_IPC_Sema_Set()
This function tries to acquire a semaphore.
If the semaphore is not available, this function returns immediately with CY_IPC_SEMA_LOCKED.
It first acquires the IPC channel that is used for all the semaphores, sets the semaphore if it is cleared, then releases the IPC channel used for the semaphore.
- Parameters
-
semaNumber | The semaphore number to acquire. |
- Note
- CAT1D has two shared memories. One is a secure memory area which is accessible from secure domains only. Another memory area which is accessible from both secure and non-secure domains. To use secure area for semaphore, user has to use CY_IPC_SEMA_SEC macro to create a secure semaphore.
- Parameters
-
preemptable | When this parameter is enabled the function can be preempted by another task or other forms of context switching in an RTOS environment. |
- Note
- If preemptable is enabled (true), the user must ensure that there are no deadlocks in the system, which can be caused by an interrupt that occurs after the IPC channel is locked. Unless the user is ready to handle IPC channel locks correctly at the application level, set preemptable to false.
- Returns
- Status of the operation
- Return values
-
CY_IPC_SEMA_SUCCESS | The semaphore was set successfully |
CY_IPC_SEMA_LOCKED | The semaphore channel is busy or locked by another process |
CY_IPC_SEMA_NOT_ACQUIRED | Semaphore was already set |
CY_IPC_SEMA_OUT_OF_RANGE | The semaphore number is not valid |
- Function Usage
#define MY_SEMA_NUM (3UL)
{
break;
break;
break;
break;
default: break;
}
check cy_semaIpcStruct != NULL
◆ Cy_IPC_Sema_Clear()
This functions tries to releases a semaphore.
It first acquires the IPC channel that is used for all the semaphores, clears the semaphore if it is set, then releases the IPC channel used for the semaphores.
- Parameters
-
semaNumber | The index of the semaphore to release. |
- Note
- CAT1D has two shared memories. One is a secure memory area which is accessible from secure domains only. Another memory area which is accessible from both secure and non-secure domains. To use secure area for semaphore, user has to use CY_IPC_SEMA_SEC macro to create a secure semaphore.
- Parameters
-
preemptable | When this parameter is enabled the function can be preempted by another task or other forms of context switching in an RTOS environment. |
- Note
- If preemptable is enabled (true), the user must ensure that there are no deadlocks in the system, which can be caused by an interrupt that occurs after the IPC channel is locked. Unless the user is ready to handle IPC channel locks correctly at the application level, set preemptable to false.
- Returns
- Status of the operation
- Return values
-
CY_IPC_SEMA_SUCCESS | The semaphore was cleared successfully |
CY_IPC_SEMA_NOT_ACQUIRED | The semaphore was already cleared |
CY_IPC_SEMA_LOCKED | The semaphore channel was semaphored or busy |
CY_IPC_SEMA_OUT_OF_RANGE | The semaphore number is not valid |
- Function Usage
#define MY_SEMA_NUM (3UL)
{
break;
break;
break;
break;
default: break;
}
check cy_semaIpcStruct != NULL
◆ Cy_IPC_Sema_Status()
This function returns the status of the semaphore.
- Parameters
-
semaNumber | The index of the semaphore to return status. |
- Note
- CAT1D has two shared memories. One is a secure memory area which is accessible from secure domains only. Another memory area which is accessible from both secure and non-secure domains. To use secure area for semaphore, user has to use CY_IPC_SEMA_SEC macro to create a secure semaphore.
- Returns
- Status of the operation
- Return values
-
CY_IPC_SEMA_STATUS_LOCKED | The semaphore is in the set state. |
CY_IPC_SEMA_STATUS_UNLOCKED | The semaphore is in the cleared state. |
CY_IPC_SEMA_OUT_OF_RANGE | The semaphore number is not valid |
- Function Usage
#define MY_SEMA_NUM (3UL)
{
break;
break;
break;
default: break;
}
check cy_semaIpcStruct != NULL
◆ Cy_IPC_Sema_GetMaxSems()
uint32_t Cy_IPC_Sema_GetMaxSems |
( |
void |
| ) |
|
This function returns the number of semaphores in the semaphores subsystem.
- Returns
- Returns the semaphores quantity.
- Function Usage
#define MY_SEMA_NUM (3UL)
{
}