ESP-IDF: How to configure GPIO to output with pulldown enabled

The following example configures GPIO12 as an output with the integrated pulldown resistor enabled using the ESP-IDF API.

#include <driver/gpio.h>

gpio_config_t io_conf;
// Disable interrupt
io_conf.intr_type = GPIO_INTR_DISABLE;
// Set as output mode
io_conf.mode = GPIO_MODE_OUTPUT;
// Bit mask of the pins that you want to set
io_conf.pin_bit_mask = (1ULL << GPIO_NUM_12);
// Set to pull-down in case of floating => fix boot
io_conf.pull_down_en = GPIO_PULLDOWN_ENABLE;
// Disable pull-up mode
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
// Configure GPIO with the given settings
gpio_config(&io_conf);