Files
kunlun/export/inc/os_shim/os_lock_api.h
2024-09-28 14:24:04 +08:00

145 lines
4.0 KiB
C
Executable File

/****************************************************************************
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
be copied by any method or incorporated into another program without
the express written consent of Aerospace C.Power. This Information or any portion
thereof remains the property of Aerospace C.Power. The Information contained herein
is believed to be accurate and Aerospace C.Power assumes no responsibility or
liability for its use in any way and conveys no license or title under
any patent or copyright and makes no representation or warranty that this
Information is free from patent or copyright infringement.
****************************************************************************/
#ifndef OS_SHIM_LOCK_API_H
#define OS_SHIM_LOCK_API_H
/* os shim includes */
#include "os_types_api.h"
/* common includes */
#include "iot_module_api.h"
#ifdef __cplusplus
extern "C" {
#endif
/** \defgroup OS_APIs PLC OS APIs
* @brief WQ30x1 PLC OS APIs
*/
/** @addtogroup OS_APIs
* @{
*/
/** \defgroup OS_MUTEX_APIs PLC OS LOCK APIs
* @brief PLC OS MUTEX
*
* OS MUTEX API for customer application.
*/
/** @addtogroup OS_MUTEX_APIs
* @{
*/
/* mutex handle definition */
typedef void *os_mutex_h;
/* sempahore handle definition */
typedef void *os_sem_h;
/**
* @brief os_create_mutex() - create a mutex.
* @param module_id: the module that creates the event.
*
* @return NULL -- for failure case
* @return otherwise -- mutex handle
*/
os_mutex_h os_create_mutex(module_id_t module_id);
/**
* @brief os_acquire_mutex() - acquire a mutex. This function can be called
* recursively from one task. For each call, a corresponding release call is
* required to release the mutex. This function can NOT be called in ISR context.
* @param mutex: mutex to be acquired
*/
void os_acquire_mutex(os_mutex_h mutex);
/**
* @brief os_try_acquire_mutex() - try to acquire a mutex. This function is
* not blocking when called. This function can NOT be called in ISR context.
* @param mutex: mutex to be acquired
* @return true -- acquire mutex successfully.
* false -- failed.
*/
bool_t os_try_acquire_mutex(os_mutex_h mutex);
/**
* @brief os_release_mutex() - release a mutex This function can NOT be called
* in ISR context.
* @param mutex: mutex to be released
*/
void os_release_mutex(os_mutex_h mutex);
/**
* @brief os_delete_mutex() - delete a mutex
* @param mutex: mutex to be deleted
*/
void os_delete_mutex(os_mutex_h mutex);
/**
* @brief os_create_sem() - create a count semaphore.
* @param module_id: the module that creates the semaphore.
* @param max_count: max count for this semaphore.
* @param init_count: init count for this semaphore.
*
* @return NULL -- for failure case
* @return otherwise -- semaphore handle
*/
os_sem_h os_create_sem(module_id_t module_id, uint32_t max_count,
uint32_t init_count);
/**
* @brief os_pend_sem() - pend to take a semaphore.
* This function can NOT be called in ISR context.
* @param semaphore: semaphore to be take.
* @param timeout: timeout time(ms).
* @return true -- take semaphore successfully.
* false -- timeout.
*/
bool_t os_pend_sem(os_sem_h semaphore, uint32_t timeout);
/**
* @brief os_post_sem() - post a semaphore.
* This function can NOT be called in ISR context.
* @param semaphore: semaphore to be posted.
* @return true -- post semaphore successfully.
* false -- failed.
*/
bool_t os_post_sem(os_sem_h semaphore);
/**
* @brief os_delete_sem() - delete a semaphore.
* @param semaphore: semaphore to be deleted
*/
void os_delete_sem(os_sem_h semaphore);
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* OS_SHIM_LOCK_API_H */