上传文件至 /
This commit is contained in:
296
IO.C
Normal file
296
IO.C
Normal file
@@ -0,0 +1,296 @@
|
||||
//****************************************************************************
|
||||
// @Module GPIO
|
||||
// @Filename IO.C
|
||||
// @Project CL2.0.dav
|
||||
//----------------------------------------------------------------------------
|
||||
// @Controller Infineon XC886CLM-8FF
|
||||
//
|
||||
// @Compiler Keil
|
||||
//
|
||||
// @Codegenerator 1.3
|
||||
//
|
||||
// @Description: This file contains functions that use the IO module.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2025/1/18 20:45:29
|
||||
//
|
||||
//****************************************************************************
|
||||
|
||||
// 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 their reset state.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2025/1/18
|
||||
//
|
||||
//****************************************************************************
|
||||
|
||||
// USER CODE BEGIN (IO_Init,1)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
void IO_vInit(void)
|
||||
{
|
||||
// USER CODE BEGIN (IO_Init,2)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
|
||||
/// ***********************************************************************
|
||||
/// Note : All peripheral related IO configurations are done in the
|
||||
/// respective peripheral modules (alternate functions selection)
|
||||
///
|
||||
/// If no pins are selected DAvE assumes that registers are in default
|
||||
/// settings
|
||||
/// ***********************************************************************
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of Port P0:
|
||||
/// -----------------------------------------------------------------------
|
||||
/// P0.0:
|
||||
/// - is used as general purpose output
|
||||
/// - push/pull output is selected
|
||||
/// - the pin status is low level
|
||||
/// - pull-down device is assigned
|
||||
/// P0.1:
|
||||
/// - is used as alternate input for the UART Receive Input
|
||||
/// - pull-up device is assigned
|
||||
/// P0.2:
|
||||
/// - is used as general purpose output
|
||||
/// - push/pull output is selected
|
||||
/// - the pin status is high level
|
||||
/// - pull-up device is assigned
|
||||
/// P0.3:
|
||||
/// - is used as general purpose output
|
||||
/// - open drain output is selected
|
||||
/// - the pin status is high level
|
||||
/// - pull-up device is assigned
|
||||
/// P0.5:
|
||||
/// - is used as alternate input for the External Interrupt Input 0
|
||||
/// - pull-up device is assigned
|
||||
|
||||
SFR_PAGE(_pp3, noSST); // switch to page 3
|
||||
P0_OD = 0x08; // load open-drain register
|
||||
|
||||
SFR_PAGE(_pp1, noSST); // switch to page 1
|
||||
P0_PUDSEL = 0xFE; // load pullup/pulldown select register
|
||||
P0_PUDEN = 0xEF; // load pullup/pulldown enable register
|
||||
|
||||
SFR_PAGE(_pp0, noSST); // switch to page 0
|
||||
P0_DIR = 0x0D; // load direction register
|
||||
P0_DATA = 0x0C; // load data output register
|
||||
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of Port P1:
|
||||
/// -----------------------------------------------------------------------
|
||||
/// P1.0:
|
||||
/// - is used as alternate input for the MCAN Node 0 Receiver Input
|
||||
/// - pull-up device is assigned
|
||||
/// P1.1:
|
||||
/// - is used as alternate output for the MCAN Node 0 Transmitter Output
|
||||
/// - push/pull output is selected
|
||||
/// - pull-up device is assigned
|
||||
/// P1.2:
|
||||
/// - is used as general input
|
||||
/// - pull-up device is assigned
|
||||
/// P1.3:
|
||||
/// - is used as general input
|
||||
/// - pull-up device is assigned
|
||||
/// P1.4:
|
||||
/// - is used as general input
|
||||
/// - pull-up device is assigned
|
||||
/// P1.5:
|
||||
/// - is used as general purpose output
|
||||
/// - push/pull output is selected
|
||||
/// - the pin status is low level
|
||||
/// - pull-down device is assigned
|
||||
/// P1.6:
|
||||
/// - is used as general purpose output
|
||||
/// - push/pull output is selected
|
||||
/// - the pin status is low level
|
||||
/// - pull device is disabled (tristate)
|
||||
|
||||
SFR_PAGE(_pp3, noSST); // switch to page 3
|
||||
P1_OD = 0x00; // load open-drain register
|
||||
|
||||
SFR_PAGE(_pp1, noSST); // switch to page 1
|
||||
P1_PUDSEL = 0xDF; // load pullup/pulldown select register
|
||||
P1_PUDEN = 0xBF; // load pullup/pulldown enable register
|
||||
|
||||
SFR_PAGE(_pp0, noSST); // switch to page 0
|
||||
P1_DIR = 0x60; // load direction register
|
||||
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of Port P2:
|
||||
/// -----------------------------------------------------------------------
|
||||
/// - no pin of port P2 is used
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of Port P3:
|
||||
/// -----------------------------------------------------------------------
|
||||
/// P3.2:
|
||||
/// - is used as general purpose output
|
||||
/// - open drain output is selected
|
||||
/// - the pin status is low level
|
||||
/// - pull-up device is assigned
|
||||
/// P3.3:
|
||||
/// - is used as general purpose output
|
||||
/// - open drain output is selected
|
||||
/// - the pin status is low level
|
||||
/// - pull-up device is assigned
|
||||
/// P3.4:
|
||||
/// - is used as general purpose output
|
||||
/// - open drain output is selected
|
||||
/// - the pin status is low level
|
||||
/// - pull-up device is assigned
|
||||
/// P3.5:
|
||||
/// - is used as general purpose output
|
||||
/// - open drain output is selected
|
||||
/// - the pin status is low level
|
||||
/// - pull-up device is assigned
|
||||
/// P3.6:
|
||||
/// - is used as general purpose output
|
||||
/// - push/pull output is selected
|
||||
/// - the pin status is low level
|
||||
/// - pull-down device is assigned
|
||||
/// P3.7:
|
||||
/// - is used as general purpose output
|
||||
/// - push/pull output is selected
|
||||
/// - the pin status is low level
|
||||
/// - pull-down device is assigned
|
||||
|
||||
SFR_PAGE(_pp3, noSST); // switch to page 3
|
||||
P3_OD = 0x3C; // load open-drain register
|
||||
|
||||
SFR_PAGE(_pp1, noSST); // switch to page 1
|
||||
P3_PUDSEL = 0x3F; // load pullup/pulldown select register
|
||||
P3_PUDEN = 0xFC; // load pullup/pulldown enable register
|
||||
|
||||
SFR_PAGE(_pp0, noSST); // switch to page 0
|
||||
P3_DIR = 0xFC; // load direction register
|
||||
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of Port P4:
|
||||
/// -----------------------------------------------------------------------
|
||||
/// P4.3:
|
||||
/// - is used as general purpose output
|
||||
/// - push/pull output is selected
|
||||
/// - the pin status is low level
|
||||
/// - pull-down device is assigned
|
||||
|
||||
|
||||
SFR_PAGE(_pp1, noSST); // switch to page 1
|
||||
P4_PUDSEL = 0x00; // load pullup/pulldown select register
|
||||
P4_PUDEN = 0x08; // load pullup/pulldown enable register
|
||||
|
||||
SFR_PAGE(_pp0, noSST); // switch to page 0
|
||||
P4_DIR = 0x08; // load direction register
|
||||
|
||||
|
||||
|
||||
// USER CODE BEGIN (IO_Init,3)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
} // End of function IO_vInit
|
||||
|
||||
|
||||
|
||||
|
||||
// USER CODE BEGIN (IO_General,10)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
Reference in New Issue
Block a user