⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 landzo

📁 【开源】线性CCD自适应性算法攻略
💻
📖 第 1 页 / 共 5 页
字号:
    {

        q31_t sum;
        q31_t r, s;

        r = (short) x;
        s = (short) y;

        r = ((r >> 1) - (y >> 17));
        s = (((x >> 17) + (s >> 1)) << 16);

        sum = (s & 0xFFFF0000) | (r & 0x0000FFFF);

        return sum;
    }


    /*
     * @brief C custom defined QSAX for M3 and M0 processors
     */
    static __INLINE q31_t __QSAX(
        q31_t x,
        q31_t y)
    {

        q31_t sum = 0;

        sum = ((sum + clip_q31_to_q15((q31_t) ((short) (x >> 16) - (short) y))) << 16) +
              clip_q31_to_q15((q31_t) ((short) x + (short) (y >> 16)));

        return sum;
    }

    /*
     * @brief C custom defined SHSAX for M3 and M0 processors
     */
    static __INLINE q31_t __SHSAX(
        q31_t x,
        q31_t y)
    {

        q31_t sum;
        q31_t r, s;

        r = (short) x;
        s = (short) y;

        r = ((r >> 1) + (y >> 17));
        s = (((x >> 17) - (s >> 1)) << 16);

        sum = (s & 0xFFFF0000) | (r & 0x0000FFFF);

        return sum;
    }

    /*
     * @brief C custom defined SMUSDX for M3 and M0 processors
     */
    static __INLINE q31_t __SMUSDX(
        q31_t x,
        q31_t y)
    {

        return ((q31_t)(((short) x * (short) (y >> 16)) -
                        ((short) (x >> 16) * (short) y)));
    }

    /*
     * @brief C custom defined SMUADX for M3 and M0 processors
     */
    static __INLINE q31_t __SMUADX(
        q31_t x,
        q31_t y)
    {

        return ((q31_t)(((short) x * (short) (y >> 16)) +
                        ((short) (x >> 16) * (short) y)));
    }

    /*
     * @brief C custom defined QADD for M3 and M0 processors
     */
    static __INLINE q31_t __QADD(
        q31_t x,
        q31_t y)
    {
        return clip_q63_to_q31((q63_t) x + y);
    }

    /*
     * @brief C custom defined QSUB for M3 and M0 processors
     */
    static __INLINE q31_t __QSUB(
        q31_t x,
        q31_t y)
    {
        return clip_q63_to_q31((q63_t) x - y);
    }

    /*
     * @brief C custom defined SMLAD for M3 and M0 processors
     */
    static __INLINE q31_t __SMLAD(
        q31_t x,
        q31_t y,
        q31_t sum)
    {

        return (sum + ((short) (x >> 16) * (short) (y >> 16)) +
                ((short) x * (short) y));
    }

    /*
     * @brief C custom defined SMLADX for M3 and M0 processors
     */
    static __INLINE q31_t __SMLADX(
        q31_t x,
        q31_t y,
        q31_t sum)
    {

        return (sum + ((short) (x >> 16) * (short) (y)) +
                ((short) x * (short) (y >> 16)));
    }

    /*
     * @brief C custom defined SMLSDX for M3 and M0 processors
     */
    static __INLINE q31_t __SMLSDX(
        q31_t x,
        q31_t y,
        q31_t sum)
    {

        return (sum - ((short) (x >> 16) * (short) (y)) +
                ((short) x * (short) (y >> 16)));
    }

    /*
     * @brief C custom defined SMLALD for M3 and M0 processors
     */
    static __INLINE q63_t __SMLALD(
        q31_t x,
        q31_t y,
        q63_t sum)
    {

        return (sum + ((short) (x >> 16) * (short) (y >> 16)) +
                ((short) x * (short) y));
    }

    /*
     * @brief C custom defined SMLALDX for M3 and M0 processors
     */
    static __INLINE q63_t __SMLALDX(
        q31_t x,
        q31_t y,
        q63_t sum)
    {

        return (sum + ((short) (x >> 16) * (short) y)) +
               ((short) x * (short) (y >> 16));
    }

    /*
     * @brief C custom defined SMUAD for M3 and M0 processors
     */
    static __INLINE q31_t __SMUAD(
        q31_t x,
        q31_t y)
    {

        return (((x >> 16) * (y >> 16)) +
                (((x << 16) >> 16) * ((y << 16) >> 16)));
    }

    /*
     * @brief C custom defined SMUSD for M3 and M0 processors
     */
    static __INLINE q31_t __SMUSD(
        q31_t x,
        q31_t y)
    {

        return (-((x >> 16) * (y >> 16)) +
                (((x << 16) >> 16) * ((y << 16) >> 16)));
    }




