public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] How to create a GPIO driver
@ 2013-03-10 18:19 EnneGi
  2013-03-10 18:59 ` Andrew Lunn
  2013-03-10 19:23 ` Ilija Kocho
  0 siblings, 2 replies; 30+ messages in thread
From: EnneGi @ 2013-03-10 18:19 UTC (permalink / raw)
  To: ecos-discuss

Hi, I must create a GPIO driver for my lpc1766 board. I try to search some
source example for do it, but for gpio drivers I don't find anything. Does
anybody tell me how I do it please?



--
View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [ECOS] How to create a GPIO driver
  2013-03-10 18:19 [ECOS] How to create a GPIO driver EnneGi
@ 2013-03-10 18:59 ` Andrew Lunn
  2013-03-10 19:23 ` Ilija Kocho
  1 sibling, 0 replies; 30+ messages in thread
From: Andrew Lunn @ 2013-03-10 18:59 UTC (permalink / raw)
  To: EnneGi; +Cc: ecos-discuss

On Sun, Mar 10, 2013 at 11:19:17AM -0700, EnneGi wrote:
> Hi, I must create a GPIO driver for my lpc1766 board. I try to search some
> source example for do it, but for gpio drivers I don't find anything. Does
> anybody tell me how I do it please?

For one example, take a look at the end of:

http://ecos.sourceware.org/cgi-bin/cvsweb.cgi/ecos/packages/hal/arm/at91/var/current/include/var_io.h?rev=1.27&content-type=text/x-cvsweb-markup&cvsroot=ecos

	Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [ECOS] How to create a GPIO driver
  2013-03-10 18:19 [ECOS] How to create a GPIO driver 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:11   ` [ECOS] " Morris, Richard
  1 sibling, 2 replies; 30+ messages in thread
From: Ilija Kocho @ 2013-03-10 19:23 UTC (permalink / raw)
  To: EnneGi; +Cc: ecos-discuss

On 10.03.2013 19:19, EnneGi wrote:
> Hi, I must create a GPIO driver for my lpc1766 board. I try to search some
> source example for do it, but for gpio drivers I don't find anything. Does
> anybody tell me how I do it please?

You could look at STM32 port.

Ilija


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [ECOS] Re: How to create a GPIO driver
  2013-03-10 19:23 ` Ilija Kocho
@ 2013-03-10 22:57   ` EnneGi
  2013-03-11 14:24     ` Morris, Richard
  2013-03-11 14:11   ` [ECOS] " Morris, Richard
  1 sibling, 1 reply; 30+ messages in thread
From: EnneGi @ 2013-03-10 22:57 UTC (permalink / raw)
  To: ecos-discuss

why STM32 port? I don't understand...



--
View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p224925.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [ECOS] How to create a GPIO driver
  2013-03-10 19:23 ` Ilija Kocho
  2013-03-10 22:57   ` [ECOS] " EnneGi
@ 2013-03-11 14:11   ` Morris, Richard
  1 sibling, 0 replies; 30+ messages in thread
From: Morris, Richard @ 2013-03-11 14:11 UTC (permalink / raw)
  To: Ilija Kocho; +Cc: EnneGi, ecos-discuss

Hi All,

We are using the STM32F4 eCos port.  It has a nice set of macros to configure and access the GPIO.  Definitely worth a look as a pattern on how to do GPIO on other boards.

--Richard


--------
On Mar 10, 2013, at 12:22 PM, Ilija Kocho <ilijak@siva.com.mk> wrote:

On 10.03.2013 19:19, EnneGi wrote:
Hi, I must create a GPIO driver for my lpc1766 board. I try to search some
source example for do it, but for gpio drivers I don't find anything. Does
anybody tell me how I do it please?

You could look at STM32 port.

Ilija


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Richard Morris
Senior Staff Firmware Engineer

T  650.638.6883
850 Lincoln Centre Dr
MS 407-1
Foster City, CA 94404
USA
http://www.lifetechnologies.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [ECOS] Re: How to create a GPIO driver
  2013-03-10 22:57   ` [ECOS] " EnneGi
@ 2013-03-11 14:24     ` Morris, Richard
  2013-03-11 16:52       ` EnneGi
  0 siblings, 1 reply; 30+ messages in thread
From: Morris, Richard @ 2013-03-11 14:24 UTC (permalink / raw)
  To: EnneGi; +Cc: ecos-discuss

The STM32 ports show up in the eCos Configuration tool under Build>Templates as: ST STM3240 EVAL board, etc.

Useful macros are CYGWRD_HAL_STM32_GPIO_SET(…), CYGHWR_HAL_STM32_GPIO_OUT(…), CYGHWR_HAL_STM32_GPIO_IN(…).  You will find these in your ecos directory tree:

    .../ecos/packages/hal/cortexm/stm32/var/current/include/var_io.h

----------------------------
On Mar 10, 2013, at 3:57 PM, EnneGi <enricogiordano1992@gmail.com> wrote:

why STM32 port? I don't understand...



--
View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p224925.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [ECOS] Re: How to create a GPIO driver
  2013-03-11 14:24     ` Morris, Richard
@ 2013-03-11 16:52       ` EnneGi
  2013-03-12 14:49         ` [ECOS] " Morris, Richard
  0 siblings, 1 reply; 30+ messages in thread
From: EnneGi @ 2013-03-11 16:52 UTC (permalink / raw)
  To: ecos-discuss

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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [ECOS] How to create a GPIO driver
  2013-03-11 16:52       ` EnneGi
@ 2013-03-12 14:49         ` Morris, Richard
  2013-03-12 22:17           ` [ECOS] " EnneGi
  2013-03-12 22:36           ` EnneGi
  0 siblings, 2 replies; 30+ messages in thread
From: Morris, Richard @ 2013-03-12 14:49 UTC (permalink / raw)
  To: EnneGi; +Cc: ecos-discuss

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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [ECOS] Re: How to create a GPIO driver
  2013-03-12 14:49         ` [ECOS] " Morris, Richard
@ 2013-03-12 22:17           ` EnneGi
  2013-03-13 15:36             ` Morris, Richard
  2013-03-12 22:36           ` EnneGi
  1 sibling, 1 reply; 30+ messages in thread
From: EnneGi @ 2013-03-12 22:17 UTC (permalink / raw)
  To: ecos-discuss

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 &amp;= ~(1&lt;&lt;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&amp;1) == 0 ) port += 4;
    HAL_WRITE_UINT32( port, 1&lt;&lt;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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [ECOS] Re: How to create a GPIO driver
  2013-03-12 14:49         ` [ECOS] " Morris, Richard
  2013-03-12 22:17           ` [ECOS] " EnneGi
@ 2013-03-12 22:36           ` EnneGi
  1 sibling, 0 replies; 30+ messages in thread
From: EnneGi @ 2013-03-12 22:36 UTC (permalink / raw)
  To: ecos-discuss

Ok, so I use the macros 

CYGHWR_HAL_LPC1XXX_GPIO_SET(…), 
CYGHWR_HAL_LPC1XXX_GPIO_OUT(…), 
CYGHWR_HAL_LPC1XXX_GPIO_IN(…)

and the parameters (__pin) is the address of my GPIO board?



--
View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p225224.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [ECOS] Re: How to create a GPIO driver
  2013-03-12 22:17           ` [ECOS] " EnneGi
@ 2013-03-13 15:36             ` Morris, Richard
  2013-03-14 14:41               ` EnneGi
  0 siblings, 1 reply; 30+ messages in thread
From: Morris, Richard @ 2013-03-13 15:36 UTC (permalink / raw)
  To: EnneGi; +Cc: ecos-discuss

The pin arguments for the hal_LPC17xx_gpio_xxx() functions you describe are likely provided by a macro, of which I don't know the name.  It may be in the var_io.h file for your eCos distribution.

Once you know the value of the PIN argument, you can call the hal_LPC17XX_gpio_xxx() functions of your distribution.


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [ECOS] Re: How to create a GPIO driver
  2013-03-13 15:36             ` Morris, Richard
@ 2013-03-14 14:41               ` EnneGi
  2013-03-14 15:05                 ` Michael Jones
  2013-03-14 15:06                 ` EnneGi
  0 siblings, 2 replies; 30+ messages in thread
From: EnneGi @ 2013-03-14 14:41 UTC (permalink / raw)
  To: ecos-discuss

I try to do the porting but i failed.
Does anybody help me step by step? I really don't understand. Thanks. 



--
View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p225400.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [ECOS] Re: How to create a GPIO driver
  2013-03-14 14:41               ` EnneGi
@ 2013-03-14 15:05                 ` Michael Jones
  2013-03-14 15:24                   ` EnneGi
  2013-03-14 15:06                 ` EnneGi
  1 sibling, 1 reply; 30+ messages in thread
From: Michael Jones @ 2013-03-14 15:05 UTC (permalink / raw)
  To: EnneGi; +Cc: ecos-discuss

EnneGi,

I don't know at what step you have a problem, so let me describe how I made changes, and if you already know this part, please forgive.

I take a copy of the code from CVS and never change it. This is for reference. Then I copy the package tree to my install area after tar'ing up my old one.

I make changes to files in the package tree. Now I can use diff or guiffy between the clean tree and the working tree if I get in trouble and need to know what I did. And I can use this for making patches.

I then have a eCos project. That project creates two directories, one ending in _build and one ending in _install.

I cd to _build and do a:

make clean
make

I do this because the build from the eCos tool may not report errors. This prevents accidental use of old files.

Then I take my application project and do a clean to make sure the compiler does not make any mistakes with old object files, and compile everything. Then I debug.

If the question is about the code itself, others may know the code you are using as an example. I am only familiar with the Kinetis macros, and I am a bit of a newbie, so I have no authority when it comes to proper coding style and structure in eCos.

Mike




On Mar 14, 2013, at 8:40 AM, EnneGi <enricogiordano1992@gmail.com> wrote:

> I try to do the porting but i failed.
> Does anybody help me step by step? I really don't understand. Thanks. 
> 
> 
> 
> --
> View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p225400.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [ECOS] Re: How to create a GPIO driver
  2013-03-14 14:41               ` EnneGi
  2013-03-14 15:05                 ` Michael Jones
@ 2013-03-14 15:06                 ` EnneGi
  2013-03-14 15:21                   ` Michael Jones
  1 sibling, 1 reply; 30+ messages in thread
From: EnneGi @ 2013-03-14 15:06 UTC (permalink / raw)
  To: ecos-discuss

I'm using ecos-3.0 with redboot-k70 packages upgrade; my target is lpc1766stk 
Thanks for reply



--
View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p225412.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [ECOS] Re: How to create a GPIO driver
  2013-03-14 15:06                 ` EnneGi
@ 2013-03-14 15:21                   ` Michael Jones
  0 siblings, 0 replies; 30+ messages in thread
From: Michael Jones @ 2013-03-14 15:21 UTC (permalink / raw)
  To: EnneGi; +Cc: ecos-discuss

EnneGi,

Look at http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001787

to see what I did.

Mike




On Mar 14, 2013, at 9:06 AM, EnneGi <enricogiordano1992@gmail.com> wrote:

> lpc1766stk


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [ECOS] Re: How to create a GPIO driver
  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
  0 siblings, 2 replies; 30+ messages in thread
From: EnneGi @ 2013-03-14 15:24 UTC (permalink / raw)
  To: ecos-discuss

thanks for reply. Now I describe my steps:

- found explicit address of gpio in the file lpc17xx.h at this url:
http://www.keil.com/dd/docs/arm/nxp/lpc17xx/lpc17xx.h
(search   "Peripheral memory map")

- copy the address in the "var_io.h" of the stm32 in the "#define" of gpio
and copy the part of source that I modify in the "var_io.h" in "the
var_io.h" of lpc1766stk

- compile ecos with 
   ecosconfig new lpc1766stk
   ecosconfig tree
   make

- try an application of gpio


<cyg/hal/var_io.h>

int main (void)
{
    hal_LPC17XX_gpio_set(/*here I put the address*/);
    hal_LPC17XX_gpio_out(/*here I put the address*/, 0);

}


I think that gpio (associated to led) send value 0 in the output.



--
View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p225418.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [ECOS] Re: How to create a GPIO driver
  2013-03-14 15:24                   ` EnneGi
@ 2013-03-14 15:26                     ` EnneGi
  2013-03-14 15:32                     ` Michael Jones
  1 sibling, 0 replies; 30+ messages in thread
From: EnneGi @ 2013-03-14 15:26 UTC (permalink / raw)
  To: ecos-discuss

the function is described in the file
ecos-3.0/packages/hal/cortexm/stm32/var/current/src/stm32_misc.c

then I copied the declaration of function in lpc1766stk_misc.c 




--
View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p225419.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [ECOS] Re: How to create a GPIO driver
  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
  1 sibling, 1 reply; 30+ messages in thread
From: Michael Jones @ 2013-03-14 15:32 UTC (permalink / raw)
  To: EnneGi; +Cc: ecos-discuss

EnneGi,

I don't know this part, but you may want to look at the configuration of the port. Most GPIO have a configuration register. It is possible the GPIO port is disabled or disconnected. You should be able to examine the configuration registers with your debugger. I find it much faster to just see what is in the registers than wade through code trying to reason my way to the registers value.

Mike



On Mar 14, 2013, at 9:23 AM, EnneGi <enricogiordano1992@gmail.com> wrote:

> thanks for reply. Now I describe my steps:
> 
> - found explicit address of gpio in the file lpc17xx.h at this url:
> http://www.keil.com/dd/docs/arm/nxp/lpc17xx/lpc17xx.h
> (search   "Peripheral memory map")
> 
> - copy the address in the "var_io.h" of the stm32 in the "#define" of gpio
> and copy the part of source that I modify in the "var_io.h" in "the
> var_io.h" of lpc1766stk
> 
> - compile ecos with 
>   ecosconfig new lpc1766stk
>   ecosconfig tree
>   make
> 
> - try an application of gpio
> 
> 
> <cyg/hal/var_io.h>
> 
> int main (void)
> {
>    hal_LPC17XX_gpio_set(/*here I put the address*/);
>    hal_LPC17XX_gpio_out(/*here I put the address*/, 0);
> 
> }
> 
> 
> I think that gpio (associated to led) send value 0 in the output.
> 
> 
> 
> --
> View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p225418.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [ECOS] Re: How to create a GPIO driver
  2013-03-14 15:32                     ` Michael Jones
@ 2013-03-14 15:35                       ` EnneGi
  2013-03-14 15:43                         ` [ECOS] " Michael Jones
  2013-03-14 16:09                         ` [ECOS] " Morris, Richard
  0 siblings, 2 replies; 30+ messages in thread
From: EnneGi @ 2013-03-14 15:35 UTC (permalink / raw)
  To: ecos-discuss

Ok, so how I locate GPIO register in this way?



--
View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p225422.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [ECOS] How to create a GPIO driver
  2013-03-14 15:35                       ` EnneGi
@ 2013-03-14 15:43                         ` Michael Jones
  2013-03-14 15:53                           ` [ECOS] " EnneGi
  2013-03-14 16:09                         ` [ECOS] " Morris, Richard
  1 sibling, 1 reply; 30+ messages in thread
From: Michael Jones @ 2013-03-14 15:43 UTC (permalink / raw)
  To: EnneGi; +Cc: ecos-discuss

You have to get the datasheet for the processor you are using, then use a memory display in your debugger.



On Mar 14, 2013, at 9:35 AM, EnneGi <enricogiordano1992@gmail.com> wrote:

> Ok, so how I locate GPIO register in this way?
> 
> 
> 
> --
> View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p225422.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [ECOS] Re: How to create a GPIO driver
  2013-03-14 15:43                         ` [ECOS] " Michael Jones
@ 2013-03-14 15:53                           ` EnneGi
  2013-03-14 15:58                             ` Michael Jones
  0 siblings, 1 reply; 30+ messages in thread
From: EnneGi @ 2013-03-14 15:53 UTC (permalink / raw)
  To: ecos-discuss

sorry, but how I use a memory display? I use openocd...



--
View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p225426.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [ECOS] Re: How to create a GPIO driver
  2013-03-14 15:53                           ` [ECOS] " EnneGi
@ 2013-03-14 15:58                             ` Michael Jones
  0 siblings, 0 replies; 30+ messages in thread
From: Michael Jones @ 2013-03-14 15:58 UTC (permalink / raw)
  To: EnneGi; +Cc: ecos-discuss

EnneGi,

You can have a debugger attach to openocd.

This blog shows how I did it with Eclipse Juno.

This is a good choice because you can then by tools that plug into Juno and help with advanced debugging.

Mike



On Mar 14, 2013, at 9:52 AM, EnneGi <enricogiordano1992@gmail.com> wrote:

> sorry, but how I use a memory display? I use openocd...
> 
> 
> 
> --
> View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p225426.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [ECOS] How to create a GPIO driver
  2013-03-14 15:35                       ` EnneGi
  2013-03-14 15:43                         ` [ECOS] " Michael Jones
@ 2013-03-14 16:09                         ` Morris, Richard
  2013-03-14 17:08                           ` [ECOS] " EnneGi
  1 sibling, 1 reply; 30+ messages in thread
From: Morris, Richard @ 2013-03-14 16:09 UTC (permalink / raw)
  To: EnneGi; +Cc: ecos-discuss

A useful document is the LPC17xx User manual:

http://www.nxp.com/documents/user_manual/UM10360.pdf

See chapter 9: LPC17xx General Purpose Input/Output (GPIO).

It is also a good idea to read:

Chapter 1: Introductory Information
Chapter 2: Memory Map


Here is an example of how I use the STM32 related functions to do GPIO:

    #include <cyg/hal/var_io.h>
    cyg_uint32 v_led_ok = CYGHWR_HAL_STM32_PIN_OUT(B,  14, OPENDRAIN, NONE,  2MHZ);

    // Turn the LED on
    CYGHWR_HAL_STM32_GPIO_OUT(v_led_ok, 1);

    // Turn the LED off
    CYGHWR_HAL_STM32_GPIO_OUT(v_led_ok, 0);

See ./packages/hal/cortexm/stm32/var/current/include/var_io_pins.h for details.

Using the user manual above and the ideas used by the STM32, you can create comparable functionality for the LPC1xxx family.

------------------------------
On Mar 14, 2013, at 8:35 AM, EnneGi <enricogiordano1992@gmail.com> wrote:

Ok, so how I locate GPIO register in this way?



--
View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p225422.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [ECOS] Re: How to create a GPIO driver
  2013-03-14 16:09                         ` [ECOS] " Morris, Richard
@ 2013-03-14 17:08                           ` EnneGi
  2013-03-14 18:17                             ` [ECOS] " Morris, Richard
  0 siblings, 1 reply; 30+ messages in thread
From: EnneGi @ 2013-03-14 17:08 UTC (permalink / raw)
  To: ecos-discuss

wait a second! I don't find "var_io_pins.h". Can you tell me how i download
it?
Thanks very much!



--
View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p225438.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [ECOS] How to create a GPIO driver
  2013-03-14 17:08                           ` [ECOS] " EnneGi
@ 2013-03-14 18:17                             ` Morris, Richard
  2013-03-14 18:27                               ` [ECOS] " EnneGi
  2013-03-14 19:59                               ` EnneGi
  0 siblings, 2 replies; 30+ messages in thread
From: Morris, Richard @ 2013-03-14 18:17 UTC (permalink / raw)
  To: EnneGi; +Cc: ecos-discuss

You will need to download the CVS development tree.  Follow the directions at the link below.  Be sure to read the directions carefully as they have good pointers.

http://ecos.sourceware.org/anoncvs.html


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [ECOS] Re: How to create a GPIO driver
  2013-03-14 18:17                             ` [ECOS] " Morris, Richard
@ 2013-03-14 18:27                               ` EnneGi
  2013-03-14 19:59                               ` EnneGi
  1 sibling, 0 replies; 30+ messages in thread
From: EnneGi @ 2013-03-14 18:27 UTC (permalink / raw)
  To: ecos-discuss

I've (another) problem (I'm very unlucky). I've this error:

cvs [login aborted]: unrecognized auth response from ecos.sourceware.org:
Service temporarily unavailable, please try again later





--
View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p225454.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [ECOS] Re: How to create a GPIO driver
  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
  1 sibling, 1 reply; 30+ messages in thread
From: EnneGi @ 2013-03-14 19:59 UTC (permalink / raw)
  To: ecos-discuss

I use this test main:

#include <cyg/infra/diag.h>
#include <cyg/hal/var_io.h>

int main (void)
{

  diag_printf("setting gpio\n");

  cyg_uint32 v_led_ok = CYGHWR_HAL_LPC17XX_PIN_OUT(B,  14, OPENDRAIN, NONE, 
2MHZ); 

    // Turn the LED on 
  CYGHWR_HAL_LPC17XX_GPIO_OUT(v_led_ok, 1); 

    // Turn the LED off 
  CYGHWR_HAL_LPC17XX_GPIO_OUT(v_led_ok, 0);  

  diag_printf("DONE\n");

  while(1)
    {;}

  return 0;

  }


and, when I compile, the compiler give me this error:


gpio.c:9: warning: implicit declaration of function
‘CYGHWR_HAL_LPC17XX_GPIO’
gpio.c:9: error: ‘B’ undeclared (first use in this function)
gpio.c:9: error: (Each undeclared identifier is reported only once
gpio.c:9: error: for each function it appears in.)
gpio.c:9: error: ‘OUT_2MHZ’ undeclared (first use in this function)
gpio.c:9: error: ‘OUT_OPENDRAIN’ undeclared (first use in this function)
make: *** [gpio.o] Error 1


what should I change?

Thanks a lot!



--
View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p225465.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [ECOS] Re: How to create a GPIO driver
  2013-03-14 19:59                               ` EnneGi
@ 2013-03-14 21:10                                 ` Morris, Richard
  2013-03-15 19:09                                   ` EnneGi
  0 siblings, 1 reply; 30+ messages in thread
From: Morris, Richard @ 2013-03-14 21:10 UTC (permalink / raw)
  To: EnneGi; +Cc: ecos-discuss

You will need to adapt the macro to the needs of the LPC17XX.  It will have different configuration that the STM32.

To do this you will need to read the GPIO section of the LPC17XX user manual and adapt the code from the STM32 to the LPC17XX.

--Richard

On Mar 14, 2013, at 12:59 PM, EnneGi <enricogiordano1992@gmail.com> wrote:

I use this test main:

#include <cyg/infra/diag.h>
#include <cyg/hal/var_io.h>

int main (void)
{

 diag_printf("setting gpio\n");

 cyg_uint32 v_led_ok = CYGHWR_HAL_LPC17XX_PIN_OUT(B,  14, OPENDRAIN, NONE, 
2MHZ); 

   // Turn the LED on 
 CYGHWR_HAL_LPC17XX_GPIO_OUT(v_led_ok, 1); 

   // Turn the LED off 
 CYGHWR_HAL_LPC17XX_GPIO_OUT(v_led_ok, 0);  

 diag_printf("DONE\n");

 while(1)
   {;}

 return 0;

 }


and, when I compile, the compiler give me this error:


gpio.c:9: warning: implicit declaration of function
‘CYGHWR_HAL_LPC17XX_GPIO’
gpio.c:9: error: ‘B’ undeclared (first use in this function)
gpio.c:9: error: (Each undeclared identifier is reported only once
gpio.c:9: error: for each function it appears in.)
gpio.c:9: error: ‘OUT_2MHZ’ undeclared (first use in this function)
gpio.c:9: error: ‘OUT_OPENDRAIN’ undeclared (first use in this function)
make: *** [gpio.o] Error 1


what should I change?

Thanks a lot!

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [ECOS] Re: How to create a GPIO driver
  2013-03-14 21:10                                 ` Morris, Richard
@ 2013-03-15 19:09                                   ` EnneGi
  2013-03-15 22:14                                     ` EnneGi
  0 siblings, 1 reply; 30+ messages in thread
From: EnneGi @ 2013-03-15 19:09 UTC (permalink / raw)
  To: ecos-discuss

Ok I compiled the sorcea right. The led doesn't turn off, so (I think) I
write the wrong address. Can I post a link of my sources? In this way you
can say what I wrong.

Very thanks! This forum is amazing!!!



--
View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p225605.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [ECOS] Re: How to create a GPIO driver
  2013-03-15 19:09                                   ` EnneGi
@ 2013-03-15 22:14                                     ` EnneGi
  0 siblings, 0 replies; 30+ messages in thread
From: EnneGi @ 2013-03-15 22:14 UTC (permalink / raw)
  To: ecos-discuss

here my sources:

http://dropcanvas.com/q12c6



--
View this message in context: http://sourceware-org.1504.n7.nabble.com/How-to-create-a-GPIO-driver-tp224910p225623.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

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2013-03-15 22:14 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-10 18:19 [ECOS] How to create a GPIO driver 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           ` [ECOS] " 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

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).