148 lines
5.4 KiB
C
148 lines
5.4 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 WQ_VTB_TOPO_INTERNAL_H
|
|
#define WQ_VTB_TOPO_INTERNAL_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "iot_utils_api.h"
|
|
/* define the maximum number of raw adc data converted from input data */
|
|
#define WQ_VTB_LOAD_RAW_DATA_NUM_MAX_INPUT 7000
|
|
#define WQ_VTB_LOAD_SIN_TAB_MAX 256
|
|
|
|
/* define the filter order of decimation filter for fs = 403225. */
|
|
#define WQ_VTB_LOAD_DECM_FILTER_ORDER_FS403225 2
|
|
/* define decimation ratio of decimation filter for fs = 403225. */
|
|
#define WQ_VTB_LOAD_DECM_FILTER_DECM_RATION_FS403225 64
|
|
|
|
/* define decimation ratio of decimation filter for fs = 250000. */
|
|
#define WQ_VTB_LOAD_DECM_FILTER_ORDER_FS250000 3
|
|
/* define decimation ratio of decimation filter for fs = 250000. */
|
|
#define WQ_VTB_LOAD_DECM_FILTER_DECM_RATION_FS250000 32
|
|
|
|
/* define the filter order of decimation filter for fs = 12820 */
|
|
#define WQ_VTB_LOAD_DECM_FILTER_ORDER_FS12820 7
|
|
/* define decimation ratio of decimation filter for fs = 12820 */
|
|
#define WQ_VTB_LOAD_DECM_FILTER_DECM_RATION_FS12820 8
|
|
|
|
/* define the filter order of decimation filter */
|
|
#define WQ_VTB_LOAD_DECM_FILTER_ORDER_FS7233 20
|
|
/* define decimation ratio of decimation filter */
|
|
#define WQ_VTB_LOAD_DECM_FILTER_DECM_RATION_FS7233 4
|
|
|
|
/* maximum or minimum decimation ratio supported by decimation filter */
|
|
#define WQ_VTB_LOAD_DECM_FILTER_DECM_RATION_MAX \
|
|
max(WQ_VTB_LOAD_DECM_FILTER_DECM_RATION_FS250000, \
|
|
max(WQ_VTB_LOAD_DECM_FILTER_DECM_RATION_FS12820, \
|
|
max(WQ_VTB_LOAD_DECM_FILTER_DECM_RATION_FS7233, \
|
|
WQ_VTB_LOAD_DECM_FILTER_DECM_RATION_FS403225)))
|
|
#define WQ_VTB_LOAD_DECM_FILTER_DECM_RATION_MIN \
|
|
min(WQ_VTB_LOAD_DECM_FILTER_DECM_RATION_FS250000, \
|
|
min(WQ_VTB_LOAD_DECM_FILTER_DECM_RATION_FS12820, \
|
|
min(WQ_VTB_LOAD_DECM_FILTER_DECM_RATION_FS7233, \
|
|
WQ_VTB_LOAD_DECM_FILTER_DECM_RATION_FS403225)))
|
|
|
|
/* maximum filter order supported by decimation filter */
|
|
#define WQ_VTB_LOAD_DECM_FILTER_ORDER_MAX \
|
|
max(WQ_VTB_LOAD_DECM_FILTER_ORDER_FS250000, \
|
|
max(WQ_VTB_LOAD_DECM_FILTER_ORDER_FS12820, \
|
|
max(WQ_VTB_LOAD_DECM_FILTER_ORDER_FS7233, \
|
|
WQ_VTB_LOAD_DECM_FILTER_ORDER_FS403225)))
|
|
|
|
/* define fixed-point complex structure */
|
|
typedef struct _wq_complex{
|
|
/* real part */
|
|
int32_t real;
|
|
/* imaginary part */
|
|
int32_t imag;
|
|
} wq_complex_t;
|
|
|
|
/* define float complex structure */
|
|
typedef struct _wq_complex_f{
|
|
/* real part */
|
|
float real;
|
|
/* imaginary part */
|
|
float imag;
|
|
} wq_complex_f_t;
|
|
|
|
/* decimation filter sub-filter structure */
|
|
typedef struct {
|
|
/* filter history status data */
|
|
wq_complex_t buf[WQ_VTB_LOAD_DECM_FILTER_ORDER_MAX];
|
|
/* filter coefficient array */
|
|
int32_t h[WQ_VTB_LOAD_DECM_FILTER_ORDER_MAX];
|
|
/* position of filter state data to be inserted */
|
|
uint8_t idx;
|
|
/* filter order */
|
|
uint8_t order;
|
|
} wq_filter_t;
|
|
|
|
/* decimation filter descriptor */
|
|
typedef struct wq_vtb_decimation_filter {
|
|
/* points to the cos table for spectrum shifting */
|
|
const int32_t *cos_tab;
|
|
/* pointer to the sin table for spectrum shifting */
|
|
const int32_t *sin_tab;
|
|
/* filter array */
|
|
wq_filter_t filter[WQ_VTB_LOAD_DECM_FILTER_DECM_RATION_MAX];
|
|
/* coefficient index of sine and cosine table for spectrum shift*/
|
|
uint8_t idx;
|
|
/* decimation ratio */
|
|
uint8_t ratio;
|
|
/* sine and cosine tables size */
|
|
uint8_t sin_tab_size;
|
|
/* scaling factor of the result output, that is, shift the "scale" bit to
|
|
* the right.
|
|
*/
|
|
uint8_t scale;
|
|
/* flag mark to if use fast calculation, in order to improve the calculation
|
|
* speed, the round operation is not performed after data truncation.
|
|
*/
|
|
uint8_t is_fast;
|
|
} wq_vtb_decimation_filter_t;
|
|
|
|
/* define hw_topo coprocessor command type */
|
|
#define WQ_VTB_LOAD_COPROCESS_CMD_T_CALC 1
|
|
|
|
/* maximum data length supported by the command, uint is word */
|
|
#define WQ_VTB_LOAD_COPROCESS_CMD_DATA_MAX_LEN 4
|
|
|
|
/* sync command structure with coprocessor.*/
|
|
typedef struct {
|
|
/* command type, see WQ_VTB_LOAD_COPROCESS_CMD_T_XXX */
|
|
uint8_t cmd;
|
|
uint8_t phase;
|
|
uint32_t data1;
|
|
uint32_t data2;
|
|
volatile uint8_t cpu1_flag;
|
|
} wq_vtb_topo_coprocess_op_t;
|
|
|
|
/* decimation filter handle array */
|
|
extern wq_vtb_decimation_filter_t g_decm_filter[];
|
|
/* points to the cos table for spectrum shifting */
|
|
extern int32_t g_cos_tab[];
|
|
/* pointer to the sin table for spectrum shifting */
|
|
extern int32_t g_sin_tab[];
|
|
extern wq_vtb_topo_coprocess_op_t g_wq_vtb_topo_op;
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* WQ_VTB_TOPO_INTERNA_H */
|