您的位置:首页 > 其它

STM32f103 IO输出控制

2016-04-11 21:42 597 查看
//   IAR 7.1

#include "stm32_led.h"

void stm32_set_gpio(GPIO_TypeDef * port, uint16_t pin_x)

{

    port->BSRR = pin_x;

}

void stm32_clr_gpio(GPIO_TypeDef * port, uint16_t pin_x)

{

    port->BRR = pin_x;

}

void stm32_led_init(void)

{

    GPIO_InitTypeDef GPIO_InitStructure;

    /* Enable the BUTTON_COLUMN Clock */

    RCC_APB2PeriphClockCmd(LED_PORT1_CLK | RCC_APB2Periph_AFIO, ENABLE);

    RCC_APB2PeriphClockCmd(LED_PORT2_CLK | RCC_APB2Periph_AFIO, ENABLE);

    GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);

    

    GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);

    

    /* Configure Button row pin as input */

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_InitStructure.GPIO_Pin = (LED_SCAN_CARD_PIN | VDD_USB_EN_Pin);

    GPIO_Init(LED_PORT1, &GPIO_InitStructure);

    GPIO_InitStructure.GPIO_Pin = (Own_Sign_PIN | Vedio_PIN  );

    GPIO_Init(LED_PORT2, &GPIO_InitStructure);

    

    GPIO_InitStructure.GPIO_Pin = (VGA_SEL_Pin|Outside_Music_Pin|Touch_Power_Pin);

    GPIO_Init(LED_PORT3, &GPIO_InitStructure);

    //GPIO_Init(LED_PORT1, &GPIO_InitStructure);

    

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_InitStructure.GPIO_Pin = (Key_Reset_PIN);

    GPIO_Init(LED_PORT2, &GPIO_InitStructure);

    

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

    GPIO_InitStructure.GPIO_Pin =PC_Sign_Check_Pin;

    GPIO_Init(LED_PORT1, &GPIO_InitStructure);

    

    stm32_set_gpio(LED_PORT1,LED_LOCK_KEY_PIN );

    stm32_clr_gpio(BEEP_PORT, BEEP);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: