Skip to contentSkip to conversation

probably bug in ds1621.c

U-Boot-Users Palkin Andrey 3 participants 4 messages Jul 2, 2003 – Jul 17, 2003

lore
Share & tools
lore
#0 lore raw

In dtt/ds1621.c file:

1.
int dtt_write(int sensor, int reg, int val)

{
    int dlen;
    uchar data[2];

    /*
     * Calculate sensor address and register.
     *
     */
    sensor = DTT_I2C_DEV_CODE + (sensor & sensor);

I think it should be:

int dtt_write(int sensor, int reg, int val)

{
    int dlen;
    uchar data[2];

    /*
     * Calculate sensor address and register.
     *
     */
    sensor = DTT_I2C_DEV_CODE + (sensor & 0x07);

2.

    else if ((reg == DTT_WRITE_START_CONV) || (reg == DTT_WRITE_STOP_CONV)) {
        dlen = 0;
        data[0] = (char)0;
        data[1] = (char)0;
    }

I think it should be:

    else if ((reg == DTT_WRITE_START_CONV) || (reg == DTT_WRITE_STOP_CONV)) {
        dlen = 1;
        data[0] = (char)0;
        data[1] = (char)0;
    }

differently MPC8260 I2C controller go in down

--
Palkin Andrey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: changes.diff
Type: application/octet-stream
Size: 656 bytes
Desc: not available
Url : http://lists.denx.de/pipermail/u-boot/attachments/20030702/21468bc8/attachment.obj

#1 lore raw

Hello,

Quoted 18 lines · in message <[email protected]> you wrote:

In dtt/ds1621.c file:

1.
int dtt_write(int sensor, int reg, int val)

{
    int dlen;
    uchar data[2];

    /*
     * Calculate sensor address and register.
     *
     */
    sensor = DTT_I2C_DEV_CODE + (sensor & sensor);

I think it should be:

int dtt_write(int sensor, int reg, int val)

Quoted 9 lines
{
    int dlen;
    uchar data[2];

    /*
     * Calculate sensor address and register.
     *
     */
    sensor = DTT_I2C_DEV_CODE + (sensor & 0x07);

I think you are right. Added.

Quoted 9 lines

2.

    else if ((reg == DTT_WRITE_START_CONV) || (reg == DTT_WRITE_STOP_CONV)) {
        dlen = 0;
        data[0] = (char)0;
        data[1] = (char)0;
    }

I think it should be:

Quoted 7 lines
    else if ((reg == DTT_WRITE_START_CONV) || (reg == DTT_WRITE_STOP_CONV)) {
        dlen = 1;
        data[0] = (char)0;
        data[1] = (char)0;
    }

differently MPC8260 I2C controller go in down

I'm not sure about this one. Erik, maybe you can comment? It's your code after all...

Best regards,

Wolfgang Denk

Signature · 5 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
The day-to-day travails of the IBM programmer are so amusing to  most
of us who are fortunate enough never to have been one - like watching
Charlie Chaplin trying to cook a shoe.
#2 lore raw
Quoted 52 lines · Wolfgang Denk

Hello,

Quoted 18 lines · in message <[email protected]> you wrote:

In dtt/ds1621.c file:

1.
int dtt_write(int sensor, int reg, int val)

{
    int dlen;
    uchar data[2];

    /*
     * Calculate sensor address and register.
     *
     */
    sensor = DTT_I2C_DEV_CODE + (sensor & sensor);

I think it should be:

int dtt_write(int sensor, int reg, int val)

Quoted 9 lines
{
    int dlen;
    uchar data[2];

    /*
     * Calculate sensor address and register.
     *
     */
    sensor = DTT_I2C_DEV_CODE + (sensor & 0x07);

I think you are right. Added.

Quoted 17 lines

2.

    else if ((reg == DTT_WRITE_START_CONV) || (reg == 
DTT_WRITE_STOP_CONV)) {
        dlen = 0;
        data[0] = (char)0;
        data[1] = (char)0;
    }

I think it should be:

    else if ((reg == DTT_WRITE_START_CONV) || (reg == 
DTT_WRITE_STOP_CONV)) {
        dlen = 1;
        data[0] = (char)0;
        data[1] = (char)0;
    }
Quoted 16 lines
Quoted 1 line

differently MPC8260 I2C controller go in down

I'm not sure about this one. Erik, maybe you can comment? It's your code after all...

Best regards,

Wolfgang Denk

Signature · 5 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
The day-to-day travails of the IBM programmer are so amusing to  most
of us who are fortunate enough never to have been one - like watching
Charlie Chaplin trying to cook a shoe.

Sorry folks,

I've been quite busy lately with several new hardware designs.

Now to the issues:

#1 - Yes it is a bug

#2 - I believe the dlen of 0 is correct as it stands. The DS1621 has a special start
and stop conversion "command". This has a data length of 0.

If someone is trying these routines on non 405 hardware, the code may require
some adjustment due to minor differences in the low level I2C routines.

Erik

#3 lore raw

Dear Erik,

Quoted 2 lines · in message <[email protected]> you wrote:

I've been quite busy lately with several new hardware designs.

Guess where I heard this before ;-)

Quoted 3 lines

Now to the issues:

#1 - Yes it is a bug

Thanks for the confirmation.

Quoted 3 lines

#2 - I believe the dlen of 0 is correct as it stands. The DS1621 has a special start
and stop conversion "command". This has a data length of 0.

This was what I thought from reading the code and the comments.

Quoted 3 lines

If someone is trying these routines on non 405 hardware, the code may require
some adjustment due to minor differences in the low level I2C routines.

Andrey - which hardware are you using?

I understand that this code as is did not work for you, and your modification made it work?

Best regards,

Wolfgang Denk

Signature · 3 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
Horses just naturally have mohawk haircuts.