EFM32之GPIO
配置时钟:
void CMU_ClockEnable(CMU_Clock_TypeDef clock, bool enable) CMU_ClockEnable(cmuClock_HFPER, true); /* Enable GPIO in CMU */
CMU_ClockEnable(cmuClock_GPIO, true);
配置引脚为输入:
void GPIO_PinModeSet(GPIO_Port_TypeDef port,
unsigned int pin,
GPIO_Mode_TypeDef mode,
unsigned int out) /* Configure PB9 and PB10 as input */
GPIO_PinModeSet(gpioPortB, , gpioModeInput, );
GPIO_PinModeSet(gpioPortB, , gpioModeInput, );
配置引脚为输出:
void GPIO_PinModeSet(GPIO_Port_TypeDef port,
unsigned int pin,
GPIO_Mode_TypeDef mode,
unsigned int out) GPIO_PinModeSet(ledArray[ledNo].port, ledArray[ledNo].pin, gpioModePushPull, );
配置引脚为中断输入:
中断初始化:
void GPIOINT_Init(void)
{
NVIC_ClearPendingIRQ(GPIO_ODD_IRQn); //清除奇数引脚中断标志
NVIC_EnableIRQ(GPIO_ODD_IRQn); //使能奇数引脚中断
NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn); //清除偶数引脚中断标志
NVIC_EnableIRQ(GPIO_EVEN_IRQn); //使能偶数引脚中断
}
先配置为输入,再配置中断
__STATIC_INLINE void GPIO_IntConfig(GPIO_Port_TypeDef port,
unsigned int pin,
bool risingEdge,
bool fallingEdge,
bool enable) /* Set falling edge interrupt for both ports */
GPIO_IntConfig(gpioPortB, , false, true, true);
GPIO_IntConfig(gpioPortB, , false, true, true);
引脚输出高电平:
__STATIC_INLINE void GPIO_PinOutSet(GPIO_Port_TypeDef port, unsigned int pin) GPIO_PinOutSet(ledArray[ledNo].port, ledArray[ledNo].pin);
引脚输出低电平:
__STATIC_INLINE void GPIO_PinOutClear(GPIO_Port_TypeDef port, unsigned int pin) GPIO_PinOutClear(ledArray[ledNo].port, ledArray[ledNo].pin);
引脚翻转输出电平:
__STATIC_INLINE void GPIO_PinOutToggle(GPIO_Port_TypeDef port, unsigned int pin) GPIO_PinOutToggle(ledArray[ledNo].port, ledArray[ledNo].pin);
读取输出引脚电平:
__STATIC_INLINE unsigned int GPIO_PinOutGet(GPIO_Port_TypeDef port,
unsigned int pin) retVal = (int)GPIO_PinOutGet(ledArray[ledNo].port, ledArray[ledNo].pin);
读取输入引脚电平:
__STATIC_INLINE unsigned int GPIO_PinInGet(GPIO_Port_TypeDef port,
unsigned int pin)
读取输入端口:
__STATIC_INLINE uint32_t GPIO_PortInGet(GPIO_Port_TypeDef port)
EFM32之GPIO的更多相关文章
- Programming Internal Flash Over the Serial Wire Debug <SWD> Interface -- EFM32
1 Debug Interface Overview 1.1 Serial Wire Debug Serial Wire Debug (SWD) is a two-wire protocol for ...
- EFM32 DMA/PRS例程
/**************************************************************************//** * @file * @brief H ...
- [转]: stm328种GPIO模式
[原创]:这段时间开始研究stm32,今天撸着一段代码一直追,追到了GPIO口模式的枚举类型这里,遂去网上查看这8种模式到底是什么,网上一查,看到了一个答案被很多博主转载或者原创,那我也就不重复废话了 ...
- 基於tiny4412的Linux內核移植--- 中斷和GPIO學習(3)
作者 彭東林 pengdonglin137@163.com 平臺 tiny4412 ADK Linux-4.4.4 u-boot使用的U-Boot 2010.12,是友善自帶的,爲支持設備樹和uIma ...
- 基於tiny4412的Linux內核移植--- 中斷和GPIO學習(2)
作者 彭東林 pengdonglin137@163.com 平臺 tiny4412 ADK Linux-4.4.4 u-boot使用的U-Boot 2010.12,是友善自帶的,爲支持設備樹和uIma ...
- 基於tiny4412的Linux內核移植--- 中斷和GPIO學習(1)
作者 彭東林 pengdonglin137@163.com 平臺 tiny4412 ADK Linux-4.4.4 u-boot使用的U-Boot 2010.12,是友善自帶的,爲支持設備樹和uIma ...
- STM32f10xxx 之 GPIO口配置
背景 配置stm32f103使其完成PWM输出的过程中,在配置GPIO口的时候,按照习惯配置GPIO口的speed为50MHZ,突然就意识到,为什么大部分例程习惯配置为50MHZ,而不是其它值,即有了 ...
- android gpio口控制
android gpio口控制 GPIO口控制方式是在jni层控制的方式实现高低电平输出,类似linux的控制句柄方式,在linux系统下将每个设备看作一个文件,android系统是基于linux内 ...
- STM32F412应用开发笔记之二:基本GPIO控制
NUCLEO-F412ZG板子上的元器件并没有完全焊接,除去ST-LINK部分和电源部分后,还有用一个USB主机接口,三个LED灯和两个按钮,不过很多功能引脚都已经引到了插针.查看原理图可发现,由原理 ...
随机推荐
- numpy 和tensorflow 中的乘法
矩阵乘法:tf.matmul() np.dot() ,@ 逐元素乘法:tf.multiply() np.multiply()
- js中this最简单清晰的解释
引自 https://www.cnblogs.com/huangwentian/p/6854472.html#commentform ① this指向的,永远只可能是对象! ② this ...
- Proxifier代理工具简介和下载
Proxifier 是一款功能非常强大的socks5客户端,可以让不支持通过代理服务器工作的网络程序能通过HTTPS或SOCKS代理或代理链.支持64位系统,支持Xp,Vista,Win7,支持soc ...
- RK3399 友善NanoPC-T4开发板使用sysfs方法控制status LED状态灯-【申嵌视频-RK3399篇】
实验1:sysfs 操作方法控制NanoPC-T4开发板上LED灯 (status LED状态灯:GPIO0_B5/LED1_OUT)root@NanoPC-T4: cd /sys/class/led ...
- 廖雪峰Java9正则表达式-2正则表达式进阶-3分组匹配
1.使用括号可以提取字符串 不加括号匹配电话号码 匹配成功后,如何提取想要的字符串? 使用(...)可以分组:"^(\d{3,4})\-(\d{6,8})$" 2.String.m ...
- Jquery Mobile 让错误提示可在后台控制显示内容
在jquery.mobile-1.4.5.min.js的5254行找到下面代码 return $.proxy(function( xhr, textStatus, errorThrown ) { 然后 ...
- factory di
services.AddScoped(typeof(Test)); //services.AddScoped<Test>() // .AddScoped<ITest, Test> ...
- [STM32F103]串口UART配置
l 串口时钟使能,GPIO时钟使能: RCC_APB2PeriphClockCmd(); l 串口复位: USART_DeInit(); 这一步不是必须的 l GPIO端口模式设置: GPIO_Ini ...
- ipset 教程
ipset介绍 ipset是iptables的扩展,它允许你创建 匹配整个地址集合的规则.而不像普通的iptables链只能单IP匹配, ip集合存储在带索引的数据结构中,这种结构即时集合比较大也可以 ...
- python-封装方法用于读取excel
1.实现获取excel某张表的行数.单元格数据 #coding=utf-8 import xlrd #获取excel文件 data = xlrd.open_workbook('file_path/xx ...