Acceleration and acoustic Sensor
Answer
11/16/17 1:12 PM

Hello,

I just start to learn how to use XDK. 

I want to  use the datalogger example ("DDL_DemoDataLogger") to measure acceleration and acoustic values and get the data every 1ms.   Now I have two questions.The first one is how to add the Sensor Aku340. The second one is how to delect the other sensor except BMA280 and Aku340. 

Thanks  for your help. 

0 (0 Votes)
RE: Acceleration and acoustic Sensor
Answer
11/16/17 2:44 PM as a reply to Zhefei Xiao.

Hello Zhefei,

regarding the removal of other sensors, there are two files that have to be stored on the SD card for configuring the Data Logger demo. These are logger.ini and custlog.ini, which you also find in your project.

To remove (disable) specific sensors, go to the file logger.ini. There, you will find configurations for each sensor. One of those configurations is

enabled=1

Simply change the 1 to a 0, to disabled the respective sensor.

Implementing the Acoustic Sensor on the other hand will be a bit more difficult. The acoustic sensor has to be enabled in the SDK first. In your project, browse to

SDK > xdk110 > Common > config > Essentials > BCDS_HALConfig.h

and add the line

#define BCDS_FEATURE_BSP_MIC_AKU340    1

The interface for the acoustic sensor can be found in

SDK > xdk110 > Platform > Essentials > include > bsp > BCDS_BSP_Mic_AKU340.h

Integrating the acoustic sensor into the DDL will be difficult, as previously mentioned. Optimally, you take a look at how the other sensors are integrated (each have their own folder inside the project, such as BMA_280), and do something similar with the acoustic sensor.

Sensor Data is retrieved inside XDK_Datalogger_cc.c, so you should take a lookt at the functions UpdateSensorValues(), Sensor_init(), and writeLogEntry().

Alternatively, since this is actually quite a lot of effort, perhaps it would be easier to take the important parts of the data logger demo (i.e. writing to SD card) and make your own application, that may be stripped down, but optimized towards your use case. The Data Logger demo was developed for demonstration purposes, which is why adding features is not as easily done as one might expect.

Please tell me if this was helpful, and do not hesitate to ask further questions.

Kind regards,
Franjo

0 (0 Votes)
RE: Acceleration and acoustic Sensor
Answer
11/18/17 7:58 PM as a reply to Franjo Stjepandic.

Dear Franjo,

first of all, thanks for your previous help!

I have tried the code you wrote in the thread , but unfortunately, some error showed up(image).

My further question is:

Is ADC a converter linked with extended devises(gateway) or just an internal converter? Which part of the general user guide can I refer to?

Thank you very much!

Zhefei Xiao

0 (0 Votes)
RE: Acceleration and acoustic Sensor
Answer
11/21/17 3:17 PM as a reply to Zhefei Xiao.

Hello Zhefei,

would you be so kind and explain how you tried the code I wrote in the thread? Did you use the functions of the header file BCDS_BSP_Mic_AKU340.h?

The error log you presented in the attached screenshot actually shows that an include cannot be found. I assume that ADC_ih.h is a header-file that you created. If that is the case, you can either write the exact path, relative to the source-file in which you included it, as your include. Or you can add the directory, where the header-file is located, to the known include-directories of your makefile.

For the first option, if your header-file is located source/ADC/ADC_ih.h, and your source file is located in source/implementation_file.c, then use #include as follows:

#include “ADC/ADC_ih.h” // the relative path from implementation_file.c to ADC_ih.h

For the second option, in the Makefile of your project, add the following line below export BCDS_XDK_INCLUDES += \

$(BCDS_APP_DIR)/ADC # directory in which header-files are located

This makes the directory, in which ADC_ih.h is located, known to the compiler.

As for the ADC, if you refer to the Analog/Digital Converter, this is an internal peripheral, and you can access it via the API given by the header-file SDK > xdk110 > Libraries > EMlib > 3rd-party > EMLib > emlib > inc > em_adc.h

The extension board allows to connect external analog sensors to the XDK’s ADC, to read those sensors as well. But there is currently no documentation regarding the ADC module’s usage. You can find hints by looking at the acoustic sensor’s implementation in the implementation file SDK > xdk110 > Platform > BSP > source > BSP_Mic_AKU340.c, since other channels of the ADC are used there. Instead of AKU_OUT_PIN and AKU_OUT_POT you would use ADC0_CH5_PIN and ADC0_CH5_PORTrespectively, if your sensor is connected to the pin PD5 (for ADC0_CH5) on the extension board.

Please tell me if this was helpful and do not hesitate to ask further questions,

Kind regards,
Franjo

0 (0 Votes)
RE: Acceleration and acoustic Sensor
Answer
11/21/17 10:27 AM as a reply to Franjo Stjepandic.

Hi Franjo,

Regardinng how I tried the code:

I just created an project in Workbench with XdkApplicationTemplate. Then I copy/paste the code into the XdkApplicationTemplate.c file under source folder.

When I built the project, the errors showed up.

Please let me know my mistakes during the utility of the code! Thanks! 

And I will do more research.

Kind Regards

Zhefei

0 (0 Votes)
RE: Acceleration and acoustic Sensor
Answer
11/21/17 5:40 PM as a reply to Zhefei Xiao.

Hello Zhefei,

Thank you for clarifying your implementation steps. I thought you made the adaption in the Data Logger demo. My complete explanation was based on that as modification. But you can, of course, build your own application in the XdkApplicationTemplate with only the acoustic sensor and the accelerometer and write their data to the SD card.

Regarding your error with ADC_ih.h, I may have to do some correction. Are you using the acoustic sensor implementation I proposed? Or are you using the implementation in this thread here? If you are using the implementation from the linked thread, then you need to take care because it is only working on the XDK-Workbench 2.0.1 and lower.

For the implementation in the latest version, I recommend to use the implementation in the post of 11/16/17.

Additionally, if you want to build your own application, I recommend to use the accelerometer implementation of the sensor guide as starting point for the acceleration measurement. For the SD card functionality, I recommend to use the SdCardExample to begin with.

Please let me know if that was helpful and do not hesitate to ask if you have further questions.

Kind regards,
Franjo

