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

📄 ma_spi.c

📁 Communication between PC and LPC2000 SPI
💻 C
字号:

/*
*****************************************************************************
**
**      Project     : My project
**
**      Component   : LPC2106 (LPC2106)
**
**      Modulename  : SPI
**
**      Filename    : ma_spi.c
**
**      Abstract    : This file implements a device driver for the SPI 
**                    module.
**
**      Compiler    : IAR C compiler
**
**      Date        : 2005-01-12 09:13:42
**
**      License no. : 9503-026-512-5571     Charles R. Grenz
**
**      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.00A) for the Philips LPC210x series of
**      microcontrollers.
**
**      (c)Copyright 2003 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 "iolpc210x.h"  /* Defines Special function registers */

#include "ma_spi.h"      /* Module driver header file */

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

#define MA_SPCR_SPI            0x000000A0  /* SPI Control Register */
#define MA_SPCR_SPI_MASK       0x000000F8  /* Used bits */
#define MA_SPDR_SPI            0x00000000  /* SPI Data Register */
#define MA_SPDR_SPI_MASK       0x000000FF  /* Used bits */
#define MA_SPCCR_SPI           0x00000008  /* SPI Clock Counter Register */
#define MA_SPCCR_SPI_MASK      0x000000FF  /* 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_SPI( void ) 
/*
**---------------------------------------------------------------------------
**
**  Abstract:
**      Initialises the SPI 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_SPI;

    /*--- Initialize registers ---*/
    SPCCR    = ( SPCCR & ~MA_SPCCR_SPI_MASK ) | MA_SPCCR_SPI;
    SPCR     = ( SPCR & ~MA_SPCR_SPI_MASK ) | MA_SPCR_SPI;

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

} /* MA_Init_SPI */





void MA_Reset_SPI( void ) 
/*
**---------------------------------------------------------------------------
**
**  Abstract:
**    Resets the SPI module. Sets all registers.
**
**  Parameters:
**      None
**
**  Returns:
**      None
**
**---------------------------------------------------------------------------
*/
{
    /*--- Handle user code on function entry ---*/
    ENTER_MA_RESET_SPI;

    /*--- Reset registers ---*/
    SPCCR    = ( SPCCR & ~MA_SPCCR_SPI_MASK ) | MA_SPCCR_SPI;
    SPCR     = ( SPCR & ~MA_SPCR_SPI_MASK ) | MA_SPCR_SPI;

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

} /* MA_Reset_SPI */





void MA_IntHandler_SPI( void ) 
/*
**---------------------------------------------------------------------------
**
**  Abstract:
**      This function is the high level language interrupt handler
**      for the SPI interrupt.
**
**  Parameters:
**      None
**
**  Returns:
**      None
**
**---------------------------------------------------------------------------
*/
{
    /*--- Handle user code on interrupt entry ---*/
    ENTER_MA_INTHANDLER_SPI;

    SPINT_bit.SPIINT = 1;      /* Clear SPI interrupt flag */ 

    /*--- Handle user code ---*/
    INSIDE_MA_INTHANDLER_SPI;

    /*--- Handle user code on interrupt exit ---*/
    EXIT_MA_INTHANDLER_SPI;

} /* MA_IntHandler_SPI */






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

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



⌨️ 快捷键说明

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