Skip to main content
Visitor II
September 29, 2020
Solved

what is problem when i write 0x01 at 0x0000 address of st25dv04k?

  • September 29, 2020
  • 3 replies
  • 1528 views

#include <stdio.h>

#include <sys/ioctl.h> // ioctl

#include <fcntl.h>    // open

#include <unistd.h>   // read/write usleep

#include <time.h>

#include <netinet/in.h> // htons

#include <linux/i2c-dev.h>

#include "smbus.h"

#define ADDRESS 0x53 // AT24C32's address on I2C bus

int main() {

 int fd;

 if ((fd = open("/dev/i2c-2", O_RDWR)) < 0) { printf("Couldn't open device! %d\n", fd); return 1; }

 if (ioctl(fd, I2C_SLAVE, ADDRESS) < 0)    { printf("Couldn't find device on address!\n"); return 1; }

write(fd,0x0000,0x01);

usleep(500);

 close(fd);

 return 0;

}

    This topic has been closed for replies.
    Best answer by Ronald B.

    Hello Mpraj.19,

    Please have a look to the STSW-ST25DV007 software package providing a Linux user space driver for the ST25DV-I2C, available here:

    https://www.st.com/content/st_com/en/products/embedded-software/st25-nfc-rfid-software/stsw-st25dv007.html#overview

    This software package comes with a User Manual for easy ramp-up.

    It must provide what you need to access ST25DV-I2C on a Linux platform.

    Regards

    3 replies

    Technical Moderator
    September 29, 2020

    Hi,

    would be good if you could share what you want to achieve as opposed what you observe....

    Above snippet looks a bit weird as the write() will probably try to read its 1 byte data from address NULL resulting in a fault.

    Regards, Ulysses

    Mpraj.19Author
    Visitor II
    September 29, 2020

    I have to write 15 bytes in eeprom of tag ic ​

    Technical Moderator
    September 30, 2020

    Hi,

    that is only first part answered - what you wan to do. Second is: What you observe. Does the program create log output? Please also feed back the return code of the write(call). What are your observations? And look again into the signature of the function - I think it is not used correctly.

    Regards, Ulysses

    Visitor II
    September 30, 2020

    Hello Mpraj.19,

    Please have a look to the STSW-ST25DV007 software package providing a Linux user space driver for the ST25DV-I2C, available here:

    https://www.st.com/content/st_com/en/products/embedded-software/st25-nfc-rfid-software/stsw-st25dv007.html#overview

    This software package comes with a User Manual for easy ramp-up.

    It must provide what you need to access ST25DV-I2C on a Linux platform.

    Regards

    Ronald B.Answer
    Visitor II
    September 30, 2020

    Hello Mpraj.19,

    Please have a look to the STSW-ST25DV007 software package providing a Linux user space driver for the ST25DV-I2C, available here:

    https://www.st.com/content/st_com/en/products/embedded-software/st25-nfc-rfid-software/stsw-st25dv007.html#overview

    This software package comes with a User Manual for easy ramp-up.

    It must provide what you need to access ST25DV-I2C on a Linux platform.

    Regards