public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] I2C Bus definition problem
@ 2007-09-07 10:23 Alexandre
  2007-09-07 11:22 ` Andrew Lunn
  2007-09-07 12:50 ` Andrew Lunn
  0 siblings, 2 replies; 6+ messages in thread
From: Alexandre @ 2007-09-07 10:23 UTC (permalink / raw)
  To: ecos-discuss

Hi everybody,

I'm near the end in my attempt to make an I2C driver for the LPC2XXX platform.
I'm trying to declare my i2c bus using the I2C generic macro CYG_I2C_BUS
Currently the declaration looks like this:

CYG_I2C_BUS(i2cBusLpc, cyg_lpc2xxx_i2c_init, cyg_lpc2xxx_i2c_tx,
cyg_lpc2xxx_i2c_rx, cyg_lpc2xxx_i2c_stop, ((void*)(&extra)) 	);

'extra' being declared two lines above like this:

static cyg_lpc2xxx_i2c_extra extra;

When I try to compile the code, the compiler says for the line where I
use the macro:

'section attribute cannot be specified for local variables'

I tried to look over the internet for hints on that error and found
nothing but error logs with the same error and nothing to get rid of
it.

Does someone have an idea of what i'm doing wrong ?

PS: For those of you unfamiliar with the ecos I2C interface, here is
what the declaration of the I2C bus structure looks like:

typedef struct cyg_i2c_bus {
    cyg_drv_mutex_t         i2c_lock;
#ifdef CYGDBG_USE_ASSERTS
    const cyg_i2c_device*   i2c_current_device;
#endif
    // The hardware-specific functions that do the real work
    void                    (*i2c_init_fn)(struct cyg_i2c_bus*);
    cyg_uint32              (*i2c_tx_fn)(const cyg_i2c_device*,
cyg_bool, const cyg_uint8*, cyg_uint32, cyg_bool);
    cyg_uint32              (*i2c_rx_fn)(const cyg_i2c_device*,
cyg_bool, cyg_uint8*, cyg_uint32, cyg_bool, cyg_bool);
    void                    (*i2c_stop_fn)(const cyg_i2c_device*);
    // A spare field for use by the driver
    void*                   i2c_extra;
} CYG_HAL_TABLE_TYPE cyg_i2c_bus;

And the declaration macro:

#define CYG_I2C_BUS(_name_, _init_fn_, _tx_fn_, _rx_fn_, _stop_fn_,
_extra_)    \
    cyg_i2c_bus _name_  CYG_HAL_TABLE_ENTRY( i2c_buses ) = {
         \
        .i2c_init_fn    = _init_fn_,
         \
        .i2c_tx_fn      = _tx_fn_,
         \
        .i2c_rx_fn      = _rx_fn_,
         \
        .i2c_stop_fn    = _stop_fn_,
         \
        .i2c_extra      = _extra_
         \
    }

-- 
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] 6+ messages in thread

* Re: [ECOS] I2C Bus definition problem
  2007-09-07 10:23 [ECOS] I2C Bus definition problem Alexandre
@ 2007-09-07 11:22 ` Andrew Lunn
  2007-09-07 12:50 ` Andrew Lunn
  1 sibling, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2007-09-07 11:22 UTC (permalink / raw)
  To: Alexandre; +Cc: ecos-discuss

On Fri, Sep 07, 2007 at 12:23:17PM +0200, Alexandre wrote:
> Hi everybody,
> 
> I'm near the end in my attempt to make an I2C driver for the LPC2XXX platform.
> I'm trying to declare my i2c bus using the I2C generic macro CYG_I2C_BUS
> Currently the declaration looks like this:
> 
> CYG_I2C_BUS(i2cBusLpc, cyg_lpc2xxx_i2c_init, cyg_lpc2xxx_i2c_tx,
> cyg_lpc2xxx_i2c_rx, cyg_lpc2xxx_i2c_stop, ((void*)(&extra)) 	);
> 
> 'extra' being declared two lines above like this:
> 
> static cyg_lpc2xxx_i2c_extra extra;
> 
> When I try to compile the code, the compiler says for the line where I
> use the macro:
> 
> 'section attribute cannot be specified for local variables'

I think this means that one of your variables is on the stack, ie
local. You don't want that! 

Can you send me the file?

    Thanks
        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] 6+ messages in thread

* Re: [ECOS] I2C Bus definition problem
  2007-09-07 10:23 [ECOS] I2C Bus definition problem Alexandre
  2007-09-07 11:22 ` Andrew Lunn
@ 2007-09-07 12:50 ` Andrew Lunn
  2007-09-07 12:53   ` Alexandre
  1 sibling, 1 reply; 6+ messages in thread
From: Andrew Lunn @ 2007-09-07 12:50 UTC (permalink / raw)
  To: Alexandre; +Cc: ecos-discuss

Hi Alex

Try this:

static cyg_lpc2xxx_i2c_extra extra;

CYG_I2C_BUS(i2cBusLpc,
            cyg_lpc2xxx_i2c_init,
            cyg_lpc2xxx_i2c_tx,
            cyg_lpc2xxx_i2c_rx,
            cyg_lpc2xxx_i2c_stop,
            ((void*)(&extra))
            );

void cyg_user_start(void)
{

  CYG_I2C_DEVICE(i2cDevCamera,
                 &i2cBusLpc,
                 (cyg_uint16)I2C_CAMERA_ADDRESS,
                 (cyg_uint16)0,
                 (cyg_uint32)0
                 );
}

        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] 6+ messages in thread

* Re: [ECOS] I2C Bus definition problem
  2007-09-07 12:50 ` Andrew Lunn
@ 2007-09-07 12:53   ` Alexandre
  2007-09-07 13:07     ` Andrew Lunn
  0 siblings, 1 reply; 6+ messages in thread
From: Alexandre @ 2007-09-07 12:53 UTC (permalink / raw)
  To: Alexandre, ecos-discuss

Ok it works !

Thank you, do you know what the error is about so ?

On 9/7/07, Andrew Lunn <andrew@lunn.ch> wrote:
> Hi Alex
>
> Try this:
>
> static cyg_lpc2xxx_i2c_extra extra;
>
> CYG_I2C_BUS(i2cBusLpc,
>             cyg_lpc2xxx_i2c_init,
>             cyg_lpc2xxx_i2c_tx,
>             cyg_lpc2xxx_i2c_rx,
>             cyg_lpc2xxx_i2c_stop,
>             ((void*)(&extra))
>             );
>
> void cyg_user_start(void)
> {
>
>   CYG_I2C_DEVICE(i2cDevCamera,
>                  &i2cBusLpc,
>                  (cyg_uint16)I2C_CAMERA_ADDRESS,
>                  (cyg_uint16)0,
>                  (cyg_uint32)0
>                  );
> }
>
>         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] 6+ messages in thread

* Re: [ECOS] I2C Bus definition problem
  2007-09-07 12:53   ` Alexandre
@ 2007-09-07 13:07     ` Andrew Lunn
  2007-09-07 13:09       ` Alexandre
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Lunn @ 2007-09-07 13:07 UTC (permalink / raw)
  To: Alexandre; +Cc: ecos-discuss

On Fri, Sep 07, 2007 at 02:53:50PM +0200, Alexandre wrote:
> Ok it works !
> 
> Thank you, do you know what the error is about so ?
> 
> On 9/7/07, Andrew Lunn <andrew@lunn.ch> wrote:
> > Hi Alex
> >
> > Try this:
> >
> > static cyg_lpc2xxx_i2c_extra extra;
> >
> > CYG_I2C_BUS(i2cBusLpc,
> >             cyg_lpc2xxx_i2c_init,
> >             cyg_lpc2xxx_i2c_tx,
> >             cyg_lpc2xxx_i2c_rx,
> >             cyg_lpc2xxx_i2c_stop,
> >             ((void*)(&extra))
> >             );

This declares a variable called i2cBusLpc. Since you have this inside
a function, it is a local variable and so on the stack. However the
macro tries to set attributes which can only be set on global
variables. 

           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] 6+ messages in thread

* Re: [ECOS] I2C Bus definition problem
  2007-09-07 13:07     ` Andrew Lunn
@ 2007-09-07 13:09       ` Alexandre
  0 siblings, 0 replies; 6+ messages in thread
From: Alexandre @ 2007-09-07 13:09 UTC (permalink / raw)
  To: Alexandre, ecos-discuss

Ok, thank you very much for you help :)

-- 
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] 6+ messages in thread

end of thread, other threads:[~2007-09-07 13:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-07 10:23 [ECOS] I2C Bus definition problem Alexandre
2007-09-07 11:22 ` Andrew Lunn
2007-09-07 12:50 ` Andrew Lunn
2007-09-07 12:53   ` Alexandre
2007-09-07 13:07     ` Andrew Lunn
2007-09-07 13:09       ` Alexandre

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