public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "" <clifford.joseph@clarinox.com>
To: ecos-discuss@ecos.sourceware.org
Subject: [ECOS] i2c bit-banging implementation
Date: Thu, 23 Jun 2005 00:28:00 -0000	[thread overview]
Message-ID: <2415853226aa4e9ea1789842461c7ae1.clifford.joseph@clarinox.com> (raw)

Hi

I am trying to implement an i2c transfer by bit-banging.

I have successfully added the hardware package CYGPKG_IO_I2C to my configuration file. (.ecc)

Iam working on the eb40a evaluation board which has already an i2c device at24c512 eeprom. 

I am using  arm-elf-gcc version 3.2.1

As described I have added this in  the plf_io.h

#define HAL_I2C_EXPORTED_DEVICES                    	          \
    extern cyg_i2c_bus                  cyg_i2c_xyzzy_bus;        \
    extern cyg_i2c_device               cyg_i2c_wallclock_ds1307; \
    extern cyg_i2c_device               cyg_i2c_eeprom;

and in the application  main.cpp file I have implemented the following function

static cyg_bool
hal_alaia_i2c_bitbang(cyg_i2c_bus* bus, cyg_i2c_bitbang_op op)
{
    cyg_bool result    = 0;
    
    switch(op) 
    {

        case CYG_I2C_BITBANG_INIT:
           {
            }
        case CYG_I2C_BITBANG_SCL_HIGH:
            {
            }
…..
…..
….
…..
.
    }
    return result;
}




This is the definition in the i2c.h file

typedef struct cyg_i2c_device {
    struct cyg_i2c_bus* i2c_bus;
    cyg_uint16          i2c_address;
    cyg_uint16          i2c_flags;
    cyg_uint32          i2c_delay;
} cyg_i2c_device;

#define CYG_I2C_DEFAULT_DELAY   10000

// A utility macro for defining an I2C device
#define CYG_I2C_DEVICE(_name_, _bus_, _address_, _flags_, _delay_)  \
    cyg_i2c_device _name_ = {                         	        \
        .i2c_bus        = _bus_,                            		        \
        .i2c_address    = _address_,                                        \
        .i2c_flags      = _flags_,                                                \
        .i2c_delay      = _delay_                                               \
    }

CYG_I2C_DEVICE(cyg_i2c_eeprom, &cyg_i2c_xyzzy_bus, 0xA0, 0x00,CYG_I2C_DEFAULT_DELAY);

It still returns the same error when I compile 

The error is

parse error before ‘.’ token

I am able create my own device without using the macro CYG_I2C_DEVICE by writing the code

extern cyg_i2c_device       cyg_i2c_eeprom;
    cyg_i2c_eeprom.i2c_bus     = &cyg_i2c_xyzzy_bus;
    cyg_i2c_eeprom.i2c_address = 0xA0;  //   10100000;
    cyg_i2c_eeprom.i2c_flags   = 0;
    cyg_i2c_eeprom.i2c_delay   = CYG_I2C_DEFAULT_DELAY;

but then i get an error at line..

   CYG_I2C_BITBANG_BUS( &cyg_i2c_xyzzy_bus, &hal_alaia_i2c_bitbang);
   
parse error before ‘.’ Token

looking at the i2c.h file the implementation of  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_                                               \
    }
Looking at the varios instances where the CYG_HAL_TABLE_ENTRY has been used in the other files

It has been implemented  in this way
Example:

 cyg_httpd_table_entry __name CYG_HAL_TABLE_ENTRY( httpd_table ) = { __pattern, __handler, __arg }

where __pattern, __handler, __arg are the arguments passed on to the httpd_table

Can somebody help me regarding this 

Has anybody been successful in implementing a bit-banging using the i2c package. 

Any idea why there is an error ? 

parse error before ‘.’ Token




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

             reply	other threads:[~2005-06-23  0:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-23  0:28 clifford.joseph [this message]
2005-06-25 13:10 ` Bart Veer
2005-07-01  5:10 clifford.joseph
2005-07-02 16:10 ` Bart Veer
2005-07-14  2:13 clifford.joseph

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=2415853226aa4e9ea1789842461c7ae1.clifford.joseph@clarinox.com \
    --to=clifford.joseph@clarinox.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).