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

📄 io.c

📁 用c语言实现对单片机端口的设置
💻 C
字号:
//****************************************************************************
// @Module        Parallel Ports
// @Filename      IO.C
// @Project       PORT3.dav
//----------------------------------------------------------------------------
// @Controller    Infineon XC167CI-32F40
//
// @Compiler      Keil
//
// @Codegenerator 2.5
//
// @Description   This file contains functions that use the IO module.
//
//----------------------------------------------------------------------------
// @Date          2007-4-3 11:44:50
//
//****************************************************************************

// USER CODE BEGIN (IO_General,1)

// USER CODE END



//****************************************************************************
// @Project Includes
//****************************************************************************

#include "MAIN.H"

// USER CODE BEGIN (IO_General,2)

// USER CODE END


//****************************************************************************
// @Macros
//****************************************************************************

// USER CODE BEGIN (IO_General,3)

// USER CODE END


//****************************************************************************
// @Defines
//****************************************************************************

// USER CODE BEGIN (IO_General,4)

// USER CODE END


//****************************************************************************
// @Typedefs
//****************************************************************************

// USER CODE BEGIN (IO_General,5)

// USER CODE END


//****************************************************************************
// @Imported Global Variables
//****************************************************************************

// USER CODE BEGIN (IO_General,6)

// USER CODE END


//****************************************************************************
// @Global Variables
//****************************************************************************

// USER CODE BEGIN (IO_General,7)

// USER CODE END


//****************************************************************************
// @External Prototypes
//****************************************************************************

// USER CODE BEGIN (IO_General,8)

// USER CODE END


//****************************************************************************
// @Prototypes Of Local Functions
//****************************************************************************

// USER CODE BEGIN (IO_General,9)

// USER CODE END


//****************************************************************************
// @Function      void IO_vInit(void) 
//
//----------------------------------------------------------------------------
// @Description   This is the initialization function of the IO function 
//                library. It is assumed that the SFRs used by this library 
//                are in its reset state. 
//
//----------------------------------------------------------------------------
// @Returnvalue   None
//
//----------------------------------------------------------------------------
// @Parameters    None
//
//----------------------------------------------------------------------------
// @Date          2007-4-3
//
//****************************************************************************

// USER CODE BEGIN (IO_Function,1)

// USER CODE END