0 (0 Votes)
RE: Acceleration and acoustic Sensor
Answer
11/22/17 9:22 AM as a reply to Franjo Stjepandic.

Dear Franjo,

thanks for the reply and the correction.

Would you be so kind to share with me the link to the implemention you mentioned on 16th Nov.?

Regards

Zhefei

0 (0 Votes)
RE: Acceleration and acoustic Sensor
Answer
11/22/17 4:56 PM as a reply to Zhefei Xiao.

Hello Zhefei,

I was referring to my post in this thread of the 16th November.:
my post:

--------------------------------------------------------------------------------------------------------------------------------------------

Hello Zhefei,

regarding the removal of other sensors, there are two files that have to be stored on the SD card for configuring the Data Logger demo. These are logger.ini and custlog.ini, which you also find in your project.

To remove (disable) specific sensors, go to the file logger.ini. There, you will find configurations for each sensor. One of those configurations is

enabled=1

Simply change the 1 to a 0, to disabled the respective sensor.

Implementing the Acoustic Sensor on the other hand will be a bit more difficult. The acoustic sensor has to be enabled in the SDK first. In your project, browse to

SDK > xdk110 > Common > config > Essentials > BCDS_HALConfig.h

and add the line

#define BCDS_FEATURE_BSP_MIC_AKU340    1

The interface for the acoustic sensor can be found in

SDK > xdk110 > Platform > Essentials > include > bsp > BCDS_BSP_Mic_AKU340.h

Integrating the acoustic sensor into the DDL will be difficult, as previously mentioned. Optimally, you take a look at how the other sensors are integrated (each have their own folder inside the project, such as BMA_280), and do something similar with the acoustic sensor.

Sensor Data is retrieved inside XDK_Datalogger_cc.c, so you should take a lookt at the functions UpdateSensorValues(), Sensor_init(), and writeLogEntry().

Alternatively, since this is actually quite a lot of effort, perhaps it would be easier to take the important parts of the data logger demo (i.e. writing to SD card) and make your own application, that may be stripped down, but optimized towards your use case. The Data Logger demo was developed for demonstration purposes, which is why adding features is not as easily done as one might expect.

Please tell me if this was helpful, and do not hesitate to ask further questions.

Kind regards,
Franjo

--------------------------------------------------------------------------------------------------------------------------------------------


Kind regards,
Franjo

0 (0 Votes)
RE: Acceleration and acoustic Sensor
Answer
11/26/17 11:09 AM as a reply to Franjo Stjepandic.

Hi Franjo,

By following your constructions, I have successfully built my accelerometer application. I did it by imitating and combining the Light sensor example and the accelerometer guide. It looks like:

/*
* Licensee agrees that the example code provided to Licensee has been developed and released by Bosch solely as an example to be used as a potential reference for Licensee�s application development. 
* Fitness and suitability of the example code for any use within Licensee�s applications need to be verified by Licensee on its own authority by taking appropriate state of the art actions and measures (e.g. by means of quality assurance measures).
* Licensee shall be responsible for conducting the development of its applications as well as integration of parts of the example code into such applications, taking into account the state of the art of technology and any statutory regulations and provisions applicable for such applications. Compliance with the functional system requirements and testing there of (including validation of information/data security aspects and functional safety) and release shall be solely incumbent upon Licensee. 
* For the avoidance of doubt, Licensee shall be responsible and fully liable for the applications and any distribution of such applications into the market.
* 
* 
* Redistribution and use in source and binary forms, with or without 
* modification, are permitted provided that the following conditions are 
* met:
* 
*     (1) Redistributions of source code must retain the above copyright
*     notice, this list of conditions and the following disclaimer. 
* 
*     (2) Redistributions in binary form must reproduce the above copyright
*     notice, this list of conditions and the following disclaimer in
*     the documentation and/or other materials provided with the
*     distribution.  
*     
*     (3)The name of the author may not be used to
*     endorse or promote products derived from this software without
*     specific prior written permission.
* 
*  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 
*  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
*  DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
*  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
*  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
*  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
*  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
*  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
*  IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
*  POSSIBILITY OF SUCH DAMAGE.
*/
/*----------------------------------------------------------------------------*/
/**
* @ingroup APPS_LIST
*
* @defgroup XDK_APPLICATION_TEMPLATE XDK Application Template
* @{
*
* @brief XDK Application Template
*
* @details Empty XDK Application Template without any functionality. Should be used as a template to start new projects.
*
* @file
**/
/* module includes ********************************************************** */

/* system header files */
#include <stdio.h>
/* additional interface header files */
#include "FreeRTOS.h"
#include "timers.h"

/* own header files */
#include "XdkApplicationTemplate.h"
#include "BCDS_CmdProcessor.h"
#include "BCDS_Assert.h"
#include "XdkSensorHandle.h"
#include "BCDS_BSP_Mic_AKU340.h"

static void initAccelSensor(void){

	Retcode_T accelerometerInitReturnValue = RETCODE_FAILURE;
	Retcode_T returnBandwidthValue = RETCODE_FAILURE;
	Retcode_T returnRangeValue = RETCODE_FAILURE;

accelerometerInitReturnValue =
Accelerometer_init(xdkAccelerometers_BMA280_Handle);

if (RETCODE_OK != accelerometerInitReturnValue) {
	printf("Acce Sensor initialization Failed\n\r");
}

returnBandwidthValue =
Accelerometer_setBandwidth(xdkAccelerometers_BMA280_Handle,
ACCELEROMETER_BMA280_BANDWIDTH_500HZ);

if (RETCODE_OK != returnBandwidthValue) {
	printf("Acce Sensor bandwidth setting Failed\n\r");
}

returnRangeValue =
Accelerometer_setRange(xdkAccelerometers_BMA280_Handle,ACCELEROMETER_BMA280_RANGE_16G);

if (RETCODE_OK != returnRangeValue) {
	printf("Acce Sensor range setting Failed\n\r");
}
}

