From: EnneGi <enricogiordano1992@gmail.com>
To: ecos-discuss@ecos.sourceware.org
Subject: [ECOS] Re: How to create a GPIO driver
Date: Tue, 12 Mar 2013 22:17:00 -0000 [thread overview]
Message-ID: <1363126636423-225218.post@n7.nabble.com> (raw)
In-Reply-To: <CDD24990-A455-41A8-BA94-C9E9A8A58B94@lifetech.com>
Great answer! Thanks! A question: can you tell me how the function
hal_LPC1XXX_gpio_set() (and other) appear in your source? In my source this
function is described in this way:
__externC void hal_LPC17XX_gpio_set( cyg_uint32 pin )
{
cyg_uint32 port = CYGHWR_HAL_LPC17XX_GPIO_PORT(pin);
int bit = CYGHWR_HAL_LPC17XX_GPIO_BIT(pin);
cyg_uint32 cm = CYGHWR_HAL_LPC17XX_GPIO_CFG(pin);
cyg_uint32 cr;
if( pin == CYGHWR_HAL_LPC17XX_GPIO_NONE )
return;
if( bit > 7 ) port += 4, bit -= 8;
HAL_READ_UINT32( port, cr );
cr &= ~(0xF<<(bit*4));
cr |= cm<<(bit*4);
HAL_WRITE_UINT32( port, cr );
// If this is a pullup/down input, set the ODR bit to switch on
// the appropriate pullup/down resistor.
if( cm ==
(CYGHWR_HAL_LPC17XX_GPIO_MODE_IN|CYGHWR_HAL_LPC17XX_GPIO_CNF_PULL) )
{
cyg_uint32 odr;
port = CYGHWR_HAL_LPC17XX_GPIO_PORT( pin );
bit = CYGHWR_HAL_LPC17XX_GPIO_BIT(pin);
HAL_READ_UINT32( port+CYGHWR_HAL_LPC17XX_GPIO_ODR, odr );
if( pin & CYGHWR_HAL_LPC17XX_GPIO_PULLUP )
odr |= (1<<bit);
else
odr &= ~(1<<bit);
HAL_WRITE_UINT32( port+CYGHWR_HAL_LPC17XX_GPIO_ODR, odr );
}
}
__externC void hal_LPC17XX_gpio_out( cyg_uint32 pin, int val )
{
cyg_uint32 port = CYGHWR_HAL_LPC17XX_GPIO_PORT(pin);
int bit = CYGHWR_HAL_LPC17XX_GPIO_BIT(pin);
port += CYGHWR_HAL_LPC17XX_GPIO_BSRR;
if( (val&1) == 0 ) port += 4;
HAL_WRITE_UINT32( port, 1<<bit );
}
__externC void hal_LPC17XX_gpio_in ( cyg_uint32 pin, int *val )
{
cyg_uint32 port = CYGHWR_HAL_LPC17XX_GPIO_PORT(pin);
int bit = CYGHWR_HAL_LPC17XX_GPIO_BIT(pin);
cyg_uint32 pd;
HAL_READ_UINT32( port+CYGHWR_HAL_LPC17XX_GPIO_IDR, pd );
*val = (pd>>bit)&1;
}
--
View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p225218.html
Sent from the Sourceware - ecos-discuss mailing list archive at Nabble.com.
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
next prev parent reply other threads:[~2013-03-12 22:17 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-10 18:19 [ECOS] " EnneGi
2013-03-10 18:59 ` Andrew Lunn
2013-03-10 19:23 ` Ilija Kocho
2013-03-10 22:57 ` [ECOS] " EnneGi
2013-03-11 14:24 ` Morris, Richard
2013-03-11 16:52 ` EnneGi
2013-03-12 14:49 ` [ECOS] " Morris, Richard
2013-03-12 22:17 ` EnneGi [this message]
2013-03-13 15:36 ` [ECOS] " Morris, Richard
2013-03-14 14:41 ` EnneGi
2013-03-14 15:05 ` Michael Jones
2013-03-14 15:24 ` EnneGi
2013-03-14 15:26 ` EnneGi
2013-03-14 15:32 ` Michael Jones
2013-03-14 15:35 ` EnneGi
2013-03-14 15:43 ` [ECOS] " Michael Jones
2013-03-14 15:53 ` [ECOS] " EnneGi
2013-03-14 15:58 ` Michael Jones
2013-03-14 16:09 ` [ECOS] " Morris, Richard
2013-03-14 17:08 ` [ECOS] " EnneGi
2013-03-14 18:17 ` [ECOS] " Morris, Richard
2013-03-14 18:27 ` [ECOS] " EnneGi
2013-03-14 19:59 ` EnneGi
2013-03-14 21:10 ` Morris, Richard
2013-03-15 19:09 ` EnneGi
2013-03-15 22:14 ` EnneGi
2013-03-14 15:06 ` EnneGi
2013-03-14 15:21 ` Michael Jones
2013-03-12 22:36 ` EnneGi
2013-03-11 14:11 ` [ECOS] " Morris, Richard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1363126636423-225218.post@n7.nabble.com \
--to=enricogiordano1992@gmail.com \
--cc=ecos-discuss@ecos.sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).