[En-Nut-Discussion] Unified GPIO implementation
uprinz2 at netscape.net
uprinz2 at netscape.net
Wed Oct 20 10:23:29 CEST 2010
Hi!
I fully agree. STM32 does support PullDown too for inputs.
I'll check the wiki and update it.
Best regards
Ulrich
-----Original Message-----
From: Thiago A. Corrêa <thiago.correa at gmail.com>
To: Ethernut User Chat (English) <en-nut-discussion at egnite.de>
Sent: Wed, Oct 20, 2010 4:46 am
Subject: Re: [En-Nut-Discussion] Unified GPIO implementation
Hi All,
About the wiki article, in the part it says:
The obsolete definitions:
#define GPIO_CFG_MULTIDRIVE Enable Open-Drain: This should default as
PushPull can break the chip if enabled by accident.
It is dangerous to have PushPull as default with GPIO_CFG_OUTPUT. If
one uses the examples with a slightly different board it might kill
the hardware. So default should be Open-Drain or Weak Pullup if the
CPU supports that. If PushPull is supported it must be set by reason
and under programmers control.
---
Actually, I think the PushPull is the one that is not available on
most platforms. AVR32 and AVR 8 bits both have weak pull ups refered
as simply pull up, and in the case of AVR32 there is a open-drain
enable register.
I think we should then have a definition where PushPull must always be
explicitly enabled, never default. And output should be open-drain if
the CPU supports that. Therefore remove the "Weak pullup" case from
the specification, as it's simply GPIO_CFG_PULLUP and it's dealt with
as a flag of it's own if the user wants it enabled.
Based on that, I'm making the changes as this:
if (flags & GPIO_CFG_OUTPUT) {
gpio_port->oders = mask;
/* Unless specified, outputs default open-drain in Nut/OS */
if(flags & ~GPIO_CFG_PULLUP)
gpio_port->odmers = mask;
else
gpio_port->odmerc = mask;
} else {
gpio_port->oderc = mask;
}
ODMER is the register to enable Open Drain mode in AVR32.
Also, if you assume that PushPull is the special case, than this part
should also be modified:
#define GPIO_CFG_PUSHPULL AVR: Enable Pullup, ARM/Cortex: Enable
strong pull-up.
#define GPIO_CFG_PULLUP Enable Pullup.
to
#define GPIO_CFG_PULLUP Enable (weak) Pullup, (AVR, AVR32, ARM/Cortex).
#define GPIO_CFG_PUSHPULL Enable strong pull-up if available (ex.
ARM/Cortex), otherwise it's just #define GPIO_CFG_PUSHPULL
GPIO_CFG_PULLUP
One other thing, we might need an GPIO_CFG_PULLDOWN as well. Looks
like there are AVR32 parts with this feature judging from the Atmel
Software Framework source code in the repository.
Kind Regards,
Thiago A. Correa
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion
More information about the En-Nut-Discussion
mailing list