static void readAccelSensor(xTimerHandle xTimer)
{
	(void) xTimer;
/* read and print BMA280 accelerometer data */
Retcode_T returnValue = RETCODE_FAILURE;

returnValue = Accelerometer_init(xdkAccelerometers_BMA280_Handle);

if ( RETCODE_OK != returnValue)
{
	 printf("return AccelSensor Data failed\n\r");
}

Accelerometer_XyzData_T bma280 = {INT32_C(0), INT32_C(0), INT32_C(0)};
memset(&bma280, 0, sizeof(Accelerometer_XyzData_T));

returnValue =Accelerometer_readXyzGValue(xdkAccelerometers_BMA280_Handle,&bma280);

if (RETCODE_OK == returnValue) {
printf("BMA280 Acceleration Data \n\r: %f \n\r %f \n\r %f \n\r", (float)
bma280.xAxisData, (float) bma280.yAxisData, (float) bma280.zAxisData);
}
}
void appInitSystem(void * CmdProcessorHandle, uint32_t param2)
{
    if (CmdProcessorHandle == NULL)
    {
        printf("Command processor handle is null \n\r");
        assert(false);
    }
    BCDS_UNUSED(param2);

    uint32_t timerBlockTime = UINT32_MAX;
    uint32_t oneSecondDelay = UINT32_C(5000);
    uint32_t timerAutoReloadOn = pdTRUE;

    xTimerHandle AccelSensorHandle = NULL;
    initAccelSensor();
    AccelSensorHandle = xTimerCreate((const char *) "readAccelSensor",
    oneSecondDelay,timerAutoReloadOn, NULL, readAccelSensor);
    xTimerStart(AccelSensorHandle,timerBlockTime);
}
/**@} */
/** ************************************************************************* */

 The next step is to include Acoustic Sensor in my application. To be honest, I am still confused with the initialization of the sensor and how to read its data. I did a trial by following the path of accelerometer:

/*
* Licensee agrees that the example code provided to Licensee has been developed and released by Bosch solely as an example to be used as a potential reference for Licensee�s application development. 
* Fitness and suitability of the example code for any use within Licensee�s applications need to be verified by Licensee on its own authority by taking appropriate state of the art actions and measures (e.g. by means of quality assurance measures).
* Licensee shall be responsible for conducting the development of its applications as well as integration of parts of the example code into such applications, taking into account the state of the art of technology and any statutory regulations and provisions applicable for such applications. Compliance with the functional system requirements and testing there of (including validation of information/data security aspects and functional safety) and release shall be solely incumbent upon Licensee. 
* For the avoidance of doubt, Licensee shall be responsible and fully liable for the applications and any distribution of such applications into the market.
* 
* 
* Redistribution and use in source and binary forms, with or without 
* modification, are permitted provided that the following conditions are 
* met:
* 
*     (1) Redistributions of source code must retain the above copyright
*     notice, this list of conditions and the following disclaimer. 
* 
*     (2) Redistributions in binary form must reproduce the above copyright
*     notice, this list of conditions and the following disclaimer in
*     the documentation and/or other materials provided with the
*     distribution.  
*     
*     (3)The name of the author may not be used to
*     endorse or promote products derived from this software without
*     specific prior written permission.
* 
*  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 
*  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
*  DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
*  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
*  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
*  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
*  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
*  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
*  IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
*  POSSIBILITY OF SUCH DAMAGE.
*/
/*----------------------------------------------------------------------------*/
/**
* @ingroup APPS_LIST
*
* @defgroup XDK_APPLICATION_TEMPLATE XDK Application Template
* @{
*
* @brief XDK Application Template
*
* @details Empty XDK Application Template without any functionality. Should be used as a template to start new projects.
*
* @file
**/
/* module includes ********************************************************** */

/* system header files */
#include <stdio.h>
/* additional interface header files */
#include "FreeRTOS.h"
#include "timers.h"

/* own header files */
#include "XdkApplicationTemplate.h"
#include "BCDS_CmdProcessor.h"
#include "BCDS_Assert.h"
#include "XdkSensorHandle.h"
#include "BCDS_BSP_Mic_AKU340.h"

static void initAcouSensor(void){

	Retcode_T acousticInitReturnValue = RETCODE_FAILURE;

acousticInitReturnValue =
Acoustic_init(BCDS_BSP_Mic_AKU340);

if (RETCODE_OK != acousticInitReturnValue) {
	printf("Acou Sensor initialization Failed\n\r");
}
}
/**
 * @brief This is a template function where the user can write his custom application.
 *
 */
void appInitSystem(void * CmdProcessorHandle, uint32_t param2)
{
    if (CmdProcessorHandle == NULL)
    {
        printf("Command processor handle is null \n\r");
        assert(false);
    }
    BCDS_UNUSED(param2);
}
/**@} */
/** ************************************************************************* */

But I encounted the errors in the image.

My question is, how should I access the acoustic sensor? By following the other sensors or in some other ways? 

I know we have talked about it before, but I really appreciate more detailed explanation.

Thanks in advance!

Regards

Zhefei

 

0 (0 Votes)
RE: Acceleration and acoustic Sensor
Answer
11/27/17 5:06 PM as a reply to Zhefei Xiao.

Hello Zhefei,

The way the acoustic sensor is initialized and read is different from the other sensors of the XDK.

To initialize it, you need to call the following two functions:

BSP_Mic_AKU340_Connect();
BSP_Mic_AKU340_Enable();

The function BSP_Mic_AKU340_Connect() will make the necessary pin configuration and the function BSP_Mic_AKU340_Enable() will activate the supply source for the acoustic sensor.

Afterwards, data can be read by using the function BSP_Mic_AKU340_Sense() as follows:

int32_t sample;
sample = BSP_Mic_AKU340_Sense();

Everything else has to be done mentioned in my previous answer.

Please let me know if that was helpful and do not hesitate to ask if you have further questions.

Kind regards,
Franjo

0 (0 Votes)
RE: Acceleration and acoustic Sensor
Answer
11/27/17 6:59 PM as a reply to Franjo Stjepandic.

Hi Franjo!

Thank you for the reply!

In the file BSP_Mic_AKU340 under folder "SDK\xdk110\Platform\BSP", I read the functions you mentioned.

In that file, I can read

BSP_Mic_AKU340_Connect();
BSP_Mic_AKU340_Enable();

as well as

