⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 portconfig.h

📁 freescale的基于802.15.4的无线通讯例程
💻 H
字号:
/************************************************************************************
* Mapping of the IO ports and pins.
*
* (c) Copyright 2006, Freescale Semiconductor, Inc. All rights reserved.
*
* Freescale Confidential Proprietary
*
* 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.
************************************************************************************/

#ifndef _PORTCONFIG_H_
#define _PORTCONFIG_H_

#include "IoConfig.h"
#include "AppToPlatformConfig.h"

#if gTargetAxiomGB60_d == 1
#include "TargetAxiomGB60.h"
#endif /* gTargetAxiomGB60_d */

#if gTargetSARD_d == 1
#include "TargetMC1319xSARD.h"
#endif /* gTargetSARD_d */


//#if gTargetRD01_d == 1
//#include "TargetMC1319xRD01.h"
//#endif /* gTargetRD01_d */

#if gTargetEVB_d == 1
#include "TargetMC1319xEVB.h"
#endif

#if gTargetMC13213NCB_d == 1
#include "TargetMC1321xNCB.h"
#endif /* gTargetMC13213NCB_d */

#if gTargetMC13213SRB_d == 1
#include "TargetMC1321xSRB.h"
#endif /* gTargetMC13213SRB_d */

#define mPORT_PE(PORT_D)  (*((volatile unsigned char*)(&PORT_D+1)))
#define mPORT_SE(PORT_D)  (*((volatile unsigned char*)(&PORT_D+2)))
#define mPORT_DD(PORT_D)  (*((volatile unsigned char*)(&PORT_D+3)))
#if gTarget_UserDefined_d == 1

  #define NotDefined 

  /* macro used for enabling Low Noise Amplifier*/
  #define EnableLNA  NotDefined
  
  /* macro used for enabling Power Amplifier*/
  #define EnablePA   NotDefined
  
  /* macro used for disabling Low Noise Amplifier*/
  #define DisableLNA NotDefined
  
  /* macro used for disabling Power Amplifier*/
  #define DisablePA NotDefined
  
  #define MC1319x    0
  #define MC1321x    1  
  #define gUserTransceiverType_d MC1321x  
  
  /* Define LED port mapping */
  #define LED_PORT  PTDD
  #define LED1_PIN  0x10
  #define LED2_PIN  0x20
  #define LED3_PIN  0x40
  #define LED4_PIN  0x80
  #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  0x10
  #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;
  /* Turn on LEDs */
  #define TURN_ON_LEDS      LED_PORT  &= ~LED_MASK;

  /* Define PORT PINS mapping */
  #define PORT_PINS         PTAD
  #define PORT1_PIN         0x01
  #define PORT2_PIN         0x02
  #define PORT3_PIN         0x04
  #define PORT4_PIN         0x08
  #define PORT_PINS_MASK    (PORT1_PIN | PORT2_PIN | PORT3_PIN | PORT4_PIN)

  /* Define PCB switch mapping */
  #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 pin mapping */
  #define gMC1319xAttnPort     PTDD
  #define gMC1319xRxTxPort     PTDD
  #define gMC1319xResetPort    PTDD
  #define gMC1319xSpiPort      PTED

  #define gMC1319xAttnMask_c   0x01
  #define gMC1319xRxTxMask_c   0x02
  #define gMC1319xResetMask_c  0x08

  #define gMC1319xGPIO1Port    PTED
  #define gMC1319xGPIO2Port    PTED
  #define gMC1319xAntSwPort    PTBD

  #define gMC1319xGPIO1Mask_c  0x80
  #define gMC1319xGPIO2Mask_c  0x40
  #define gMC1319xAntSwMask_c   0x00

  #define gMC1319xSpiTxD1Mask_c  (1<<0)
  #define gMC1319xSpiRxD1Mask_c  (1<<1)
  #define gMC1319xSpiSsMask_c    (1<<2)
  #define gMC1319xSpiMisoMask_c  (1<<3)
  #define gMC1319xSpiMosiMask_c  (1<<4)
  #define gMC1319xSpiSpsckMask_c (1<<5)

  /* Define HW port mapping (Refer to MCU IO spreadsheet or schematic for details) */

  /* Port A - Not used by MC1319x driver. Available for application. */
  
  #define gPTADValue_c      0x00
  #define gPTAPEValue_c     0x3C
  #define gPTADDValue_c     0x42
  
  #define  mSETUP_PORT_A    PTAD  = gPTADValue_c;\
                            PTAPE = gPTAPEValue_c;\
                            PTADD = gPTADDValue_c; // Set as input

  /* Port B - Not used by MC1319x driver. Available for application. */
  
  #define gPTBDValue_c      0x00 // Port value
  #define gPTBPEValue_c     0x00 // Pullup Enable  1 PullUp enable 0 PullUp disable
  #define gPTBDDValue_c     0x00 // Data direction 1 output , 
  
  #define  mSETUP_PORT_B    PTBD  = gPTBDValue_c;\
                            PTBPE = gPTBPEValue_c;\
                            PTBDD = gPTBDDValue_c;  

  /* Port C - Not used by MC1319x driver. Available for application. */
  
  #define gPTCDValue_c      0x10
  #define gPTCPEValue_c     0x00
  #define gPTCDDValue_c     0x10  
  
  #define  mSETUP_PORT_C    PTCD  = gPTCDValue_c;\
                            PTCPE = gPTCPEValue_c;\
                            PTCDD = gPTCDDValue_c; 

  /* Port D - Used by MC1319x driver. Add pins for application if needed. */
  
  #define gPTDDValue_c      0xF2
  #define gPTDPEValue_c     0x00
  #define gPTDDDValue_c     0xFB   
  
  #define  mSETUP_PORT_D    PTDD  = gPTDDValue_c;\
                            PTDPE = gPTDPEValue_c;\
                            PTDDD = gPTDDDValue_c;
  
  /* Port E - Used by MC1319x driver. Add pins for application if needed. */
  
  #define gPTEDValue_c      0x14
  #define gPTEPEValue_c     0x00
  #define gPTEDDValue_c     0x1B     
  
  #define  mSETUP_PORT_E    PTED  = gPTEDValue_c;\
                            PTEPE = gPTEPEValue_c;\
                            PTEDD = gPTEDDValue_c;

  /* Port F - Not used by MC1319x driver. Available for application. */
  
  #define gPTFDValue_c      0x00
  #define gPTFPEValue_c     0x00
  #define gPTFDDValue_c     0x00    
  
  #define  mSETUP_PORT_F    PTFD  = gPTFDValue_c;\
                            PTFPE = gPTFPEValue_c;\
                            PTFDD = gPTFDDValue_c; 

  // Port G - Not used by MC1319x driver. Available for application.
  
  #define gPTGDValue_c      0x00
  #define gPTGPEValue_c     0x00
  #define gPTGDDValue_c     0x00     
  
  #define mSETUP_PORT_G      PTGD  = gPTGDValue_c;\
                             PTGPE = gPTGPEValue_c;\
   						               PTGDD = gPTGDDValue_c;
  
  
  #define mSETUP_SWICH_PORT mPORT_PE(SWITCH_PORT) |= mSWITCH_MASK;\
                            mPORT_DD(SWITCH_PORT) &= ~mSWITCH_MASK;
  
  
  #define mSETUP_TRANCEIVER_PORT  gMC1319xResetPort &= ~gMC1319xResetMask_c;\
                                  gMC1319xAttnPort &= ~gMC1319xAttnMask_c;\
                                  gMC1319xRxTxPort |=  gMC1319xRxTxMask_c;\
                                  mPORT_DD(gMC1319xResetPort) |= gMC1319xResetMask_c;\
                                  mPORT_DD(gMC1319xAttnPort)  |= gMC1319xAttnMask_c;\
                                  mPORT_DD(gMC1319xRxTxPort)  |= gMC1319xRxTxMask_c;\
                                  mPORT_PE(gMC1319xGPIO1Port) &= ~gMC1319xGPIO1Mask_c;\
                                  mPORT_PE(gMC1319xGPIO2Port) &= ~gMC1319xGPIO2Mask_c;\
                                  mPORT_DD(gMC1319xGPIO1Port) &= ~gMC1319xGPIO1Mask_c;\
                                  mPORT_DD(gMC1319xGPIO2Port) &= ~gMC1319xGPIO2Mask_c;\
                                  gMC1319xAntSwPort &= ~gMC1319xAntSwMask_c;\
                                  mPORT_DD(gMC1319xAntSwPort)  |= gMC1319xAntSwMask_c;\
                                  PTED  |= (gMC1319xSpiMosiMask_c | gMC1319xSpiSsMask_c);\
                                  PTEPE &= (~(gMC1319xSpiMisoMask_c  | gMC1319xSpiRxD1Mask_c));\
                                  PTEDD |= ((gMC1319xSpiTxD1Mask_c  | gMC1319xSpiSsMask_c | gMC1319xSpiMosiMask_c  | gMC1319xSpiSpsckMask_c ))\
                                         & (~(gMC1319xSpiMisoMask_c  | gMC1319xSpiRxD1Mask_c));

#define mSETUP_LED_PORT          LED_PORT |=LED_MASK;\
                                 mPORT_DD(LED_PORT)  |=LED_MASK;\
                                 LED5_PORT |= LED5_MASK;\
                                 mPORT_DD(LED5_PORT) |=LED5_MASK; 

/************************************************************************************
*************************************************************************************
Uart Port setup is for choosing the flow control pins RTS and CTS. 
The user can choose the port and the pin for RTS or CTS.  
*************************************************************************************
************************************************************************************/  
#define gSCI1RTSPort_c PTAD
#define gSCI1RTSPin_c 0x02
/* Set the pin direction OUTPUT*/
#define mSETUP_SCI1RTS_OUTPUT mPORT_DD(gSCI1RTSPort_c) |= gSCI1RTSPin_c;
 
#define gSCI1CTSPort_c PTAD
#define gSCI1CTSPin_c 0x01
/* Set the pin direction INPUT*/
#define mSETUP_SCI1CTS_INPUT mPORT_DD(gSCI1CTSPort_c) &= ~gSCI1CTSPin_c;
 
#define gSCI2RTSPort_c PTAD
#define gSCI2RTSPin_c 0x40
/* Set the pin direction OUTPUT*/
#define mSETUP_SCI2RTS_OUTPUT mPORT_DD(gSCI2RTSPort_c) |= gSCI2RTSPin_c;

#define gSCI2CTSPort_c PTAD
#define gSCI2CTSPin_c 0x80
/* Set the pin direction INPUT*/
#define mSETUP_SCI2CTS_INPUT mPORT_DD(gSCI2CTSPort_c) &= ~gSCI2CTSPin_c;

#define mSETUP_SCIxPINS mSETUP_SCI1RTS_OUTPUT\
                        mSETUP_SCI1CTS_INPUT\
                        mSETUP_SCI2RTS_OUTPUT\
                        mSETUP_SCI2CTS_INPUT

#endif /* gTarget_UserDefined_c */

#endif /* _PORTCONFIG_H_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -