0
\$\begingroup\$

I'm writing some diagnostics for a Cortex-M4 -- in this case an ATSAME54. I'd like to be able to read the configuration of individual GPIO pins, namely:

  • bool level
  • enum gpio_direction direction [IN, OUT, OFF]
  • enum gpio_pull_mode pull_mode [UP, DOWN, NONE]

I've figured out how to read the level and the pull mode, but I'm stumped on reading the direction.

Has someone out there solved how to do this?

\$\endgroup\$
  • 3
    \$\begingroup\$ See the data sheet (programmer's manual, GPIO register section) of course. Direction will probably be right next to the things you have been able to read, so it's odd that you are having trouble with that. Note that your enum's are purely program conveniences, they may reflect that actual state of bits or they could only be constants meaningful to a particular Software Library's API that get translated into bits meaningful to the hardware. \$\endgroup\$ – Chris Stratton Dec 20 '18 at 16:16
  • \$\begingroup\$ @ChrisStratton: you are correct. I'm using the Atmel ASF library enums only as a notational convenience. What perplexes me is that the library routines for configuring the GPIO registers don't seem to match what I see in the data sheet. Thus my question... \$\endgroup\$ – fearless_fool Dec 20 '18 at 16:40
  • 2
    \$\begingroup\$ Such a mismatch in configuring would be quite different than the question you posted about reading back configuration. Generally I/O HAL libraries don't support reading out configuration, you'd probably have to go straight to the hardware for that. Seems like you should probably edit this to be specific about where you are getting stuck, ie "the data sheet implies this but when I read register A I see X and not the expected Y" \$\endgroup\$ – Chris Stratton Dec 20 '18 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.