/************************************************************************************
* The global header file containing platform specific definitions for
* the embedded platform
*
* Author(s): Allan Lyneborg Poulsen
*
* (c) Copyright 2004, Freescale, Inc.  All rights reserved.
*
* Freescale Confidential Proprietary
* Digianswer Confidential
*
* No part of this document must be reproduced in any form - including copied,
* transcribed, printed or by any electronic means - without specific written
* permission from Freescale.
*
* Last Inspected:
* Last Tested:
************************************************************************************/

#ifndef _APP_SPECIFIC_H_
#define _APP_SPECIFIC_H_

#include "gb60_io.h"

//**********************************************************************************
// Compiler warning removal pragmas
//**********************************************************************************

//**********************************************************************************
// Define target Hardware platform:
//**********************************************************************************

// Undef target defines because target.h is included in digitype.h!!!!

/*
#undef TARGET_DIG528_2
#undef TARGET_DIG536_2
#undef TARGET_DIG534_1
#undef TARGET_AXIOM_GB60
#undef TARGET_RD01
#undef TARGET_ABELWEAP
#undef TARGET_TOROWEAP
*/
#if !(defined(TARGET_DIG528_2) || defined(TARGET_DIG536_2) || defined(TARGET_DIG534_1) || defined(TARGET_AXIOM_GB60) ||\
      defined(TARGET_RD01) || defined(TARGET_ABELWEAP) || defined(TARGET_TOROWEAP))

// Enable target platform
//#define TARGET_DIG528_2 // 13192-EVB
//#define TARGET_DIG536_2 // 13192-SARD
//#define TARGET_DIG534_1 // Sniffer
#define TARGET_AXIOM_GB60 // 802.15.4 Dev Platform
//#define TARGET_RD01 // For all boards which uses the Freescale reference design 01 layout
//#define TARGET_ABELWEAP // For FSL 560 board using Abelweap
//#define TARGET_TOROWEAP // For FSL 562 and 563 board using Toroweap
    // Sub targets - Select only one
    //#define MC13213_NCB // For FSL 562 Coordinator/router board using Toroweap with LCD
    #define MC13213_SRB // For FSL 563 Sensor board using Toroweap with acc. meter

#endif

//**********************************************************************************

// MAC device type minimum clock values. User can specify a higher clock frequency.
#ifdef Type_RFDNBNS
	#define SYSTEM_CLOCK_16MHZ
#endif Type_RFDNBNS

#ifdef Type_RFDNBNV
	#define SYSTEM_CLOCK_16MHZ
#endif Type_RFDNBNV

#ifdef  Type_RFDNB
	#define SYSTEM_CLOCK_16MHZ
#endif  Type_RFDNB

#ifdef Type_RFD
	#define SYSTEM_CLOCK_16MHZ
#endif Type_RFD

#ifdef Type_FFDNBNS
	#define SYSTEM_CLOCK_16MHZ
#endif Type_FFDNBNS

#ifdef Type_FFDNBNV
	#define SYSTEM_CLOCK_16MHZ
#endif Type_FFDNBNV

#ifdef Type_FFDNB
	#define SYSTEM_CLOCK_16MHZ
#endif Type_FFDNB

#ifdef Type_FFDNGTS
	#define SYSTEM_CLOCK_16MHZ
#endif Type_FFDNGTS

#ifdef Type_FFD
	#define SYSTEM_CLOCK_16MHZ
#endif Type_FFD

#ifdef Type_FFDPNBNV
	#define SYSTEM_CLOCK_16MHZ
#endif Type_FFD

#ifndef gDeviceType_d // If device type is not predefined use the following definitions:
  #define SYSTEM_CLOCK_16MHZ
#endif gDeviceType_d

//**********************************************************************************

#ifdef TARGET_AXIOM_GB60
  // UART interface select SCI1 or SCI2- enable one
  #define SELECT_SCI1
  //#define SELECT_SCI2
  			
  #define LED_PORT  PTFD
  #define LED1_PIN  (1<<0)
  #define LED2_PIN  (1<<1)
  #define LED3_PIN  (1<<2)
  #define LED4_PIN  (1<<3)
  #define LED_MASK  (LED1_PIN | LED2_PIN | LED3_PIN | LED4_PIN)
  
  #define LED1ON            LED_PORT &= ~LED1_PIN;
  #define LED1OFF           LED_PORT |= LED1_PIN;
  #define LED1TOGGLE        LED_PORT ^= LED1_PIN;

  #define LED2ON            LED_PORT &= ~LED2_PIN;
  #define LED2OFF           LED_PORT |= LED2_PIN;
  #define LED2TOGGLE        LED_PORT ^= LED2_PIN;

  #define LED3ON            LED_PORT &= ~LED3_PIN;
  #define LED3OFF           LED_PORT |= LED3_PIN;
  #define LED3TOGGLE        LED_PORT ^= LED3_PIN;

  #define LED4ON            LED_PORT &= ~LED4_PIN;
  #define LED4OFF           LED_PORT |= LED4_PIN;
  #define LED4TOGGLE        LED_PORT ^= LED4_PIN;

    // Turn off LEDs
  #define TURN_OFF_LEDS     LED_PORT |= LED_MASK;

  
  // PCB switches defines
  #define SWITCH_PORT   PTAD
  #define mSWITCH1_MASK 0x10
  #define mSWITCH2_MASK 0x20
  #define mSWITCH3_MASK 0x40
  #define mSWITCH4_MASK 0x80
  #define mSWITCH_MASK  (mSWITCH1_MASK | mSWITCH2_MASK |  mSWITCH3_MASK | mSWITCH4_MASK)
  
  #define mSWITCH_PORT_GET  ((SWITCH_PORT & mSWITCH_MASK) ^ mSWITCH_MASK)

// LCD Display
    #define LCD_ENABLE  // To enable support for LCD display - else mask out

    // LCD macros
    #define COMMAND_MODE        PTED &= ~0x40; //RS cleared
    #define DATA_MODE           PTED |= 0x40;  //RS set
    
    // This function toggles the E(EN) line (LCD).
    #define TOGGLE_LCD_ENABLE   PTED |=  0x80;\
                                PTED &= ~0x80;
                                
    // Target PCB specific
    #define LCD_PORT            PTGD
    #define LCD_LEFT_SHIFT      4
    #define LCD_RIGHT_SHIFT     0
    #define LCD_READ_AND_MASK   0x0F
    
    #define LCD_WRITE_MSB_AND_MASK  0xF0
    #define LCD_WRITE_LSB_AND_MASK  0x0F

    #define LCD_MASK1           0xC0; // PTE6:7 as output for LCD display
    #define LCD_MASK2           0xF8; // PTG3:7 as output for LCD display

                                

// Define HW port mappings
  // Port A - not used by PHY layer. Reinitialize in application if needed.
  #define  mAPP_SETUP_PORT_A    PTAD  = 0x00;\
                                PTAPE = mSWITCH_MASK;\
                                PTADD = 0x00; // Set as input

  // Port B - used by PHY layer. Remember to AND or OR new values to preserve original settings.
  #define  mAPP_SETUP_PORT_B    //PTBD  = 0x00;\
                                //PTBPE = 0x00;\
                                //PTBDD = 0x00;
                            
  // Port C - used by PHY layer. Remember to AND or OR new values to preserve original settings.
  #define  mAPP_SETUP_PORT_C    //PTCD  = 0x00;\
                                //PTCPE = 0x00;\
                                //PTCDD = 0x00;
                            
  // Port D - used by PHY layer. Reinitialize in application if needed.
  #define  mAPP_SETUP_PORT_D    //PTDD  = 0x00;\
                                //PTDPE = 0x00;\
   						        //PTDDD = 0x00;

  // Port E - not used by PHY layer. Reinitialize in application if needed.
  #ifdef LCD_ENABLE
     #define  mAPP_SETUP_PORT_E    PTED  |= 0x00;\
                                   PTEPE |= 0x00;\
   	                               PTEDD |= LCD_MASK1;
  #else
    #define  mAPP_SETUP_PORT_E
  #endif LCD_ENABLE

  // Port F - not used by PHY layer. Reinitialize in application if needed.
  #define  mAPP_SETUP_PORT_F    PTFD  = 0x00;\
                                PTFPE = 0x00;\
   			                    PTFDD = LED_MASK;

  #ifdef LCD_ENABLE
  // Port G - not used by PHY layer. Reinitialize in application if needed.
    #define  mAPP_SETUP_PORT_G    PTGD  = 0x00;\
                                  PTGPE = 0x00;\
   	                              PTGDD = LCD_MASK2;
  #else
    #define  mAPP_SETUP_PORT_G  
  #endif LCD_ENABLE

  // Select one - to get correct baud rate
  //#define __SYSTEM_BUS_CLOCK_32_78
  //#define __SYSTEM_BUS_CLOCK_62_5
  #define __USE_BAUD_RATE_FROM_NV_RAM


  // Select default baud rates when no NVM is found. SELECT ONLY ONE
  #define BAUD_RATE_19200_AT16MHZ
  //#define BAUD_RATE_115200_AT16_78MHZ
  			

