This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

数据结构求助



想声明一个结构体,里面的变量是指向N个寄存器的成员,便于应用程序的管理。

比如

 

typedef struct

 {  

volatile struct EPWM_REG *channel1;  

volatile struct EPWM_REG *channel2;

volatile struct EPWM_REG *channel3;

} Channel;

当我对声明一个Channel类型的变量CHANNEL,

CHANNEL.channe1= &EPwm1Regs;

CHANNEL.channel2=&EPwm2Regs;

……

报错,这语法究竟错在哪里啊?

请教论坛的高手们,指点一下!

  • 把EPWM_REG的定义贴上来,以及对EPwm1Regs的定义。

    Eric

  • EPWM_REG是DSP2803x_EPWM.h自带的数据类型:

     

    struct EPWM_REGS {    union  TBCTL_REG               TBCTL;           // Time Base Control Register    union  TBSTS_REG               TBSTS;           // Time Base Status Register    union  TBPHS_HRPWM_GROUP   TBPHS;           // Union of TBPHS:TBPHSHR    Uint16                           TBCTR;           // Time Base Counter    Uint16                           TBPRD;           // Time Base Period register set    Uint16                           TBPRDHR;        // Time Base Period High Res Register    union  CMPCTL_REG             CMPCTL;         // Compare control    union  CMPA_HRPWM_GROUP    CMPA;            // Union of CMPA:CMPAHR    Uint16                           CMPB;            // Compare B reg    union  AQCTL_REG               AQCTLA;          // Action qual output A    union  AQCTL_REG               AQCTLB;          // Action qual output B    union  AQSFRC_REG             AQSFRC;          // Action qual SW force    union  AQCSFRC_REG            AQCSFRC;        // Action qualifier continuous SW force    union  DBCTL_REG               DBCTL;           // Dead-band control    Uint16                           DBRED;           // Dead-band rising edge delay    Uint16                           DBFED;           // Dead-band falling edge delay    union  TZSEL_REG               TZSEL;           // Trip zone select    union  TZDCSEL_REG            TZDCSEL;         // Trip zone digital comparator select    union  TZCTL_REG               TZCTL;           // Trip zone control    union  TZEINT_REG              TZEINT;          // Trip zone interrupt enable    union  TZFLG_REG               TZFLG;           // Trip zone interrupt flags    union  TZCLR_REG               TZCLR;           // Trip zone clear    union  TZFRC_REG               TZFRC;           // Trip zone force interrupt    union  ETSEL_REG               ETSEL;            // Event trigger selection    union  ETPS_REG                ETPS;             // Event trigger pre-scaler    union  ETFLG_REG               ETFLG;           // Event trigger flags    union  ETCLR_REG               ETCLR;           // Event trigger clear    union  ETFRC_REG               ETFRC;           // Event trigger force    union  PCCTL_REG               PCCTL;           // PWM chopper control    Uint16                           rsvd3;    union  HRCNFG_REG             HRCNFG;         // HRPWM Config Reg    union  HRPWR_REG        HRPWR;           // HRPWM Power Register    Uint16                           rsvd4[4];    Uint16                           HRMSTEP;        // HRPWM MEP Step Register    Uint16                           rsvd5;    union  HRPCTL_REG             HRPCTL;          // High Resolution Period Control    Uint16                           rsvd6;    union  TBPRD_HRPWM_GROUP   TBPRDM;          // Union of TBPRD:TBPRDHR mirror registers    union  CMPA_HRPWM_GROUP    CMPAM;          // Union of CMPA:CMPAHR mirror registers    Uint16                           rsvd7[2];    union  DCTRIPSEL_REG          DCTRIPSEL;      // Digital Compare Trip Select    union  DCCTL_REG               DCACTL;          // Digital Compare A Control    union  DCCTL_REG               DCBCTL;          // Digital Compare B Control    union  DCFCTL_REG             DCFCTL;          // Digital Compare Filter Control    union  DCCAPCTL_REG           DCCAPCTL;       // Digital Compare Capture Control    Uint16                           DCFOFFSET;      // Digital Compare Filter Offset    Uint16                           DCFOFFSETCNT;  // Digital Compare Filter Offset Counter    Uint16                           DCFWINDOW;     // Digital Compare Filter Window    Uint16                           DCFWINDOWCNT; // Digital Compare Filter Window Counter    Uint16                           DCCAP;           // Digital Compare Filter Counter Capture };

    //---------------------------------------------------------------------------

    // External References & Function Declarations:

     extern volatile struct EPWM_REGS EPwm1Regs;

     extern volatile struct EPWM_REGS EPwm2Regs;

    extern volatile struct EPWM_REGS EPwm3Regs;

    extern volatile struct EPWM_REGS EPwm4Regs;

    extern volatile struct EPWM_REGS EPwm5Regs;

    extern volatile struct EPWM_REGS EPwm6Regs;

    extern volatile struct EPWM_REGS EPwm7Regs;