168 lines
5.1 KiB
C
168 lines
5.1 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 _MAC_ZC_HW_H_
|
|
#define _MAC_ZC_HW_H_
|
|
|
|
#include "os_types.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
* mac zc system connect relationship.
|
|
* board_hw -> GPIO -> signal(cap. zc module)
|
|
*/
|
|
/* mac zc hw signal id module define */
|
|
#define MAC_ZC_HW_SIG0_ID 47
|
|
#define MAC_ZC_HW_SIG1_ID 48
|
|
#define MAC_ZC_HW_SIG2_ID 49
|
|
#define MAC_ZC_HW_SIG3_ID 50
|
|
#define MAC_ZC_HW_SIG4_ID 51
|
|
#define MAC_ZC_HW_SIG5_ID 52
|
|
|
|
/* mac zc hw capture module define */
|
|
#define MAC_ZC_HW_CAP0 0
|
|
#define MAC_ZC_HW_CAP1 1
|
|
#define MAC_ZC_HW_CAP2 2
|
|
#define MAC_ZC_HW_CAP3 3
|
|
#define MAC_ZC_HW_CAP4 4
|
|
#define MAC_ZC_HW_CAP5 5
|
|
#define MAC_ZC_HW_CAP_CNT 6
|
|
|
|
/* mac zc hw capture fifo buffer depth */
|
|
#define MAC_ZC_HW_CAP_BUF_DEPTH 8
|
|
|
|
/* mac zc hw set capture edge */
|
|
#define MAC_ZC_HW_CAP_EDGE_RISE 0
|
|
#define MAC_ZC_HW_CAP_EDGE_FALL 1
|
|
|
|
/* mac zc hw filter pulse low count num, unit:1/75us */
|
|
#define MAC_ZC_HW_FILTER_LOW_CNT 200
|
|
|
|
/* mac zc hw filter pulse high count num, unit:1/75us */
|
|
#define MAC_ZC_HW_FILTER_HIGH_CNT 200
|
|
|
|
/*
|
|
* @brief enable/disable zc hw captures
|
|
*
|
|
* @param cap_id: see MAC_ZC_HW_CAPx
|
|
* @param is_ena: 0 : disable this capture hw
|
|
* others: enable this capture hw
|
|
* @retval: none
|
|
*/
|
|
void mac_zc_hw_cap_enable_set(uint8_t cap_id, uint8_t is_ena);
|
|
|
|
/*
|
|
* @brief generate a zc interrupt when every N successful ZC sample
|
|
*
|
|
* @param cap_id: see MAC_ZC_HW_CAPx
|
|
* @param num: every N successful ZC sample
|
|
* @retval: none
|
|
*/
|
|
void mac_zc_hw_cap_intr_num_set(uint8_t cap_id, uint8_t num);
|
|
|
|
/*
|
|
* @brief sample a zc point in every N ZC period.
|
|
*
|
|
* @param cap_id: see MAC_ZC_HW_CAPx
|
|
* @param num: every N period
|
|
* @retval: none
|
|
*/
|
|
void mac_zc_hw_cap_sample_num_set(uint8_t cap_id, uint8_t num);
|
|
|
|
/*
|
|
* @brief config zc fifo save capture data point.
|
|
*
|
|
* @param cap_id: see MAC_ZC_HW_CAPx
|
|
* @param in_sel: 0 - sample first point
|
|
* 1 - sample firset point + SOLID_TIME
|
|
* @retval: none
|
|
*/
|
|
void mac_zc_hw_cap_in_sel_set(uint8_t cap_id, uint8_t in_sel);
|
|
|
|
/*
|
|
* @brief config hw sample input signal rise or fall edge.
|
|
*
|
|
* @param cap_id: see MAC_ZC_HW_CAPx
|
|
* @param is_fall_edge: 0 - rise edge, 1 - fall edge
|
|
* @retval: none
|
|
*/
|
|
void mac_zc_hw_cap_edge_set(uint8_t cap_id, uint8_t is_fall_edge);
|
|
|
|
/*
|
|
* @brief config hw filter parameters.
|
|
*
|
|
* @param cap_id: see MAC_ZC_HW_CAPx
|
|
* @param high: high level filter paramter. see MAC_ZC_HW_FILTER_HIGH_CNT
|
|
* @param low: low level filter paramter. see MAC_ZC_HW_FILTER_LOW_CNT
|
|
* @retval: none
|
|
*/
|
|
void mac_zc_hw_cap_filter_set(uint8_t cap_id, uint16_t high, uint16_t low);
|
|
|
|
/*
|
|
* @brief get hw capture fifo valid data count
|
|
*
|
|
* @param cap_id: see MAC_ZC_HW_CAPx
|
|
* @param ntb_num: ntb fifo valid data number
|
|
* @param ntb_num: local fifo valid data number
|
|
* @retval: none
|
|
*/
|
|
void mac_zc_hw_cap_data_num_get(uint32_t cap_id, uint8_t *ntb_num,
|
|
uint8_t *lts_num);
|
|
|
|
/*
|
|
* @brief read hw capture ntb fifo data
|
|
*
|
|
* @param cap_id: see MAC_ZC_HW_CAPx
|
|
* @param num: expected get data num
|
|
* @param buf: save data buffer
|
|
* @retval: actual read data count
|
|
*/
|
|
uint8_t mac_zc_hw_cap_ntb_read(uint8_t cap_id, uint8_t num,
|
|
uint32_t *buf);
|
|
|
|
/*
|
|
* @brief read hw capture local fifo data
|
|
*
|
|
* @param cap_id: see MAC_ZC_HW_CAPx
|
|
* @param num: expected get data num
|
|
* @param buf: save data buffer
|
|
* @retval: actual read data count
|
|
*/
|
|
uint8_t mac_zc_hw_cap_lts_read(uint8_t cap_id, uint8_t num,
|
|
uint32_t *buf);
|
|
|
|
/*
|
|
* @brief clear hw capture buffer data
|
|
*
|
|
* @param cap_id: see MAC_ZC_HW_CAPx
|
|
* @retval: none
|
|
*/
|
|
void mac_zc_hw_cap_data_clr(uint8_t cap_id);
|
|
|
|
/*
|
|
* @brief zc hw init
|
|
* @param is_half_collect: is half collect
|
|
* @param cap_edge: hw cap edge, see MAC_ZC_HW_CAP_EDGE_XXX
|
|
* @retval: none
|
|
*/
|
|
void mac_zc_hw_init(uint8_t is_half_collect, uint8_t cap_edge);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif //_MAC_ZC_HW_H_
|