//////// Sniffer Defines ///////////////
  #define GREEN_LED_OFF     LED1OFF
  #define GREEN_LED_ON      LED1ON
  #define GREEN_LED_TOGGLE  LED1TOGGLE

  #define RED_LED_OFF       LED2OFF
  #define RED_LED_ON        LED2ON
  #define RED_LED_TOGGLE    LED2TOGGLE
////////////////////////////////////////

#endif TARGET_AXIOM_GB60

//**********************************************************************************
#if defined TARGET_ABELWEAP
  // UART interface select SCI1 or SCI2- enable one
  #define SELECT_SCI1
  //#define SELECT_SCI2

  #define LED_PORT  PTDD
  #define LED1_PIN  (1<<4)
  #define LED2_PIN  (1<<5)
  #define LED3_PIN  (1<<6)
  #define LED4_PIN  (1<<7)
  #define LED_MASK  (LED1_PIN | LED2_PIN | LED3_PIN | LED4_PIN)
  
  #define LED1ON            LED_PORT &= ~LED1_PIN;
  #define LED1OFF           LED_PORT |= LED1_PIN;
  #define LED1TOGGLE        LED_PORT ^= LED1_PIN;

  #define LED2ON            LED_PORT &= ~LED2_PIN;
  #define LED2OFF           LED_PORT |= LED2_PIN;
  #define LED2TOGGLE        LED_PORT ^= LED2_PIN;

  #define LED3ON            LED_PORT &= ~LED3_PIN;
  #define LED3OFF           LED_PORT |= LED3_PIN;
  #define LED3TOGGLE        LED_PORT ^= LED3_PIN;

  #define LED4ON            LED_PORT &= ~LED4_PIN;
  #define LED4OFF           LED_PORT |= LED4_PIN;
  #define LED4TOGGLE        LED_PORT ^= LED4_PIN;
  
    // Turn off LEDs
  #define TURN_OFF_LEDS     LED_PORT |= LED_MASK;

  // PCB switches defines
  #define SWITCH_PORT   PTAD
  #define mSWITCH1_MASK 0x04
  #define mSWITCH2_MASK 0x08
  #define mSWITCH3_MASK 0x10
  #define mSWITCH4_MASK 0x20
  #define mSWITCH_MASK  (mSWITCH1_MASK | mSWITCH2_MASK |  mSWITCH3_MASK | mSWITCH4_MASK)
  
  #define mSWITCH_PORT_GET  ((SWITCH_PORT & mSWITCH_MASK) ^ mSWITCH_MASK)

// Define HW port mappings
  // Port A - not used by PHY layer. Reinitialize in application if needed.
  #define  mAPP_SETUP_PORT_A    PTAD  = 0x00;\
                                PTAPE |= mSWITCH_MASK;\
                                PTADD = 0x00; // Set as input

  // Port B - used by PHY layer. Remember to AND or OR new values to preserve original settings.
  #define  mAPP_SETUP_PORT_B    //PTBD  = 0x00;\
                                //PTBPE = 0x00;\
                                //PTBDD = 0x00;
                            
  // Port C - used by PHY layer. Remember to AND or OR new values to preserve original settings.
  #define  mAPP_SETUP_PORT_C    //PTCD  = 0x00;\
                                //PTCPE = 0x00;\
                                //PTCDD = 0x00;
                            
  // Port D - not used by PHY layer. Reinitialize in application if needed.
  #define  mAPP_SETUP_PORT_D    PTDD  |= 0x00;\
                                PTDPE |= 0x00;\
   						        PTDDD |= LED_MASK;

  // Port E - not used by PHY layer. Reinitialize in application if needed.
  #define  mAPP_SETUP_PORT_E    //PTED  = 0x00;\
                                //PTEPE = 0x00;\
   						        //PTEDD = 0x00;

  // Port F - not used by PHY layer. Reinitialize in application if needed.
  #define  mAPP_SETUP_PORT_F    //PTFD  = 0x00;\
                                //PTFPE = 0x00;\
                                //PTFDD = 0x00;

  #define  mAPP_SETUP_PORT_G    //PTGD  = 0x00;\
                                //PTGPE = 0x00;\
   						        //PTGDD = 0x00;

  //#define FTDI_USB

  // Select one - to get correct baud rate
  //#define __SYSTEM_BUS_CLOCK_32_78
  //#define __SYSTEM_BUS_CLOCK_62_5
  #define __USE_BAUD_RATE_FROM_NV_RAM


  // Select default baud rates when no NVM is found. SELECT ONLY ONE
  #define BAUD_RATE_19200_AT16MHZ
  //#define BAUD_RATE_115200_AT16_78MHZ

  // Store detected SCI-port in Embedded Bootloader memory space. Nasty!!!
  // Addresses in Embedded Bootloader must NOT change. Adjust if necessary.
  // 20.08.04 MVC

  //#define NO_EMBEDDED_BOOTLOADER
  //#define EMBEDDED_BOOTLOADER_400
  //#define EMBEDDED_BOOTLOADER_410
  //#define EMBEDDED_BOOTLOADER_501
  //#define EMBEDDED_BOOTLOADER_520
  //#define EMBEDDED_BOOTLOADER_530
  //#define BOOTLOADER_LITE_100

  #ifdef EMBEDDED_BOOTLOADER_400
      #define EB_SCIX_S1_REG_ADDRESS  0x1079
      #define EB_SCIX_D_REG_ADDRESS   0x107B
  #endif EMBEDDED_BOOTLOADER_400

  #ifdef EMBEDDED_BOOTLOADER_410
      #define EB_SCIX_S1_REG_ADDRESS  0x107A
      #define EB_SCIX_D_REG_ADDRESS   0x107C
  #endif EMBEDDED_BOOTLOADER_410

  #ifdef EMBEDDED_BOOTLOADER_501
      // Calls a function instead
  #endif EMBEDDED_BOOTLOADER_501

  #ifdef EMBEDDED_BOOTLOADER_520
      // Calls a function instead
  #endif EMBEDDED_BOOTLOADER_520

  #ifdef EMBEDDED_BOOTLOADER_530
      // Calls a function instead
  #endif EMBEDDED_BOOTLOADER_530

  #ifdef BOOTLOADER_LITE_100
      // Calls a function instead
  #endif BOOTLOADER_LITE_100

#endif defined TARGET_ABELWEAP