BSP_Mic_AKU340_DisConnect();
BSP_Mic_AKU340_DisEnable();

I assume the first two functions are for the initiation of the sensor and the latter two functions are for the uninitiation. So in my application, I just included the initiation-functions.

For the reading part, some difference can be noticed between the file BSP_Mic_AKU340 and your last relpy. In the file, we have different conditions.

After building my application, it had no errors after building. But I got no responce after flashing. I assume something is missing after  BCDS_UNUSED(param2); at the bottom. But I do not know what to add.

Maybe I need more help if possible!

/*
* Licensee agrees that the example code provided to Licensee has been developed and released by Bosch solely as an example to be used as a potential reference for Licensee�s application development. 
* Fitness and suitability of the example code for any use within Licensee�s applications need to be verified by Licensee on its own authority by taking appropriate state of the art actions and measures (e.g. by means of quality assurance measures).
* Licensee shall be responsible for conducting the development of its applications as well as integration of parts of the example code into such applications, taking into account the state of the art of technology and any statutory regulations and provisions applicable for such applications. Compliance with the functional system requirements and testing there of (including validation of information/data security aspects and functional safety) and release shall be solely incumbent upon Licensee. 
* For the avoidance of doubt, Licensee shall be responsible and fully liable for the applications and any distribution of such applications into the market.
* 
* 
* Redistribution and use in source and binary forms, with or without 
* modification, are permitted provided that the following conditions are 
* met:
* 
*     (1) Redistributions of source code must retain the above copyright
*     notice, this list of conditions and the following disclaimer. 
* 
*     (2) Redistributions in binary form must reproduce the above copyright
*     notice, this list of conditions and the following disclaimer in
*     the documentation and/or other materials provided with the
*     distribution.  
*     
*     (3)The name of the author may not be used to
*     endorse or promote products derived from this software without
*     specific prior written permission.
* 
*  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 
*  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
*  DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
*  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
*  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
*  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
*  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
*  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
*  IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
*  POSSIBILITY OF SUCH DAMAGE.
*/
/*----------------------------------------------------------------------------*/
/**
* @ingroup APPS_LIST
*
* @defgroup XDK_APPLICATION_TEMPLATE XDK Application Template
* @{
*
* @brief XDK Application Template
*
* @details Empty XDK Application Template without any functionality. Should be used as a template to start new projects.
*
* @file
**/
/* module includes ********************************************************** */

/* system header files */
#include <stdio.h>
/* additional interface header files */
#include "FreeRTOS.h"
#include "timers.h"

/* own header files */
#include "XdkApplicationTemplate.h"
#include "BCDS_CmdProcessor.h"
#include "BCDS_Assert.h"

#include "BCDS_BSP.h"
#undef BCDS_MODULE_ID
#define BCDS_MODULE_ID BCDS_BSP_MODULE_ID_MIC_AKU340

#include "BCDS_HAL.h"
#if BCDS_FEATURE_BSP_MIC_AKU340

#include "BCDS_BSP_Mic_AKU340.h"
#include "BSP_BoardType.h"
#include "BSP_Mic_AKU340.h"
#include "BSP_BoardSettings.h"
#include "BSP_BoardShared.h"


static bool micEnabled = false;
/*
 * Refer to interface header for description
 */
Retcode_T BSP_Mic_AKU340_Connect(void)
{

    /**
     * Due to electrical issues noted,
     * the AKU VOUT port has to be permanently drained using
     * a pull-down to ground level in order to avoid charge accumulation
     */
	GPIO_PinModeSet(VDD_AKU_PORT, VDD_AKU_PIN, gpioModePushPull, 0);
    GPIO_PinModeSet(AKU_OUT_PORT, AKU_OUT_PIN, gpioModeInputPull, 0);
    return RETCODE_OK;
}

/*
 * Refer to interface header for description
 */
Retcode_T BSP_Mic_AKU340_Enable(void)
{
    micEnabled = true;

	Board_WakeupPowerSupply2V5(MIC_AKU340);

    GPIO_PinOutSet(VDD_AKU_PORT, VDD_AKU_PIN);
    GPIO_PinOutClear(AKU_OUT_PORT, AKU_OUT_PIN);
    return RETCODE_OK;
}



int32_t BSP_Mic_AKU340_Sense(void)
{
    ADC_InitSingle_TypeDef singleInit = ADC_INITSINGLE_DEFAULT;
    int32_t sample;
   sample = BSP_Mic_AKU340_Sense();
}
#endif /* BCDS_FEATURE_BSP_MIC_AKU340 */

/**
 * @brief This is a template function where the user can write his custom application.
 *
 */
void appInitSystem(void * CmdProcessorHandle, uint32_t param2)
{
    if (CmdProcessorHandle == NULL)
    {
        printf("Command processor handle is null \n\r");
        assert(false);
    }
    BCDS_UNUSED(param2);
}

Regards

Zhefei

0 (0 Votes)
RE: Acceleration and acoustic Sensor
Answer
11/28/17 3:57 PM as a reply to Zhefei Xiao.

Hello Zhefei,

I actually only explained how to use the functions provided by the interface BCDS_BSP_Mic_AKU340.h. Copying the implementation into your application will not work as you might thought it will be.

I would recommend to follow the instructions from my last post.

The implementation in your appInitSystem() should look like this, for example:

void appInitSystem(void * CmdProcessorHandle, uint32_t param2) {

    if (CmdProcessorHandle == NULL) {

    printf("Command processor handle is null \n\r");

    assert(false);

    }

    BSP_Mic_AKU340_Connect();

    BSP_Mic_AKU340_Enable();

    // Create a timer for reading the acoustic sensor here

}

Furthermore, sampling the acoustic sensor should look as follows:

void readAcousticSensor(xTimerHandle xTimer){

    BCDS_UNUSED(xTimer);

    int32_t sample; sample = BSP_Mic_AKU340_Sense();

    // Further implementation...

}

You can use this function in a timer. For more information on timers, please refer to the FreeRTOS Guide, which you can find in the XDK's Guide Section.
Currently, you replaced the entire implementation of BSP_Mic_AKU340_Sense() with the code I previously posted. That will not work either and will only result in a stack overflow. My explanation was based on how to use the function to read the data from the acoustic sensor in a similar way as with the accelerometer.

