* [ECOS] i2c driver complie error
@ 2005-05-09 19:22 liu hua
2005-05-16 5:26 ` Bart Veer
0 siblings, 1 reply; 2+ messages in thread
From: liu hua @ 2005-05-09 19:22 UTC (permalink / raw)
To: ecos-discuss
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb2312; format=flowed, Size: 5376 bytes --]
I need help for i2c driver.
In my project,I use the PCA9564 (I2C bus controller). So,I will write a
driver for PCA9564. I download the I2C driver code from eCos CVS server,and
write a test driver i2c_pca9564.c. This driver use the code from I2C doc
file. But,when I complie the eCos with configtool,there are some compile
error:
arm-elf-gcc -c -I/ecos-h/ecos20/9301ss_install/include
-I/ecos-h/ecos-2.0/2005-02-27/ecos-2.0/packages/devs/i2c/current
-I/ecos-h/ecos-2.0/2005-02-27/ecos-2.0/packages/devs/i2c/current/src
-I/ecos-h/ecos-2.0/2005-02-27/ecos-2.0/packages/devs/i2c/current/tests -I.
-I/ecos-h/ecos-2.0/2005-02-27/ecos-2.0/packages/devs/i2c/current/src/
-finline-limit=7000 -Wall -Wpointer-arith -Wstrict-prototypes -Winline
-Wundef -g -O2 -ffunction-sections -fdata-sections -fno-exceptions
-Wp,-MD,src/i2c_pca9564.tmp -o src/devs_i2c_i2c_pca9564.o
/ecos-h/ecos-2.0/2005-02-27/ecos-2.0/packages/devs/i2c/current/src/i2c_pca9564.c
make[1]: Leaving directory `/ecos-h/ecos20/9301ss_build/devs/i2c/current'
/ecos-h/ecos-2.0/2005-02-27/ecos-2.0/packages/devs/i2c/current/src/i2c_pca9564.c:120:
warning: initialization from incompatible pointer type
make: Leaving directory `/ecos-h/ecos20/9301ss_build'
/ecos-h/ecos-2.0/2005-02-27/ecos-2.0/packages/devs/i2c/current/src/i2c_pca9564.c:120:
warning: initialization from incompatible pointer type
/ecos-h/ecos-2.0/2005-02-27/ecos-2.0/packages/devs/i2c/current/src/i2c_pca9564.c:126:
initializer element is not constant
/ecos-h/ecos-2.0/2005-02-27/ecos-2.0/packages/devs/i2c/current/src/i2c_pca9564.c:126:
(near initialization for `cyg_i2c_wallclock_ds1307.i2c_bus')
/ecos-h/ecos-2.0/2005-02-27/ecos-2.0/packages/devs/i2c/current/src/i2c_pca9564.c:132:
initializer element is not constant
/ecos-h/ecos-2.0/2005-02-27/ecos-2.0/packages/devs/i2c/current/src/i2c_pca9564.c:132:
(near initialization for `hal_alaia_i2c_fs6377.i2c_bus')
make[1]: *** [src/i2c_pca9564.o.d] Error 1
make: *** [build] Error 2
Can you tell me what error are in my driver?
Following is the i2c_pca9564.c:
//==========================================================================
#include <pkgconf/system.h>
#include <pkgconf/io_i2c_pca9564.h>
#include <stdio.h> /* printf */
#include <cyg/io/i2c.h>
#include <cyg/hal/hal_arch.h>
#include <cyg/hal/hal_intr.h>
#include <string.h>
#include <cyg/infra/diag.h> // diagnostic output
#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 hal_alaia_i2c_fs6377;
struct xyzzy_data {
int test;
} *xyzzy_object;
static cyg_bool
xyzzy_i2c_extra(cyg_i2c_bus* bus)
{
cyg_bool result = 0;
return result;
}
static void
xyzzy_i2c_init(struct cyg_i2c_bus* bus)
{
printf("Init i2c xyzzy...\n");
}
static cyg_uint32
xyzzy_i2c_tx(const cyg_i2c_device* dev,
cyg_bool send_start,
cyg_uint8* tx_data, cyg_uint32 count,
cyg_bool send_stop)
{
printf("tx t2c xyzzy...\n");
}
static cyg_uint32
xyzzy_i2c_rx(const cyg_i2c_device* dev,
cyg_bool send_start,
cyg_uint8* tx_data, cyg_uint32 count,
cyg_bool send_stop)
{
printf("rx i2c xyzzy...\n");
}
static void
xyzzy_i2c_stop(const cyg_i2c_device* dev)
{
printf("stop i2c xyzzy...\n");
}
CYG_I2C_BUS(cyg_i2c_xyzzy_bus,
xyzzy_i2c_init,
xyzzy_i2c_tx,
xyzzy_i2c_rx,
xyzzy_i2c_stop,
(void *) xyzzy_i2c_extra); //line 120
CYG_I2C_DEVICE( cyg_i2c_wallclock_ds1307,
cyg_i2c_xyzzy_bus,
0x68,
0x00,
CYG_I2C_DEFAULT_DELAY); //line 126
CYG_I2C_DEVICE(hal_alaia_i2c_fs6377,
cyg_i2c_xyzzy_bus,
0x58,
0x00,
CYG_I2C_DEFAULT_DELAY); //line 132
-----------------------------------------------------------------------------
Following is the CDL file i2c-pca9564.cdl:
#========================================================================*/
cdl_package CYGPKG_IO_I2C_PCA9564 {
display "I2C device PCA9564 driver."
include_dir cyg/dev/i2c
requires CYGPKG_IO_I2C
parent CYGPKG_IO_I2C
description "I2C device PCA9564 driver."
compile -library=libextras.a i2c_pca9564.c
cdl_option CYGDAT_IO_I2C_PCA9564_NAME {
display "Device name for the I2C device PCA9564"
flavor data
default_value {"\"/dev/i2c/pca9564\""}
description "This option sets the device name for the
PCA9564."
}
}
_________________________________________________________________
ÓëÁª»úµÄÅóÓѽøÐн»Á÷£¬ÇëʹÓà MSN Messenger: http://messenger.msn.com/cn
--
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] 2+ messages in thread
* Re: [ECOS] i2c driver complie error
2005-05-09 19:22 [ECOS] i2c driver complie error liu hua
@ 2005-05-16 5:26 ` Bart Veer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Veer @ 2005-05-16 5:26 UTC (permalink / raw)
To: rongye_liu; +Cc: ecos-discuss
>>>>> "liu" == liu hua <rongye_liu@hotmail.com> writes:
liu> I need help for i2c driver.
liu> In my project,I use the PCA9564 (I2C bus controller). So,I
liu> will write a driver for PCA9564. I download the I2C driver
liu> code from eCos CVS server,and write a test driver
liu> i2c_pca9564.c. This driver use the code from I2C doc file.
liu> But,when I complie the eCos with configtool,there are some
liu> compile error:
There were a number of problems with that documentation, caused by
excessive cutting and pasting. These have now been fixed. Then you
introduced a few more problems in your code:
<snip>
liu> #define HAL_I2C_EXPORTED_DEVICES \
liu> extern cyg_i2c_bus cyg_i2c_xyzzy_bus; \
liu> extern cyg_i2c_device cyg_i2c_wallclock_ds1307; \
liu> extern cyg_i2c_device hal_alaia_i2c_fs6377;
This should go into a platform HAL header file, usually plf_io.h, not
in your driver sources. An I2C bus device driver does not know what
devices are attached to the bus, that is a characteristic of the
platform.
liu> struct xyzzy_data {
liu> int test;
liu> } *xyzzy_object;
liu> static cyg_bool
liu> xyzzy_i2c_extra(cyg_i2c_bus* bus)
liu> {
liu> cyg_bool result = 0;
liu> return result;
liu> }
The driver's extra field can be a pointer to a function if that is
appropriate, but more commonly it will be a pointer to a data
structure (i.e. a struct xyzzy_data) holding driver-specific
information. If the driver does not need any such data, e.g. because
all the state is held in statics, then a NULL pointer can be used.
liu> static cyg_uint32
liu> xyzzy_i2c_tx(const cyg_i2c_device* dev,
liu> cyg_bool send_start,
liu> cyg_uint8* tx_data, cyg_uint32 count,
liu> cyg_bool send_stop)
liu> {
liu> printf("tx t2c xyzzy...\n");
liu> }
The documentation used the wrong prototype. It should be:
static cyg_uint32
xyzzy_i2c_tx(const cyg_i2c_device* dev,
cyg_bool send_start,
const cyg_uint8* tx_data, cyg_uint32 count,
cyg_bool send_stop)
{
printf("tx t2c xyzzy...\n");
}
liu> static cyg_uint32
liu> xyzzy_i2c_rx(const cyg_i2c_device* dev,
liu> cyg_bool send_start,
liu> cyg_uint8* tx_data, cyg_uint32 count,
liu> cyg_bool send_stop)
liu> {
liu> printf("rx i2c xyzzy...\n");
liu> }
Again the prototype was wrong. It should be:
static cyg_uint32
xyzzy_i2c_rx(const cyg_i2c_device* dev,
cyg_bool send_start,
cyg_uint8* rx_data, cyg_uint32 count,
cyg_bool send_nack, cyg_bool send_stop)
{
printf("rx i2c xyzzy...\n");
}
liu> CYG_I2C_BUS(cyg_i2c_xyzzy_bus,
liu> xyzzy_i2c_init,
liu> xyzzy_i2c_tx,
liu> xyzzy_i2c_rx,
liu> xyzzy_i2c_stop,
liu> (void *) xyzzy_i2c_extra);
Although optional, these should really be &xyzzy_i2c_init,
&xyzzy_i2c_tx, etc.
liu> CYG_I2C_DEVICE( cyg_i2c_wallclock_ds1307,
liu> cyg_i2c_xyzzy_bus,
liu> 0x68,
liu> 0x00,
liu> CYG_I2C_DEFAULT_DELAY);
liu> CYG_I2C_DEVICE(hal_alaia_i2c_fs6377,
liu> cyg_i2c_xyzzy_bus,
liu> 0x58,
liu> 0x00,
liu> CYG_I2C_DEFAULT_DELAY);
Both device instantiations need to use &cyg_i2c_xyzzy_bus. Devices are
normally instantiated in the platform HAL, not in a bus device driver,
since only the platform knows what devices are attached to the bus.
Bart
--
Bart Veer eCos Configuration Architect
http://www.ecoscentric.com/ The eCos and RedBoot experts
--
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] 2+ messages in thread
end of thread, other threads:[~2005-05-14 16:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-09 19:22 [ECOS] i2c driver complie error liu hua
2005-05-16 5:26 ` Bart Veer
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).