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

📄 ffsport_spi.h

📁 The Fat Fs module is a middleware that written in ANSI C. There is no platform dependence, so long a
💻 H
字号:
/***********************************************************
*           MMC/SD-interface to SPI-slot of STM32          *
*                                                          *
*          by  Frank Goetze  -  www.embedded-os.de         *
************************************************************
*                      FFSPort_SPI.c                       *
*                 SPI-PORT DECLARATIONS                    *
***********************************************************/
#define MMC_STM32

#define MMC_MCBSTM32                                      // select Keil-board (or Olimex STM32-H103)


#include "../../../../inc/OS_Def_STM32.h"

#include "../../../../inc/STM32/library/inc/stm32f10x_rcc.h"
#include "../../../../inc/STM32/library/inc/stm32f10x_spi.h"
#include "../../../../inc/STM32/library/inc/stm32f10x_gpio.h"

/*
************************************************************
*                      DEFINITIONS
************************************************************
*/
#define SPI_      0                                        // define the used of 0=SPI1 or 1=SPI2 (for Keil-board must be "0")

#if (!SPI_)
 #define SPIx     SPI1                                     // **** SPI1 ****
 #define SPIx_bit GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7     // -> on SPI1 its PA5, PA6, PA7
 #define SPIx_Gx  GPIOA
 #define CS_bit   GPIO_Pin_4                               // -> on SPI1 its PA4
 #define CS_Gx    GPIOA
 #ifdef MMC_MCBSTM32
  #define WP_bit   GPIO_Pin_8                              // -> on SPI1 we use PAx (simu), PA8 (WP not connected)
  #define CD_bit   GPIO_Pin_8
  #define WPCD_Gx  GPIOA
 #else
  #define WP_bit   GPIO_Pin_0                              // -> on SPI1 we use PC0, PC1
  #define CD_bit   GPIO_Pin_1 
  #define WPCD_Gx  GPIOC
 #endif
#else
 #define SPIx     SPI2                                     // **** SPI2 ****
 #define SPIx_bit GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15  // -> on SPI2 its PB13, PB14, PB15
 #define SPIx_Gx  GPIOB
 #define CS_bit   GPIO_Pin_12                              // -> on SPI2 its PB12
 #define CS_Gx    GPIOB
 #define WP_bit   GPIO_Pin_2                               // -> on SPI1 we use PC2, PC3
 #define CD_bit   GPIO_Pin_3
 #define WPCD_Gx  GPIOC
#endif

#define FFSPort_MMC_CS_OFF    GPIO_SetBits(CS_Gx, CS_bit)             // set CS high
#define FFSPort_MMC_CS_ON     GPIO_ResetBits(CS_Gx, CS_bit)           // set CS low
#define FFSPort_MMC_CD()      GPIO_ReadInputDataBit(WPCD_Gx, CD_bit)  // card-detect -- only for none-INT based card-detect
#ifndef MMC_MCBSTM32
 #define FFSPort_MMC_WP()     GPIO_ReadInputDataBit(WPCD_Gx, WP_bit)  // write-protect
#else
 #define FFSPort_MMC_WP()     FFS_NO_ERR                              // default "not protected"
#endif

/*
***********************************************************
*          MMC-Port of FFS/FAT FUNCTION PROTOTYPES
***********************************************************
*/
U32 FFSPort_MMC_SetBR(U32 maxclk);
U08 FFSPort_MMC_Send(U08 w);
U08 FFSPort_MMC_Init(void);
U08 FFSPort_MMC_ReInit(void);
//U08 FFSPort_MMC_CD(void);                        // for INT based card-detect

/************************* END ****************************/

⌨️ 快捷键说明

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