Since you are a beginner with the XDK, I would strongly recommend going through the first steps guide to get familiar with how to program applications on the XDK efficiently.

Please let me know if that was helpful and do not hesitate to ask if you have further questions.

Kind regards,
Franjo

0 (0 Votes)
RE: Acceleration and acoustic Sensor
Answer
11/29/17 8:41 AM as a reply to Franjo Stjepandic.

Hi Franjo!

Thank you for the reply.

I combined the acoustic functions you mentioned and the example in first steps guide.

But I think I need to figure out how to call the acoustic functions in my own application. It seems that calling acoustic functions is not the same as calling functions of other sensors. May I ask for some help on that?

/* system header files */
#include <stdio.h>
/* additional interface header files */
#include "FreeRTOS.h"
#include "timers.h"

/* own header files */
#include "XdkApplicationTemplate.h"
#include "BCDS_CmdProcessor.h"
#include "BCDS_Assert.h"
#include "XdkSensorHandle.h"
#include "BCDS_BSP_Mic_AKU340.h"

static void initAkuSensor(void)
{
	Retcode_T returnValue = RETCODE_FAILURE;
	BSP_Mic_AKU340_Connect();
	returnValue = BSP_Mic_AKU340_Enable();
	if(RETCODE_OK != returnValue)
	{
		printf("Aku Sensor Initialization Failed\n\r");
	}
}

void readAkuSensor(xTimerHandle xTimer)
{
	BCDS_UNUSED(xTimer);
	int32_t sample;
	sample = BSP_Mic_AKU340_Sense();
	printf("Aku sensor data obtained in Voltage :%lu mV\n\r",(unsigned long)sample);

}


/**
 * @brief This is a template function where the user can write his custom application.
 *
 */
void appInitSystem(void * CmdProcessorHandle, uint32_t param2)
{
    if (CmdProcessorHandle == NULL)
    {
        printf("Command processor handle is null \n\r");
        assert(false);
    }
    BCDS_UNUSED(param2);
    initAkuSensor();

    uint32_t timerBlockTime = UINT32_MAX;
    uint32_t oneSecondDelay = UINT32_C(1000);
    uint32_t timerAutoReloadOn = pdTRUE;

    xTimerHandle AkuSensorHandle = NULL;

    AkuSensorHandle = xTimerCreate((const char *) "readAkuSensor",
    oneSecondDelay,timerAutoReloadOn, NULL, readAkuSensor);

    xTimerStart(AkuSensorHandle,timerBlockTime);
}

Actually, the acoustic relating functions are undeclared after building the project.

Regards

Zhefei

0 (0 Votes)
RE: Acceleration and acoustic Sensor
Answer
11/29/17 5:08 PM as a reply to Zhefei Xiao.

Hello Zhefei,

the code should now work as intended, but in an earlier post, I told you to add the line

#define BCDS_FEATURE_BSP_MIC_AKU340    1

in BCDS_HALConfig.h. Have you done this? If you have not, then this would explain why the compiler can't find the implementations of the functions. In that case, I would ask you to do take a look at my previous post.

If you have already done this, could you verify that the same macro as defined above is used on line 54 in the implementation file

SDK > xdk110 > Platform > BSP > source > BSP_Mic_AKU340.c

The corresponding line should be:

#if BCDS_FEATURE_BSP_MIC_AKU340

If it is not, please change it accordingly, then clean the project and build it again. Additionaly, if this does not solve your issue, could you additionally tell me your Workbench Version?

Please tell me if this was helpful, and do not hesitate to ask further questions.

Kind regards,
Franjo

0 (0 Votes)
RE: Acceleration and acoustic Sensor
Answer
12/4/17 11:35 AM as a reply to Franjo Stjepandic.

Hi Franjo,

first of all, I want to thank you for the previous help from you! I successfully activated acoustic sensor!

Now I am trying to store the sensor data into sd card. After reading the sdcardexample and the Datalogger demo, I created the following code:

#include "XDKAppInfo.h"
#undef BCDS_MODULE_ID  /* Module ID define before including Basics package*/
#define BCDS_MODULE_ID XDK_APP_MODULE_ID_SDCARD_EXAMPLE

/* own header files */
#include "SDCardExample.h"

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

/* additional interface header files */
#include "BCDS_SDCard_Driver.h"
#include "BCDS_CmdProcessor.h"
#include "BSP_BoardType.h"
#include "BCDS_BSP_LED.h"
#include "ff.h"
#include "BCDS_Assert.h"
#include <FreeRTOS.h>
#include <timers.h>
#include "XdkSensorHandle.h"
#include "BCDS_BSP_Mic_AKU340.h"


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

/* local variables ********************************************************** */
static xTimerHandle sdCardWriteReadHandle; /**< variable to store timer handle*/
static CmdProcessor_T *AppCmdProcessor; /**< Application Command Processor Instance */
static SDCardDriver_DiskStatus_T diskInitStatus = SDCARD_NOT_INITIALIZED;
#if FAT_FILE_SYSTEM==1
static FATFS FatFileSystemObject; /* File system specific objects */
#endif
/* global variables ********************************************************* */

/* local module global variable declarations */

uint8_t writeBuffer[SINGLE_SECTOR_LEN] = "XDK ASAMPLE TEST FOR MMC"; /**< Write Buffer for SD-Card */
uint8_t readBuffer[SINGLE_SECTOR_LEN]; /**< read buffer for SD-Card */

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

static void initAccelSensor(void){

	Retcode_T accelerometerInitReturnValue = RETCODE_FAILURE;
	Retcode_T returnBandwidthValue = RETCODE_FAILURE;
	Retcode_T returnRangeValue = RETCODE_FAILURE;

accelerometerInitReturnValue =
Accelerometer_init(xdkAccelerometers_BMA280_Handle);

if (RETCODE_OK != accelerometerInitReturnValue) {
	printf("Acce Sensor initialization Failed\n\r");
}

returnBandwidthValue =
Accelerometer_setBandwidth(xdkAccelerometers_BMA280_Handle,
ACCELEROMETER_BMA280_BANDWIDTH_500HZ);

if (RETCODE_OK != returnBandwidthValue) {
	printf("Acce Sensor bandwidth setting Failed\n\r");
}

returnRangeValue =
Accelerometer_setRange(xdkAccelerometers_BMA280_Handle,ACCELEROMETER_BMA280_RANGE_16G);

if (RETCODE_OK != returnRangeValue) {
	printf("Acce Sensor range setting Failed\n\r");
}
}

static void initAkuSensor(void)
{
	Retcode_T returnValue = RETCODE_FAILURE;
	BSP_Mic_AKU340_Connect();
	returnValue = BSP_Mic_AKU340_Enable();
	if(RETCODE_OK != returnValue)
	{
		printf("Aku Sensor Initialization Failed\n\r");
	}
}

#if FAT_FILE_SYSTEM==1
/**
 * @brief
 *      The sdCardFatFileSystemWriteRead API uses the FAT file system library calls.
 *      This API will mount and create the file system, then it will open, seek write,
 *      read and close the files. This API will compare the contents which has been
 *      written and read.
 *
 * @retval
 *      SDCARD_APP_NO_ERROR - All the file operations are success
 *
 * @retval
 *      SDCARD_APP_ERROR - one of the file operation failed
 *
 * @retval
 *      SDCARD_INIT_FAILED - disk has not been initialized
 */
static Retcode_T sdCardFatFileSystemWriteRead(void)
{
	Retcode_T returnvalue = RETCODE_FAILURE;
    Accelerometer_XyzData_T bma280 = {INT32_C(0), INT32_C(0), INT32_C(0)};
	memset(&bma280, 0, sizeof(Accelerometer_XyzData_T));
	returnvalue = Accelerometer_readXyzGValue(xdkAccelerometers_BMA280_Handle,&bma280);

	int32_t sample;
	sample = BSP_Mic_AKU340_Sense();

    FIL fileObject; /* File objects */
    int8_t ramBufferWrite[BUFFER_SIZE]; /* Temporary buffer for write file */
    int8_t ramBufferRead[BUFFER_SIZE]; /* Temporary buffer for read file */
    int8_t stringTestBuffer[50];
    uint16_t fileSize;
    UINT bytesWritten;
    UINT bytesRead;
    uint8_t fileStatus = FILE_EQUAL;

    Retcode_T result;
    FRESULT fileSystemResult;

    /* read and print BMA280 accelerometer data */
    Retcode_T returnValue = RETCODE_FAILURE;

    returnValue = Accelerometer_init(xdkAccelerometers_BMA280_Handle);

    if ( RETCODE_OK != returnValue)
    {
    	 printf("return AccelSensor Data failed\n\r");
    }

    /*Step1 - Initialization of file buffer write */
    if (RETCODE_OK == returnvalue)
    {
         snprintf( stringTestBuffer, sizeof stringTestBuffer , "BMA280 X-data: %ld" , (long int) bma280.xAxisData);
         snprintf( stringTestBuffer, sizeof stringTestBuffer , "BMA280 y-data: %ld" , (long int) bma280.yAxisData);
         snprintf( stringTestBuffer, sizeof stringTestBuffer , "BMA280 z-data: %ld" , (long int) bma280.zAxisData);
         snprintf( stringTestBuffer, sizeof stringTestBuffer , "AKU340 %lu ",(unsigned long)sample);
    }

    /* step2 - Initialization of SD card */
    if (diskInitStatus != SDCARD_DISK_INITIALIZED) /*SD-Card Disk Not Initialized */
    {
        diskInitStatus = (SDCardDriver_DiskStatus_T)SDCardDriver_DiskInitialize(DRIVE_ZERO); /* Initialize SD card */
    }

    if (SDCARD_DISK_INITIALIZED == diskInitStatus)
    {
        /*Step1 - open the file to write */
        /*  If file does not exist create it*/
        fileSystemResult = f_open(&fileObject, TEST_FILENAME,
        FA_OPEN_ALWAYS | FA_WRITE);
        if (fileSystemResult != FR_OK)
        {
            /* Error. Cannot create the file */
            return RETCODE(RETCODE_SEVERITY_ERROR, FILE_OPEN_ERROR);
        }

        /*Step2 - Set the file write pointer to first location */
        fileSystemResult = f_lseek(&fileObject, f_size(&fileObject));
        if (fileSystemResult != FR_OK)
        {
            /* Error. Cannot set the file write pointer */
            return RETCODE(RETCODE_SEVERITY_ERROR, FILE_LSEEK_ERROR);
        }

        /*Step3 - Write a buffer to file*/
        fileSystemResult = f_write(&fileObject, ramBufferWrite, fileSize,
                &bytesWritten);
        if ((fileSystemResult != FR_OK) || (fileSize != bytesWritten))
        {
            /* Error. Cannot write the file */
            return RETCODE(RETCODE_SEVERITY_ERROR, FILE_WRITE_ERROR);
        }

        /*Step4 - Close the file */
        fileSystemResult = f_close(&fileObject);
        if (fileSystemResult != FR_OK)
        {
            /* Error. Cannot close the file */
            return RETCODE(RETCODE_SEVERITY_ERROR, FILE_CLOSE_ERROR);
        }

        /*Step5 - Open the file for read */
        fileSystemResult = f_open(&fileObject, TEST_FILENAME, FA_READ);
        if (fileSystemResult != FR_OK)
        {
            /* Error. Cannot create the file */
            return RETCODE(RETCODE_SEVERITY_ERROR, FILE_OPEN_ERROR);
        }

        /*Step6 - Set the file read pointer to first location */
        fileSystemResult = f_lseek(&fileObject, (f_size(&fileObject) - fileSize));
        if (fileSystemResult != FR_OK)
        {
            /* Error. Cannot set the file pointer */
            return RETCODE(RETCODE_SEVERITY_ERROR, FILE_LSEEK_ERROR);
        }

        /*Step7 - Read some data from file */
        fileSystemResult = f_read(&fileObject, ramBufferRead, fileSize,
                &bytesRead);
        if ((fileSystemResult != FR_OK) || (fileSize != bytesRead))
        {
            /* Error. Cannot read the file */
            return RETCODE(RETCODE_SEVERITY_ERROR, SDCARD_APP_ERROR);
        }

        /*Step8 - Close the file */
        fileSystemResult = f_close(&fileObject);
        if (fileSystemResult != FR_OK)
        {
            /* Error. Cannot close the file */
            return RETCODE(RETCODE_SEVERITY_ERROR, FILE_CLOSE_ERROR);
        }

        /*Step9 - Compare ramBufferWrite and ramBufferRead */
        for (uint8_t index = 0; index < fileSize; index++)
        {
            if ((ramBufferWrite[index]) != (ramBufferRead[index]))
            {
                /* Error compare buffers*/
                fileStatus = FILE_NOT_EQUAL;
            }
        }

        if (FILE_EQUAL == fileStatus)
        {
            return RETCODE_OK;
        }
        else
        {
            return RETCODE(RETCODE_SEVERITY_ERROR, SDCARD_APP_ERROR);
        }
    }
    else
    {
        result = RETCODE(RETCODE_SEVERITY_ERROR, SDCARD_INIT_FAILED);
    }
    return (result);
}
#else

