因此,如果你需要读某个IO口状态,或者将某个IO口置1,那么请使用nrf_gpio.h里面的API,比如 nrf_gpio_cfg_input用来将IO口设为输入模式 nrf_gpio_pin_set用来输出1到IO口 Nordic GPIO口输入模式可以配置为没有pull,有上拉电阻,有下拉电阻,悬浮等4种状态。GPIO输出模式下驱动力灵活可配,可以配置为普通驱动力(2...
nrf_gpio_cfg_output(LED_1); nrf_gpio_cfg_output(LED_2); nrf_gpio_cfg_output(LED_3); nrf_gpio_cfg_output(LED_4); ret_code_t err_code; //初始化GPIOTE err_code = nrf_drv_gpiote_init(); APP_ERROR_CHECK(err_code); //配置SENSE模式,选择fales为sense配置 nrf_drv_gpiote_in_config_...
*/staticvoidgpio_init(void){nrf_gpio_cfg_output(PIN_OUT);//led灯的输出ret_code_terr_code;err_code=nrf_drv_gpiote_init();//初始化GPIOTEAPP_ERROR_CHECK(err_code);nrf_drv_gpiote_in_config_tin_config=GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);in_config.pull=NRF_GPIO_PIN_PULLUP;err_code=nrf_...
__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) //GPIO端口状态配置 { //配置端口 NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&...
其中GPIO_DT_SPEC_GET,GPIO_DT_SPEC_GET_OR是获取节点GPIO列表中的第一个GPIO(index=0)的gpio_dt_spec;而GPIO_DT_SPEC_GET_BY_IDX,GPIO_DT_SPEC_GET_BY_IDX_OR则是获取节点GPIO列表里指定index的gpio_dt_spec。相对于GPIO_DT_SPEC_GET_BY_IDX,GPIO_DT_SPEC_GET,在使用GPIO_DT_SPEC_GET_BY_IDX_OR...
nrf_gpio_cfg_sense_input(uint32_t pin_number, nrf_gpio_pin_pull_t pull_config, nrf_gpio_pin_sense_t sense_config) :电平检测高或低由传入参数而定;驱动能力是最低等级;上下拉根据传入参数而定;启动input buffer;输入; nrf_gpio_pin_dir_set(uint32_t pin_number, nrf_gpio_pin_dir_t direction...
// Set the timer in counter Mode.// NRF_TIMER0->BITMODE = TIMER_BITMODE_BITMODE_24Bit; // 24-bit mode.uint32_terr_code=NRF_SUCCESS;//定义定时器配置结构体,并使用默认配置参数初始化结构体nrfx_timer_config_ttimer_cfg=NRFX_TIMER_DEFAULT_CONFIG;//Timer0配置为计数模式timer_cfg.mode=NRF_TI...
nrf_gpio_cfg_sense_input(6,NRF_GPIO_PIN_PULLUP,NRF_GPIO_PIN_SENSE_LOW); sd_power_system_off(); } } } } 以上这段代码循环处理动态的向外广播气体传感器数据, if(start_adv_flag == 0xa5) 这个变量是uart_event_handle 串口接收中断里进行赋值的,因为52840和气体传感器通过串口进行相连,当此变量等...
nrf_gpio_cfg_output(led_number); nrf_gpio_pin_clear(led_number); } void LED_Off(uint32_t led_number) { nrf_gpio_cfg_output(led_number); nrf_gpio_pin_set(led_number); } Finally, look at the main.c file, as shown below, and keep the four LEDs on for 500ms and off for 500...
advertising_init(); advertising_start(); } if(start_adv_flag == 0x5a) { idle_state_handle(); } else { if(nrf_gpio_pin_read(6) == 1) { nrf_gpio_cfg_sense_input(6,NRF_GPIO_PIN_PULLUP,NRF_GPIO_PIN_SENSE_LOW); sd_power_system_off(); } } }}<...