3 Replies Latest reply on Mar 24, 2016 4:59 AM by userc_19497

    Adding external Library

      Hi,

       

      I am using accelerometer LIS3DH with BCM20737S and using WICED SDK 2.2.2 when I call library function "lis3dhInit" its showing following error on compilation.

       

       

      C:\WICED\WICED-Smart-SDK-2.2.2\WICED-Smart-SDK\Wiced-Smart\spar/../../Apps/MyProject/MyProject.c:968: undefined reference to `lis3dhInit'

       

      I have added the source and header file.  Also it is invoking right function on F3 but not compiling it. Guidance is need what I'm missing or doing wrong.

       

      Thanks in advance.

       

      Kind Regard,

      Ghalib

        • 1. Re: Adding external Library
          JacobT_81

          The function 'lis3dhInit' does not exist in any library included within the SDK. Unless this is user-defined, it should give this compile error.

           

          wiced_sence.c contains a sample init function for the lis3dh sensor, however, initialization can take on many forms and it is up to you to define the exact characteristics you need based on the sensor datasheet.

           

          Jacob

          • 2. Re: Adding external Library

            Thanks a million for your reply Jcob.

             

            "lis3dhInit" is user defined function, I have added its source and header in App created project folder; as shown below.

            Kindly explain it for me HOW TO ADD IT TO SDK as I'm facing similar issues in adding other files.

             

            Thanks a again.

            Kind Regards,

            Ghalib

            • 3. Re: Adding external Library

              Hello.

               

              Like Jacob said, you can look at wiced_sense as a reference.

              Here's an example of sensor init function for accelerometer from wiced sense app:

              // Initialize accelerometer
              void wiced_sense_initialize_lis3dsh(void)
              {
                  if(SetODR(ODR_25Hz) == MEMS_SUCCESS)
                      ble_trace0("LIS3DSH_SetODR Successful");
                  else
                      ble_trace0("LIS3DSH_SetODR Failed.");
              
                  if(SetFullScale(FULLSCALE_8) == MEMS_SUCCESS)
                      ble_trace0("LIS3DSH_SetFullScale Successful");
                  else
                      ble_trace0("LIS3DSH_SetFullScale Failed.");
              
                  if(SetAxis(X_ENABLE | Y_ENABLE | Z_ENABLE) == MEMS_SUCCESS)
                      ble_trace0("LIS3DSH_SetAxis Successful");
                  else
                      ble_trace0("LIS3DSH_SetAxis Failed.");
              
                  if(VectFiltEnable(MEMS_DISABLE) == MEMS_SUCCESS)
                      ble_trace0("LIS3DSH_VectFiltEnable Successful");
                  else
                      ble_trace0("LIS3DSH_VectFiltEnable Failed.");
              
                  if(SoftReset(MEMS_DISABLE) == MEMS_SUCCESS)
                      ble_trace0("LIS3DSH_SoftReset Successful");
                  else
                      ble_trace0("LIS3DSH_SoftReset Failed.");
              
                  if(SetBDU(MEMS_ENABLE) == MEMS_SUCCESS)
                      ble_trace0("SetBDU Successful");
                  else
                      ble_trace0("SetBDU Failed");
              }
              

               

              Essentially, what you have to do is set all the control registers to the right values.

              For example, in the function above, ODR is set, axes are enabled, etc.

              You should look at the datasheet of your sensor and the header file to figure out which ctrl registers you want to set and how to set them.

              (datasheet: https://www.adafruit.com/datasheets/LIS3DH.pdf )

              The values would depend on what you want the accelerometer to do.

               

              Also, depending on the implementation of your "library" file, you might have to redefine the read and write register functions.

              Hope this helps. Please let us know if you need more help.

               

              James

              1 of 1 people found this helpful