This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

GPIO port definition in devicetree

Dear Nordic, 

Could you please help me to understand the concept of using the DTS files and board initialization sequence?

We have just one GPIO port to control some external ICs on the board. It should be set to HIGH state when the peripheral is on use and go to LOW when device is in low-power state.

For now, port is controlled by mockup code: 

const struct device *gpio_dev;

void pwrct_sf_init()
{
gpio_dev = device_get_binding("GPIO_1");
/* Set power control pin as output */
gpio_pin_configure(gpio_dev, 9, GPIO_OUTPUT_LOW | GPIO_ACTIVE_HIGH); //p1.09 == LDO_EN active high
}

#if 1

void pwrct_sf_on()
{
gpio_pin_set(gpio_dev, 9, 1); 
}


void pwrct_sf_off()
{
gpio_pin_set(gpio_dev, 9, 0); 
}

How we should define it in DTS (e.g. like leds section) to make it defined clearly (port & pin number, active state, label should be defined in DTS).

Is there a way to add calls to this port on / off to particular functions related to SPI init / deinit and QSPI init / deinit?

Related