//**********************************************************************************
#if defined TARGET_TOROWEAP
  // UART interface select SCI1 or SCI2- enable one
  #define SELECT_SCI1
  //#define SELECT_SCI2

  #define LED_PORT  PTDD
  #define LED1_PIN  (1<<4)
  #define LED2_PIN  (1<<5)
  #define LED3_PIN  (1<<6)
  #define LED4_PIN  (1<<7)
  #define LED_MASK  (LED1_PIN | LED2_PIN | LED3_PIN | LED4_PIN)
  
  #define LED1ON            LED_PORT &= ~LED1_PIN;
  #define LED1OFF           LED_PORT |= LED1_PIN;
  #define LED1TOGGLE        LED_PORT ^= LED1_PIN;

  #define LED2ON            LED_PORT &= ~LED2_PIN;
  #define LED2OFF           LED_PORT |= LED2_PIN;
  #define LED2TOGGLE        LED_PORT ^= LED2_PIN;

  #define LED3ON            LED_PORT &= ~LED3_PIN;
  #define LED3OFF           LED_PORT |= LED3_PIN;
  #define LED3TOGGLE        LED_PORT ^= LED3_PIN;

  #define LED4ON            LED_PORT &= ~LED4_PIN;
  #define LED4OFF           LED_PORT |= LED4_PIN;
  #define LED4TOGGLE        LED_PORT ^= LED4_PIN;


  #define LED5_PORT  PTCD
  #define LED5_PIN  (1<<4)
  #define LED5_MASK  (LED5_PIN)
  
  #define LED5ON            LED5_PORT &= ~LED5_PIN;
  #define LED5OFF           LED5_PORT |= LED5_PIN;
  #define LED5TOGGLE        LED5_PORT ^= LED5_PIN;


  // Turn off LEDs
  #define TURN_OFF_LEDS     LED_PORT |= LED_MASK;\
                            LED5_PORT |= LED5_MASK;

  // PCB switches defines
  #define SWITCH_PORT   PTAD
  #define mSWITCH1_MASK 0x04
  #define mSWITCH2_MASK 0x08
  #define mSWITCH3_MASK 0x10
  #define mSWITCH4_MASK 0x20
  #define mSWITCH_MASK  (mSWITCH1_MASK | mSWITCH2_MASK |  mSWITCH3_MASK | mSWITCH4_MASK)
  
  #define mSWITCH_PORT_GET  ((SWITCH_PORT & mSWITCH_MASK) ^ mSWITCH_MASK)


#ifdef MC13213_NCB

// LCD Display
    #define LCD_ENABLE  // To enable support for LCD display - else mask out

    // LCD macros
    #define COMMAND_MODE        PTBD &= ~0x02; //RS cleared
    #define DATA_MODE           PTBD |= 0x02;  //RS set
    
    // This function toggles the E(EN) line (LCD).
    #define TOGGLE_LCD_ENABLE   PTBD |=  0x04;\
                                PTBD &= ~0x04;
                                
    // Target PCB specific
    #define LCD_PORT            PTBD
    #define LCD_LEFT_SHIFT      4
    #define LCD_RIGHT_SHIFT     0
    #define LCD_READ_AND_MASK   0x0F
    
    #define LCD_WRITE_MSB_AND_MASK  0xF0
    #define LCD_WRITE_LSB_AND_MASK  0x0F

    #define LCD_MASK            0xFF // Set as output for LCD display

#endif MC13213_NCB

    #define EEPROM_CS           0x80 // To avoid that EEPROM is selected CS, Must be high


// Define HW port mappings
  // Port A - not used by PHY layer. Reinitialize in application if needed.
  #define  mAPP_SETUP_PORT_A    PTAD  = 0x00;\
                                PTAPE |= mSWITCH_MASK;\
                                PTADD = 0x00; // Set as input

  
  // Port B - used by PHY layer. Remember to AND or OR new values to preserve original settings.
  #ifdef LCD_ENABLE

    #define  mAPP_SETUP_PORT_B    PTBD  = 0x00;\
                                  PTBPE = 0x00;\
                                  PTBDD = LCD_MASK; // As output for LCD display
