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);
}
#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);
}
相关文章推荐
- Sublime Text 3 搭建 React.js 开发环境
- IOS 字符串中去除特殊符号 stringByTrimmingCharactersInSet 应该用于账号登录等
- Flume与Kafka整合
- Component SAP_GWFND is locked against OCS package
- 递归
- 又爱又恨系列之枚举enum
- Firemonkey绑定对象列表
- Sublime Text 3 搭建 React.js 开发环境
- Linux find命令的之我的使用
- 大数据时代的精准数据挖掘——使用R语言
- HYSBZ 3991 寻宝游戏(lca)
- tomcat(5)servlet容器(lastest version)
- byte[]与ByteBuffer相互转化
- HDU2097 Sky数
- 如何对Android应用程序进行JUnit测试
- 剑指offer之面试题4:替换空格
- HDU 1827 —— Summer Holiday
- TCP的三次握手建立连接与四次挥手释放连接
- 人之初,只有欲望
- LeetCode -- Tiangle