四、编程代码
relay.c
#include "stm32f10x.h"
#include "relay.h"
void Relay_Init(void)
{
GPIO_InitTypeDef relay_init; //½á¹¹Ìå³õʼ»¯
//1.µ÷ÓÃGPIOAʱÖÓ
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
//2.GPIOA3½á¹¹ÌåÅäÖÃ
relay_init.GPIO_Mode = GPIO_Mode_Out_PP; //Êä³öģʽ
relay_init.GPIO_Pin = GPIO_Pin_3; //Êä³öPIN¿Ú
relay_init.GPIO_Speed = GPIO_Speed_10MHz ;//Êä³öËÙ¶È
GPIO_Init(GPIOA,&relay_init ); //GPIOA³õʼ»¯º¯Êý
}
|