2024-04-03 16:40:57 +08:00
|
|
|
/*
|
2025-04-23 17:54:31 +08:00
|
|
|
* Copyright (c) 2022-2025, ArtInChip Technology Co., Ltd
|
2024-04-03 16:40:57 +08:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*
|
|
|
|
|
* Authors: zrq <ruiqi.zheng@artinchip.com>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef _ARTINCHIP_HAL_PWMCS_H_
|
|
|
|
|
#define _ARTINCHIP_HAL_PWMCS_H_
|
|
|
|
|
|
|
|
|
|
#include "aic_common.h"
|
|
|
|
|
|
2025-07-22 11:15:46 +08:00
|
|
|
#ifdef FPGA_BOARD_ARTINCHIP
|
2024-04-03 16:40:57 +08:00
|
|
|
#define QEP_CLK_RATE 24000000 /* 24 MHz */
|
|
|
|
|
#else
|
|
|
|
|
#define QEP_CLK_RATE 200000000 /* 200 MHz */
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define QEP_POS_CMP_INT_FLG BIT(8)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum aic_qep_cnt_mode {
|
|
|
|
|
QUADRATURE_COUNT = 0,
|
|
|
|
|
DIR_COUNT,
|
|
|
|
|
INCREMENTAL_COUNT,
|
|
|
|
|
DECREMENT_COUNT,
|
|
|
|
|
CW_CCW_HIGH_COUNT,
|
|
|
|
|
CW_CCW_LOW_COUNT
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum aic_qep_icap_mode {
|
|
|
|
|
RESERVED = 0,
|
|
|
|
|
QEP_IDX_RISING,
|
|
|
|
|
QEP_IDS_FALLING,
|
|
|
|
|
QEP_IDX_MKR
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct aic_qep_data {
|
|
|
|
|
u8 id;
|
|
|
|
|
};
|
|
|
|
|
|
2025-04-23 17:54:31 +08:00
|
|
|
void hal_qep_clear_cnt(u32 ch);
|
2025-01-08 19:12:06 +08:00
|
|
|
u32 hal_qep_get_cnt(u32 ch);
|
2025-04-23 17:54:31 +08:00
|
|
|
u32 hal_qep_global_stat();
|
2024-04-03 16:40:57 +08:00
|
|
|
u32 hal_qep_int_stat(u32 ch);
|
|
|
|
|
void hal_qep_clr_int(u32 ch, u32 stat);
|
|
|
|
|
void hal_qep_set_cnt_ep(u32 i, u32 cnt);
|
|
|
|
|
void hal_qep_set_cnt_cmp(u32 i, u32 cnt);
|
|
|
|
|
void hal_qep_config(u32 ch);
|
|
|
|
|
void hal_qep_int_enable(u32 ch, u32 enable);
|
|
|
|
|
void hal_qep_enable(u32 ch, u32 enable);
|
|
|
|
|
int hal_qep_init(void);
|
|
|
|
|
int hal_qep_deinit(void);
|
|
|
|
|
|
|
|
|
|
#endif // end of _ARTINCHIP_HAL_PWMCS_H_
|