Files
kunlun/driver/extern/virtualchannel/inc/vc_task.h
2024-09-28 14:24:04 +08:00

119 lines
3.8 KiB
C

/****************************************************************************
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 _VC_TASK__H_
#define _VC_TASK__H_
#include "vc_task_api.h"
#define VC_TASK_MODULE_ID 0
#ifdef LOCAL
#undef LOCAL
#endif
#define LOCAL static
/* define uart baudrate for vc task */
#define VC_TASK_UART_BAUDRATE 230400
#define VC_TASK_UART_PARITY 0
#define VC_TASK_UART_DATA_LEN 8
#define VC_TASK_UART_STOP_BIT 1
/**
* @brief vc_chn_valid - Check channel if valid.
* @param ch: Channel number to check.
* @return true -- Valid.
* @return false -- Invalid.
*/
#define vc_chn_valid(ch) ((uint32_t)(ch) < VC_CHNID_MAX ? true : false)
/**
* @brief vc_get_chn_bitmap - Set related bit as '1' with the channel number.
* @param ch: Channel number to set.
* @return Bitmap of this channel.
*/
#define vc_get_chn_bitmap(ch) ((vc_chn_valid(ch)) ? (1 << (ch)) : 0)
/**
* @brief vc_drv_id_valid - Check driver if valid.
* @param ch: Driver id to check.
* @return true -- Valid.
* @return false -- Invalid.
*/
#define vc_drv_id_valid(drv) ((uint32_t)(drv) < VC_DRVID_MAX ? true : false)
/**
* @brief VC_CMD_CHNID - Channel No. of inner command used.
*/
#define VC_CMD_CHNID VC_CHNID_0
/**
* @brief VC_CMD_DRV - Driver No. of inner command used.
*/
#define VC_CMD_DRV VC_DRVID_UART
/**
* @brief VC_TASK_SHARE_TIMER_COUNT - Number of share timer.
*/
#define VC_TASK_SHARE_TIMER_COUNT 3
/**
* @brief VC_TASK_SHARE_TIMER_STEP - The least timeout time the share timer takes.
*/
#define VC_TASK_SHARE_TIMER_STEP 100
/**
* @brief vc_module_share_timer_func - Share timer callback funcfion.
* @param delta_time: Delta timer in micro-seconds from last calling to this.
*/
typedef void (*vc_module_share_timer_func)(uint32_t delta_time);
/**
* @brief vc_module_share_timer_register - To register a share timer.
* @param fn: Ref to vc_module_share_timer_func.
* @param time_out: timeout time in n * VC_TASK_SHARE_TIMER_STEP micro-seconds.
* @return ERR_FAIL -- Operation failed.
* @return ERR_OK -- Operation Successful.
*/
uint32_t vc_module_share_timer_register(vc_module_share_timer_func fn,
uint32_t time_out);
/**
* @brief vc_upg_rcv_func - Function pointer to get received data while upgrading.
* @param p_buf: Pointer of a buffer holding data received.
* @param len: Length of buffer.
* @return Bytes of data that confirmed by this function.
*/
typedef uint32_t (*vc_upg_rcv_func)(uint8_t *p_buf, uint32_t len);
/**
* @brief vc_module_upgrade_register_receive - To register upgrading receive function.
* @param func: Ref to vc_upg_rcv_func.
* @return ERR_FAIL -- Operation failed.
* @return ERR_OK -- Operation Successful.
*/
uint32_t vc_module_upgrade_register_receive(vc_upg_rcv_func fn);
/**
* @brief vc_module_response_send_to_K68 - Send response to K68.
* @param p_ack: Response to send.
* @return ERR_FAIL -- Operation failed.
* @return ERR_OK -- Operation Successful.
*/
uint32_t vc_module_response_send_to_K68(vc_ack_t *p_ack);
#endif /* _VC_TASK__H_ */