/**
 * @brief
 *      The sdCardSingleBlockWriteRead API is used to write some string and read the string.
 *      then validate the written and read string.
 *
 * @param[in] sector
 *        SDC Disk sector value for read/Write process.
 *
 * @retval
 *      SDCARD_INIT_FAILED - disk has not been initialized
 */
static Retcode_T sdCardSingleBlockWriteRead(uint32_t sector)
{

    Retcode_T sdcWriteReadStatus; /* Default return value is in Error state */

    if (diskInitStatus != SDCARD_DISK_INITIALIZED)
    { /*SD-Card Disk Not Initialized */
        diskInitStatus = SDCardDriver_DiskInitialize(DRIVE_ZERO);/* Initialize SD card */
    }

    if (diskInitStatus == SDCARD_DISK_INITIALIZED)
    {
        if (SDCardDriver_DiskWrite(DRIVE_ZERO, writeBuffer, sector, SINGLE_BLOCK) == RETCODE_OK)
        {/* Write Data into SD-Card */
            if (SDCardDriver_DiskRead(DRIVE_ZERO, readBuffer, sector, SINGLE_BLOCK) == RETCODE_OK)
            {/* Read Data's from the SD-CARD */
                int8_t sdCardWriteReadCheck; /* Validate the SD_card Write/read Buffer */
                sdCardWriteReadCheck = strncmp((const char*) writeBuffer, (const char*) readBuffer, sizeof(writeBuffer));
                if (INT8_C(0) == sdCardWriteReadCheck )
                {
                    sdcWriteReadStatus = RETCODE_OK;
                }
                else
                {
                    sdcWriteReadStatus = RETCODE(RETCODE_SEVERITY_ERROR, SDCARD_APP_ERROR);
                }
            }
            else
            { /* SDC Read failure */
                printf("\r\nSD_CARD Read failure\n\r");
                sdcWriteReadStatus = RETCODE(RETCODE_SEVERITY_ERROR, FILE_READ_ERROR);
            }
        }
        else
        { /* SDC Write failure */
            printf("\r\nSD_CARD Write failure\n\r");
            sdcWriteReadStatus = RETCODE(RETCODE_SEVERITY_ERROR, FILE_WRITE_ERROR);
        }
    }
    else
    {
        printf("\r\nSD_CARD Initialize failure\n\r");
        sdcWriteReadStatus = RETCODE(RETCODE_SEVERITY_ERROR, SDCARD_INIT_FAILED);
    }

    return (sdcWriteReadStatus);
}

#endif

/** @brief
 *      The function used to write and read depending on the SD card Detect status .
 *      The status can be SD card inserted or not inserted.
 *
 *  @param[in] void *pvParameters
 *      Rtos task should be defined with the type void *(as argument).
 */
static void SDCardWriteRead(void *pvParameters)
{
    Retcode_T returnVal = RETCODE_OK;
    BCDS_UNUSED(pvParameters);
#if FAT_FILE_SYSTEM==1
    FRESULT FileSystemResult = FR_OK;
#endif
    static uint8_t sdcardeject = FALSE;
    static uint8_t sdcardInsert = FALSE;

    Retcode_T sdCardWriteReadReturn = RETCODE(RETCODE_SEVERITY_ERROR, SDCARD_APP_ERROR); /* variable for SD-Card ReadWrite status check */

    /* Get the SD Card status as inserted in XDK or not */
    if (SDCARD_INSERTED == SDCardDriver_GetDetectStatus())
    {
        sdcardInsert = TRUE;
        printf("SD card is inserted in XDK\n\r");

        returnVal = BSP_LED_Switch((uint32_t) BSP_XDK_LED_R, (uint32_t) BSP_LED_COMMAND_ON); /**< Switch ON LED1 */

        if (returnVal != RETCODE_OK)
        {
            printf("SD card is inserted LED indication failure XDK\n\r");
        }
        if (sdcardeject == TRUE)
        {
            if (RETCODE_OK == returnVal)
            {
                returnVal = SDCardDriver_DiskInitialize(DRIVE_ZERO);
                if (RETCODE_OK == returnVal)
                {
                    diskInitStatus = SDCARD_DISK_INITIALIZED;
                }
            }

#if FAT_FILE_SYSTEM==1
            if (RETCODE_OK == returnVal)
            {
                FileSystemResult = f_mount(&FatFileSystemObject, DEFAULT_LOGICAL_DRIVE, FORCE_MOUNT);
                if (FR_OK != FileSystemResult)
                {
                    printf("f_mount failed hence read and write in Sdcard using FATfs is not possible \n\r");
                    assert(0);
                    return;
                }
            }
#endif
            sdcardeject = FALSE;
        }
#if FAT_FILE_SYSTEM==1 /* Already restrict this value to be 0 or 1. */
        /* SDC Disk FAT file system Write/Read functionality */
        sdCardWriteReadReturn = sdCardFatFileSystemWriteRead();
        if (sdCardWriteReadReturn == RETCODE_OK)
        {
            printf("Write and read using FAT file system success \n\r");
        }
        else
        {
            printf("Write and read using FAT file system failed\n\r");
        }
#else /* FAT_FILE_SYSTEM == 0 */
        /* SDC Disk  single block write and read without FAT file system  */
        sdCardWriteReadReturn = sdCardSingleBlockWriteRead(SECTOR_VALUE);
        if (sdCardWriteReadReturn == RETCODE_OK)
        {
            printf("single block write and read without FAT file system success \n\r");
        }
        else
        {
            printf("single block write and read without FAT file system failed \n\r");
        }
#endif /* FAT_FILE_SYSTEM == 1 */
    }
    else
    {
        if (TRUE == sdcardInsert)
        {
            sdcardeject = TRUE;
        }
        sdcardInsert = FALSE;
        printf("\r\nSD card is not inserted in XDK\n\r");

        returnVal = BSP_LED_Switch((uint32_t) BSP_XDK_LED_R, (uint32_t) BSP_LED_COMMAND_OFF); /**< Switch OFF LED1 */
        if (returnVal != RETCODE_OK)
        {
            printf("SD card is not inserted LED indication failure XDK\n\r");
        }
    }
}

