121 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			121 lines
		
	
	
		
			3.5 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_TIMER_API_H
 | 
						|
#define OS_SHIM_TIMER_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_TIMER_APIs PLC OS TIMER APIs
 | 
						|
  * @brief PLC OS TIMER
 | 
						|
  *
 | 
						|
  * OS Timer helper functions. Application can use for their own timers
 | 
						|
  *
 | 
						|
  */
 | 
						|
 | 
						|
/** @addtogroup OS_TIMER_APIs
 | 
						|
  * @{
 | 
						|
  */
 | 
						|
 | 
						|
typedef uint32_t timer_id_t;
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief void(*os_timer_func_t)() - define timer callback function pointer type.
 | 
						|
 * @param timer_id:             timer_id of the timer related with this callback method.
 | 
						|
 * @param arg:                  arg for the callback passed in os_timer_create.
 | 
						|
 */
 | 
						|
typedef void(*os_timer_func_t)(timer_id_t timer_id, void * arg);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief os_create_timer() - create a timer
 | 
						|
 * @param module_id:            id of module that the timer belongs to.
 | 
						|
 * @param auto_reload:          parameter passed to the function call.
 | 
						|
 * @param cb:                   callback method of the timer.
 | 
						|
 * @param arg:                  argument for the callback method.
 | 
						|
 *
 | 
						|
 * @return                      0 -- for failure case
 | 
						|
 * @return                      otherwise -- timer id
 | 
						|
 */
 | 
						|
timer_id_t os_create_timer(module_id_t module_id,
 | 
						|
                           bool_t auto_reload,
 | 
						|
                           os_timer_func_t cb,
 | 
						|
                           void* arg);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief os_start_timer() - start a timer. This method should not be called in ISR.
 | 
						|
 * @param id:                   id of the timer to be started.
 | 
						|
 * @param period:               time period of the timer in milliseconds.
 | 
						|
 */
 | 
						|
void os_start_timer(timer_id_t id, uint32_t period);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief os_stop_timer() - stop a timer. This method should not be called in ISR.
 | 
						|
 * @param id:                   id of the timer to be stopped.
 | 
						|
 */
 | 
						|
void os_stop_timer(timer_id_t id);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief os_reset_timer() - reset a timer. This method should not be called in ISR.
 | 
						|
 * @param id:                   id of the timer to be checked.
 | 
						|
 */
 | 
						|
void os_reset_timer(timer_id_t id);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief os_delete_timer() - delete a timer.
 | 
						|
 * @param id:                   id of the timer to be deleted.
 | 
						|
 */
 | 
						|
void os_delete_timer(timer_id_t id);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief os_is_timer_active() - check if timer is active. Active means if
 | 
						|
 * started AND callback will be called later
 | 
						|
 * @param id:                   id of the timer to be reset
 | 
						|
 *
 | 
						|
 * @return                      0 -- if the timer is not active
 | 
						|
 * @return                      1 -- if the timer is active
 | 
						|
 */
 | 
						|
uint32_t os_is_timer_active(timer_id_t id);
 | 
						|
 | 
						|
/**
 | 
						|
  * @}
 | 
						|
  */
 | 
						|
 | 
						|
/**
 | 
						|
  * @}
 | 
						|
  */
 | 
						|
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
}
 | 
						|
#endif
 | 
						|
 | 
						|
#endif /* OS_SHIM_TIMER_API_H */ |