How to get the best performance out the script
응답
18. 3. 16 오후 2:10

I used the SendVirtualDataOverUSB - example and edited the main together with CalibratedSensor.c to send sensor data over USB.

But I'm asking myself, sinse I have no experience in C, what parts of project I can kick out of the example-project and edited files to get the best performance.

What I need is the highest possible resolution of the accelerometer. Should I change therefor some parameters?

My code of SendVirtualDataOverUSB.c is as follows:

* @file
 **/

/* module includes ********************************************************** */

/* own header files */
#include "XDKAppInfo.h"
#undef BCDS_MODULE_ID
#define BCDS_MODULE_ID XDK_APP_MODULE_ID_SEND_VIRTUAL_SENSOR
#include "OrientationData.h"
#include "CompassData.h"
#include "GravityData.h"
#include "RotationData.h"
#include "HumidityData.h"
#include "StepCounter.h"
#include "CalibratedSensor.h"
#include "MagneticFingerPrint.h"
#include "LinearAccelData.h"
#include "GestureData.h"

/* system header files */
#include "BCDS_Basics.h"
#include "stdio.h"

/* additional interface header files */
#include "BCDS_Assert.h"
#include "BCDS_TaskConfig.h"
#include "BCDS_CmdProcessor.h"
#include "FreeRTOS.h"
#include "timers.h"
/*Application Command Processor Instance */
CmdProcessor_T *AppCmdProcessorHandle;

/* constant definitions ***************************************************** */

/* local variables ********************************************************** */
typedef enum printToolboxData_e
{
    PRINT_ORIENTATION,/**< Prints Virtual Orientation Sensor data */
    PRINT_ROTATION,/**< Prints Virtual Orientation Sensor data */
    PRINT_COMPASS,/**< Prints Virtual Compass Sensor data */
    PRINT_HUMIDITY,/**< Prints Virtual Humidity Sensor data */
    PRINT_CALIBRATED_SENSORS, /**<Prints Calibrated Sensors data */
    PRINT_GRAVITY, /**<Prints Gravity Sensor data */
    PRINT_STEP_COUNTER,/**< Prints Step counter data */
    MAG_FINGER_PRINT, /**< Magnetic finger print Sensor application */
    PRINT_LINEAR_ACCELERATION,/**< Linear acceleration Sensor application */
    PRINT_GESTURE/**< Gesture Sensor application */
} printToolboxData_t;

/* global variables ********************************************************* */
static printToolboxData_t sensorToPrint = PRINT_CALIBRATED_SENSORS; /**< variable which indicates which virtual sensor data will be printed */

/* inline functions ********************************************************* */

/* local functions ********************************************************** */

/* global functions ********************************************************** */

/**
 * @brief The function initializes printToolboxData which calls the individual virtual sensor data print functions
 */
void init(void)
{
    Retcode_T returnValue = (Retcode_T) RETCODE_FAILURE;
    switch (sensorToPrint)
    {
    case PRINT_ORIENTATION:

        returnValue = OrientationSensorInit();
        break;

    case PRINT_ROTATION:

        returnValue = RotationDataInit();
        break;

    case PRINT_COMPASS:

        returnValue = compassInit();
        break;

    case PRINT_HUMIDITY:

        returnValue = humiditySensorInit();
        break;

    case PRINT_STEP_COUNTER:

        returnValue = stepCounterSensorInit();
        break;

    case PRINT_CALIBRATED_SENSORS:

        returnValue = calibratedSensorInit();
        break;

    case PRINT_GRAVITY:

        returnValue = gravityInit();
        break;

    case MAG_FINGER_PRINT:

        returnValue = magneticFingerPrintInit();
        break;

    case PRINT_LINEAR_ACCELERATION:

        returnValue = LinearAccelInit();
        break;
    case PRINT_GESTURE:

        returnValue = GestureDataInit();
        break;

    default:
        break;
    }
    if (RETCODE_OK == returnValue)
    {
        printf("Sensor intialization succeeded");
    }
    else
    {
        printf("Sensor intialization failed");
    }
}