void IO_vInit(void)
{
  // USER CODE BEGIN (IO_Function,2)

  // USER CODE END

  ///  -----------------------------------------------------------------------
  ///  General Port Settings:
  ///  -----------------------------------------------------------------------
  PICON          =  0x0000;      // load input configuration register

  ///  -----------------------------------------------------------------------
  ///  Configuration of Port P0H:
  ///  -----------------------------------------------------------------------
  ///  - no pin of port P0H is used

  P0H            =  0x0000;      // load data register
  POCON0H        =  0x0000;      // load output control register
  DP0H           =  0x0000;      // load direction register

  ///  -----------------------------------------------------------------------
  ///  Configuration of Port P0L:
  ///  -----------------------------------------------------------------------
  ///  - no pin of port P0L is used

  P0L            =  0x0000;      // load data register
  POCON0L        =  0x0000;      // load output control register
  DP0L           =  0x0000;      // load direction register

  ///  -----------------------------------------------------------------------
  ///  Configuration of Port P1H:
  ///  -----------------------------------------------------------------------
  ///  - no pin of port P1H is used

  P1H            =  0x0000;      // load data register
  ALTSEL0P1H     =  0x0000;      // load alternate output function select 
                                 // register 0
  POCON1H        =  0x0000;      // load output control register
  DP1H           =  0x0000;      // load direction register

  ///  -----------------------------------------------------------------------
  ///  Configuration of Port P1L:
  ///  -----------------------------------------------------------------------
  ///  - no pin of port P1L is used

  P1L            =  0x0000;      // load data register
  ALTSEL0P1L     =  0x0000;      // load alternate output function select 
                                 // register 0
  POCON1L        =  0x0000;      // load output control register
  DP1L           =  0x0000;      // load direction register

  ///  -----------------------------------------------------------------------
  ///  Configuration of Port P2:
  ///  -----------------------------------------------------------------------
  ///  - no pin of port P2 is used

  ODP2           =  0x0000;      // load open-drain register
  P2             =  0x0000;      // load data register
  ALTSEL0P2      =  0x0000;      // load alternate output function select 
                                 // register 0
  POCON2         =  0x0000;      // load output control register
  DP2            =  0x0000;      // load direction register

  ///  -----------------------------------------------------------------------
  ///  Configuration of Port P3:
  ///  -----------------------------------------------------------------------
  ///  P3.0 is used as general purpose output
  ///  - push/pull output is selected
  ///  - the pin status is low level
  ///  P3.1 is used as general purpose output
  ///  - push/pull output is selected
  ///  - the pin status is low level
  ///  P3.2 is used as general purpose output
  ///  - push/pull output is selected
  ///  - the pin status is low level
  ///  P3.3 is used as general purpose output
  ///  - push/pull output is selected
  ///  - the pin status is low level
  ///  P3.4 is used as general purpose output
  ///  - push/pull output is selected
  ///  - the pin status is low level
  ///  P3.5 is used as general purpose output
  ///  - push/pull output is selected
  ///  - the pin status is low level
  ///  P3.6 is used as general purpose output
  ///  - push/pull output is selected
  ///  - the pin status is low level
  ///  P3.7 is used as general purpose output
  ///  - push/pull output is selected
  ///  - the pin status is low level
  ///  P3.8 is used as general purpose output
  ///  - push/pull output is selected
  ///  - the pin status is low level
  ///  P3.9 is used as general purpose output
  ///  - push/pull output is selected
  ///  - the pin status is low level

  ///  P3.0 - P3.7 threshold type: TTL input
  ///  P3.8 - P3.15 threshold type: TTL input

  ///  P3.0 - P3.3 output driver characteristic: strong driver
  ///  P3.4 - P3.7 output driver characteristic: strong driver
  ///  P3.8 - P3.11 output driver characteristic: strong driver
  ///  P3.12 - P3.15 output driver characteristic: strong driver

  ///  P3.0 - P3.3 output edge characteristic: sharp edge mode
  ///  P3.4 - P3.7 output edge characteristic: sharp edge mode
  ///  P3.8 - P3.11 output edge characteristic: sharp edge mode
  ///  P3.12 - P3.15 output edge characteristic: sharp edge mode

  ODP3           =  0x0000;      // load open-drain register
  P3             =  0x0000;      // load data register
  ALTSEL0P3      =  0x0000;      // load alternate output function select 
                                 // register 0
  ALTSEL1P3      =  0x0000;      // load alternate output function select 
                                 // register 1
  POCON3         =  0x0000;      // load output control register
  DP3            =  0x03FF;      // load direction register

  ///  -----------------------------------------------------------------------
  ///  Configuration of Port P4:
  ///  -----------------------------------------------------------------------
  ///  P4.0 is used as alternate input for the Port Pin (A16)
  ///  P4.1 is used as alternate input for the Port Pin (A17)

  ///  P4.0 - P4.7 threshold type: TTL input

  ///  P4.0 - P4.3 output driver characteristic: strong driver
  ///  P4.4 - P4.7 output driver characteristic: strong driver

  ///  P4.0 - P4.3 output edge characteristic: sharp edge mode
  ///  P4.4 - P4.7 output edge characteristic: sharp edge mode

  ODP4           =  0x0000;      // load open-drain register
  P4             =  0x0000;      // load data register
  ALTSEL0P4      =  0x0000;      // load alternate output function select 
                                 // register 0
  ALTSEL1P4      =  0x0000;      // load alternate output function select 
                                 // register 1
  POCON4         =  0x0000;      // load output control register
  DP4            =  0x0000;      // load direction register

  ///  -----------------------------------------------------------------------
  ///  Configuration of Port P5:
  ///  -----------------------------------------------------------------------
  ///  - no pin of port P5 is used
  ///  - Port5 Data register P5(Read only)


  ///  -----------------------------------------------------------------------
  ///  Configuration of Port P6:
  ///  -----------------------------------------------------------------------
  ///  P6.0 is used as alternate input for the Chip select (CS0_n)
  ///  P6.1 is used as alternate input for the Chip select (CS1_n)

  ///  P6.0 - P6.7 threshold type: TTL input

  ///  P6.0 - P6.3 output driver characteristic: strong driver
  ///  P6.4 - P6.7 output driver characteristic: strong driver

  ///  P6.0 - P6.3 output edge characteristic: sharp edge mode
  ///  P6.4 - P6.7 output edge characteristic: sharp edge mode

  ODP6           =  0x0000;      // load open-drain register
  P6             =  0x0000;      // load data register
  ALTSEL0P6      =  0x0000;      // load alternate output function select 
                                 // register 0
  POCON6         =  0x0000;      // load output control register
  DP6            =  0x0000;      // load direction register

  ///  -----------------------------------------------------------------------
  ///  Configuration of Port P7:
  ///  -----------------------------------------------------------------------
  ///  - no pin of port P7 is used

  ODP7           =  0x0000;      // load open-drain register
  P7             =  0x0000;      // load data register
  ALTSEL0P7      =  0x0000;      // load alternate output function select 
                                 // register 0
  ALTSEL1P7      =  0x0000;      // load alternate output function select 
                                 // register 1
  POCON7         =  0x0000;      // load output control register
  DP7            =  0x0000;      // load direction register

  ///  -----------------------------------------------------------------------
  ///  Configuration of Port P9:
  ///  -----------------------------------------------------------------------
  ///  - no pin of port P9 is used

  ODP9           =  0x0000;      // load open-drain register
  P9             =  0x0000;      // load data register
  ALTSEL0P9      =  0x0000;      // load alternate output function select 
                                 // register 0
  ALTSEL1P9      =  0x0000;      // load alternate output function select 
                                 // register 1
  POCON9         =  0x0000;      // load output control register
  DP9            =  0x0000;      // load direction register

  ///  -----------------------------------------------------------------------
  ///  Configuration of Port P20:
  ///  -----------------------------------------------------------------------
  ///  - no pin of port P20 is used

  P20            =  0x0000;      // load data register
  POCON20        =  0x0000;      // load output control register
  DP20           =  0x0000;      // load direction register


  // USER CODE BEGIN (IO_Function,3)

  // USER CODE END

} //  End of function IO_vInit




// USER CODE BEGIN (IO_General,10)

// USER CODE END

⌨️ 快捷键说明

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