ts-7000
[Top] [All Lists]

[ts-7000] Using i2c

To:
Subject: [ts-7000] Using i2c
From: "j_stahls" <>
Date: Tue, 10 Oct 2006 18:59:53 -0000
Not sure if this is specific to the ts-7000 linux distros or not but
I'm having a heck of a time getting my i2c programs to compile... 
I've tried compiling them on my x86 dev box with teh crosstools
compiler and on the ts-7200 I have both give me similar errors.

Here is the entire output from gcc, this is built against the i2c
headers/drivers from lm_sensors but the errors are the same if built
against the 2.4.26 headers/drivers.
In file included from /usr/include/linux/sched.h:12,
                 from /usr/include/linux/module.h:10,
                 from i2c-2.10.1/kernel/i2c.h:41,
                 from test.c:10:
/usr/include/linux/jiffies.h:16: error: syntax error before "jiffies_64"
/usr/include/linux/jiffies.h:20: error: syntax error before
"get_jiffies_64"
In file included from /usr/include/linux/cpumask.h:8,
                 from /usr/include/linux/sched.h:15,
                 from /usr/include/linux/module.h:10,
                 from i2c-2.10.1/kernel/i2c.h:41,
                 from test.c:10:
/usr/include/linux/bitmap.h: In function `bitmap_empty':
/usr/include/linux/bitmap.h:15: error: `BITS_PER_LONG' undeclared
(first use in this function)
/usr/include/linux/bitmap.h:15: error: (Each undeclared identifier is
reported only once
/usr/include/linux/bitmap.h:15: error: for each function it appears in.)
/usr/include/linux/bitmap.h: In function `bitmap_full':
/usr/include/linux/bitmap.h:29: error: `BITS_PER_LONG' undeclared
(first use in this function)
/usr/include/linux/bitmap.h: In function `bitmap_equal':
/usr/include/linux/bitmap.h:44: error: `BITS_PER_LONG' undeclared
(first use in this function)
/usr/include/linux/bitmap.h: In function `bitmap_shift_right':
/usr/include/linux/bitmap.h:85: error: `__shr_tmp' undeclared (first
use in this function)
/usr/include/linux/bitmap.h: In function `bitmap_shift_left':
/usr/include/linux/bitmap.h:98: error: `__shl_tmp' undeclared (first
use in this function)
/usr/include/linux/bitmap.h: In function `bitmap_weight':
/usr/include/linux/bitmap.h:144: error: `BITS_PER_LONG' undeclared
(first use in this function)
In file included from /usr/include/linux/sched.h:18,
                 from /usr/include/linux/module.h:10,
                 from i2c-2.10.1/kernel/i2c.h:41,
                 from test.c:10:
/usr/include/asm/semaphore.h: At top level:
/usr/include/asm/semaphore.h:18: error: syntax error before
"wait_queue_head_t"
/usr/include/asm/semaphore.h: In function `sema_init':
/usr/include/asm/semaphore.h:46: error: dereferencing pointer to
incomplete type
/usr/include/asm/semaphore.h:47: error: dereferencing pointer to
incomplete type
/usr/include/asm/semaphore.h:48: error: dereferencing pointer to
incomplete type
/usr/include/asm/semaphore.h: In function `sema_count':
/usr/include/asm/semaphore.h:66: error: dereferencing pointer to
incomplete type
In file included from /usr/include/linux/signal.h:6,
                 from /usr/include/linux/sched.h:25,
                 from /usr/include/linux/module.h:10,
                 from i2c-2.10.1/kernel/i2c.h:41,
                 from test.c:10:
/usr/include/asm/signal.h: At top level:
/usr/include/asm/signal.h:27: error: conflicting types for `sigset_t'
/usr/include/sys/select.h:38: error: previous declaration of `sigset_t'
In file included from /usr/include/linux/sched.h:29,
                 from /usr/include/linux/module.h:10,
                 from i2c-2.10.1/kernel/i2c.h:41,
                 from test.c:10:
/usr/include/linux/completion.h:15: error: syntax error before
"wait_queue_head_t"
/usr/include/linux/completion.h: In function `init_completion':
/usr/include/linux/completion.h:26: error: dereferencing pointer to
incomplete type
/usr/include/linux/completion.h:27: error: dereferencing pointer to
incomplete type
In file included from /usr/include/linux/sched.h:30,
                 from /usr/include/linux/module.h:10,
                 from i2c-2.10.1/kernel/i2c.h:41,
                 from test.c:10:
/usr/include/linux/pid.h: At top level:
/usr/include/linux/pid.h:18: error: field `task_list' has incomplete type
/usr/include/linux/pid.h:19: error: field `hash_chain' has incomplete type
/usr/include/linux/pid.h:24: error: field `pid_chain' has incomplete type
In file included from /usr/include/linux/sched.h:31,
                 from /usr/include/linux/module.h:10,
                 from i2c-2.10.1/kernel/i2c.h:41,
                 from test.c:10:
/usr/include/linux/percpu.h: In function `__alloc_percpu':
/usr/include/linux/percpu.h:46: error: `GFP_KERNEL' undeclared (first
use in this function)
In file included from /usr/include/linux/sched.h:102,
                 from /usr/include/linux/module.h:10,
                 from i2c-2.10.1/kernel/i2c.h:41,
                 from test.c:10:
/usr/include/linux/timer.h: At top level:
/usr/include/linux/timer.h:11: error: field `entry' has incomplete type
In file included from /usr/include/asm/local.h:1,
                 from /usr/include/linux/module.h:19,
                 from i2c-2.10.1/kernel/i2c.h:41,
                 from test.c:10:
/usr/include/asm-generic/local.h: In function `local_inc':
/usr/include/asm-generic/local.h:65: error: invalid type argument of `->'
/usr/include/asm-generic/local.h:65: error: invalid type argument of `->'
/usr/include/asm-generic/local.h: In function `local_dec':
/usr/include/asm-generic/local.h:72: error: invalid type argument of `->'
/usr/include/asm-generic/local.h:72: error: invalid type argument of `->'
/usr/include/asm-generic/local.h: In function `local_add':
/usr/include/asm-generic/local.h:79: error: invalid type argument of `->'
/usr/include/asm-generic/local.h:79: error: invalid type argument of `->'
/usr/include/asm-generic/local.h: In function `local_sub':
/usr/include/asm-generic/local.h:86: error: invalid type argument of `->'
/usr/include/asm-generic/local.h:86: error: invalid type argument of `->'
In file included from test.c:10:
i2c-2.10.1/kernel/i2c.h: At top level:
i2c-2.10.1/kernel/i2c.h:89: error: syntax error before "i2c_smbus_xfer"
i2c-2.10.1/kernel/i2c.h:89: error: syntax error before "u16"
i2c-2.10.1/kernel/i2c.h:92: warning: type defaults to `int' in
declaration of `i2c_smbus_xfer'
i2c-2.10.1/kernel/i2c.h:92: warning: data definition has no type or
storage class
i2c-2.10.1/kernel/i2c.h:97: error: syntax error before
"i2c_smbus_write_quick"
i2c-2.10.1/kernel/i2c.h:97: error: syntax error before "u8"
i2c-2.10.1/kernel/i2c.h:97: warning: type defaults to `int' in
declaration of `i2c_smbus_write_quick'
i2c-2.10.1/kernel/i2c.h:97: warning: data definition has no type or
storage class
i2c-2.10.1/kernel/i2c.h:98: error: syntax error before
"i2c_smbus_read_byte"
i2c-2.10.1/kernel/i2c.h:98: warning: type defaults to `int' in
declaration of `i2c_smbus_read_byte'
i2c-2.10.1/kernel/i2c.h:98: warning: data definition has no type or
storage class
i2c-2.10.1/kernel/i2c.h:99: error: syntax error before
"i2c_smbus_write_byte"
i2c-2.10.1/kernel/i2c.h:99: error: syntax error before "u8"
i2c-2.10.1/kernel/i2c.h:99: warning: type defaults to `int' in
declaration of `i2c_smbus_write_byte'
i2c-2.10.1/kernel/i2c.h:99: warning: data definition has no type or
storage class
i2c-2.10.1/kernel/i2c.h:100: error: syntax error before
"i2c_smbus_read_byte_data"
i2c-2.10.1/kernel/i2c.h:100: error: syntax error before "u8"
i2c-2.10.1/kernel/i2c.h:100: warning: type defaults to `int' in
declaration of `i2c_smbus_read_byte_data'
i2c-2.10.1/kernel/i2c.h:100: warning: data definition has no type or
storage class
i2c-2.10.1/kernel/i2c.h:101: error: syntax error before
"i2c_smbus_write_byte_data"
i2c-2.10.1/kernel/i2c.h:102: error: syntax error before "u8"
i2c-2.10.1/kernel/i2c.h:102: warning: type defaults to `int' in
declaration of `i2c_smbus_write_byte_data'
i2c-2.10.1/kernel/i2c.h:102: warning: data definition has no type or
storage class
i2c-2.10.1/kernel/i2c.h:103: error: syntax error before
"i2c_smbus_read_word_data"
i2c-2.10.1/kernel/i2c.h:103: error: syntax error before "u8"
i2c-2.10.1/kernel/i2c.h:103: warning: type defaults to `int' in
declaration of `i2c_smbus_read_word_data'
i2c-2.10.1/kernel/i2c.h:103: warning: data definition has no type or
storage class
i2c-2.10.1/kernel/i2c.h:104: error: syntax error before
"i2c_smbus_write_word_data"
i2c-2.10.1/kernel/i2c.h:105: error: syntax error before "u8"
i2c-2.10.1/kernel/i2c.h:105: warning: type defaults to `int' in
declaration of `i2c_smbus_write_word_data'
i2c-2.10.1/kernel/i2c.h:105: warning: data definition has no type or
storage class
i2c-2.10.1/kernel/i2c.h:106: error: syntax error before
"i2c_smbus_process_call"
i2c-2.10.1/kernel/i2c.h:107: error: syntax error before "u8"
i2c-2.10.1/kernel/i2c.h:107: warning: type defaults to `int' in
declaration of `i2c_smbus_process_call'
i2c-2.10.1/kernel/i2c.h:107: warning: data definition has no type or
storage class
i2c-2.10.1/kernel/i2c.h:109: error: syntax error before
"i2c_smbus_read_block_data"
i2c-2.10.1/kernel/i2c.h:110: error: syntax error before "u8"
i2c-2.10.1/kernel/i2c.h:110: warning: type defaults to `int' in
declaration of `i2c_smbus_read_block_data'
i2c-2.10.1/kernel/i2c.h:110: warning: data definition has no type or
storage class
i2c-2.10.1/kernel/i2c.h:111: error: syntax error before
"i2c_smbus_write_block_data"
i2c-2.10.1/kernel/i2c.h:112: error: syntax error before "u8"
i2c-2.10.1/kernel/i2c.h:113: warning: type defaults to `int' in
declaration of `i2c_smbus_write_block_data'
i2c-2.10.1/kernel/i2c.h:113: warning: data definition has no type or
storage class
i2c-2.10.1/kernel/i2c.h:115: error: syntax error before
"i2c_smbus_read_i2c_block_data"
i2c-2.10.1/kernel/i2c.h:116: error: syntax error before "u8"
i2c-2.10.1/kernel/i2c.h:116: warning: type defaults to `int' in
declaration of `i2c_smbus_read_i2c_block_data'
i2c-2.10.1/kernel/i2c.h:116: warning: data definition has no type or
storage class
i2c-2.10.1/kernel/i2c.h:117: error: syntax error before
"i2c_smbus_write_i2c_block_data"
i2c-2.10.1/kernel/i2c.h:118: error: syntax error before "u8"
i2c-2.10.1/kernel/i2c.h:119: warning: type defaults to `int' in
declaration of `i2c_smbus_write_i2c_block_data'
i2c-2.10.1/kernel/i2c.h:119: warning: data definition has no type or
storage class
i2c-2.10.1/kernel/i2c.h:208: error: syntax error before "u16"
i2c-2.10.1/kernel/i2c.h:220: error: syntax error before "u32"
i2c-2.10.1/kernel/i2c.h:220: warning: no semicolon at end of struct or
union
i2c-2.10.1/kernel/i2c.h:248: error: field `bus' has incomplete type
i2c-2.10.1/kernel/i2c.h:371: error: syntax error before
"i2c_get_functionality"
i2c-2.10.1/kernel/i2c.h:371: warning: type defaults to `int' in
declaration of `i2c_get_functionality'
i2c-2.10.1/kernel/i2c.h:371: warning: data definition has no type or
storage class
i2c-2.10.1/kernel/i2c.h:374: error: syntax error before "u32"
i2c-2.10.1/kernel/i2c.h: In function `i2c_delay':
i2c-2.10.1/kernel/i2c.h:561: warning: implicit declaration of function
`set_mb'
i2c-2.10.1/kernel/i2c.h:561: error: `current' undeclared (first use in
this function)
i2c-2.10.1/kernel/i2c.h:562: warning: implicit declaration of function
`schedule_timeout'


This is the code as it sits

#include <stdio.h>
#include <stdlib.h>
#include <stropts.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

//#include <linux/types.h>
#include "i2c-2.10.1/kernel/i2c.h"
#include "i2c-2.10.1/kernel/i2c-dev.h"

int main(int argc, char **argv) {

        int file;
        int adapter_nl = 0;
        char filename[20];

        sprintf(filename, "/dev/i2c-%d",adapter_nl);

        if ((file = open(filename,O_RDWR)) < 0) {
                exit(1);
        }

        int addr = 0x40;
        if (ioctl(file, I2C_SLAVE, addr) < 0) {
                exit(2);
        }
}


Anyone know where I've messed up? :)

Thanks,

Jason









 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ts-7000/join
    (Yahoo! ID required)

<*> To change settings via email:
     
    

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



<Prev in Thread] Current Thread [Next in Thread>
  • [ts-7000] Using i2c, j_stahls <=
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU