Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. why below code give me .o error 1 ?
Forum Updated to NodeBB v4.3 + New Features

why below code give me .o error 1 ?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 3 Posters 403 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on last edited by
    #1

    #include "st25dv-i2c_linux.h"
    #include <fcntl.h>
    #include <stdio.h>
    #include <time.h>
    #include <stdint.h>
    #include <string.h>
    #include <errno.h>

    #include <linux/i2c-dev.h>
    #include <sys/ioctl.h>
    #include <linux/i2c.h>

    #include "st25dv-i2c_linux.h"
    #include "unistd.h"
    #include "stdlib.h"

    #include "hwconfig.h"
    #include "st25dv.h"
    st25dvi2c_linux::st25dvi2c_linux()
    {

    }

    /** @addtogroup ST25DV_I2C_BSP

    • @{
    • @brief <b>This file contains the BSP IO layer for the ST25DV-I2C</b>
      */

    #define REVERSE16(x) ((X >> 8) | ((X & 0xFF) << 8))
    static int filehandle;

    /** @defgroup ST25DV_I2C_BSP_IO_Private_Functions

    • @{
      /
      /
      #define ST25DVI2C_DBG_ENABLE 1*/

    /**

    • @}
      */

    /** @defgroup ST25DV_I2C_BSP_IO_Public_Functions

    • @{
      */

    /******************************** LINK NFC *******************************/
    uint32_t ts2milisec(struct timespec
    ts)
    {
    return ((ts->tv_sec * (uint32_t)1000) + (ts->tv_nsec/1000000));
    }

    /**

    • @brief Tick function used in NFC device low level driver.
    • @retval Current Tick
      */
      int32_t NFC_IO_Tick(void)
      {
      struct timespec cur_ts;
      clock_gettime(CLOCK_MONOTONIC, &cur_ts);
      return ts2milisec(&cur_ts);
      }

    /**

    • @brief DeInitializes Sensors low level.
    • @retval Status Success (0), Error (1)
      */
      int32_t NFC_IO_DeInit(void)
      {
      if(close(filehandle) < 0)
      {
      // printf(" Error Can't close /dev/i2c-x%\n");
      exit(1);
      }
      return 0;
      }

    /**

    • @brief Initializes Sensors low level.
    • @retval Status Success (0), Error (1)
      */
      int32_t NFC_IO_Init(void)
      {

    static char filename[20];
    static int adapter_nr = 2;

    snprintf(filename, 19, "/dev/i2c-%d", adapter_nr);
    filehandle = open(filename,O_RDWR);
    if (filehandle < 0) {
    printf("Error : Can't open /dev/i2c-%d\n",adapter_nr);
    /* ERROR HANDLING; you can check errno to see what went wrong */
    exit(1);
    }

    return 0;
    }

    /**

    • @brief Checks if target device is ready for communication.
    • @param Addr NFC device I2C address
    • @param Trials Number of trials
    • @retval Status Success (0), Timeout (1)
      /
      int32_t NFC_IO_IsDeviceReady(uint16_t DevAddr, uint32_t Trials)
      {
      uint32_t tickstart = 0;
      uint32_t currenttick = 0;
      int8_t ret = -8;
      uint8_t regAddr[2] = {0,0};
      uint8_t pData[1];
      #ifdef ST25DVI2C_DBG_ENABLE
      printf("NFC_IO_IsDeviceReady(%x,%d)\r\n",DevAddr,Trials);
      #endif
      usleep(1000);
      #ifdef ST25DVI2C_DBG_ENABLE
      /
      Get tick */
      tickstart = NFC_IO_Tick();
      printf("time = %d\r\n",tickstart);
      #endif
      struct i2c_msg messages[2] = {
      {
      .addr = DevAddr >>1,
      .buf = regAddr,
      .len = 2,
      .flags = 0,
      },
      {
      .addr = DevAddr >>1,
      .buf = pData,
      .len = 1,
      .flags = I2C_M_RD | I2C_M_NOSTART,
      }
      };

    struct i2c_rdwr_ioctl_data payload = {
    .msgs = messages,
    .nmsgs = 2,
    };
    ret = ioctl(filehandle, I2C_RDWR, &payload);

    #ifdef ST25DVI2C_DBG_ENABLE
    printf("time = %d ret=%d\r\n",NFC_IO_Tick(),ret);
    #endif
    if (ret < 0)
    {
    return NFC_I2C_ERROR_TIMEOUT;
    }

    return NFC_I2C_STATUS_SUCCESS;
    }

    /**

    • @brief Write a value in a register of the device through BUS.

    • @param DevAddr Device address on Bus.

    • @param Reg The target register address to write

    • @param pData Pointer to data buffer to write

    • @param Length Data Length (max is 256)

    • @retval Status Success (0), Linux errno
      */

    int32_t NFC_IO_WriteReg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length)
    {
    int8_t ret = -8;
    uint8_t buffer[258];

    if(Length > 256)
    {
    printf("ERROR NFC_IO_WriteReg16 Length is too big %d\r\n",Length);
    return -1;
    }

    #ifdef ST25DVI2C_DBG_ENABLE
    printf("NFC_IO_WriteReg16(%x,%x,%x,%d)\r\n",DevAddr,Reg,pData,Length);
    for (int i = 0 ; i < Length ; i++)
    printf("%x ",pData[i]);
    printf("\n");
    printf("time = %d\r\n",NFC_IO_Tick());
    #endif

    /* Prepare tx buffer */
    buffer[0] = Reg>>8;
    buffer[1] = Reg & 0xFF;
    memcpy(&buffer[2],pData,Length);

    struct i2c_msg messages[1] = {
    {
    .addr = DevAddr >>1,
    .buf = buffer,
    .len = Length + 2,
    .flags = 0,
    }
    };

    struct i2c_rdwr_ioctl_data payload = {
    .msgs = messages,
    .nmsgs = 1,
    };

    ret = ioctl(filehandle, I2C_RDWR, &payload);
    if (ret < 0) {
        /* Workaround as Linux doesnt return any specific error code for NACK */
        /* ST25DV-I2C NACK when writing ENDAx registers*/
        if((DevAddr == ST25DV_ADDR_SYST_I2C) &&
            ((Reg == ST25DV_ENDA2_REG) || (Reg == ST25DV_ENDA3_REG)) &&
            (errno == ENXIO))
        {
            /* this value is the expected error code for a NACK */
            ret = -102;
        } else {
            ret = -errno;
            printf("\r\nError %d while writing @%X (devAddr=%X)\r\n", ret,Reg,DevAddr);
        }
        return ret;
    }
    

    /* todo check return status for nack detection /
    /
    return NFC_I2C_ERROR_NACK; */

    return NFC_I2C_STATUS_SUCCESS;
    }

    /**

    • @brief Read registers through a bus (16 bits)
    • @param DevAddr: Device address on BUS
    • @param Reg: The target register address to read
    • @param Length Data Length
    • @retval Status Success (0), Error (1)
      */
      int32_t NFC_IO_ReadReg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length)
      {
      int8_t ret = -8;
      uint8_t regAddr[2];
      regAddr[0] = Reg>>8;
      regAddr[1] = Reg & 0xFF;

    #ifdef ST25DVI2C_DBG_ENABLE
    printf("NFC_IO_ReadReg16(%x,%x,%x,%d)\r\n",DevAddr,Reg,pData,Length);
    #endif
    struct i2c_msg messages[2] = {
    {
    .addr = DevAddr >>1,
    .buf = regAddr,
    .len = 2,
    .flags = 0,
    },
    {
    .addr = DevAddr >>1,
    .buf = pData,
    .len = Length,
    .flags = I2C_M_RD | I2C_M_NOSTART,
    }
    };

    struct i2c_rdwr_ioctl_data payload = {
    .msgs = messages,
    .nmsgs = 2,
    };

    ret = ioctl(filehandle, I2C_RDWR, &payload);
    if (ret < 0) {
        ret = -errno;
        printf("\r\nError %d while reading @%X (devAddr=%X)\r\n", ret,Reg,DevAddr);
        return ret;
    }
    

    /* todo check return status for nack detection /
    /
    return NFC_I2C_ERROR_NACK; */
    #ifdef ST25DVI2C_DBG_ENABLE
    printf("NFC_IO_ReadReg16 OK\r\n");
    for (int i = 0 ; i < Length ; i++)
    printf("%x ",pData[i]);
    printf("\n");
    #endif
    return NFC_I2C_STATUS_SUCCESS;

    }

    jsulmJ JonBJ 2 Replies Last reply
    0
    • Q Qt embedded developer

      #include "st25dv-i2c_linux.h"
      #include <fcntl.h>
      #include <stdio.h>
      #include <time.h>
      #include <stdint.h>
      #include <string.h>
      #include <errno.h>

      #include <linux/i2c-dev.h>
      #include <sys/ioctl.h>
      #include <linux/i2c.h>

      #include "st25dv-i2c_linux.h"
      #include "unistd.h"
      #include "stdlib.h"

      #include "hwconfig.h"
      #include "st25dv.h"
      st25dvi2c_linux::st25dvi2c_linux()
      {

      }

      /** @addtogroup ST25DV_I2C_BSP

      • @{
      • @brief <b>This file contains the BSP IO layer for the ST25DV-I2C</b>
        */

      #define REVERSE16(x) ((X >> 8) | ((X & 0xFF) << 8))
      static int filehandle;

      /** @defgroup ST25DV_I2C_BSP_IO_Private_Functions

      • @{
        /
        /
        #define ST25DVI2C_DBG_ENABLE 1*/

      /**

      • @}
        */

      /** @defgroup ST25DV_I2C_BSP_IO_Public_Functions

      • @{
        */

      /******************************** LINK NFC *******************************/
      uint32_t ts2milisec(struct timespec
      ts)
      {
      return ((ts->tv_sec * (uint32_t)1000) + (ts->tv_nsec/1000000));
      }

      /**

      • @brief Tick function used in NFC device low level driver.
      • @retval Current Tick
        */
        int32_t NFC_IO_Tick(void)
        {
        struct timespec cur_ts;
        clock_gettime(CLOCK_MONOTONIC, &cur_ts);
        return ts2milisec(&cur_ts);
        }

      /**

      • @brief DeInitializes Sensors low level.
      • @retval Status Success (0), Error (1)
        */
        int32_t NFC_IO_DeInit(void)
        {
        if(close(filehandle) < 0)
        {
        // printf(" Error Can't close /dev/i2c-x%\n");
        exit(1);
        }
        return 0;
        }

      /**

      • @brief Initializes Sensors low level.
      • @retval Status Success (0), Error (1)
        */
        int32_t NFC_IO_Init(void)
        {

      static char filename[20];
      static int adapter_nr = 2;

      snprintf(filename, 19, "/dev/i2c-%d", adapter_nr);
      filehandle = open(filename,O_RDWR);
      if (filehandle < 0) {
      printf("Error : Can't open /dev/i2c-%d\n",adapter_nr);
      /* ERROR HANDLING; you can check errno to see what went wrong */
      exit(1);
      }

      return 0;
      }

      /**

      • @brief Checks if target device is ready for communication.
      • @param Addr NFC device I2C address
      • @param Trials Number of trials
      • @retval Status Success (0), Timeout (1)
        /
        int32_t NFC_IO_IsDeviceReady(uint16_t DevAddr, uint32_t Trials)
        {
        uint32_t tickstart = 0;
        uint32_t currenttick = 0;
        int8_t ret = -8;
        uint8_t regAddr[2] = {0,0};
        uint8_t pData[1];
        #ifdef ST25DVI2C_DBG_ENABLE
        printf("NFC_IO_IsDeviceReady(%x,%d)\r\n",DevAddr,Trials);
        #endif
        usleep(1000);
        #ifdef ST25DVI2C_DBG_ENABLE
        /
        Get tick */
        tickstart = NFC_IO_Tick();
        printf("time = %d\r\n",tickstart);
        #endif
        struct i2c_msg messages[2] = {
        {
        .addr = DevAddr >>1,
        .buf = regAddr,
        .len = 2,
        .flags = 0,
        },
        {
        .addr = DevAddr >>1,
        .buf = pData,
        .len = 1,
        .flags = I2C_M_RD | I2C_M_NOSTART,
        }
        };

      struct i2c_rdwr_ioctl_data payload = {
      .msgs = messages,
      .nmsgs = 2,
      };
      ret = ioctl(filehandle, I2C_RDWR, &payload);

      #ifdef ST25DVI2C_DBG_ENABLE
      printf("time = %d ret=%d\r\n",NFC_IO_Tick(),ret);
      #endif
      if (ret < 0)
      {
      return NFC_I2C_ERROR_TIMEOUT;
      }

      return NFC_I2C_STATUS_SUCCESS;
      }

      /**

      • @brief Write a value in a register of the device through BUS.

      • @param DevAddr Device address on Bus.

      • @param Reg The target register address to write

      • @param pData Pointer to data buffer to write

      • @param Length Data Length (max is 256)

      • @retval Status Success (0), Linux errno
        */

      int32_t NFC_IO_WriteReg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length)
      {
      int8_t ret = -8;
      uint8_t buffer[258];

      if(Length > 256)
      {
      printf("ERROR NFC_IO_WriteReg16 Length is too big %d\r\n",Length);
      return -1;
      }

      #ifdef ST25DVI2C_DBG_ENABLE
      printf("NFC_IO_WriteReg16(%x,%x,%x,%d)\r\n",DevAddr,Reg,pData,Length);
      for (int i = 0 ; i < Length ; i++)
      printf("%x ",pData[i]);
      printf("\n");
      printf("time = %d\r\n",NFC_IO_Tick());
      #endif

      /* Prepare tx buffer */
      buffer[0] = Reg>>8;
      buffer[1] = Reg & 0xFF;
      memcpy(&buffer[2],pData,Length);

      struct i2c_msg messages[1] = {
      {
      .addr = DevAddr >>1,
      .buf = buffer,
      .len = Length + 2,
      .flags = 0,
      }
      };

      struct i2c_rdwr_ioctl_data payload = {
      .msgs = messages,
      .nmsgs = 1,
      };

      ret = ioctl(filehandle, I2C_RDWR, &payload);
      if (ret < 0) {
          /* Workaround as Linux doesnt return any specific error code for NACK */
          /* ST25DV-I2C NACK when writing ENDAx registers*/
          if((DevAddr == ST25DV_ADDR_SYST_I2C) &&
              ((Reg == ST25DV_ENDA2_REG) || (Reg == ST25DV_ENDA3_REG)) &&
              (errno == ENXIO))
          {
              /* this value is the expected error code for a NACK */
              ret = -102;
          } else {
              ret = -errno;
              printf("\r\nError %d while writing @%X (devAddr=%X)\r\n", ret,Reg,DevAddr);
          }
          return ret;
      }
      

      /* todo check return status for nack detection /
      /
      return NFC_I2C_ERROR_NACK; */

      return NFC_I2C_STATUS_SUCCESS;
      }

      /**

      • @brief Read registers through a bus (16 bits)
      • @param DevAddr: Device address on BUS
      • @param Reg: The target register address to read
      • @param Length Data Length
      • @retval Status Success (0), Error (1)
        */
        int32_t NFC_IO_ReadReg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length)
        {
        int8_t ret = -8;
        uint8_t regAddr[2];
        regAddr[0] = Reg>>8;
        regAddr[1] = Reg & 0xFF;

      #ifdef ST25DVI2C_DBG_ENABLE
      printf("NFC_IO_ReadReg16(%x,%x,%x,%d)\r\n",DevAddr,Reg,pData,Length);
      #endif
      struct i2c_msg messages[2] = {
      {
      .addr = DevAddr >>1,
      .buf = regAddr,
      .len = 2,
      .flags = 0,
      },
      {
      .addr = DevAddr >>1,
      .buf = pData,
      .len = Length,
      .flags = I2C_M_RD | I2C_M_NOSTART,
      }
      };

      struct i2c_rdwr_ioctl_data payload = {
      .msgs = messages,
      .nmsgs = 2,
      };

      ret = ioctl(filehandle, I2C_RDWR, &payload);
      if (ret < 0) {
          ret = -errno;
          printf("\r\nError %d while reading @%X (devAddr=%X)\r\n", ret,Reg,DevAddr);
          return ret;
      }
      

      /* todo check return status for nack detection /
      /
      return NFC_I2C_ERROR_NACK; */
      #ifdef ST25DVI2C_DBG_ENABLE
      printf("NFC_IO_ReadReg16 OK\r\n");
      for (int i = 0 ; i < Length ; i++)
      printf("%x ",pData[i]);
      printf("\n");
      #endif
      return NFC_I2C_STATUS_SUCCESS;

      }

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @Qt-embedded-developer Please post exact error message...
      Also, how is this code related to Qt?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      5
      • Q Qt embedded developer

        #include "st25dv-i2c_linux.h"
        #include <fcntl.h>
        #include <stdio.h>
        #include <time.h>
        #include <stdint.h>
        #include <string.h>
        #include <errno.h>

        #include <linux/i2c-dev.h>
        #include <sys/ioctl.h>
        #include <linux/i2c.h>

        #include "st25dv-i2c_linux.h"
        #include "unistd.h"
        #include "stdlib.h"

        #include "hwconfig.h"
        #include "st25dv.h"
        st25dvi2c_linux::st25dvi2c_linux()
        {

        }

        /** @addtogroup ST25DV_I2C_BSP

        • @{
        • @brief <b>This file contains the BSP IO layer for the ST25DV-I2C</b>
          */

        #define REVERSE16(x) ((X >> 8) | ((X & 0xFF) << 8))
        static int filehandle;

        /** @defgroup ST25DV_I2C_BSP_IO_Private_Functions

        • @{
          /
          /
          #define ST25DVI2C_DBG_ENABLE 1*/

        /**

        • @}
          */

        /** @defgroup ST25DV_I2C_BSP_IO_Public_Functions

        • @{
          */

        /******************************** LINK NFC *******************************/
        uint32_t ts2milisec(struct timespec
        ts)
        {
        return ((ts->tv_sec * (uint32_t)1000) + (ts->tv_nsec/1000000));
        }

        /**

        • @brief Tick function used in NFC device low level driver.
        • @retval Current Tick
          */
          int32_t NFC_IO_Tick(void)
          {
          struct timespec cur_ts;
          clock_gettime(CLOCK_MONOTONIC, &cur_ts);
          return ts2milisec(&cur_ts);
          }

        /**

        • @brief DeInitializes Sensors low level.
        • @retval Status Success (0), Error (1)
          */
          int32_t NFC_IO_DeInit(void)
          {
          if(close(filehandle) < 0)
          {
          // printf(" Error Can't close /dev/i2c-x%\n");
          exit(1);
          }
          return 0;
          }

        /**

        • @brief Initializes Sensors low level.
        • @retval Status Success (0), Error (1)
          */
          int32_t NFC_IO_Init(void)
          {

        static char filename[20];
        static int adapter_nr = 2;

        snprintf(filename, 19, "/dev/i2c-%d", adapter_nr);
        filehandle = open(filename,O_RDWR);
        if (filehandle < 0) {
        printf("Error : Can't open /dev/i2c-%d\n",adapter_nr);
        /* ERROR HANDLING; you can check errno to see what went wrong */
        exit(1);
        }

        return 0;
        }

        /**

        • @brief Checks if target device is ready for communication.
        • @param Addr NFC device I2C address
        • @param Trials Number of trials
        • @retval Status Success (0), Timeout (1)
          /
          int32_t NFC_IO_IsDeviceReady(uint16_t DevAddr, uint32_t Trials)
          {
          uint32_t tickstart = 0;
          uint32_t currenttick = 0;
          int8_t ret = -8;
          uint8_t regAddr[2] = {0,0};
          uint8_t pData[1];
          #ifdef ST25DVI2C_DBG_ENABLE
          printf("NFC_IO_IsDeviceReady(%x,%d)\r\n",DevAddr,Trials);
          #endif
          usleep(1000);
          #ifdef ST25DVI2C_DBG_ENABLE
          /
          Get tick */
          tickstart = NFC_IO_Tick();
          printf("time = %d\r\n",tickstart);
          #endif
          struct i2c_msg messages[2] = {
          {
          .addr = DevAddr >>1,
          .buf = regAddr,
          .len = 2,
          .flags = 0,
          },
          {
          .addr = DevAddr >>1,
          .buf = pData,
          .len = 1,
          .flags = I2C_M_RD | I2C_M_NOSTART,
          }
          };

        struct i2c_rdwr_ioctl_data payload = {
        .msgs = messages,
        .nmsgs = 2,
        };
        ret = ioctl(filehandle, I2C_RDWR, &payload);

        #ifdef ST25DVI2C_DBG_ENABLE
        printf("time = %d ret=%d\r\n",NFC_IO_Tick(),ret);
        #endif
        if (ret < 0)
        {
        return NFC_I2C_ERROR_TIMEOUT;
        }

        return NFC_I2C_STATUS_SUCCESS;
        }

        /**

        • @brief Write a value in a register of the device through BUS.

        • @param DevAddr Device address on Bus.

        • @param Reg The target register address to write

        • @param pData Pointer to data buffer to write

        • @param Length Data Length (max is 256)

        • @retval Status Success (0), Linux errno
          */

        int32_t NFC_IO_WriteReg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length)
        {
        int8_t ret = -8;
        uint8_t buffer[258];

        if(Length > 256)
        {
        printf("ERROR NFC_IO_WriteReg16 Length is too big %d\r\n",Length);
        return -1;
        }

        #ifdef ST25DVI2C_DBG_ENABLE
        printf("NFC_IO_WriteReg16(%x,%x,%x,%d)\r\n",DevAddr,Reg,pData,Length);
        for (int i = 0 ; i < Length ; i++)
        printf("%x ",pData[i]);
        printf("\n");
        printf("time = %d\r\n",NFC_IO_Tick());
        #endif

        /* Prepare tx buffer */
        buffer[0] = Reg>>8;
        buffer[1] = Reg & 0xFF;
        memcpy(&buffer[2],pData,Length);

        struct i2c_msg messages[1] = {
        {
        .addr = DevAddr >>1,
        .buf = buffer,
        .len = Length + 2,
        .flags = 0,
        }
        };

        struct i2c_rdwr_ioctl_data payload = {
        .msgs = messages,
        .nmsgs = 1,
        };

        ret = ioctl(filehandle, I2C_RDWR, &payload);
        if (ret < 0) {
            /* Workaround as Linux doesnt return any specific error code for NACK */
            /* ST25DV-I2C NACK when writing ENDAx registers*/
            if((DevAddr == ST25DV_ADDR_SYST_I2C) &&
                ((Reg == ST25DV_ENDA2_REG) || (Reg == ST25DV_ENDA3_REG)) &&
                (errno == ENXIO))
            {
                /* this value is the expected error code for a NACK */
                ret = -102;
            } else {
                ret = -errno;
                printf("\r\nError %d while writing @%X (devAddr=%X)\r\n", ret,Reg,DevAddr);
            }
            return ret;
        }
        

        /* todo check return status for nack detection /
        /
        return NFC_I2C_ERROR_NACK; */

        return NFC_I2C_STATUS_SUCCESS;
        }

        /**

        • @brief Read registers through a bus (16 bits)
        • @param DevAddr: Device address on BUS
        • @param Reg: The target register address to read
        • @param Length Data Length
        • @retval Status Success (0), Error (1)
          */
          int32_t NFC_IO_ReadReg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length)
          {
          int8_t ret = -8;
          uint8_t regAddr[2];
          regAddr[0] = Reg>>8;
          regAddr[1] = Reg & 0xFF;

        #ifdef ST25DVI2C_DBG_ENABLE
        printf("NFC_IO_ReadReg16(%x,%x,%x,%d)\r\n",DevAddr,Reg,pData,Length);
        #endif
        struct i2c_msg messages[2] = {
        {
        .addr = DevAddr >>1,
        .buf = regAddr,
        .len = 2,
        .flags = 0,
        },
        {
        .addr = DevAddr >>1,
        .buf = pData,
        .len = Length,
        .flags = I2C_M_RD | I2C_M_NOSTART,
        }
        };

        struct i2c_rdwr_ioctl_data payload = {
        .msgs = messages,
        .nmsgs = 2,
        };

        ret = ioctl(filehandle, I2C_RDWR, &payload);
        if (ret < 0) {
            ret = -errno;
            printf("\r\nError %d while reading @%X (devAddr=%X)\r\n", ret,Reg,DevAddr);
            return ret;
        }
        

        /* todo check return status for nack detection /
        /
        return NFC_I2C_ERROR_NACK; */
        #ifdef ST25DVI2C_DBG_ENABLE
        printf("NFC_IO_ReadReg16 OK\r\n");
        for (int i = 0 ; i < Length ; i++)
        printf("%x ",pData[i]);
        printf("\n");
        #endif
        return NFC_I2C_STATUS_SUCCESS;

        }

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @Qt-embedded-developer
        In addition to @jsulm, did you make any effort to reduce the size of your code to find a minimal which reproduces the error, or did you not bother?

        1 Reply Last reply
        1
        • Q Offline
          Q Offline
          Qt embedded developer
          wrote on last edited by
          #4

          Because proper file are not added so i created new project and linked all file properly that resolve my error

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved