arc.h 5.65 KB
#ifndef __arc_h__
#define __arc_h__
/*HEADER******************************************************************
**************************************************************************
*** 
*** Copyright (c) 2001-2002 ARC International.
*** All rights reserved                                          
***                                                              
*** This software embodies materials and concepts which are      
*** confidential to ARC International and is made
*** available solely pursuant to the terms of a written license   
*** agreement with ARC International             
***
*** $Workfile:arc.h$
*** $Revision: 1.1 $
*** $Date: 2003/02/17 20:49:01 $
***
*** Description:      
***  This file contains ARC-specific defines.
***                                                               
**************************************************************************
*END*********************************************************************/

/*--------------------------------------------------------------------------*/
/*
**                            STANDARD TYPES
*/

/*
**  The following typedefs allow us to minimize portability problems
**  due to the various C compilers (even for the same processor) not
**  agreeing on the sizes of "int"s and "short int"s and "longs".
*/

#define _PTR_      *
#define _CODE_PTR_ *

typedef char _PTR_                    char_ptr;    /* signed character       */
typedef unsigned char  uchar, _PTR_   uchar_ptr;   /* unsigned character     */

typedef signed   char   int_8, _PTR_   int_8_ptr;   /* 8-bit signed integer   */
typedef unsigned char  uint_8, _PTR_   uint_8_ptr;  /* 8-bit signed integer   */

typedef          short int_16, _PTR_   int_16_ptr;  /* 16-bit signed integer  */
typedef unsigned short uint_16, _PTR_  uint_16_ptr; /* 16-bit unsigned integer*/

typedef          long  int_32, _PTR_   int_32_ptr;  /* 32-bit signed integer  */
typedef unsigned long  uint_32, _PTR_  uint_32_ptr; /* 32-bit unsigned integer*/

typedef unsigned long  boolean;  /* Machine representation of a boolean */

typedef void _PTR_     pointer;  /* Machine representation of a pointer */

/* IEEE single precision floating point number (32 bits, 8 exponent bits) */
typedef float          ieee_single;

/* IEEE double precision floating point number (64 bits, 11 exponent bits) */
typedef double         ieee_double;

typedef pointer        _usb_host_handle;

/*--------------------------------------------------------------------------*/
/*
**                          STANDARD CONSTANTS
**
**  Note that if standard 'C' library files are included after types.h,
**  the defines of TRUE, FALSE and NULL may sometimes conflict, as most
**  standard library files do not check for previous definitions.
*/

#ifdef  FALSE
   #undef  FALSE
#endif
#define FALSE ((boolean)0)

#ifdef  TRUE
   #undef  TRUE
#endif
#define TRUE ((boolean)1) 

#ifdef  NULL
   #undef  NULL
#endif

#ifdef __cplusplus
   #define NULL (0)
#else
   #define NULL ((pointer)0)
#endif

typedef  uint_32  VUSB_REGISTER;

#define  BSP_VUSB11_HOST_BASE_ADDRESS0       (0xFC4080)
#define  BSP_VUSB11_HOST_VECTOR0             (3)
#define  ARC_JMP_TO_ADDR_INSTRN              ((uint_32)(0x381F0000))

#define  BSP_VUSB11_DEVICE_BASE_ADDRESS0     (0xFC4080)
#define  BSP_VUSB11_DEVICE_VECTOR0           (3)
#define  ARC_JMP_TO_ADDR_INSTRN              ((uint_32)(0x381F0000))

#define  BSP_VUSB11_OTG_BASE_ADDRESS0        (0xFC4080)
#define  BSP_VUSB11_OTG_VECTOR0              (3)
#define  BSP_VUSB11_OTG_USB_OFFSET           (0x70)

/* The ARC is little-endian, just like USB */
#define USB_uint_16_low(x)                   ((x) & 0xFF)
#define USB_uint_16_high(x)                  (((x) >> 8) & 0xFF)

#ifndef __USB_OTG__
#if BSP_VUSB11_HOST_VECTOR0 < 6
   #define  HOST_INTERRUPT_ROUTINE_KEYWORD        _Interrupt1
#else
   #define  HOST_INTERRUPT_ROUTINE_KEYWORD        _Interrupt2
#endif

#if BSP_VUSB11_DEVICE_VECTOR0 < 6
	#define  DEVICE_INTERRUPT_ROUTINE_KEYWORD      _Interrupt1
#else
   #define  DEVICE_INTERRUPT_ROUTINE_KEYWORD      _Interrupt2
#endif
#endif

#if BSP_VUSB11_OTG_VECTOR0 < 6
   #define  OTG_INTERRUPT_ROUTINE_KEYWORD         _Interrupt1
#else
   #define  OTG_INTERRUPT_ROUTINE_KEYWORD         _Interrupt2
#endif

#ifdef __USB_OTG__
#define DEVICE_INTERRUPT_ROUTINE_KEYWORD
#define HOST_INTERRUPT_ROUTINE_KEYWORD
#define  INTERRUPT_ROUTINE_KEYWORD OTG_INTERRUPT_ROUTINE_KEYWORD
#else
#define  INTERRUPT_ROUTINE_KEYWORD HOST_INTERRUPT_ROUTINE_KEYWORD
#endif

#define  VUSB_ARC_BDT_OUT_BIT                (0x10)
#define  VUSB_ARC_BDT_IN_BIT                 (0x00)
#define  VUSB_ARC_BDT_ODD_EVEN_BIT           (0x08)

#define  VUSB_BDT_OUT_BIT                    (VUSB_ARC_BDT_OUT_BIT)
#define  VUSB_BDT_IN_BIT                     (VUSB_ARC_BDT_IN_BIT)
#define  VUSB_BDT_ODD_EVEN_BIT               (VUSB_ARC_BDT_ODD_EVEN_BIT)

#define  VUSB_GET_STATUS(BDT_ptr)            (BDT_ptr->PID & VUSB_BD_PID_MASKS)
#define  VUSB_GET_BYTE_COUNT(BDT_ptr)        (BDT_ptr->BC)
#define  VUSB_ENDPT_REG_OFFSET               (0x40)

#define  DISABLE_INTERRUPTS()                _ASM(".equ DI,0");\
                                             _ASM("flag DI")

#define  ENABLE_INTERRUPTS()                 _ASM(".equ EI,6");\
                                             _ASM("flag EI");

#ifdef __cplusplus
extern "C" {
#endif
#ifndef __USB_OS_MQX__
extern void USB_int_install_isr(uint_8, 
   INTERRUPT_ROUTINE_KEYWORD void (_CODE_PTR_ )(void), pointer);
extern void _disable_interrupts(void);
extern void _enable_interrupts(void);
#endif
#ifdef __cplusplus
}
#endif
   
#endif