/*
 * Defines the prototype to which timer callback functions must conform.
 */
/**
 * @brief        This is a application timer callback function used to enqueue SDCardwriteread function
 *               to the command processor.
 *
 * @param[in]    pvParameters unused parameter.
 */
static void EnqueueSDCardWriteread(void *pvParameters)
{
    BCDS_UNUSED(pvParameters);

    Retcode_T retVal = CmdProcessor_enqueue(AppCmdProcessor, (CmdProcessor_Func_T) SDCardWriteRead, NULL, UINT32_C(0));
    if (RETCODE_OK != retVal)
    {
        printf("Failed to Enqueue SDCard write read to Application Command Processor \r\n");
    }
}

/**
 * @brief
 *      The SDC_sdCardWriteReadInit API creates a Write/read task and starts the task.
 */
static void Init(void)
{
    Retcode_T retVal;
#if FAT_FILE_SYSTEM==1
    FRESULT FileSystemResult = FR_OK;
    FILINFO FileInfo;
#endif
    static_assert((portTICK_RATE_MS != 0), "Tick rate MS is zero");

    retVal = SDCardDriver_Initialize();
    if (RETCODE_OK == retVal)
    {
        retVal = SDCardDriver_DiskInitialize(DRIVE_ZERO);
        if (RETCODE_OK == retVal)
        {
            diskInitStatus = SDCARD_DISK_INITIALIZED;
        }
    }

#if FAT_FILE_SYSTEM==1
    if (RETCODE_OK == retVal)
    {
        FileSystemResult = f_mount(&FatFileSystemObject, DEFAULT_LOGICAL_DRIVE, FORCE_MOUNT);
        if (FR_OK == FileSystemResult)
        {
            FileSystemResult = f_stat(TEST_FILENAME, &FileInfo);
            if (FR_OK == FileSystemResult)
            {
                FileSystemResult = f_unlink(TEST_FILENAME);
            }
            if (FR_NO_FILE == FileSystemResult)
            {
                printf("File does not exist. \n\r");
            }
        }
        else
        {
            printf("f_mount failed hence read and write in Sdcard using FATfs is not possible \n\r");
            assert(0);
            return;
        }
    }
#endif

    if (RETCODE_OK == retVal)
    {
        /* create timer task to write and read data form SDCard one second automatically*/
        sdCardWriteReadHandle = xTimerCreate(
                (const char * const ) "SDCardWriteRead",
                pdMS_TO_TICKS(WRITEREAD_DELAY), TIMER_AUTORELOAD_ON, NULL, EnqueueSDCardWriteread);

        if ((NULL != sdCardWriteReadHandle)) /* Timer was not created */
        {
            /* start the created timer */
            if (pdTRUE != xTimerStart(sdCardWriteReadHandle,
                    WRITEREAD_BLOCK_TIME))
            {
                printf("Failed to initialize because of SDCard/Command Processor/Timer Create fail \n");
                assert(false);
            }
        }
    }
}

/**
 * @brief This is a template function where the user can write his custom application.
 *
 */
void appInitSystem(void * CmdProcessorHandle, uint32_t param2)
{
 if (CmdProcessorHandle == NULL)
 {
 printf("Command processor handle is null \n\r");
 assert(false);
 }
 BCDS_UNUSED(param2);

    uint32_t timerBlockTime = UINT32_MAX;
    uint32_t oneSecondDelay = UINT32_C(5000);
    uint32_t timerAutoReloadOn = pdTRUE;

    xTimerHandle SensorHandle = NULL;
    SensorHandle = xTimerCreate((const char *) "sdCardFatFileSystemWriteRead",
    oneSecondDelay,timerAutoReloadOn, NULL, sdCardFatFileSystemWriteRead);

 initAccelSensor();
 initAkuSensor();
 Init();
 sdCardFatFileSystemWriteRead();
}


/**
 * @brief
 *      The SDC_sdCardWriteReadDeInit API Delete the Write/read task.
 *
 * @retval
 *      SDCARD_APP_NO_ERROR  Task was created successfully.
 */
Retcode_T DeInit(void)
{

    Retcode_T DeInitStatus = RETCODE(RETCODE_SEVERITY_ERROR, SDCARD_DE_INIT_FAILED); /* Default return value is in Error Deinit state */

    if (pdFAIL != xTimerStop(sdCardWriteReadHandle,
            WRITEREAD_BLOCK_TIME))
    {
        DeInitStatus = RETCODE_OK;
    }

    return (DeInitStatus);

But what I got in sd card is a txt file containing random characters, not sensor data.

May I ask for some help upon this?

Regards

Zhefei

0 (0 Votes)
RE: Acceleration and acoustic Sensor
Answer
12/4/17 5:48 PM as a reply to Zhefei Xiao.

Hello Zhefei,

I am glad to hear that you were able to make the acoustic sensor implementation work.

Regarding your new issue, I would ask you to open a new thread for this issue, since the initial issue of this thread is already solved.

Other users with similar issues will find the proposed solutions more easily, when there is only one thread per issue.

Nevertheless, I will deal with your issue immediately, after you open the new thread.

Kind regards,
Franjo

0 (0 Votes)