What does this Declaration means???

Discussion in 'Embedded Systems and Microcontrollers' started by embpic, May 21, 2014.

  1. embpic

    Thread Starter Member

    May 29, 2013
    187
    3
    volatile BDT_ENTRY BDT[BDT_NUM_ENTRIES] BDT_BASE_ADDR_TAG;

    here are some defination.
    Code ( (Unknown Language)):
    1.  
    2. #define BDT_NUM_ENTRIES      ((USB_MAX_EP_NUMBER + 1) * 4)
    3. #define USB_MAX_EP_NUMBER       2
    4. #define BDT_BASE_ADDR   0x2000
    5. #define BDT_BASE_ADDR_TAG @ BDT_BASE_ADDR
    6.  
    7.  
    8. typedef union __BDT
    9. {
    10.     struct
    11.     {
    12.         BD_STAT STAT;
    13.         BYTE CNT;
    14.         BYTE ADRL;                      //Buffer Address Low
    15.         BYTE ADRH;                      //Buffer Address High
    16.     };
    17.     struct
    18.     {
    19.         unsigned filler1:8;
    20.         unsigned filler2:8;
    21.         WORD     ADR;                      //Buffer Address
    22.     };
    23.     DWORD Val;
    24.     BYTE v[4];
    25. } BDT_ENTRY;
    26.  
    upto this, it is ok.
    but here,
    volatile BDT_ENTRY BDT[BDT_NUM_ENTRIES] BDT_BASE_ADDR_TAG;

    it shows three part BDT_ENTRY is typedef of union and BDT[BDT_NUM_ENTRIES] is array of BDT_ENTRY.
    This is also ok but again there is third part of BDT_BASE_ADDR_TAG.
    what is doing here???

    is it for address??
    that is to locate this variable at that position??
     
  2. JohnInTX

    Moderator

    Jun 26, 2012
    2,341
    1,024
    Looks like it.

    'volatile' tells the compiler that other things can modify the variable e.g. a hardware peripheral and that it must not move it, share it or optimize it out.

    If you walk back through the defines you'll see that
    volatile BDT_ENTRY BDT[BDT_NUM_ENTRIES] BDT_BASE_ADDR_TAG;

    where BDT_BASE_ADDR_TAG evaluates to @ 0x2000, declares an array of structs of type BDT_ENTRY named BDT containing some computed number of structures at the absolute, non relocatable address 2000h (presumably a set of hardware buffers or pointers to them)
     
  3. embpic

    Thread Starter Member

    May 29, 2013
    187
    3
    Thank you sir but following point is not getting cleared.

     
  4. embpic

    Thread Starter Member

    May 29, 2013
    187
    3
    sir please explain it again i am not getting it clearly.
     
Loading...