I want to to modify a register to get the same results as
gpio_set_direction(GPIO_NUM_0, GPIO_MODE_INPUT);
I was trying GPIO.enable_w1tc = ((uint32_t)1 << 1); but its not working.
code
// configure GPIO
gpio_config_t io_conf;
const int bundleA_gpios[] = {0,1,2};
for (int i = 0; i < sizeof(bundleA_gpios) / sizeof(bundleA_gpios[0]); i++)
{
io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = (1ULL<<i);
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
gpio_config(&io_conf);
}
// Create bundleA, output only
dedic_gpio_bundle_handle_t bundleA = NULL;
dedic_gpio_bundle_config_t bundleA_config =
{
.gpio_array = bundleA_gpios,
.array_size = sizeof(bundleA_gpios) / sizeof(bundleA_gpios[0]),
.flags = {
.out_en = 1,
},
};
(dedic_gpio_new_bundle(&bundleA_config, &bundleA));
gpio_set_direction(GPIO_NUM_0, GPIO_MODE_INPUT);
//GPIO.enable_w1tc = ((uint32_t)1 << 1);
modify directional registers.
modify directional registers.
Last edited by ulaoulao on Sat Jun 22, 2024 4:05 pm, edited 2 times in total.
-
- Posts: 1725
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: modify directional registers.
GPIO_NUM_0 is ... 0, i.e. not 1 Try
Code: Select all
GPIO.enable_w1tc = ((uint32_t)1 << 0);
Re: modify directional registers.
yeah I think I just typed that in wrong.
but looks like GPIO.enable_w1tc and GPIO.enable_w1ts are not for inputs, they are the gates for outputs. so I tried
IN_INPUT_ENABLE(IO_MUX_GPIO0_REG + (GPIO_NUM_1 * 4));
PIN_INPUT_ENABLE(IO_MUX_GPIO0_REG + (GPIO_NUM_0 * 4));
and also tried
WRITE_PERI_REG((IO_MUX_GPIO0_REG), (READ_PERI_REG(IO_MUX_GPIO0_REG)|(1<<9)));
WRITE_PERI_REG((IO_MUX_GPIO1_REG), (READ_PERI_REG(IO_MUX_GPIO1_REG)|(1<<9)));
neither worked, so then I tried
//enable inputs gates
IN_INPUT_ENABLE(IO_MUX_GPIO0_REG + (GPIO_NUM_1 * 4));
PIN_INPUT_ENABLE(IO_MUX_GPIO0_REG + (GPIO_NUM_0 * 4));
//disable out gates
GPIO.enable_w1tc = ((uint32_t)1 << 0);
GPIO.enable_w1tc = ((uint32_t)1 << 1);
but still not working where just using
gpio_set_direction(GPIO_NUM_0, GPIO_MODE_INPUT);
gpio_set_direction(GPIO_NUM_0, GPIO_MODE_INPUT);
works.
but looks like GPIO.enable_w1tc and GPIO.enable_w1ts are not for inputs, they are the gates for outputs. so I tried
IN_INPUT_ENABLE(IO_MUX_GPIO0_REG + (GPIO_NUM_1 * 4));
PIN_INPUT_ENABLE(IO_MUX_GPIO0_REG + (GPIO_NUM_0 * 4));
and also tried
WRITE_PERI_REG((IO_MUX_GPIO0_REG), (READ_PERI_REG(IO_MUX_GPIO0_REG)|(1<<9)));
WRITE_PERI_REG((IO_MUX_GPIO1_REG), (READ_PERI_REG(IO_MUX_GPIO1_REG)|(1<<9)));
neither worked, so then I tried
//enable inputs gates
IN_INPUT_ENABLE(IO_MUX_GPIO0_REG + (GPIO_NUM_1 * 4));
PIN_INPUT_ENABLE(IO_MUX_GPIO0_REG + (GPIO_NUM_0 * 4));
//disable out gates
GPIO.enable_w1tc = ((uint32_t)1 << 0);
GPIO.enable_w1tc = ((uint32_t)1 << 1);
but still not working where just using
gpio_set_direction(GPIO_NUM_0, GPIO_MODE_INPUT);
gpio_set_direction(GPIO_NUM_0, GPIO_MODE_INPUT);
works.
Who is online
Users browsing this forum: Bing [Bot] and 356 guests