How to read data from user area of st25dvo4k using read(2) system call?
st25dv04k is interfaced with i.mx6. we install kernal version 4.9.88-10182-gec7d7d8-dirty on i.mx6. i written below code in c.
#include <stdio.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include <time.h>
#include <netinet/in.h>
#include <linux/i2c-dev.h>
#define ADDRESS 0x53
int main() {
int fd;
unsigned char buffer[3];
unsigned char buffer1[2];
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;
}
buffer[0] = 0x00;
buffer[1] = 0x00;
buffer[2] = 0x65;
if (write(fd, buffer, 3) != 3)
{
printf("ERROR HANDLING: i2c transcations failed\n");
}
else
printf("i2c write success\n");
usleep(5000);
buffer1[0] = 0x00;
buffer1[1] = 0x00;
//buffer1[2] = 0x65;
if(read(fd, buffer1, 2) != 2)
{
printf("Failed to read from the i2c bus.\n\n");
}
else {
printf("Successful read\n");
printf("Value: %02x\n\n", buffer1[0]);
printf("Value: %02x\n\n", buffer1[1]);
}
close(fd);
return 0;
}
//////////////////////
q] what to write in above code to read value from register address of 2 byte?
q] is this right approach to read and write ? if not then what chage i need to do in above code for write in user area?
q] what ndef sequence byte i need to write in above code for send 'text data' ?
q] my main aim is to write data in nfc tag ic st25dv04k. that ic is work as slave. our master is second i.mx6 board. when tag connected to slave ic . when master comes near this tag i need to send written text data to master. so what to approach in above code?
i hope you not send any link. i want code development help. i don't want to use any driver.
Thanks for help and support.