#else
    #define  mAPP_SETUP_PORT_B
  #endif LCD_ENABLE
                            
  // Port C - used by PHY layer. Remember to AND or OR new values to preserve original settings.
  #define  mAPP_SETUP_PORT_C    PTCD  |= EEPROM_CS;\
                                PTCPE = 0x00;\
                                PTCDD |= (EEPROM_CS | LED5_MASK);
                            
  // Port D - not used by PHY layer. Reinitialize in application if needed.
  #define  mAPP_SETUP_PORT_D    PTDD  |= LED_MASK;\
                                PTDPE |= 0x00;\
   						        PTDDD |= LED_MASK;

  // Port E - not used by PHY layer. Reinitialize in application if needed.
  #define  mAPP_SETUP_PORT_E    //PTED  = 0x00;\
                                //PTEPE = 0x00;\
   						        //PTEDD = 0x00;

  // Port F - not used by PHY layer. Reinitialize in application if needed.
  #define  mAPP_SETUP_PORT_F    //PTFD  = 0x00;\
                                //PTFPE = 0x00;\
   						        //PTFDD = 0x00;

  #define  mAPP_SETUP_PORT_G    //PTGD  = 0x00;\
                                //PTGPE = 0x00;\
   						        //PTGDD = 0x00;

  //#define FTDI_USB

  // Select one - to get correct baud rate
  //#define __SYSTEM_BUS_CLOCK_32_78
  //#define __SYSTEM_BUS_CLOCK_62_5
  #define __USE_BAUD_RATE_FROM_NV_RAM


  // Select default baud rates when no NVM is found. SELECT ONLY ONE
  #define BAUD_RATE_19200_AT16MHZ
  //#define BAUD_RATE_115200_AT16_78MHZ

  // Store detected SCI-port in Embedded Bootloader memory space. Nasty!!!
  // Addresses in Embedded Bootloader must NOT change. Adjust if necessary.
  // 20.08.04 MVC

  //#define NO_EMBEDDED_BOOTLOADER
  //#define EMBEDDED_BOOTLOADER_400
  //#define EMBEDDED_BOOTLOADER_410
  //#define EMBEDDED_BOOTLOADER_501
  //#define EMBEDDED_BOOTLOADER_520
  //#define EMBEDDED_BOOTLOADER_530
  //#define BOOTLOADER_LITE_100

  #ifdef EMBEDDED_BOOTLOADER_400
      #define EB_SCIX_S1_REG_ADDRESS  0x1079
      #define EB_SCIX_D_REG_ADDRESS   0x107B
  #endif EMBEDDED_BOOTLOADER_400

  #ifdef EMBEDDED_BOOTLOADER_410
      #define EB_SCIX_S1_REG_ADDRESS  0x107A
      #define EB_SCIX_D_REG_ADDRESS   0x107C
  #endif EMBEDDED_BOOTLOADER_410

  #ifdef EMBEDDED_BOOTLOADER_501
      // Calls a function instead
  #endif EMBEDDED_BOOTLOADER_501

  #ifdef EMBEDDED_BOOTLOADER_520
      // Calls a function instead
  #endif EMBEDDED_BOOTLOADER_520

  #ifdef EMBEDDED_BOOTLOADER_530
      // Calls a function instead
  #endif EMBEDDED_BOOTLOADER_530

  #ifdef BOOTLOADER_LITE_100
      // Calls a function instead
  #endif BOOTLOADER_LITE_100

#endif defined TARGET_TOROWEAP

//**********************************************************************************