void appInitSystem(void * CmdProcessorHandle, uint32_t param2)
{
    if (CmdProcessorHandle == NULL)
    {
        printf("Command processor handle is null \n\r");
        assert(false);
    }
    AppCmdProcessorHandle = (CmdProcessor_T *) CmdProcessorHandle;
    BCDS_UNUSED(param2);
    init();
}

/**
 *  @brief API to deinitialize the PTB module
 */
void deinit(void)
{
    Retcode_T returnValue = (Retcode_T) RETCODE_FAILURE;
    switch (sensorToPrint)
    {
    case PRINT_ORIENTATION:

        returnValue = OrientationSensorDeinit();
        break;

    case PRINT_ROTATION:

        returnValue = RotationDataDeinit();
        break;

    case PRINT_COMPASS:

        returnValue = compassDeinit();
        break;

    case PRINT_HUMIDITY:

        returnValue = humiditySensorDeinit();
        break;

    case PRINT_STEP_COUNTER:

        returnValue = stepCounterSensorDeinit();
        break;

    case PRINT_CALIBRATED_SENSORS:

        returnValue = calibratedSensorDeinit();
        break;

    case MAG_FINGER_PRINT:

        returnValue = magneticFingerPrintDeinit();
        break;

    case PRINT_LINEAR_ACCELERATION:

        returnValue = LinearAccelDeInit();
        break;
    case PRINT_GESTURE:

        returnValue = GestureDataDeinit();
        break;

    case PRINT_GRAVITY:

        returnValue = gravityDeinit();
        break;
    default:
        break;
    }
    if (RETCODE_OK == returnValue)
    {
        printf("Sensor Deintialization succeeded");
    }
    else
    {
        printf("Sensor Deintialization failed");
    }
}

CmdProcessor_T * GetAppCmdProcessorHandle(void)
{
    return AppCmdProcessorHandle;
}
/**@} */
/** ************************************************************************* */

 

 

And the code of CalibratedSensor.c is:

* @file
**/
/*----------------------------------------------------------------------------*/

/* module includes ********************************************************** */

/* own header files */
#include "XDKAppInfo.h"
#undef BCDS_MODULE_ID
#define BCDS_MODULE_ID XDK_APP_MODULE_ID_CALIBRATION_SENSOR
#include "CalibratedSensor.h"
#include "XdkSensorHandle.h"
#include "SendVirtualSensorDataOverUsb.h"

/* system header files */
#include <stdio.h>
#include "BCDS_Basics.h"

/* additional interface header files */
#include "BCDS_CalibratedAccel.h"
#include "BCDS_CalibratedGyro.h"
#include "BCDS_CalibratedMag.h"
#include "BCDS_Assert.h"
#include "BCDS_BSP_LED.h"
#include "BSP_BoardType.h"
#include "BCDS_CmdProcessor.h"
#include "FreeRTOS.h"
#include "timers.h"

/* constant definitions ***************************************************** */

/* local variables ********************************************************** */
#define DELAY  UINT32_C(50)      /**< Timer delay is represented by this macro */
#define TIMERBLOCKTIME  UINT32_C(0xffff)    /**< Macro used to define blocktime of a timer*/
#define CALIBRATION_DONE UINT8_C(1) /**<Represents calibration done status */
#define CALIBRATION_NOT_DONE UINT8_C(0) /**<Represents calibration not done status */
#define TIMER_NOT_ENOUGH_MEMORY            (-1L)/**<Macro to define not enough memory error in timer*/
#define TIMER_NO_ERROR            (0L)/**<Macro to define not enough memory error in timer*/
#define TIMER_AUTORELOAD_ON             UINT32_C(1)             /**< Auto reload of timer is enabled*/

/** Enum values represent the type of calibrated sensor data to be printed */
typedef enum printData_e
{
    PRINT_CALIBRATED_ACCEL_DATA,/**< Prints calibrated accel data */
    PRINT_CALIBRATED_GYRO_DATA,/**< Prints calibrated gyro data  */
    PRINT_CALIBRATED_MAG_DATA, /**< Prints calibrated mag data */
} printData_t;

/** Enum values represent the calibration Status of sensor */
typedef enum calibrationStatus_e
{
    CALIBRATION_STATUS_UNRELIABLE,/**< unreliable calibration sensor Status of sensor */
    CALIBRATION_STATUS_LOW,/**< low calibration sensor Status of sensor  */
    CALIBRATION_STATUS_MEDIUM,/**< medium calibration sensor Status of sensor */
    CALIBRATION_STATUS_HIGH, /**< low calibration sensor Status of sensor */
} calibrationStatus_t;

static uint8_t isCalibrated = CALIBRATION_NOT_DONE; /**< variable to store calibration status */
static xTimerHandle printTimerHandle = NULL;/**< variable to store timer handle*/
static calibrationStatus_t calibSensorAccuracyStatus = CALIBRATION_STATUS_UNRELIABLE; /**<variable to store calibration status of sensor */
/**
 * The variable decides which calibrated sensor data has to be printed. By default CALIBRATED ACCELEROMETER values are printed.
 * user can switch to CALIBRATED GYROSCOPE or CALIBRATED MAGNETOMETER by using corresponding sensor value
 * available in printData_t enumeration
 */
static printData_t dataToPrint = PRINT_CALIBRATED_ACCEL_DATA;/**< variable which indicates what data of calibrated sensor is to be printed */

/* inline functions ********************************************************* */

/* local functions ********************************************************** */

/**
 * @brief   API used to check whether sensor calibration is done or not.
 *          Once the sensor calibration is done, yellow LED starts to glow constantly
 *          if the calibration is not done, then the LED will continue to Blink
 *
 * @retval  CSD_CALIBRATION_NOT_DONE        sensor calibration is not done
 * @retval  CSD_CALIBRATION_DONE            sensor calibration is done
 */
static uint8_t isCalibrationDone(void)
{
    Retcode_T calibrationStatus = (Retcode_T) RETCODE_FAILURE;
    Retcode_T returnVal = RETCODE_OK;
    /* Initially LED is set to TOGGLE state */
    returnVal = BSP_LED_Enable((uint32_t) BSP_XDK_LED_Y);
    if (RETCODE_OK != returnVal)
    {
        returnVal = BSP_LED_Switch((uint32_t) BSP_XDK_LED_Y, (uint32_t) BSP_LED_COMMAND_TOGGLE);
        if (RETCODE_OK != returnVal)
        {
            printf(" Error occurred in Toggling YELLOW LED  %u \n", (unsigned int) returnVal);
            assert(false);
        }
    }
    switch (dataToPrint)
    {
    case PRINT_CALIBRATED_ACCEL_DATA:
        /* reading calibration status of calibrated accelerometer */
        calibrationStatus = CalibratedAccel_getStatus((CalibratedAccel_StatusPtr_T) &calibSensorAccuracyStatus);
        break;
    case PRINT_CALIBRATED_GYRO_DATA:
        /* reading calibration status of calibrated gyroscope */
        calibrationStatus = CalibratedGyro_getStatus((CalibratedGyro_CalibStatusPtr_T) &calibSensorAccuracyStatus);
        break;
    case PRINT_CALIBRATED_MAG_DATA:
        /* reading calibration status of calibrated magnetometer */
        calibrationStatus = CalibratedMag_getStatus((CalibratedMag_CalibStatusPtr_T) &calibSensorAccuracyStatus);
        break;
    default:
        calibrationStatus = (Retcode_T) RETCODE_FAILURE;
        break;
    }

    if ((calibrationStatus != RETCODE_OK) || (CALIBRATION_STATUS_HIGH != (calibrationStatus_t) calibSensorAccuracyStatus))
    {
        return (CALIBRATION_NOT_DONE);
    }
    else
    {
        returnVal = BSP_LED_Switch((uint32_t) BSP_XDK_LED_Y, (uint32_t) BSP_LED_COMMAND_ON);
        if (RETCODE_OK != returnVal)
        {
            printf(" Error occurred switching on YELLOW LED  %u \n", (unsigned int) returnVal);
            assert(false);
        }
        return (CALIBRATION_DONE);
    }
}

/**
 * @brief   Gets the data from Corresponding calibrated sensor and prints through the USB printf on serial port.
 *
 * @param[in]   *param1: a generic pointer to any context data structure which will be passed to the function when it is invoked by the command processor.
 *
 * @param[in]    param2: a generic 32 bit value  which will be passed to the function when it is invoked by the command processor.
 */
