資源簡介
主要通過stm32f103的硬件SPI接口編寫的25lc512驅(qū)動文件

代碼片段和文件信息
#include?“25lc512.h“
/*******************************************************************************
*?Function?Name??:?
*?Description????:?
*?Input??????????:?None
*?Output?????????:?None
*?Return?????????:?None
*******************************************************************************/
void?sEPROM_GPIO_Init(void)
{
??GPIO_InitTypeDef?GPIO_InitStructure;
??//Enable?GPIO?clock
??RCC_APB2PeriphClockCmd(sEPROM_CS_GPIO_CLK?|?sEPROM_SPI_MOSI_GPIO_CLK?|?sEPROM_SPI_MISO_GPIO_CLK?|
?????????????????????????sEPROM_SPI_SCK_GPIO_CLK?ENABLE);
??//?sEPROM_SPI?Periph?clock?enable
??RCC_APB2PeriphClockCmd(sEPROM_SPI_CLK?ENABLE);
??
??//?Configure?sEPROM_SPI?pins:?SCK
??GPIO_InitStructure.GPIO_Pin?=?sEPROM_SPI_SCK_PIN;
??GPIO_InitStructure.GPIO_Speed?=?GPIO_Speed_50MHz;
??GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_AF_PP;
??GPIO_Init(sEPROM_SPI_SCK_GPIO_PORT?&GPIO_InitStructure);
??//?Configure?sEPROM_SPI?pins:?MISO
??GPIO_InitStructure.GPIO_Pin?=?sEPROM_SPI_MISO_PIN;
??GPIO_Init(sEPROM_SPI_MISO_GPIO_PORT?&GPIO_InitStructure);
??//?Configure?sEPROM_SPI?pins:?MOSI
??GPIO_InitStructure.GPIO_Pin?=?sEPROM_SPI_MOSI_PIN;
??GPIO_Init(sEPROM_SPI_MOSI_GPIO_PORT?&GPIO_InitStructure);
??//?Configure?sEPROM_CS_PIN?pin:?sEPROM?Card?CS?pin
??GPIO_InitStructure.GPIO_Pin?=?sEPROM_CS_PIN;
??GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_Out_PP;
??GPIO_Init(sEPROM_CS_GPIO_PORT?&GPIO_InitStructure);
}
/*******************************************************************************
*?Function?Name??:?
*?Description????:?
*?Input??????????:?None
*?Output?????????:?None
*?Return?????????:?None
*******************************************************************************/
void?sEPROM_CS_HIGH(void)
{
sEPROM_CS_GPIO_PORT->BSRR?=?sEPROM_CS_PIN;
}
/*******************************************************************************
*?Function?Name??:?
*?Description????:?
*?Input??????????:?None
*?Output?????????:?None
*?Return?????????:?None
*******************************************************************************/
void?sEPROM_CS_LOW(void)
{
sEPROM_CS_GPIO_PORT->BRR?=?sEPROM_CS_PIN;
}
/*******************************************************************************
*?Function?Name??:?
*?Description????:?
*?Input??????????:?None
*?Output?????????:?None
*?Return?????????:?None
*******************************************************************************/
void?sEPROM_Init(void)
{
??SPI_InitTypeDef??SPI_InitStructure;
??sEPROM_GPIO_Init();
????
??/*!??sEPROM_CS_HIGH();
??/*!??SPI_InitStructure.SPI_Direction?=?SPI_Direction_2Lines_FullDuplex;
??SPI_InitStructure.SPI_Mode?=?SPI_Mode_Master;
??SPI_InitStructure.SPI_DataSize?=?SPI_DataSize_8b;
??SPI_InitStructure.SPI_CPOL?=?SPI_CPOL_High;
??SPI_InitStructure.SPI_CPHA?=?SPI_CPHA_2Edge;
??SPI_InitStructure.SPI_NSS?=?SPI_NSS_Soft;
??SPI_InitStructure.SPI_BaudRatePrescaler?=?SPI_B
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????7963??2015-11-26?12:39??25lc512.c
?????文件???????2642??2015-11-10?15:56??25lc512.h
-----------?---------??----------?-----??----
????????????????10605????????????????????2
- 上一篇:harris+ncc+ransac
- 下一篇:CSS+DIV+JS導航顯示
評論
共有 條評論