#if defined TARGET_DIG536_2 || defined TARGET_DIG528_2 || defined TARGET_RD01 // 13192-SARD or 13192-EVB
  // UART interface select SCI1 or SCI2- enable one
  #define SELECT_SCI1
  //#define SELECT_SCI2

  #define LED_PORT  PTDD
  #define LED1_PIN  (1<<0)
  #define LED2_PIN  (1<<1)
  #define LED3_PIN  (1<<3)
  #define LED4_PIN  (1<<4)
  #define LED_MASK  (LED1_PIN | LED2_PIN | LED3_PIN | LED4_PIN)
  
  #define LED1ON            LED_PORT &= ~LED1_PIN;
  #define LED1OFF           LED_PORT |= LED1_PIN;
  #define LED1TOGGLE        LED_PORT ^= LED1_PIN;

  #define LED2ON            LED_PORT &= ~LED2_PIN;
  #define LED2OFF           LED_PORT |= LED2_PIN;
  #define LED2TOGGLE        LED_PORT ^= LED2_PIN;

  #define LED3ON            LED_PORT &= ~LED3_PIN;
  #define LED3OFF           LED_PORT |= LED3_PIN;
  #define LED3TOGGLE        LED_PORT ^= LED3_PIN;

  #define LED4ON            LED_PORT &= ~LED4_PIN;
  #define LED4OFF           LED_PORT |= LED4_PIN;
  #define LED4TOGGLE        LED_PORT ^= LED4_PIN;

    // Turn off LEDs
  #define TURN_OFF_LEDS     LED_PORT |= LED_MASK;

  // PCB switches defines
  #define SWITCH_PORT   PTAD
  #define mSWITCH1_MASK 0x04
  #define mSWITCH2_MASK 0x08
  #define mSWITCH3_MASK 0x10
  #define mSWITCH4_MASK 0x20
  #define mSWITCH_MASK  (mSWITCH1_MASK | mSWITCH2_MASK |  mSWITCH3_MASK | mSWITCH4_MASK)
  
  #define mSWITCH_PORT_GET  ((SWITCH_PORT & mSWITCH_MASK) ^ mSWITCH_MASK)

// Define HW port mappings
  // Port A - not used by PHY layer. Reinitialize in application if needed.
  #define  mAPP_SETUP_PORT_A    PTAD  = 0x00;\
                                PTAPE = mSWITCH_MASK;\
                                PTADD = 0x00; // Set as input

  // Port B - used by PHY layer. Remember to AND or OR new values to preserve original settings.
  #define  mAPP_SETUP_PORT_B    //PTBD  = 0x00;\
                                //PTBPE = 0x00;\
                                //PTBDD = 0x00;
                            
  // Port C - used by PHY layer. Remember to AND or OR new values to preserve original settings.
  #define  mAPP_SETUP_PORT_C    //PTCD  = 0x00;\
                                //PTCPE = 0x00;\
                                //PTCDD = 0x00;
                            
  // Port D - not used by PHY layer. Reinitialize in application if needed.
  #define  mAPP_SETUP_PORT_D    PTDD  = 0x00;\
                                PTDPE = 0x00;\
   						                  PTDDD = LED_MASK;

  // Port E - not used by PHY layer. Reinitialize in application if needed.
  #define  mAPP_SETUP_PORT_E    //PTED  = 0x00;\
                                //PTEPE = 0x00;\
   						                  //PTEDD = 0x00;

  // Port F - not used by PHY layer. Reinitialize in application if needed.
  #define  mAPP_SETUP_PORT_F    //PTFD  = 0x00;\
                                //PTFPE = 0x00;\
   						                  //PTFDD = 0x00;


  #define  mAPP_SETUP_PORT_G

  //#define FTDI_USB

  // Select one - to get correct baud rate
  //#define __SYSTEM_BUS_CLOCK_32_78
  //#define __SYSTEM_BUS_CLOCK_62_5
  #define __USE_BAUD_RATE_FROM_NV_RAM


  // Select default baud rates when no NVM is found. SELECT ONLY ONE
  #define BAUD_RATE_19200_AT16MHZ
  //#define BAUD_RATE_115200_AT16_78MHZ

  // Store detected SCI-port in Embedded Bootloader memory space. Nasty!!!
  // Addresses in Embedded Bootloader must NOT change. Adjust if necessary.
  // 20.08.04 MVC

  // The below defines are moved to preprocessor
  // So change compiler setting if changed
  // DO NOT ENABLE HEARE
  //#define NO_EMBEDDED_BOOTLOADER
  //#define EMBEDDED_BOOTLOADER_400
  //#define EMBEDDED_BOOTLOADER_410
  //#define EMBEDDED_BOOTLOADER_501
  //#define EMBEDDED_BOOTLOADER_520
  //#define EMBEDDED_BOOTLOADER_530
  //#define EMBEDDED_BOOTLOADER_DYN_530
  //#define BOOTLOADER_LITE_100
  //#define BOOTLOADER_LITE_200
  //#define HCS08_FLASH_LIB_530
  //#define HCS08_DYN_FLASH_LIB_530

  #ifdef EMBEDDED_BOOTLOADER_400
      #define EB_SCIX_S1_REG_ADDRESS  0x1079
      #define EB_SCIX_D_REG_ADDRESS   0x107B
  #endif EMBEDDED_BOOTLOADER_400

  #ifdef EMBEDDED_BOOTLOADER_410
      #define EB_SCIX_S1_REG_ADDRESS  0x107A
      #define EB_SCIX_D_REG_ADDRESS   0x107C
  #endif EMBEDDED_BOOTLOADER_410

  #ifdef EMBEDDED_BOOTLOADER_501
      // Calls a function instead
  #endif EMBEDDED_BOOTLOADER_501

  #ifdef EMBEDDED_BOOTLOADER_520
      // Calls a function instead
  #endif EMBEDDED_BOOTLOADER_520

  #ifdef EMBEDDED_BOOTLOADER_530
      // Calls a function instead
  #endif EMBEDDED_BOOTLOADER_530

