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

📄 ma_gpio.c

📁 NXP LPC系列AMR7的开发程序源码(LCD
💻 C
字号:

/*
*****************************************************************************
**
**      Project     : My project
**
**      Component   : LPC2106 (LPC2106)
**
**      Modulename  : GPIO
**
**      Filename    : ma_gpio.c
**
**      Abstract    : This file implements a device driver for the GPIO 
**                    module.
**
**      Compiler    : IAR C compiler
**
**      Date        : 2004-05-26 17:21:26
**
**      License no. : 9503-663-863-6224     Ivan
**
**      Warning     : This file has been automatically generated.
**                    Do not edit this file if you intend to regenerate it.
**
**      This device driver was created by IAR MakeApp version 
**      4.02A (Philips LPC210x: 4.00C) for the Philips LPC210x series of
**      microcontrollers.
**
**      (c)Copyright 2004 IAR Systems.
**      Your rights to this file are explained in the IAR MakeApp 
**      License Agreement. All other rights reserved.
**
*****************************************************************************
*/

/*
**===========================================================================
**  1       GENERAL
**  1.1     Revisions
**
**  Please read the IAR MakeApp for Philips LPC210x readme file 
**  
**
**===========================================================================
*/

/*
**===========================================================================
**  1.2     References
** 
**  No   Identification          Name or Description
**  ==   ===================     ================================
**
**  1    02/Oct/2003             Philips LPC210x Hardware Manual
** 
**===========================================================================
*/

/*
**===========================================================================
**  2.      INCLUDE FILES
**  2.1     Standard include files
**===========================================================================
*/

/*
**===========================================================================
**  2.2     Application include files
**===========================================================================
*/

#include "usercode.h"   /* Usercode macros (see <template.h>) */
#include "ma_tgt.h"     /* Target specific header file */
#include "ma_sfr.h"     /* Special function register bitfield macros */
#include "NXP/iolpc210x.h"  /* Defines Special function registers */

#include "ma_gpio.h"     /* GPIO Module driver header file */

/*
**===========================================================================
**  3.      DECLARATIONS
**  3.1     Internal constants
**===========================================================================
*/

#define MA_IOPIN_GPIO          0x00000000  /* GPIO Pin Value Register */
#define MA_IOPIN_GPIO_MASK     0xFFFFFFFF  /* Used bits */
#define MA_IOSET_GPIO          0x00000000  /* GPIO Output Set Register */
#define MA_IOSET_GPIO_MASK     0xFFFFFFFF  /* Used bits */
#define MA_IODIR_GPIO          0x00000400  /* GPIO Direction Register */
#define MA_IODIR_GPIO_MASK     0xFFFFFFFF  /* Used bits */
#define MA_IOCLR_GPIO          0x00000000  /* GPIO output set register */
#define MA_IOCLR_GPIO_MASK     0xFFFFFFFF  /* Used bits */

/*
**===========================================================================
**  3.2     Internal macros
**===========================================================================
*/

/*
**===========================================================================
**  3.3     Internal type definitions
**===========================================================================
*/

/*
**===========================================================================
**  3.4     Global variables (declared as 'extern' in some header file)
**===========================================================================
*/

/*
**===========================================================================
**  3.5     Internal function prototypes (defined in Section 5)
**===========================================================================
*/

/*
**===========================================================================
**  3.6     Internal variables
**===========================================================================
*/

/*
**===========================================================================
**  4.      GLOBAL FUNCTIONS (declared as 'extern' in some header file)
**===========================================================================
*/




void MA_Init_GPIO( void ) 
/*
**---------------------------------------------------------------------------
**
**  Abstract:
**      Initialises the GPIO module. Only sets those registers with  
**      values not equal to the power-on reset values. 
**
**  Parameters:
**      None
**
**  Returns:
**      None
**
**---------------------------------------------------------------------------
*/
{
    /*--- Handle user code on function entry ---*/
    ENTER_MA_INIT_GPIO;
            
    /*--- Init GPIO registers ---*/     
    IODIR    = MA_IODIR_GPIO;

    /*--- Handle user code on function exit ---*/
    EXIT_MA_INIT_GPIO;
    
} /* MA_Init_GPIO */






void MA_Reset_GPIO( void ) 
/*
**---------------------------------------------------------------------------
**
**  Abstract:
**      Resets the GPIO module. Sets all registers. 
**
**  Parameters:
**      None
**
**  Returns:
**      None
**
**---------------------------------------------------------------------------
*/
{
    /*--- Handle user code on function entry ---*/
    ENTER_MA_RESET_GPIO;
            
    /*--- Reset IODIR register ---*/     
    IODIR    = MA_IODIR_GPIO;

    /*--- Handle user code on function exit ---*/
    EXIT_MA_RESET_GPIO;
    
} /* MA_Reset_GPIO */






S8 MA_SetPortIn_GPIO( U32 BitMask ) 
/*
**---------------------------------------------------------------------------
**
**  Abstract:
**      Reprograms selected I/O pins as input pins.
**
**  Parameters:
**      BitMask   Set a bit to program the corresponding pin to input
**
**  Returns:
**      MA_OK
**
**---------------------------------------------------------------------------
*/
{
    /*--- Handle user code on function entry ---*/
    ENTER_MA_SETPORTIN_GPIO;

    /*--- Set direction to input ---*/
    IODIR &= ~BitMask;

    /*--- Handle user code on function exit ---*/
    EXIT_MA_SETPORTIN_GPIO;

    return MA_OK;  
        
}  /* MA_SetPortIn_GPIO */





S8 MA_SetPortOut_GPIO( U32 BitMask ) 
/*
**---------------------------------------------------------------------------
**
**  Abstract:
**      Reprograms selected I/O pins as output pins.
**
**  Parameters:
**      BitMask   Set a bit to program the corresponding pin to output
**
**  Returns:
**      MA_OK
**
**---------------------------------------------------------------------------
*/
{
    /*--- Handle user code on function entry ---*/
    ENTER_MA_SETPORTOUT_GPIO;

    /*--- Set direction to output ---*/
    IODIR |= BitMask;

    /*--- Handle user code on function exit ---*/
    EXIT_MA_SETPORTOUT_GPIO;

    return MA_OK; 
        
}  /* MA_SetPortOut_GPIO */





U32 MA_ReadPort_GPIO( void ) 
/*
**---------------------------------------------------------------------------
**
**  Abstract:
**      Reads I/O port. Each port pin will be mapped to the corresponding 
**      bit in the return value.
**
**  Parameters:
**      None
**
**  Returns:
**      The read data
** 
**---------------------------------------------------------------------------
*/ 
{
    U32 Data;

    /*--- Handle user code on function entry ---*/
    ENTER_MA_READPORT_GPIO;

    /*--- Read port ---*/
    Data = IOPIN;

    /*--- Handle user code on function exit ---*/
    EXIT_MA_READPORT_GPIO;

    /*--- Return read port value ---*/
    return Data;

}   /* MA_ReadPort_GPIO */





S8 MA_WritePort_GPIO( U32 Value, U32 BitMask ) 
/*
**---------------------------------------------------------------------------
**
**  Abstract:
**      Writes data to the selected I/O port. Each bit in the selected
**      port which has a corresponding bit set in the bitmask, will 
**      output the bit value that are defined in the 'Value' parameter.
**
**  Parameters:
**      Value      The data to write
**      BitMask    Bitmask which selects the bits in the port to change  
**
**  Returns:
**      MA_OK       
** 
**---------------------------------------------------------------------------
*/ 
{
    /*--- Handle user code on function entry ---*/
    ENTER_MA_WRITEPORT_GPIO;

    /*--- Clear bits in GPIO using CLEAR register ---*/
    IOCLR = (~Value & BitMask);

    /*--- Set bits in GPIO using SET register ---*/
    IOSET = (Value & BitMask);

    /*--- Handle user code on function exit ---*/
    EXIT_MA_WRITEPORT_GPIO;

    return MA_OK;
    
}   /* MA_WritePort_GPIO */



/*
**===========================================================================
**  5.      INTERNAL FUNCTIONS (declared in Section 3.5)
**===========================================================================
*/

/*
**===========================================================================
** END OF FILE
**===========================================================================
*/ 



⌨️ 快捷键说明

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