930电子网

 找回密码
 立即注册
艾克姆科技推出最新产品STC32G12K128开发板
查看: 14635|回复: 1

nRF52830 GPIO 管脚定义

[复制链接]

5

主题

8

帖子

49

积分

新手上路

Rank: 1

积分
49
发表于 2018-12-10 12:01:01 | 显示全部楼层 |阅读模式
** Descriptions:        GPIO驱动LED指示灯实验
**---------------------------------------------------------------------------------------------------*/
#include <stdbool.h>
#include <stdint.h>
#include "nrf_delay.h"
#include "boards.h"

/* IK-52832DK开发板中LED指示灯D1占用的nRF52832引脚资源
P0.17:输出 :驱动指示灯D1
*/


int main(void)
{
      //配置用于驱动LED指示灯D1的管脚,即配置P0.17为输出
      nrf_gpio_cfg_output(LED_1);  

我想问一下  LED_1 定义为P0.17为输出 是通过下边的void nrf_gpio_cfg结构体实现的吗 ?具体代码在哪里?可以指出在哪个头文件上吗 谢谢

   
__STATIC_INLINE void nrf_gpio_cfg(
    uint32_t             pin_number,
    nrf_gpio_pin_dir_t   dir,
    nrf_gpio_pin_input_t input,
    nrf_gpio_pin_pull_t  pull,
    nrf_gpio_pin_drive_t drive,
    nrf_gpio_pin_sense_t sense);


回复

使用道具 举报

52

主题

339

帖子

6487

积分

版主

Rank: 7Rank: 7Rank: 7

积分
6487
发表于 2018-12-11 09:00:43 | 显示全部楼层
引脚配置最终是使用nrf_gpio_cfg()函数完成配置的,nrf_gpio_cfg()是函数,不是结构体。nrf_gpio_cfg()函数在“nrf_gpio.h”文件中,代码如下:
  1. __STATIC_INLINE void nrf_gpio_cfg(
  2.     uint32_t             pin_number,
  3.     nrf_gpio_pin_dir_t   dir,
  4.     nrf_gpio_pin_input_t input,
  5.     nrf_gpio_pin_pull_t  pull,
  6.     nrf_gpio_pin_drive_t drive,
  7.     nrf_gpio_pin_sense_t sense)
  8. {
  9.     NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);

  10.     reg->PIN_CNF[pin_number] = ((uint32_t)dir << GPIO_PIN_CNF_DIR_Pos)       //设置引脚方向
  11.                                | ((uint32_t)input << GPIO_PIN_CNF_INPUT_Pos) //设置是否连接输入缓冲器
  12.                                | ((uint32_t)pull << GPIO_PIN_CNF_PULL_Pos)   //设备引脚上拉/下拉电阻
  13.                                | ((uint32_t)drive << GPIO_PIN_CNF_DRIVE_Pos) //设置引脚驱动能力
  14.                                | ((uint32_t)sense << GPIO_PIN_CNF_SENSE_Pos);//设置引脚感知功能
  15. }
复制代码
可以看到,该函数内部是通过PIN_CNF寄存器配置PIN的。




回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|官方淘宝店|930电子网 ( 皖ICP备16000695号-2 )

GMT+8, 2024-5-3 18:26 , Processed in 0.063005 second(s), 21 queries .

快速回复 返回顶部 返回列表