From: "Morris, Richard" <Richard.Morris@lifetech.com>
To: EnneGi <enricogiordano1992@gmail.com>
Cc: "ecos-discuss@ecos.sourceware.org" <ecos-discuss@ecos.sourceware.org>
Subject: Re: [ECOS] How to create a GPIO driver
Date: Tue, 12 Mar 2013 14:49:00 -0000 [thread overview]
Message-ID: <CDD24990-A455-41A8-BA94-C9E9A8A58B94@lifetech.com> (raw)
In-Reply-To: <1363020733839-225026.post@n7.nabble.com>
Hi EnneGi,
You may want to use the CYGHWR_HAL_LPC1XXX_GPIO_SET(…), CYGHWR_HAL_LPC1XXX_GPIO_OUT(…), and CYGHWR_HAL_LPC1XXX_GPIO_IN(…) macros.
I have found it useful to grep the eCos code base for examples of how to use macros, etc.
For examples, you can see code that uses them here:
./packages/hal/cortexm/lpc1xxx/var/v3_1_33/src/lpc1xxx_misc.c
./packages/devs/eth/arm/lpc2xxx/v3_1_33/src/if_lpc2xxx-lwip.c
Here are the related macros for the LPC1766, found in: .../packages/hal/cortexm/lpc1xxx/var/v3_1_33/include/var_io.h:
// This macro packs the port number, bit number and mode for a GPIO
// pin into a single word. The packing puts the mode in the ls 8 bits,
// the bit number in 16:20 and the GPIO port number bits 8:10. The
// mode is only specified using the last component of the name to
// keep definitions short.
#define CYGHWR_HAL_LPC1XXX_GPIO(__port, __bit, __mode ) \
(((__port)<< 8) | \
((__bit)<<16) | \
(CYGHWR_HAL_LPC1XXX_GPIO_MODE_##__mode) )
// Macros to extract encoded values
#define CYGHWR_HAL_LPC1XXX_GPIO_PORT(__pin) (((__pin)&0x00000700)>>8)
#define CYGHWR_HAL_LPC1XXX_GPIO_BIT(__pin) (((__pin)>>16)&0x1F)
#define CYGHWR_HAL_LPC1XXX_GPIO_MODE(__pin) ((__pin)&0xFF)
#define CYGHWR_HAL_LPC1XXX_GPIO_NONE (0xFFFFFFFF)
// Functions and macros to configure GPIO ports.
__externC void hal_lpc1xxx_gpio_set( cyg_uint32 pin );
__externC void hal_lpc1xxx_gpio_out( cyg_uint32 pin, int val );
__externC void hal_lpc1xxx_gpio_in ( cyg_uint32 pin, int *val );
#define CYGHWR_HAL_LPC1XXX_GPIO_SET(__pin ) hal_lpc1xxx_gpio_set( __pin )
#define CYGHWR_HAL_LPC1XXX_GPIO_OUT(__pin, __val ) hal_lpc1xxx_gpio_out( __pin, __val )
#define CYGHWR_HAL_LPC1XXX_GPIO_IN(__pin, __val ) hal_lpc1xxx_gpio_in( __pin, __val )
Hope this helps.
--Richard
------
On Mar 11, 2013, at 9:52 AM, EnneGi <enricogiordano1992@gmail.com> wrote:
Thanks a lot! So, for my work, I "copy" the instruction of stm32 in the
"var_io.h" file of lpc1766 (changing adress) and define the function of GPIO
set in a file on the directory devs/ right?
--
View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p225026.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
--
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 14:49 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-10 18:19 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 ` Morris, Richard [this message]
2013-03-12 22:17 ` EnneGi
2013-03-13 15:36 ` 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=CDD24990-A455-41A8-BA94-C9E9A8A58B94@lifetech.com \
--to=richard.morris@lifetech.com \
--cc=ecos-discuss@ecos.sourceware.org \
--cc=enricogiordano1992@gmail.com \
/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).