/**
******************************************************************************
* @file bsp_led.c
* @author fire
* @version V1.0
* @date 2013-xx-xx
* @brief ledó|ó?oˉêy?ó?ú
******************************************************************************
* @attention
*
* êμ?é??ì¨:ò°?e iSO-MINI STM32 ?a·¢°?
* ??ì3 :http://www.firebbs.cn
* ì?±| :http://firestm32.taobao.com
*
******************************************************************************
*/
#include "bsp_led.h"
#include "stm32f10x_spi.h"
/**
* @brief 3?ê??ˉ????LEDμ?IO
* @param ?T
* @retval ?T
*/
void LED_GPIO_Config(void)
{
/*?¨ò?ò???GPIO_InitTypeDefààDíμ??á11ì?*/
GPIO_InitTypeDef GPIO_InitStructure;
/*?a??LEDμ?íaéèê±?ó*/
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC, ENABLE);
/*????òa????μ?GPIOBòy??*/
// GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
// GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
// GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10|GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/*????òa????μ?òy??*/
/*****************************************************
********PBòy??????************************************
********PB3£?PB4**************************************
******************************************************/
// GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3|GPIO_Pin_4;
// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
// GPIO_Init(GPIOB, &GPIO_InitStructure);
}
void SPI3_Init()
{
GPIO_InitTypeDef GPIO_InitStructure;
SPI_InitTypeDef SPI_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE);
/**************************
******AFIO****************
**************************/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable,ENABLE);
// AFIO->MAPR =(AFIO->MAPR|0x02000000)&0xFAFFFFFF;
/**************************
******SPI3_NSS*************
**************************/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/**************************
******SPI3_CLK*************
**************************/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
/**************************
******SPI3_DIN*************
**************************/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
/**************************
******SPI3_DOUT************
***************************/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
GPIO_Init(GPIOB, &GPIO_InitStructure);
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_BaudRatePrescaler_4;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(SPI3, &SPI_InitStructure);
/***********************
******ENABLE SPII3******
***********************/
SPI_Cmd(SPI3, ENABLE);
}
/*********************************************END OF FILE**********************/
这是我配置的,请大神看看有什么问题 |