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

📄 figtest.c

📁 dsp6713开发板的许多例程.对入门特别有用
💻 C
字号:
/*
 *  Copyright 2003 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */
/* "@(#) XDAS 2.50.02 11-28-03 (xdas,dsk6713-a05)" */
/*
 *  ======== figtest.c ========
 *  Example use of FIG, FIR and ALG modules.  This test creates some
 *  number of FIR filtes that all share a common set of coefficients
 *  and working buffer.  It then applys the filter to the data and
 *  displays the results.
 */
#include <std.h>
#include <fig.h>
#include <fir.h>
#include <log.h>

#include <fig_ti.h>
#include <fir_ti.h>

extern far LOG_Obj trace;

#define NUMFRAMES   2           /* number of frames of data to process */

#define NUMINST     4           /* number of FIR filters to create */
#define FRAMELEN    7           /* length of in/out frames (words) */
#define FILTERLEN   8           /* length of coeff array (words) */

Int coeff[FILTERLEN] = {        /* filter coefficients */
    1, 2, 3, 4, 4, 3, 2, 1
};

Int in[NUMINST][FRAMELEN] = {   /* input data frames */
    {1, 0, 0, 0, 0, 0, 0},
    {0, 1, 0, 0, 0, 0, 0},
    {0, 0, 1, 0, 0, 0, 0},
    {0, 0, 0, 1, 0, 0, 0}
};
Int out[NUMINST][FRAMELEN];     /* output data frames */

static Void display(Int a[], Int n);

/*
 *  ======== main ========
 */
Int main(Int argc, String argv[])
{
    FIG_Params figParams;
    FIR_Params firParams;
    FIG_Status figStatus;
    FIG_Handle group;
    FIR_Handle inst[NUMINST];
    Bool status;
    Int i, n;
    
    FIG_init();
    FIR_init();
    
    figParams = FIG_PARAMS;
    figParams.filterLen = FILTERLEN;
    figParams.coeffPtr = coeff;

    /* create the filter group */
    if ((group = FIG_create(&FIG_TI_IFIG, &figParams)) != NULL) {

        /* get FIG pointers */
        FIG_getStatus(group, &figStatus);
        
        /* create multiple filter instance objects that reference group */
        firParams = FIR_PARAMS;
        firParams.frameLen = FRAMELEN;
        firParams.filterLen = FILTERLEN;
        firParams.coeffPtr = figStatus.coeffPtr;
        for (status = TRUE, i = 0; i < NUMINST; i++) {
            inst[i] = FIR_create(&FIR_TI_IFIR, &firParams);
            if (inst[i] == NULL) {
                status = FALSE;
            }
        }

        /* if object creation succeeded, apply filters to data */
        if (status) {
            /* activate group object */
            FIG_activate(group);
        
            /* apply all filters on all frames */
            for (n = 0; n < NUMFRAMES; n++) {
                for (i = 0; i < NUMINST; i++) {
                    FIR_apply(inst[i], in[i], out[i]);
                    display(out[i], FRAMELEN);
                }
            }

            /* deactivate group object */
            FIG_deactivate(group);
        }
        
        /* delete filter instances */
        for (i = 0; i < NUMINST; i++) {
            FIR_delete(inst[i]);
        }

        /* delete filter group object */
        FIG_delete(group);
    }

    FIG_exit();
    FIR_exit();

    return (0);
}

/*
 *  ======== display ========
 */
static Void display(Int a[], Int n)
{
    Int i;

    for (i = 0; i < n; i++) {
        LOG_printf(&trace, "%d ", a[i]);
    }

    LOG_printf(&trace, "\n");
}

⌨️ 快捷键说明

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