//###############################################################################
//
// FILE:   cyclone_can_ram.h
//
// TITLE:  Cyclone CAN RAM Interface Register Definitions.
//
// NOTES:
//  1) Bitfields have been defined for big-endian only.
//###############################################################################
//
//  Ver  | dd mmm yyyy | Who  | Description of changes
// ======|=============|======|==============================================
//  1.00 | 19 Aug 2008 | CMF  | Started with Spartan_Pmbus.h.
//       |             |      | Updated for 1.0 Memory map document.
//       |             |      |
//
//  Texas Instruments, Inc
//  Copyright Texas Instruments 2009. All rights reserved.
//###############################################################################

#ifndef CYCLONE_CANRAM_H
#define CYCLONE_CANRAM_H

#ifdef __cplusplus
extern "C" {
#endif

  //-----------------------------------------------------------------------------
  // CAN RAM Field definitions
  //-----------------------------------------------------------------------------
  struct ID_FIELD_BITS {            // bits   description
    Uint32  IDE:1;                  // 31       Identifier Extension Enable Bit 
    Uint32  EN_ADDR_MASK:1;         // 30       Enable Address Mask
    Uint32  AUTO_ANS:1;             // 29       Auto Answer Bit     
    Uint32  STDID:11;               // 28:18    STD ID      
    Uint32  EXTID:18;               // 17:0     EXTID ID      
  };
  union ID_FIELD_REG{
    struct ID_FIELD_BITS    bit;
    Uint32                 all;
  };

  struct CONTROL_FIELD_BITS {       // bits   description
    Uint32 rsvd0:27;                // 31:5   Reserved
    Uint32 RTR:1;                   // 4      RTR
    Uint32 DLC:4;                   // 3:0    DLC
  };

  union CONTROL_FIELD_REG{
     struct CONTROL_FIELD_BITS    bit;
     Uint32                 all;
   };

  struct DATA_LSB_FIELD_BYTES {      // bits   description
	   Uint8  BYTE3;                  // 31:24
	   Uint8  BYTE2;                  // 16:23  Byte #2
	   Uint8  BYTE1;                  // 8:15   Byte #1
	   Uint8  BYTE0;                  // 0:7    Byte #0
  };

  union DATA_LSB_FIELD_REG {
	struct DATA_LSB_FIELD_BYTES	byte;
    Uint32                   all;
  };


  struct DATA_MSB_FIELD_BYTES {      // bits   description
	   Uint8  BYTE3;                  // 31:24
	   Uint8  BYTE2;                  // 16:23  Byte #2
	   Uint8  BYTE1;                  // 8:15   Byte #1
	   Uint8  BYTE0;                  // 0:7    Byte #0
  };

  union DATA_MSB_FIELD_REG {
	struct DATA_MSB_FIELD_BYTES	byte;
    Uint32                   all;
  };


  union MBOX_NUM_REG{
      union ID_FIELD_REG       ID_FIELD;
      union CONTROL_FIELD_REG  CONTROL_FIELD;
      union DATA_LSB_FIELD_REG DATA_LSB_FIELD;
      union DATA_MSB_FIELD_REG DATA_MSB_FIELD;
  };

  //---------------------------------------------------------------------------
  // CANRAM Interface External References & Function Declarations:
  //
  extern volatile union MBOX_NUM_REG CanRamRegs[16];
  
  //===========================================================================
#ifdef __cplusplus
}       // end of extern "C"
#endif

#endif  // end of CYCLONE_CANRAM_H definition

//===========================================================================
// End of file
//===========================================================================
