By this forum thread, for unused GPIOs in nRF51822/nRF52832, programmer should set those as input pin, and set those in disconnection (from input buffer).
Following the rule, the code be:
//#include "nrf_gpio.h" /**@brief Function to disable all gpio */ static void disable_all_gpio(void) { uint32_t i; for( i = 0; i< NUMBER_OF_PINS; i++){ NRF_GPIO->PIN_CNF[i] = (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_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos); }/*for i*/ }/*disable_all_gpio*/
If you avoid to manipulate the GPIO registers directly, you could call the wrapping function, nrf_gpio_input_disconnect.
//#include "nrf_gpio.h" /**@brief Function to disable all gpio */ static void disable_all_gpio(void) { uint32_t i; for( i = 0; i< NUMBER_OF_PINS; i++) nrf_gpio_input_disconnect(i); }/*disable_all_gpio*/
Theoretically, if you set the unused GPIOs in that way, the power-consumption will be lower.
本文介绍了一种通过设置未使用的GPIO为输入状态并断开输入缓冲的方式,来减少nRF51822/nRF52832设备的功耗。提供了两种实现方法:直接操作寄存器和调用API函数。

1649

被折叠的 条评论
为什么被折叠?



