NRF51822开发笔记-9.nRF51822裸机实验GPIO分析

本文详细介绍了NRF51822的GPIO设计思路,包括GPIO初始化、输出高电平和低电平的程序配置解析。通过对GPIO寄存器的理解,阐述了如何通过函数配置GPIO状态,从而实现对硬件的控制。
摘要由CSDN通过智能技术生成

一、GPIO设计思路

1.在NRF51822规格书中相关的GPIO章节,从如下图中可以看到,有32的GPIO,编号0-31,每个GPIO都有OUT/IN/PIN_CNF[],左侧是GPIO内部的结构,学过STM32的都了解,和STM32类似。
在这里插入图片描述
2.GPIO的配置无非也是配置上拉,下拉,驱动能力等等,根据自己使用的GPIO的实际情况去配置相关的寄存器
在这里插入图片描述

二、程序配置解析

1.GPIO初始化函数解析

在main函数中,通常先要初始化函数,比如控制LED的实验中的初始化函数为nrf_gpio_cfg_output(LED_0);找到对应的函数体

static __INLINE void nrf_gpio_cfg_output(uint32_t pin_number)
{
   
    /*lint -e{845} // A zero has been given as right argument to operator '|'" */
NRF_GPIO->PIN_CNF[pin_number] = 
(GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
| (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
| (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos)
| (GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INP
nrf51822中文参考手册,nRF51822 是一款集成nRF51x系列无线收发器的超低功耗的片上系统 (Soc) , 包含一个32位ARM Cortex-M0 CPU , flash 存储器和模拟、数字外设。NORDIC SEMICONDUCTOR nRF51822 Product Specification v1.3 Liability disclaimer Nordic Semiconductor ASa reserves the right to make changes without further notice to the product to improve reliability, function or design. Nordic Semiconductor asa does not assume any liability arising out of the application or use of any product or circuits described herein ife support applications Nordic Semiconductor's products are not designed for use in life support appliances, devices, or systems where malfunction of these products can reasonably be expected to result in personal injury. Nordic Semiconductor ASa customers using or selling these products for use in such applications do so at their own risk and agree to fully indemnify Nordic Semiconductor ASA for any damages resulting from such improper use or sale Contact details Foryournearestdistributorpleasevisitwww.nordicsemi.com Information regarding product updates, downloads, and technical support can be accessed through your My Page account on our home page Main office: Otto Nielsens veg 12 Mailing address: Nordic Semiconductor 7052 Trondheim P.O. Box 2336 Norway 7004 Trondhe Phone:+4772898900 Norway 4772898989 画N远 NS-EN ISO 9001 CERTIFICATEDFIRM RoHS and reach statement Nordic semiconductor's products meet the requirements of Directive 2002/95/EC of the European Parliament and of the Council on the restriction of Hazardous Substances(roHS)and the requirements of the reach regulation(EC 1907/2006)on Registration, Evaluation, Authorization and Restriction of Chemicals. The SvHC(Substances of Very High Concern) candidate list is continually being updated Complete hazardous substance reports material composition reports and latest version of nordics reach statementcanbefoundonourwebsitewww.nordicsemicom Page 2 of 67 NORDIC SEMICONDUCTOR nRF51822 Product Specification v1.3 Datasheet status Status Description Objective Pro
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值