#endif /* (ARM_MATH_CM3) || defined (ARM_MATH_CM0) */


    /**
     * @brief Instance structure for the Q7 FIR filter.
     */
    typedef struct
    {
        uint16_t numTaps;        /**< number of filter coefficients in the filter. */
        q7_t *pState;            /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
        q7_t *pCoeffs;           /**< points to the coefficient array. The array is of length numTaps.*/
    } arm_fir_instance_q7;

    /**
     * @brief Instance structure for the Q15 FIR filter.
     */
    typedef struct
    {
        uint16_t numTaps;         /**< number of filter coefficients in the filter. */
        q15_t *pState;            /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
        q15_t *pCoeffs;           /**< points to the coefficient array. The array is of length numTaps.*/
    } arm_fir_instance_q15;

    /**
     * @brief Instance structure for the Q31 FIR filter.
     */
    typedef struct
    {
        uint16_t numTaps;         /**< number of filter coefficients in the filter. */
        q31_t *pState;            /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
        q31_t *pCoeffs;           /**< points to the coefficient array. The array is of length numTaps. */
    } arm_fir_instance_q31;

    /**
     * @brief Instance structure for the floating-point FIR filter.
     */
    typedef struct
    {
        uint16_t numTaps;     /**< number of filter coefficients in the filter. */
        float32_t *pState;    /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
        float32_t *pCoeffs;   /**< points to the coefficient array. The array is of length numTaps. */
    } arm_fir_instance_f32;


    /**
     * @brief Processing function for the Q7 FIR filter.
     * @param[in] *S points to an instance of the Q7 FIR filter structure.
     * @param[in] *pSrc points to the block of input data.
     * @param[out] *pDst points to the block of output data.
     * @param[in] blockSize number of samples to process.
     * @return none.
     */
    void arm_fir_q7(
        const arm_fir_instance_q7 *S,
        q7_t *pSrc,
        q7_t *pDst,
        uint32_t blockSize);


    /**
     * @brief  Initialization function for the Q7 FIR filter.
     * @param[in,out] *S points to an instance of the Q7 FIR structure.
     * @param[in] numTaps  Number of filter coefficients in the filter.
     * @param[in] *pCoeffs points to the filter coefficients.
     * @param[in] *pState points to the state buffer.
     * @param[in] blockSize number of samples that are processed.
     * @return none
     */
    void arm_fir_init_q7(
        arm_fir_instance_q7 *S,
        uint16_t numTaps,
        q7_t *pCoeffs,
        q7_t *pState,
        uint32_t blockSize);


    /**
     * @brief Processing function for the Q15 FIR filter.
     * @param[in] *S points to an instance of the Q15 FIR structure.
     * @param[in] *pSrc points to the block of input data.
     * @param[out] *pDst points to the block of output data.
     * @param[in] blockSize number of samples to process.
     * @return none.
     */
    void arm_fir_q15(
        const arm_fir_instance_q15 *S,
        q15_t *pSrc,
        q15_t *pDst,
        uint32_t blockSize);

    /**
     * @brief Processing function for the fast Q15 FIR filter for Cortex-M3 and Cortex-M4.
     * @param[in] *S points to an instance of the Q15 FIR filter structure.
     * @param[in] *pSrc points to the block of input data.
     * @param[out] *pDst points to the block of output data.
     * @param[in] blockSize number of samples to process.
     * @return none.
     */
    void arm_fir_fast_q15(
        const arm_fir_instance_q15 *S,
        q15_t *pSrc,
        q15_t *pDst,
        uint32_t blockSize);

    /**
     * @brief  Initialization function for the Q15 FIR filter.
     * @param[in,out] *S points to an instance of the Q15 FIR filter structure.
     * @param[in] numTaps  Number of filter coefficients in the filter. Must be even and greater than or equal to 4.
     * @param[in] *pCoeffs points to the filter coefficients.
     * @param[in] *pState points to the state buffer.
     * @param[in] blockSize number of samples that are processed at a time.
     * @return The function returns ARM_MATH_SUCCESS if initialization was successful or ARM_MATH_ARGUMENT_ERROR if
     * <code>numTaps</code> is not a supported value.
     */

    arm_status arm_fir_init_q15(
        arm_fir_instance_q15 *S,
        uint16_t numTaps,
        q15_t *pCoeffs,
        q15_t *pState,
        uint32_t blockSize);

    /**
     * @brief Processing function for the Q31 FIR filter.
     * @param[in] *S points to an instance of the Q31 FIR filter structure.
     * @param[in] *pSrc points to the block of input data.
     * @param[out] *pDst points to the block of output data.
     * @param[in] blockSize number of samples to process.
     * @return none.
     */
    void arm_fir_q31(
        const arm_fir_instance_q31 *S,
        q31_t *pSrc,
        q31_t *pDst,
        uint32_t blockSize);

    /**
     * @brief Processing function for the fast Q31 FIR filter for Cortex-M3 and Cortex-M4.
     * @param[in] *S points to an instance of the Q31 FIR structure.
     * @param[in] *pSrc points to the block of input data.
     * @param[out] *pDst points to the block of output data.
     * @param[in] blockSize number of samples to process.
     * @return none.
     */
    void arm_fir_fast_q31(
        const arm_fir_instance_q31 *S,
        q31_t *pSrc,
        q31_t *pDst,
        uint32_t blockSize);

    /**
     * @brief  Initialization function for the Q31 FIR filter.
     * @param[in,out] *S points to an instance of the Q31 FIR structure.
     * @param[in] 	numTaps  Number of filter coefficients in the filter.
     * @param[in] 	*pCoeffs points to the filter coefficients.
     * @param[in] 	*pState points to the state buffer.
     * @param[in] 	blockSize number of samples that are processed at a time.
     * @return 		none.
     */
    void arm_fir_init_q31(
        arm_fir_instance_q31 *S,
        uint16_t numTaps,
        q31_t *pCoeffs,
        q31_t *pState,
        uint32_t blockSize);

    /**
     * @brief Processing function for the floating-point FIR filter.
     * @param[in] *S points to an instance of the floating-point FIR structure.
     * @param[in] *pSrc points to the block of input data.
     * @param[out] *pDst points to the block of output data.
     * @param[in] blockSize number of samples to process.
     * @return none.
     */
    void arm_fir_f32(
        const arm_fir_instance_f32 *S,
        float32_t *pSrc,
        float32_t *pDst,
        uint32_t blockSize);

    /**
     * @brief  Initialization function for the floating-point FIR filter.
     * @param[in,out] *S points to an instance of the floating-point FIR filter structure.
     * @param[in] 	numTaps  Number of filter coefficients in the filter.
     * @param[in] 	*pCoeffs points to the filter coefficients.
     * @param[in] 	*pState points to the state buffer.
     * @param[in] 	blockSize number of samples that are processed at a time.
     * @return    	none.
     */
    void arm_fir_init_f32(
        arm_fir_instance_f32 *S,
        uint16_t numTaps,
        float32_t *pCoeffs,
        float32_t *pState,
        uint32_t blockSize);


    /**
     * @brief Instance structure for the Q15 Biquad cascade filter.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -