欢迎来到天天文库
浏览记录
ID:1646141
大小:492.13 KB
页数:7页
时间:2017-11-12
《nrf51822学习笔记之gpio》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、GPIO手册介绍:共有32个GPIO参数Thefollowingparameterscanbeconfiguredthroughtheseregisters:•Direction•Drivestrength•Enablingofpull-upandpull-downresistors•Pinsensing•Inputbufferdisconnect•Analoginput(forselectedpins)各寄存器说明(手册)代码实现(示例代码)结构体:theGPIOportsaredefinedasfollows:*-Port0->pin
2、0-7*-Port1->pin8-15*-Port2->pin16-23*-Port3->pin24-31typedefenum{NRF_GPIO_PORT_DIR_OUTPUT,NRF_GPIO_PORT_DIR_INPUT}nrf_gpio_port_dir_t;//port/***@enumnrf_gpio_pin_dir_t*Pindirectiondefinitions.*/typedefenum{NRF_GPIO_PIN_DIR_INPUT,NRF_GPIO_PIN_DIR_OUTPUT}nrf_gpio_pin_dir_t;
3、//Dir/***@enumnrf_gpio_port_select_t*@briefEnumeratorusedforselectingbetweenport0-3.*/typedefenum{NRF_GPIO_PORT_SELECT_PORT0=0,///4、3,///5、RF_GPIO_PIN_PULLUP=GPIO_PIN_CNF_PULL_Pullup,}nrf_gpio_pin_pull_t;/**@enumnrf_gpio_pin_sense_t@briefEnumeratorusedforselectingthepintosensehighorlowlevelonthepininput.*/typedefenum{NRF_GPIO_PIN_NOSENSE=GPIO_PIN_CNF_SENSE_Disabled,NRF_GPIO_PIN_SENSE_LOW=GPIO_PIN_CNF_SENSE_L6、ow,NRF_GPIO_PIN_SENSE_HIGH=GPIO_PIN_CNF_SENSE_High,}nrf_gpio_pin_sense_t;分解:l#defineNRF_GPIO((NRF_GPIO_Type*)NRF_GPIO_BASE)其中:ltypedefstruct{//!7、t32_tOUTCLR;//ClearindividualbitsinGPIOport.__Iuint32_tIN;//ReadGPIOport.__IOuint32_tDIR;//DirectionofGPIOpins.__IOuint32_tDIRSET;//DIRsetregister.__IOuint32_tDIRCLR;//DIRclearregister.__Iuint32_tRESERVED1[120];__IOuint32_tPIN_CNF[32];//ConfigurationofGPIOpins.}NRF_GPIO_T8、ype;l#defineNRF_GPIO_BASE0x50000000UL函数:Ønrf_gpio_cfg_output(LED_1);其中:NRF_GPIO->PIN_CNF[pin_num
4、3,///5、RF_GPIO_PIN_PULLUP=GPIO_PIN_CNF_PULL_Pullup,}nrf_gpio_pin_pull_t;/**@enumnrf_gpio_pin_sense_t@briefEnumeratorusedforselectingthepintosensehighorlowlevelonthepininput.*/typedefenum{NRF_GPIO_PIN_NOSENSE=GPIO_PIN_CNF_SENSE_Disabled,NRF_GPIO_PIN_SENSE_LOW=GPIO_PIN_CNF_SENSE_L6、ow,NRF_GPIO_PIN_SENSE_HIGH=GPIO_PIN_CNF_SENSE_High,}nrf_gpio_pin_sense_t;分解:l#defineNRF_GPIO((NRF_GPIO_Type*)NRF_GPIO_BASE)其中:ltypedefstruct{//!7、t32_tOUTCLR;//ClearindividualbitsinGPIOport.__Iuint32_tIN;//ReadGPIOport.__IOuint32_tDIR;//DirectionofGPIOpins.__IOuint32_tDIRSET;//DIRsetregister.__IOuint32_tDIRCLR;//DIRclearregister.__Iuint32_tRESERVED1[120];__IOuint32_tPIN_CNF[32];//ConfigurationofGPIOpins.}NRF_GPIO_T8、ype;l#defineNRF_GPIO_BASE0x50000000UL函数:Ønrf_gpio_cfg_output(LED_1);其中:NRF_GPIO->PIN_CNF[pin_num
5、RF_GPIO_PIN_PULLUP=GPIO_PIN_CNF_PULL_Pullup,}nrf_gpio_pin_pull_t;/**@enumnrf_gpio_pin_sense_t@briefEnumeratorusedforselectingthepintosensehighorlowlevelonthepininput.*/typedefenum{NRF_GPIO_PIN_NOSENSE=GPIO_PIN_CNF_SENSE_Disabled,NRF_GPIO_PIN_SENSE_LOW=GPIO_PIN_CNF_SENSE_L
6、ow,NRF_GPIO_PIN_SENSE_HIGH=GPIO_PIN_CNF_SENSE_High,}nrf_gpio_pin_sense_t;分解:l#defineNRF_GPIO((NRF_GPIO_Type*)NRF_GPIO_BASE)其中:ltypedefstruct{//!7、t32_tOUTCLR;//ClearindividualbitsinGPIOport.__Iuint32_tIN;//ReadGPIOport.__IOuint32_tDIR;//DirectionofGPIOpins.__IOuint32_tDIRSET;//DIRsetregister.__IOuint32_tDIRCLR;//DIRclearregister.__Iuint32_tRESERVED1[120];__IOuint32_tPIN_CNF[32];//ConfigurationofGPIOpins.}NRF_GPIO_T8、ype;l#defineNRF_GPIO_BASE0x50000000UL函数:Ønrf_gpio_cfg_output(LED_1);其中:NRF_GPIO->PIN_CNF[pin_num
7、t32_tOUTCLR;//ClearindividualbitsinGPIOport.__Iuint32_tIN;//ReadGPIOport.__IOuint32_tDIR;//DirectionofGPIOpins.__IOuint32_tDIRSET;//DIRsetregister.__IOuint32_tDIRCLR;//DIRclearregister.__Iuint32_tRESERVED1[120];__IOuint32_tPIN_CNF[32];//ConfigurationofGPIOpins.}NRF_GPIO_T
8、ype;l#defineNRF_GPIO_BASE0x50000000UL函数:Ønrf_gpio_cfg_output(LED_1);其中:NRF_GPIO->PIN_CNF[pin_num
此文档下载收益归作者所有