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

📄 bspi.h

📁 基于Arm Developer suite 1.2开发
💻 H
字号:
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name          : bspi.h
* Author             : MCD Application Team
* Date First Issued  : 16/05/2003
* Description        : This file contains all the functions prototypes for the
*                      BSPI software library.
********************************************************************************
* History:
*  01/01/2004 : V1.2
*  14/07/2004 : V1.3
*******************************************************************************/

#ifndef __bspi_H
#define __bspi_H

#include "71x_lib.h"

typedef enum {
  BSPI_BERIT = 0x80,
  BSPI_RCIT  = 0x10,
  BSPI_ALL   = 0x90
} BSPI_ITS;

typedef enum {
  BSPI_BERR = 0x004,
  BSPI_RFNE = 0x008,
  BSPI_RFF  = 0x010,
  BSPI_ROFL = 0x020,
  BSPI_TFE  = 0x040,
  BSPI_TUFL = 0x080,
  BSPI_TFF  = 0x100,
  BSPI_TFNE = 0x200
} BSPI_Flags;

typedef enum {
  BSPI_TR_FE,
  BSPI_TR_UFL,
  BSPI_TR_FF,
  BSPI_TR_DIS
} BSPI_TR_IT_SRCS;

typedef enum {
  BSPI_RC_FNE,
  BSPI_RC_FF,
  BSPI_RC_DIS
} BSPI_RC_IR_SRCS;

#define BSPI_PESET_Mask 0x01
#define BSPI_DFIFO_Mask 0xFFFE
#define BSPI_CPHA_Mask  0x200
#define BSPI_CPOL_Mask  0x100
#define BSPI_BSPI0_Base 0xA000
#define BSPI_BSPI1_Base 0xB000


/*******************************************************************************
* Function Name  : BSPI_BSPI0Conf
* Description    : configure STARM71x on BSPI0 mode.
* Input 2        : NewState: specifies the status of the BSPI
*		 : NewState value must be either ENABLE or DISABLE:
*		 : ENABLE: the specified BSPI0 peripheral will be enabled.
*		 : DISABLE: the specified BSPI0 peripheral will be disabled..
* Output         : SPI0 EN  bit  in BOOTCR.
* Return         : None.
*******************************************************************************/
inline void BSPI_BSPI0Conf(FunctionalState NewState)
{
  if (NewState == ENABLE) PCU->BOOTCR |= 0x04; else PCU->BOOTCR &= ~0x04;
}

/*******************************************************************************
* Function Name  : BSPI_Init
* Description    : Initializes BSPI peripheral control and registers to their default reset values.
* Input          : BSPIx where x can be 0 or 1 to select the BSPI peripheral.
* Output         : BSPI peripheral registers and BSPI global variables are initialized.
* Return         : None.
*******************************************************************************/
void BSPI_Init( BSPI_TypeDef *BSPIx);

/*******************************************************************************
* Function Name  : BSPI_Enable
* Description    : Enables/disables the specified BSPI peripheral.
* Input 1        : BSPIx where x can be 0 or 1 to select the BSPI peripheral to be enabled or disabled.
* Input 2        : NewState: specifies the status of the BSPI
*		 : NewState value must be either ENABLE or DISABLE:
*		 : ENABLE: the specified BSPI peripheral will be enabled.
*		 : DISABLE: the specified BSPI peripheral will be disabled.
* Output         : BSPE bit  in BSPCSR1.
* Return         : None.
*******************************************************************************/
inline void BSPI_Enable( BSPI_TypeDef *BSPIx, FunctionalState NewState)
{
  if (NewState == ENABLE) BSPIx->CSR1 |= BSPI_PESET_Mask;
    else BSPIx->CSR1 &= ~BSPI_PESET_Mask;
}

/*******************************************************************************
* Function Name  : BSPI_MasterEnable
* Description    : Configures the BSPI as a Master or a Slave.
* Input 1        : BSPIx where x can be 0 or 1 to select the BSPI peripheral.
* Input 2        : NewState: specifies whether configuring BSPI as master is enabled or disabled.
*		 : ENABLE: the specified BSPI will be configured as a master.
*		 : DISABLE: the specified BSPI will be configured as a slave.
* Output         : MSTR bit in BSPCSR1 is modified register.
* Return         : None.
*******************************************************************************/
inline void BSPI_MasterEnable(BSPI_TypeDef *BSPIx, FunctionalState NewState)
{
  if (NewState == ENABLE) BSPIx->CSR1 |= 0x02; else BSPIx->CSR1 &= ~0x02;
}

/*******************************************************************************
* Function Name  : BSPI_TrItSrc.
* Description    : Configures the transmit interrupt source.
* Input 1        : BSPIx where x can be 0 or 1 to select the BSPI peripheral.
* Input 2        : TrItSrc: specifies the transmit interrupt source.
*		 : Refer to the section 慣ransmit Interrupt Sources

⌨️ 快捷键说明

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