138 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			138 lines
		
	
	
		
			3.9 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 IOT_DBGLOG_API_H
 | 
						|
#define IOT_DBGLOG_API_H
 | 
						|
 | 
						|
#include "iot_config_api.h"
 | 
						|
#include "iot_dbglog_parser_api.h"
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
extern "C" {
 | 
						|
#endif
 | 
						|
 | 
						|
/** \defgroup DBGLOG_APIs DEBUGLOG APIs
 | 
						|
  * @brief WQ30x1 DEBUGLOG APIs
 | 
						|
  *
 | 
						|
  * APIs to control, ouput debug messages through vairous physical interfaces.
 | 
						|
  * case1: cco/sta output by local uart port.
 | 
						|
  * case2: sta deliver through powerline to cco,and cco help to print with
 | 
						|
  * uart to host
 | 
						|
  *
 | 
						|
  * TODO: need add API to config output level, and output physcial interface.
 | 
						|
  */
 | 
						|
 | 
						|
/** @addtogroup DBGLOG_APIs
 | 
						|
  * @{
 | 
						|
  */
 | 
						|
 | 
						|
#if (HW_PLATFORM == HW_PLATFORM_SIMU)
 | 
						|
 | 
						|
/** define minimum debug log level supported in compilation stage */
 | 
						|
#define DBG_LOG_MINIMUM_LEVEL   DBGLOG_INFO_LVL_2
 | 
						|
 | 
						|
#else /* HW_PLATFORM == HW_PLATFORM_SIMU || IOT_FLASH_SIZE > 2 */
 | 
						|
 | 
						|
#define DBG_LOG_MINIMUM_LEVEL   DBGLOG_ERR
 | 
						|
 | 
						|
#endif /* HW_PLATFORM == HW_PLATFORM_SIMU || IOT_FLASH_SIZE > 2 */
 | 
						|
 | 
						|
typedef enum {
 | 
						|
    DBGLOG_VERBOSE = 1,
 | 
						|
    DBGLOG_INFO,
 | 
						|
    DBGLOG_INFO_LVL_1,
 | 
						|
    DBGLOG_INFO_LVL_2,
 | 
						|
    DBGLOG_WARN,
 | 
						|
    DBGLOG_ERR,
 | 
						|
    DBGLOG_LVL_MAX
 | 
						|
} DBGLOG_LOG_LVL;
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief iot_dbglog_input() - input debug log
 | 
						|
 * @param mod_id:              module id
 | 
						|
 * @param log_lvl:             log level
 | 
						|
 * @param msg_id:              messgage id
 | 
						|
 * @param arg_cnt:             arg count
 | 
						|
 *
 | 
						|
 * @return 0 -- for success case
 | 
						|
 * @return ERR_INVAL -- for failure case
 | 
						|
 */
 | 
						|
#if IOT_DBGLOG_DEBUG_DISABLE
 | 
						|
 | 
						|
#define iot_dbglog_input(mod_id, log_lvl, msg_id, arg_cnt, ...) \
 | 
						|
    do { \
 | 
						|
        (void)mod_id; \
 | 
						|
        (void)log_lvl; \
 | 
						|
        (void)msg_id; \
 | 
						|
        (void)arg_cnt; \
 | 
						|
    } while(0)
 | 
						|
 | 
						|
#else /* IOT_DBGLOG_DEBUG_DISABLE */
 | 
						|
 | 
						|
#if IOT_FLASH_SIZE > 2
 | 
						|
 | 
						|
int32_t iot_dbglog_input_ex(uint16_t mod_id,
 | 
						|
    uint8_t log_lvl, uint16_t msg_id, uint8_t arg_cnt, ...);
 | 
						|
 | 
						|
#define iot_dbglog_input(mod_id, log_lvl, msg_id, arg_cnt, ...) \
 | 
						|
    do { \
 | 
						|
        (void)mod_id; \
 | 
						|
        (void)log_lvl; \
 | 
						|
        (void)msg_id; \
 | 
						|
        (void)arg_cnt; \
 | 
						|
        if (log_lvl >= DBG_LOG_MINIMUM_LEVEL) { \
 | 
						|
            iot_dbglog_input_ex(mod_id, log_lvl, msg_id, \
 | 
						|
                arg_cnt, ##__VA_ARGS__); \
 | 
						|
        }; \
 | 
						|
    } while(0)
 | 
						|
 | 
						|
#else /* IOT_FLASH_SIZE > 2 */
 | 
						|
 | 
						|
int32_t iot_dbglog_input_ex(uint16_t mod_id,
 | 
						|
    uint16_t msg_id, uint8_t arg_cnt, ...);
 | 
						|
 | 
						|
#define iot_dbglog_input(mod_id, log_lvl, msg_id, arg_cnt, ...) \
 | 
						|
    do { \
 | 
						|
        (void)mod_id; \
 | 
						|
        (void)log_lvl; \
 | 
						|
        (void)msg_id; \
 | 
						|
        (void)arg_cnt; \
 | 
						|
        if (log_lvl >= DBG_LOG_MINIMUM_LEVEL) { \
 | 
						|
            iot_dbglog_input_ex(mod_id, msg_id, \
 | 
						|
                arg_cnt, ##__VA_ARGS__); \
 | 
						|
        }; \
 | 
						|
    } while(0)
 | 
						|
 | 
						|
#endif /* IOT_FLASH_SIZE > 2 */
 | 
						|
 | 
						|
#endif /* IOT_DBGLOG_DEBUG_DISABLE */
 | 
						|
 | 
						|
/**
 | 
						|
* @brief iot_crash_dbglog_input() - input crash debug log, will write to flash
 | 
						|
* directly
 | 
						|
* @param mod_id:              module id
 | 
						|
* @param msg_id:              messgage id
 | 
						|
* @param buffer:              raw log
 | 
						|
* @param buffer_len:          log len
 | 
						|
*/
 | 
						|
void iot_crash_dbglog_input(uint16_t mod_id, uint16_t msg_id,
 | 
						|
    uint8_t* data, uint32_t datalen);
 | 
						|
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
}
 | 
						|
#endif
 | 
						|
 | 
						|
#endif // !IOT_DBGLOG_API_H
 |