static void processCalibratedSensorsData(void * param1, uint32_t param2)
{
    BCDS_UNUSED(param1);
    BCDS_UNUSED(param2);

    Retcode_T calibratedSensorReturnStatus = (Retcode_T) RETCODE_FAILURE;
    Retcode_T calibratedSensorReturnStatusMag = (Retcode_T) RETCODE_FAILURE;

    switch (dataToPrint)
    {

    case PRINT_CALIBRATED_ACCEL_DATA:
        {
       // CalibratedAccel_XyzLsbData_T calibAccelLsbData;
        CalibratedMag_XyzMicroTesla_T calibMagMicroTeslaData;
        CalibratedAccel_XyzMps2Data_T calibAccelMps2Data;
        //CalibratedAccel_XyzGData_T calibAccelGData;
        /* initializing structure elements */
        //memset(&calibAccelLsbData, 0, sizeof(CalibratedAccel_XyzLsbData_T));
        memset(&calibMagMicroTeslaData, 0, sizeof(CalibratedMag_XyzMicroTesla_T));
        memset(&calibAccelMps2Data, 0, sizeof(CalibratedAccel_XyzMps2Data_T));
        //memset(&calibAccelGData, 0, sizeof(CalibratedAccel_XyzGData_T));

        if ( CALIBRATION_NOT_DONE == isCalibrated)
        {
            /* Checking the calibration status of calibrated accelerometer */
            isCalibrated = isCalibrationDone();
        }
        if ( CALIBRATION_DONE == isCalibrated)
        {
            /* Reading calibrated accelerometer lsb value */
           // calibratedSensorReturnStatus = CalibratedAccel_readXyzLsbValue(&calibAccelLsbData);
           // if (RETCODE_OK == calibratedSensorReturnStatus)
           // {
                /* Print calibrated accelerometer lsb information */
             //   printf("CALIBRATED ACCEL DATA - LSB\t: %ld lsb\t%ld lsb\t%ld lsb\n\r",
               //         (long int) calibAccelLsbData.xAxisData, (long int) calibAccelLsbData.yAxisData, (long int) calibAccelLsbData.zAxisData);
           // }
           // else
           // {
            //    printf("Calibrated Accelerometer lsb Value Read failed \n\r");
            //}
            /* Reading calibrated accelerometer m/s2 value */
        	calibratedSensorReturnStatusMag = CalibratedMag_readMicroTeslaVal(&calibMagMicroTeslaData);
            calibratedSensorReturnStatus = CalibratedAccel_readXyzMps2Value(&calibAccelMps2Data);
            if (RETCODE_OK == calibratedSensorReturnStatus)
            {
                /* Print calibrated accelerometer m/s2 information */
            	printf("%.4f;%.4f;%.4f;%.4f;%.4f;%.4f\n\r",
            	                        (float) calibMagMicroTeslaData.xAxisData, (float) calibMagMicroTeslaData.yAxisData, (float) calibMagMicroTeslaData.zAxisData, (float) calibAccelMps2Data.xAxisData, (float) calibAccelMps2Data.yAxisData, (float) calibAccelMps2Data.zAxisData);
               // printf("CALIBRATED ACCEL DATA - M/S2\t xAxis = %.4f m/s2;\t yAxis = %.4f m/s2\t zAxis = %.4f m/s2;\n\r",
                       // (float) calibAccelMps2Data.xAxisData, (float) calibAccelMps2Data.yAxisData, (float) calibAccelMps2Data.zAxisData);
            }
            else
            {
                printf("Calibrated Accelerometer metre per second squared Value Read failed \n\r");
            }
            /* Reading calibrated accelerometer g value */
            //calibratedSensorReturnStatus = CalibratedAccel_readXyzGValue(&calibAccelGData);
           //if (RETCODE_OK == calibratedSensorReturnStatus)
            //{
                /* Print calibrated accelerometer g information */
             //   printf("CALIBRATED ACCEL DATA - G\t: %.4f g\t%.4f g\t%.4f g\n\n\r",
             //           (float) calibAccelGData.xAxisData, (float) calibAccelGData.yAxisData, (float) calibAccelGData.zAxisData);
           // }
           // else
           // {
           //     printf("Calibrated Accelerometer G Value Read failed \n\r");
           // }
        }
    }
        break;

    case PRINT_CALIBRATED_GYRO_DATA:
        {
        CalibratedGyro_XyzLsbData_T calibGyroLsbData;
        CalibratedGyro_XyzRpsData_T calibGyroRpsData;
        CalibratedGyro_XyzDpsData_T calibGyroDpsData;
        /* initializing structure elements */
        memset(&calibGyroLsbData, 0, sizeof(CalibratedGyro_XyzLsbData_T));
        memset(&calibGyroRpsData, 0, sizeof(CalibratedGyro_XyzRpsData_T));
        memset(&calibGyroDpsData, 0, sizeof(CalibratedGyro_XyzDpsData_T));

        if (CALIBRATION_NOT_DONE == isCalibrated)
        {
            /* Checking the calibration status of calibrated gyroscope */
            isCalibrated = isCalibrationDone();
        }
        if (CALIBRATION_DONE == isCalibrated)
        {
            /* Reading calibrated gyroscope lsb value */
            calibratedSensorReturnStatus = CalibratedGyro_readXyzLsbValue(&calibGyroLsbData);
            if (RETCODE_OK == calibratedSensorReturnStatus)
            {
                /* Print calibrated gyroscope lsb information */
                printf("CALIBRATED GYRO DATA - LSB\t: %ld lsb\t%ld lsb\t%ld lsb\n\r",
                        (long int) calibGyroLsbData.xAxisData, (long int) calibGyroLsbData.yAxisData, (long int) calibGyroLsbData.zAxisData);
            }
            else
            {
                printf("Calibrated Gyroscope lsb Value Read failed \n\r");
            }
            /* Reading calibrated gyroscope rad/sec value */
            calibratedSensorReturnStatus = CalibratedGyro_readXyzRpsValue(&calibGyroRpsData);
            if (RETCODE_OK == calibratedSensorReturnStatus)
            {
                /* Print calibrated gyroscope rad/s information */
                printf("CALIBRATED GYRO DATA - RAD/SEC\t: %.4f rad/s\t%.4f rad/s\t%.4f rad/s\n\r",
                        (float) calibGyroRpsData.xAxisData, (float) calibGyroRpsData.yAxisData, (float) calibGyroRpsData.zAxisData);
            }
            else
            {
                printf("Calibrated Gyroscope radians per second Value Read failed \n\r");
            }
            /* Reading calibrated gyroscope deg/sec value */
            calibratedSensorReturnStatus = CalibratedGyro_readXyzDpsValue(&calibGyroDpsData);
            if (RETCODE_OK == calibratedSensorReturnStatus)
            {
                /* Print calibrated gyroscope deg/sec information */
                printf("CALIBRATED GYRO DATA - DEG/SEC\t: %.4f deg/s\t%.4f deg/s\t%.4f deg/s\n\n\r",
                        (float) calibGyroDpsData.xAxisData, (float) calibGyroDpsData.yAxisData, (float) calibGyroDpsData.zAxisData);
            }
            else
            {
                printf("Calibrated Gyroscope degrees per second Value Read failed \n\r");
            }
        }
    }
        break;

    case PRINT_CALIBRATED_MAG_DATA:
        {
        CalibratedMag_XyzLsbData_T calibMagLsbData;
        CalibratedMag_XyzMicroTesla_T calibMagMicroTeslaData;
        CalibratedMag_XyzGaussData_T calibMagGaussData;
        /* initializing structure elements */
        memset(&calibMagLsbData, 0, sizeof(CalibratedMag_XyzLsbData_T));
        memset(&calibMagMicroTeslaData, 0, sizeof(CalibratedMag_XyzMicroTesla_T));
        memset(&calibMagGaussData, 0, sizeof(CalibratedMag_XyzGaussData_T));

        if (CALIBRATION_NOT_DONE == isCalibrated)
        {
            /* Checking the calibration status of calibrated magnetometer */
            isCalibrated = isCalibrationDone();
        }
        if (CALIBRATION_DONE == isCalibrated)
        {
            /* Reading calibrated magnetometer lsb value */
            calibratedSensorReturnStatus = CalibratedMag_readXyzLsbVal(&calibMagLsbData);

            if (RETCODE_OK == calibratedSensorReturnStatus)
            {
                /* Print calibrated magnetometer lsb information */
                printf("CALIBRATED MAG DATA - LSB\t: %ld lsb\t%ld lsb\t%ld lsb\n\r",
                        (long int) calibMagLsbData.xAxisData, (long int) calibMagLsbData.yAxisData, (long int) calibMagLsbData.zAxisData);
            }
            else
            {
                printf("Calibrated Magnetometer lsb Value Read failed \n\r");
            }
            /* Reading calibrated magnetometer micro tesla value */
            calibratedSensorReturnStatus = CalibratedMag_readMicroTeslaVal(&calibMagMicroTeslaData);
            if (RETCODE_OK == calibratedSensorReturnStatus)
            {
                /* Print calibrated magnetometer micro tesla information */
                printf("CALIBRATED MAG DATA - uT\t: %.4f uT\t%.4f uT\t%.4f uT\n\r",
                        (float) calibMagMicroTeslaData.xAxisData, (float) calibMagMicroTeslaData.yAxisData, (float) calibMagMicroTeslaData.zAxisData);
            }
            else
            {
                printf("Calibrated Magnetometer micro tesla Value Read failed \n\r");
            }
            /* Reading calibrated magnetometer gauss value */
            calibratedSensorReturnStatus = CalibratedMag_readXyzGaussVal(&calibMagGaussData);
            if (RETCODE_OK == calibratedSensorReturnStatus)
            {
                /* Print calibrated magnetometer gauss information */
                printf("CALIBRATED MAG DATA - GAUSS\t: %.4f gauss\t%.4f gauss\t%.4f gauss\n\n\r",
                        (float) calibMagGaussData.xAxisData, (float) calibMagGaussData.yAxisData, (float) calibMagGaussData.zAxisData);
            }
            else
            {
                printf("Calibrated Magnetometer Gauss Value Read failed \n\r");
            }
        }
    }
        break;

    default:
        printf("Invalid data to print");
        break;
    }
}

