81 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			81 lines
		
	
	
		
			2.7 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
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								//TODO: need move some code to mac_zc_hw_cmn.h/c
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * mac zc system connect relationship.
							 | 
						||
| 
								 | 
							
								 * board_hw -> GPIO -> signal -> detect -> cap -> zc_gen_module
							 | 
						||
| 
								 | 
							
								 * For example:
							 | 
						||
| 
								 | 
							
								 * board_hw(Phase_A) -> GPIO47 -> sig51 -> detect0 -> cap0 -> zc_gen_module
							 | 
						||
| 
								 | 
							
								 * board_hw(Phase_B) -> GPIO48 -> sig52 -> detect1 -> cap1
							 | 
						||
| 
								 | 
							
								 * board_hw(Phase_C) -> GPIO45 -> sig53 -> detect2 -> cap2
							 | 
						||
| 
								 | 
							
								 * in the chip, there is only one gen module.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* mac zc hw signal id module define */
							 | 
						||
| 
								 | 
							
								#define MAC_ZC_HW_SIG0_ID                   51
							 | 
						||
| 
								 | 
							
								#define MAC_ZC_HW_SIG1_ID                   52
							 | 
						||
| 
								 | 
							
								#define MAC_ZC_HW_SIG2_ID                   53
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* mac zc hw filter pulse low count num, unit:1/75us */
							 | 
						||
| 
								 | 
							
								#define MAC_ZC_HW_FILTER_LOW_CNT            400
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* mac zc hw filter pulse high count num, unit:1/75us */
							 | 
						||
| 
								 | 
							
								#define MAC_ZC_HW_FILTER_HIGH_CNT           400
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief                    mac zc hw logic select
							 | 
						||
| 
								 | 
							
								 * @param chip_hw_logic_id:  hw logic id
							 | 
						||
| 
								 | 
							
								 * @retval:                  none
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void mac_zc_hw_logic_sel(uint8_t chip_hw_logic_id);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief                   hw capx trigger reset
							 | 
						||
| 
								 | 
							
								 * @param signal_id:        signal id
							 | 
						||
| 
								 | 
							
								 * @param cap_edge:         hw cap edge
							 | 
						||
| 
								 | 
							
								 * @retval:                 none
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void mac_zc_hw_capx_reset_trig(uint8_t signal_id, uint8_t cap_edge);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief                   get zc hw cap data
							 | 
						||
| 
								 | 
							
								 * @param buf:              where to buffer the data
							 | 
						||
| 
								 | 
							
								 * @param cap_id:           which cap's fifo to get
							 | 
						||
| 
								 | 
							
								 * @param buf_sz:           buffer size
							 | 
						||
| 
								 | 
							
								 * @retval:                 hw cap data count
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t mac_zc_hw_get_cap_data(uint32_t *buf, uint8_t cap_id, uint32_t buf_sz);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief                   zc hw init
							 | 
						||
| 
								 | 
							
								 * @param is_half_collect:  is half collect
							 | 
						||
| 
								 | 
							
								 * @param cap_edge:         hw cap edge
							 | 
						||
| 
								 | 
							
								 * @retval:                 none
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void mac_zc_hw_init(uint8_t is_half_collect, uint8_t cap_edge);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif //_MAC_ZC_HW_H_
							 |