// TI File $Revision: /main/5 $
// Checkin $Date: January 22, 2008   16:55:35 $
//###########################################################################
//
// FILE:   DSP2833x_Device.h
//
// TITLE:  DSP2833x Device Definitions.
//
//###########################################################################
// $TI Release: DSP2833x/DSP2823x Header Files V1.20 $
// $Release Date: August 1, 2008 $
//###########################################################################

#ifndef DSP2833x_DEVICE_H
#define DSP2833x_DEVICE_H


#ifdef __cplusplus
extern "C" {
#endif


#define   TARGET   1
//---------------------------------------------------------------------------
// User To Select Target Device:

#define   DSP28_28335   TARGET    // Selects '28335/'28235
#define   DSP28_28334   0         // Selects '28334/'28234
#define   DSP28_28332   0         // Selects '28332/'28232


//---------------------------------------------------------------------------
// Common CPU Definitions:
//

extern cregister volatile unsigned int IFR;
extern cregister volatile unsigned int IER;

#define  EINT   asm(" clrc INTM")
#define  DINT   asm(" setc INTM")
#define  ERTM   asm(" clrc DBGM")
#define  DRTM   asm(" setc DBGM")
#define  EALLOW asm(" EALLOW")
#define  EDIS   asm(" EDIS")
#define  ESTOP0 asm(" ESTOP0")

#define M_INT1  0x0001
#define M_INT2  0x0002
#define M_INT3  0x0004
#define M_INT4  0x0008
#define M_INT5  0x0010
#define M_INT6  0x0020
#define M_INT7  0x0040
#define M_INT8  0x0080
#define M_INT9  0x0100
#define M_INT10 0x0200
#define M_INT11 0x0400
#define M_INT12 0x0800
#define M_INT13 0x1000
#define M_INT14 0x2000
#define M_DLOG  0x4000
#define M_RTOS  0x8000

#define BIT0    0x0001
#define BIT1    0x0002
#define BIT2    0x0004
#define BIT3    0x0008
#define BIT4    0x0010
#define BIT5    0x0020
#define BIT6    0x0040
#define BIT7    0x0080
#define BIT8    0x0100
#define BIT9    0x0200
#define BIT10   0x0400
#define BIT11   0x0800
#define BIT12   0x1000
#define BIT13   0x2000
#define BIT14   0x4000
#define BIT15   0x8000



//---------------------------------------------------------------------------
// For Portability, User Is Recommended To Use Following Data Type Size
// Definitions For 16-bit and 32-Bit Signed/Unsigned Integers:
//

#ifndef DSP28_DATA_TYPES
#define DSP28_DATA_TYPES
typedef int                int16;
typedef long               int32;
typedef long long          int64;
typedef unsigned int       Uint16;
typedef unsigned long      Uint32;
typedef unsigned long long Uint64;
typedef float              float32;
typedef long double        float64;
#endif

typedef union
{
	struct      
	{
		unsigned int bit0:	1;
		unsigned int bit1:	1;
		unsigned int bit2:	1;
		unsigned int bit3:	1;
		unsigned int bit4:	1;
		unsigned int bit5:	1;
		unsigned int bit6:	1;
		unsigned int bit7:	1;

	} bit;

	struct
	{
	    unsigned int quad_0	:4;
	    unsigned int quad_1	:4;

	} qua;

	unsigned short all;

} BAITE; 

typedef union
{
	struct      
	{
		unsigned int bit0:	1;
		unsigned int bit1:	1;
		unsigned int bit2:	1;
		unsigned int bit3:	1;
		unsigned int bit4:	1;
		unsigned int bit5:	1;
		unsigned int bit6:	1;
		unsigned int bit7:	1;
		unsigned int bit8:	1;
		unsigned int bit9:	1;
		unsigned int bitA:	1;
		unsigned int bitB:	1;
		unsigned int bitC:	1;
		unsigned int bitD:	1;
		unsigned int bitE:	1;
		unsigned int bitF:	1;

	} bit;

	struct
	{
	    unsigned int quad_0	:4;
	    unsigned int quad_1	:4;
	    unsigned int quad_2	:4;
	    unsigned int quad_3	:4;

	} qua;

	struct
	{
	    unsigned int byte_0	:8;
	    unsigned int byte_1	:8;

	} byt;

	int all;

} WORDE; 

typedef union
{
	struct      
	{
		unsigned int bit00:	1;
		unsigned int bit01:	1;
		unsigned int bit02:	1;
		unsigned int bit03:	1;
		unsigned int bit04:	1;
		unsigned int bit05:	1;
		unsigned int bit06:	1;
		unsigned int bit07:	1;
		unsigned int bit08:	1;
		unsigned int bit09:	1;
		unsigned int bit0A:	1;
		unsigned int bit0B:	1;
		unsigned int bit0C:	1;
		unsigned int bit0D:	1;
		unsigned int bit0E:	1;
		unsigned int bit0F:	1;
		unsigned int bit10:	1;
		unsigned int bit11:	1;
		unsigned int bit12:	1;
		unsigned int bit13:	1;
		unsigned int bit14:	1;
		unsigned int bit15:	1;
		unsigned int bit16:	1;
		unsigned int bit17:	1;
		unsigned int bit18:	1;
		unsigned int bit19:	1;
		unsigned int bit1A:	1;
		unsigned int bit1B:	1;
		unsigned int bit1C:	1;
		unsigned int bit1D:	1;
		unsigned int bit1E:	1;
		unsigned int bit1F:	1;

	} bit;

	struct
	{
	    unsigned int quad_0	:4;
	    unsigned int quad_1	:4;
	    unsigned int quad_2	:4;
	    unsigned int quad_3	:4;
	    unsigned int quad_4	:4;
	    unsigned int quad_5	:4;
	    unsigned int quad_6	:4;
	    unsigned int quad_7	:4;

	} qua;

	struct
	{
	    unsigned int byte_0	:8;
	    unsigned int byte_1	:8;
	    unsigned int byte_2	:8;
	    unsigned int byte_3	:8;

	} byt;

	struct
	{
	    unsigned int word_0	:16;
	    unsigned int word_1	:16;

	} wrd;

	unsigned long all;

} LONGE; 

#define XCLKIN 30000000	// external oscillator frequency
extern long SYSCLKOUT, LSPCLK, HSPCLK;

#define LOWORD(l)((short int)( (long int)(l)     &0xFFFF))
#define HIWORD(l)((short int)(((long int)(l)>>16)&0xFFFF))

#define LOBYTE(w)((char)( (short int)(w)    &0xFF))
#define HIBYTE(w)((char)(((short int)(w)>>8)&0xFF))

#define BYTE3(l)((char)(((long int)(l)>>24)&0xFF))
#define BYTE2(l)((char)(((long int)(l)>>16)&0xFF))
#define BYTE1(l)((char)(((long int)(l)>> 8)&0xFF))
#define BYTE0(l)((char)( (long int)(l)     &0xFF))

//---------------------------------------------------------------------------
// Include All Peripheral Header Files:
//
#include "DSP2833x_Adc.h"                // ADC Registers
#include "DSP2833x_DevEmu.h"             // Device Emulation Registers
#include "DSP2833x_CpuTimers.h"          // 32-bit CPU Timers
#include "DSP2833x_ECan.h"               // Enhanced eCAN Registers
#include "DSP2833x_ECap.h"               // Enhanced Capture
#include "DSP2833x_DMA.h"                // DMA Registers
#include "DSP2833x_EPwm.h"               // Enhanced PWM
#include "DSP2833x_EQep.h"               // Enhanced QEP
#include "DSP2833x_Gpio.h"               // General Purpose I/O Registers
#include "DSP2833x_I2c.h"                // I2C Registers
#include "DSP2833x_McBSP.h"              // McBSP
#include "DSP2833x_PieCtrl.h"            // PIE Control Registers
#include "DSP2833x_PieVect.h"            // PIE Vector Table
#include "DSP2833x_Spi.h"                // SPI Registers
#include "DSP2833x_Sci.h"                // SCI Registers
#include "DSP2833x_SysCtrl.h"            // System Control/Power Modes
#include "DSP2833x_XIntrupt.h"           // External Interrupts
#include "DSP2833x_Xintf.h"              // XINTF External Interface

#include "DSP2833x_GlobalPrototypes.h"         // Prototypes for global functions within the

#if DSP28_28335
#define DSP28_EPWM1  1
#define DSP28_EPWM2  1
#define DSP28_EPWM3  1
#define DSP28_EPWM4  1
#define DSP28_EPWM5  1
#define DSP28_EPWM6  1
#define DSP28_ECAP1  1
#define DSP28_ECAP2  1
#define DSP28_ECAP3  1
#define DSP28_ECAP4  1
#define DSP28_ECAP5  1
#define DSP28_ECAP6  1
#define DSP28_EQEP1  1
#define DSP28_EQEP2  1
#define DSP28_ECANA  1
#define DSP28_ECANB  1
#define DSP28_MCBSPA 1
#define DSP28_MCBSPB 1
#define DSP28_SPIA   1
#define DSP28_SCIA   1
#define DSP28_SCIB   1
#define DSP28_SCIC   1
#define DSP28_I2CA   1
#endif  // end DSP28_28335

#if DSP28_28334
#define DSP28_EPWM1  1
#define DSP28_EPWM2  1
#define DSP28_EPWM3  1
#define DSP28_EPWM4  1
#define DSP28_EPWM5  1
#define DSP28_EPWM6  1
#define DSP28_ECAP1  1
#define DSP28_ECAP2  1
#define DSP28_ECAP3  1
#define DSP28_ECAP4  1
#define DSP28_ECAP5  0
#define DSP28_ECAP6  0
#define DSP28_EQEP1  1
#define DSP28_EQEP2  1
#define DSP28_ECANA  1
#define DSP28_ECANB  1
#define DSP28_MCBSPA 1
#define DSP28_MCBSPB 1
#define DSP28_SPIA   1
#define DSP28_SCIA   1
#define DSP28_SCIB   1
#define DSP28_SCIC   1
#define DSP28_I2CA   1
#endif  // end DSP28_28334

#if DSP28_28332
#define DSP28_EPWM1  1
#define DSP28_EPWM2  1
#define DSP28_EPWM3  1
#define DSP28_EPWM4  1
#define DSP28_EPWM5  1
#define DSP28_EPWM6  1
#define DSP28_ECAP1  1
#define DSP28_ECAP2  1
#define DSP28_ECAP3  1
#define DSP28_ECAP4  1
#define DSP28_ECAP5  0
#define DSP28_ECAP6  0
#define DSP28_EQEP1  1
#define DSP28_EQEP2  1
#define DSP28_ECANA  1
#define DSP28_ECANB  1
#define DSP28_MCBSPA 1
#define DSP28_MCBSPB 0
#define DSP28_SPIA   1
#define DSP28_SCIA   1
#define DSP28_SCIB   1
#define DSP28_SCIC   0
#define DSP28_I2CA   1
#endif  // end DSP28_28332

#ifdef __cplusplus
}
#endif /* extern "C" */

#endif  // end of DSP2833x_DEVICE_H definition


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