#endif TARGET_DIG536_2 || TARGET_DIG528_2 || defined TARGET_RD01

//**********************************************************************************

#ifdef TARGET_DIG534_1 // Sniffer
  #define FTDI_USB
// UART interface select SCI1 or SCI2- enable one
  #define SELECT_SCI1
//#define SELECT_SCI2

  #define LED_PORT  PTDD
  #define LED1_PIN  (1<<3)
  #define LED2_PIN  (1<<4)
  #define LED_MASK  (LED1_PIN | LED2_PIN)
  
  #define LED1ON            LED_PORT &= ~LED1_PIN;
  #define LED1OFF           LED_PORT |= LED1_PIN;
  #define LED1TOGGLE        LED_PORT ^= LED1_PIN;

  #define LED2ON            LED_PORT &= ~LED2_PIN;
  #define LED2OFF           LED_PORT |= LED2_PIN;
  #define LED2TOGGLE        LED_PORT ^= LED2_PIN;


// Define HW port mappings
  // Port A - not used by PHY layer. Reinitialize in application if needed.
  #define  mAPP_SETUP_PORT_A    //PTAD  = 0x00;\
                                //PTAPE = 0x00;\
                                //PTADD = 0x00; // Set as input

  // Port B - used by PHY layer. Remember to AND or OR new values to preserve original settings.
  #define  mAPP_SETUP_PORT_B    //PTBD  = 0x00;\
                                //PTBPE = 0x00;\
                                //PTBDD = 0x00;
                            
  // Port C - used by PHY layer. Remember to AND or OR new values to preserve original settings.
  #define  mAPP_SETUP_PORT_C    //PTCD  = 0x00;\
                                //PTCPE = 0x00;\
                                //PTCDD = 0x00;
                            
  // Port D - not used by PHY layer. Reinitialize in application if needed.
  #define  mAPP_SETUP_PORT_D    PTDD  = 0x00;\
                                PTDPE = 0x00;\
   						        PTDDD = LED_MASK;

  // Port E - not used by PHY layer. Reinitialize in application if needed.
  #define  mAPP_SETUP_PORT_E    //PTED  = 0x00;\
                                //PTEPE = 0x00;\
   						                  //PTEDD = 0x00;

  // Port F - not used by PHY layer. Reinitialize in application if needed.
  #define  mAPP_SETUP_PORT_F    //PTFD  = 0x00;\
                                //PTFPE = 0x00;\
   						                  //PTFDD = 0x00;

  #define GREEN_LED_OFF            LED1OFF
  #define GREEN_LED_ON             LED1ON
  #define GREEN_LED_TOGGLE         LED1TOGGLE

  #define RED_LED_OFF              LED2OFF
  #define RED_LED_ON               LED2ON
  #define RED_LED_TOGGLE           LED2TOGGLE

#endif TARGET_DIG534_1


//**********************************************************************************

#endif _APP_SPECIFIC_H_
