Hi,

According to the manual,

The mask argument can be used to apply value only to select pins, and
retain the existing value on the rest. Because of this feature, this API
call will incur two register transactions (one read, one write).

I think the value parameter should be a hexadecimal number, each bit
represents the value of the corresponding pin.
If you want to set pin 0 and 1 to 1 at the same time.
It should be
usrp->set_gpio_attr("FP0", "OUT", 0x0003, 0x0003);
And that only apply values to the pin you selected.

Cao Jiahui

Will Haftel via USRP-users <usrp-users@lists.ettus.com> 于2024年11月20日周三
04:17写道:

> Hi,
>
> I am having some issues controlling the GPIO on the x310. So far I have
> only been able to control the output of pin 0. Here are some code snippets
> of things I have tried:
>
>
> I have these lines before trying to control pins:
>
> usrp->set_gpio_attr("FP0", "CTRL", 0x000, 0xFFF);
>
> usrp->set_gpio_attr("FP0", "DDR", 0xFFF, 0xFFF);
>
>
> This block works - set pin 0 to high, and pins 1 and 2 to low:
>
> usrp->set_gpio_attr("FP0", "OUT", 1, 1);
>
> usrp->set_gpio_attr("FP0", "OUT", 0, (1<<1));
>
> usrp->set_gpio_attr("FP0", "OUT", 0, (1<<2));
>
>
> This block does not work - trying to set pins 0 and 1 to high, but only
> pin 0 outputs high:
>
> usrp->set_gpio_attr("FP0", "OUT", 1, 1);
>
> usrp->set_gpio_attr("FP0", "OUT", 1, (1<<1));
>
> usrp->set_gpio_attr("FP0", "OUT", 0, (1<<2));
>
>
> I attempt to set all pins to high using this line, but again only pin 0
> outputs high:
>
> usrp->set_gpio_attr("FP0", "OUT", 1, 0xFFF);
>
>
> Am I doing something wrong in the cases where the GPIO doesn’t have my
> desired outputs?
>
>
> Thanks,
>
> Will
>
>
>
> _______________________________________________
> USRP-users mailing list -- usrp-users@lists.ettus.com
> To unsubscribe send an email to usrp-users-le...@lists.ettus.com
>
_______________________________________________
USRP-users mailing list -- usrp-users@lists.ettus.com
To unsubscribe send an email to usrp-users-le...@lists.ettus.com

Reply via email to