/**
 * @brief The function enqueue processCalibratedSensorsData function to the command processor.
 *
 * @param[in] pvParameters Rtos task should be defined with the type void *(as argument)
 */
static void printCalibratedSensorsData(void *pvParameters)
{
    BCDS_UNUSED(pvParameters);
    Retcode_T returnValue = RETCODE_OK;
    returnValue = CmdProcessor_Enqueue(GetAppCmdProcessorHandle(), processCalibratedSensorsData, NULL, UINT32_C(0));
    if (RETCODE_OK != returnValue)
    {
        printf("Enqueuing for CalibratedSensors callback failed\n\r");
    }
}

/* global functions ********************************************************* */\

/* API documentation is in the header */
Retcode_T calibratedSensorInit(void)
{
    int8_t retValPerSwTimer = TIMER_NOT_ENOUGH_MEMORY;
    Retcode_T calibratedSensorInitStatus2 = (Retcode_T) RETCODE_FAILURE;
    Retcode_T calibratedSensorInitStatus = (Retcode_T) RETCODE_FAILURE;

    switch (dataToPrint)
    {
    case PRINT_CALIBRATED_ACCEL_DATA:
        /* initialize calibrated accelerometer */
        calibratedSensorInitStatus = CalibratedAccel_init(xdkCalibratedAccelerometer_Handle);
        calibratedSensorInitStatus2 = CalibratedMag_init(xdkCalibratedMagnetometer_Handle);
        break;
    case PRINT_CALIBRATED_GYRO_DATA:
        /* initialize calibrated gyroscope */
        calibratedSensorInitStatus = CalibratedGyro_init(xdkCalibratedGyroscope_Handle);
        break;
    case PRINT_CALIBRATED_MAG_DATA:
        /* initialize calibrated magnetometer */
        calibratedSensorInitStatus2 = CalibratedMag_init(xdkCalibratedMagnetometer_Handle);
        break;
    default:
        calibratedSensorInitStatus = (Retcode_T) RETCODE_FAILURE;
        break;
    }

    if (RETCODE_OK == calibratedSensorInitStatus)
    {
        uint32_t Ticks = DELAY;

        if (Ticks != UINT32_MAX) /* Validated for portMAX_DELAY to assist the task to wait Infinitely (without timing out) */
        {
            Ticks /= portTICK_RATE_MS;
        }
        if (UINT32_C(0) == Ticks) /* ticks cannot be 0 in FreeRTOS timer. So ticks is assigned to 1 */
        {
            Ticks = UINT32_C(1);
        }
        /* create timer task to get and print calibrated sensor data periodically */
        printTimerHandle = xTimerCreate((const char * const ) "calibratedSensorsDemo",
                Ticks, TIMER_AUTORELOAD_ON, NULL, printCalibratedSensorsData);

        /* CSD timer create fail case */
        if (NULL == printTimerHandle)
        {
            /* Assertion Reason: "This software timer was not Created, Due to Insufficient heap memory" */
            printf("Software timer was not Created, Due to Insufficient heap memory");
            assert(false);
        }

        /* Start the created timer*/
        retValPerSwTimer = xTimerStart(printTimerHandle, TIMERBLOCKTIME);

        /* CSD timer start fail case */
        if (TIMER_NOT_ENOUGH_MEMORY == retValPerSwTimer)
        {
            /* Assertion Reason: "This software timer was not started, Due to Insufficient heap memory" */
            assert(false);
        }
    }
    else
    {
        printf("calibrated sensor initialisation failed \n\r");
    }
    return calibratedSensorInitStatus;
}

/* API documentation is in the header */
Retcode_T calibratedSensorDeinit(void)
{
    Retcode_T calibratedSensorDeinitStatus = (Retcode_T) RETCODE_FAILURE;
    Retcode_T calibratedSensorDeinitStatus2 = (Retcode_T) RETCODE_FAILURE;
    Retcode_T returnVal = RETCODE_OK;
    returnVal = BSP_LED_Disable((uint32_t) BSP_XDK_LED_Y);
    if (RETCODE_OK != returnVal)
    {
        assert(false);
        printf("Enabling the yellow LED control failed with error %u \n", (unsigned int) returnVal);
    }
    switch (dataToPrint)
    {
    case PRINT_CALIBRATED_ACCEL_DATA:
        /* deinitialize calibrated accelerometer */
        calibratedSensorDeinitStatus = CalibratedAccel_deInit();
        calibratedSensorDeinitStatus2 = CalibratedMag_deInit();
        break;
    case PRINT_CALIBRATED_GYRO_DATA:
        /* deinitialize calibrated gyroscope */
        calibratedSensorDeinitStatus = CalibratedGyro_deInit();
        break;
    case PRINT_CALIBRATED_MAG_DATA:
        /* deinitialize calibrated magnetometer */
        calibratedSensorDeinitStatus2 = CalibratedMag_deInit();
        break;
    default:
        break;
    }
    if (RETCODE_OK == calibratedSensorDeinitStatus)
    {
        /* clear the calibration status flag */
        isCalibrated = CALIBRATION_NOT_DONE;
        /* Stop the created CSD timer */
        if (pdFAIL == xTimerStop(printTimerHandle, TIMERBLOCKTIME))
        {
            assert(false);
        }
    }
    else
    {
        printf("calibrated sensor deinitialisation failed \n\r");
    }
    return calibratedSensorDeinitStatus;
}
/**@} */
/** ************************************************************************* */

 

0 (0 투표)
RE: How to get the best performance out the script
응답
18. 3. 16 오후 3:50 as a reply to Aleksandr Gorovoj.
Hello Aleksandr,

It depends on what kind of performance you want to achieve. You can, of course, remove all unrelated parts of the SendVirtualDataOverUsb example to suit your use case best. For the calibrated sensor feature, you would only need to remove all code parts involving the calibrated gyroscope and magnetometer in CalibratedSensor.c to achieve the highest performance.

Alternatively, if you want to receive acceleration data with the highest possible resolution, an custom implementation of the accelerometer BMI160 might be worth thinking about. This sensor has a 16-bit resolution compared to the 13-bit resolution of the BMA280. An own implementation would be beneficial because you would be able to adjust the resolution with the range parameter instead of using the calibrated accelerometer, where this is not possible.

For more information on this topic, I recommend taking a look at the accelerometer section in the Sensor guide or at the full code example from the XDK Knowledgebase .

Please let me know if that was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
0 (0 투표)
RE: How to get the best performance out the script
응답
18. 3. 23 오후 10:59 as a reply to Franjo Stjepandic.

Dear Franjo, tanks for your suggestion.

I tried to copy-paste the full-example-code from XDK Knowledge Base to a freshly opened XdkApplicationTemplate.c, but if I try to Build and flash it to the XDK, I get this error:

 

Creating .out C:/Users/Lena/XDK-Workspace/XdkApplicationTemplate/debug/XdkApplicationTemplate.out
./../Platform/Sensors/debug/libSensors_efm32_debug.a(Accelerometer.o): In function `Accelerometer_setBandwidth':
C:\XDK-Workbench\XDK\SDK\xdk110\Platform\Sensors/source/Accelerometer/Accelerometer.c:382: undefined reference to `bma2x2_set_high_bw'
C:\XDK-Workbench\XDK\SDK\xdk110\Platform\Sensors/source/Accelerometer/Accelerometer.c:386: undefined reference to `bma2x2_set_bw'
./../Platform/Sensors/debug/libSensors_efm32_debug.a(Accelerometer.o): In function `Accelerometer_setRange':
C:\XDK-Workbench\XDK\SDK\xdk110\Platform\Sensors/source/Accelerometer/Accelerometer.c:529: undefined reference to `bma2x2_set_range'
./../Platform/Sensors/debug/libSensors_efm32_debug.a(Accelerometer.o): In function `Accelerometer_readXyzGValue':
C:\XDK-Workbench\XDK\SDK\xdk110\Platform\Sensors/source/Accelerometer/Accelerometer.c:966: undefined reference to `bma2x2_read_accel_xyz'
./../Platform/SensorUtils/debug/libSensorUtils_efm32_debug.a(Bma280Utils.o): In function `Bma280Utils_initialize':
C:\XDK-Workbench\XDK\SDK\xdk110\Platform\SensorUtils/source/Carbon/Bma280Utils/Bma280Utils.c:225: undefined reference to `bma2x2_init'
C:\XDK-Workbench\XDK\SDK\xdk110\Platform\SensorUtils/source/Carbon/Bma280Utils/Bma280Utils.c:229: undefined reference to `bma2x2_set_bw'
application.mk:356: recipe for target 'C:/Users/Lena/XDK-Workspace/XdkApplicationTemplate/debug/XdkApplicationTemplate.out' failed
collect2.exe: error: ld returned 1 exit status
mingw32-make[1]: Leaving directory 'C:/XDK-Workbench/XDK/SDK/xdk110/Common'
mingw32-make[1]: *** [C:/Users/Lena/XDK-Workspace/XdkApplicationTemplate/debug/XdkApplicationTemplate.out] Error 1
Makefile:32: recipe for target 'debug' failed
mingw32-make: *** [debug] Error 2

23:29:47 Build Finished (took 22s.554ms)

 

How comes? What should I do?

What I want to do is to print accelerator and lightsensor via USB.

0 (0 투표)
RE: How to get the best performance out the script
응답
18. 3. 26 오후 2:50 as a reply to Aleksandr Gorovoj.
Hello Aleksandr,

Unfortunately, I was not able to reproduce your error with the full code example for the accelerometer from the XDK Knowledgebase on XDK-Workbench versions 3.3.0 and 3.3.1.

The error messages indicate that the implementation of the Low-Level API interface bma2x2.h for the acceleration sensor cannot be found. This would point to an issue with the SDK of your XDK-Workbench.

To see if this is a general issue with your XDK-Workbench, I would ask you to try to build another example, which uses the accelerometer BMA280, such as the SendAccelerometerDataOverBle .

If the result is the same, then I my assumptions may be correct, regarding the SDK. In that case, I recommend to reinstall your XDK-Workbench first, because some of the configuration may be wrong.

Kind regards,
Franjo
0 (0 투표)