Skip to content

Commit

Permalink
Sensors - Add LSM6DSOX example (#2)
Browse files Browse the repository at this point in the history
Add a sensors example using the LSM6DSOX and the Nucleo IKS01A2. Work with I2C, test all sensors, display values on LCD screen and on serial connection.
  • Loading branch information
YannLocatelli authored and ladislas committed May 15, 2020
1 parent adfdcf5 commit c00c365
Show file tree
Hide file tree
Showing 173 changed files with 76,756 additions and 0 deletions.
4 changes: 4 additions & 0 deletions LKExp-mbed-x-nucleo-iks01a2/.mbed
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MBED_OS_DIR=./lib/mbed-os
TARGET=disco_f769ni
TOOLCHAIN=GCC_ARM
ROOT=.
24 changes: 24 additions & 0 deletions LKExp-mbed-x-nucleo-iks01a2/.mbedignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
### Ignored directories to speed up compilation time

test/**
#lib/mbed-os/components/**
lib/mbed-os/features/cellular/**
lib/mbed-os/features/cryptocell/**
lib/mbed-os/features/deprecated_warnings/**

lib/mbed-os/features/FEATURE_BLE/**
lib/mbed-os/features/FEATURE_BOOTLOADER/**

lib/mbed-os/features/lorawan/**
lib/mbed-os/features/lwipstack/**

lib/mbed-os/features/nanostack/**
lib/mbed-os/features/netsocket/**
lib/mbed-os/features/nfc/**
lib/mbed-os/features/unsupported/**

### Needed directories

# lib/mbed-os/features/device_key/**
# lib/mbed-os/features/frameworks/**
# lib/mbed-os/features/mbedtls/**
26 changes: 26 additions & 0 deletions LKExp-mbed-x-nucleo-iks01a2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# LKExp-mbed-X\_NUCLEO\_IKS01A2

## Goal

Run mbed examples with X\_NUCLEO\_IKS01A2 board, especially motion MEMS.

## Ressources

[X-NUCLEO-IKS01A2 ST page](https://www.st.com/en/ecosystems/x-nucleo-iks01a2.html#resource)
[X\_NUCLEO\_IKS01A2 on os.mbed.com](https://os.mbed.com/components/X-NUCLEO-IKS01A2/)

To display in other IRQ : [Simplify your code with mbed events](https://os.mbed.com/blog/entry/Simplify-your-code-with-mbed-events/)

Autre source de drivers, hors mbed (fournie par Ladislas) : <https://github.com/STMicroelectronics/STMems_Standard_C_drivers>

### LSM6DSOX
To use LSM6DSOX on the STEVAL-MKI197V1 with X-NUCLEO-IKS01A2:

* [LSM6DSOX ST page](https://www.st.com/en/mems-and-sensors/lsm6dsox.html).
* [LSM6DSOX datasheet](https://www.st.com/resource/en/datasheet/lsm6dsox.pdf) to understand how it works.
* [How to use the sensor on a DIL 24 socket](https://www.st.com/resource/en/application_note/dm00628155-how-to-use-a-sensor-on-a-dil-24-socket-in-xcubemems1-package-applications-stmicroelectronics.pdf) (case of STEVAL-MKI197V1). Application note using LSM6DSO instead of LSM6DSOX but process could be similar.
* [STEVAL-MKI197V1 schematic](https://www.st.com/content/ccc/resource/technical/layouts_and_diagrams/schematic_pack/group0/d3/08/61/50/15/e4/46/7e/STEVAL-MKI197V1_SCHEMATIC/files/steval-mki197v1_schematic.pdf/jcr:content/translations/en.steval-mki197v1_schematic.pdf) to identify pins from LSM6DSOX to X-NUCLEO-IKS01A2.
* [X-NUCLEO-IKS01A2 ST page](https://www.st.com/en/ecosystems/x-nucleo-iks01a2.html).
* [X-NUCLEO-IKS01A2 UM](https://www.st.com/resource/en/user_manual/dm00333132-getting-started-with-the-xnucleoiks01a2-motion-mems-and-environmental-sensor-expansion-board-for-stm32-nucleo-stmicroelectronics.pdf) to understand how it works.
* [X-NUCLEO-IKS01A2 schematic](https://www.st.com/content/ccc/resource/technical/layouts_and_diagrams/schematic_pack/group0/e1/7a/8c/96/73/11/4e/0a/X-NUCLEO-IKS01A2%20schematics/files/x-nucleo-iks01a2_schematic.pdf/jcr:content/translations/en.x-nucleo-iks01a2_schematic.pdf) to identify pins from X-NUCLEO-IKS01A2 to "Arduino connector" pins (associated with "Arduino connector" STM32F769I-DISCO for example). Plus understand how to configure hardware to set Mode 2 presented in LSM6DSOX datasheet.
* [LSM6DSOX library under mbed](https://os.mbed.com/teams/ST/code/LSM6DSOX/)
1 change: 1 addition & 0 deletions LKExp-mbed-x-nucleo-iks01a2/lib/BSP_DISCO_F769NI.lib
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://os.mbed.com/teams/ST/code/BSP_DISCO_F769NI/#d13d7c447539
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/**
******************************************************************************
* @file accelero.h
* @author MCD Application Team
* @version V4.0.1
* @date 21-July-2015
* @brief This header file contains the functions prototypes for the Accelerometer driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
*
* 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. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDER OR CONTRIBUTORS 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.
*
******************************************************************************
*/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __ACCELERO_H
#define __ACCELERO_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include <stdint.h>

/** @addtogroup BSP
* @{
*/

/** @addtogroup Components
* @{
*/

/** @addtogroup ACCELERO
* @{
*/

/** @defgroup ACCELERO_Exported_Types
* @{
*/

/** @defgroup ACCELERO_Driver_structure Accelerometer Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t);
void (*DeInit)(void);
uint8_t (*ReadID)(void);
void (*Reset)(void);
void (*LowPower)(void);
void (*ConfigIT)(void);
void (*EnableIT)(uint8_t);
void (*DisableIT)(uint8_t);
uint8_t (*ITStatus)(uint16_t);
void (*ClearIT)(void);
void (*FilterConfig)(uint8_t);
void (*FilterCmd)(uint8_t);
void (*GetXYZ)(int16_t *);
}ACCELERO_DrvTypeDef;
/**
* @}
*/

/** @defgroup ACCELERO_Configuration_structure Accelerometer Configuration structure
* @{
*/

/* ACCELERO struct */
typedef struct
{
uint8_t Power_Mode; /* Power-down/Normal Mode */
uint8_t AccOutput_DataRate; /* OUT data rate */
uint8_t Axes_Enable; /* Axes enable */
uint8_t High_Resolution; /* High Resolution enabling/disabling */
uint8_t BlockData_Update; /* Block Data Update */
uint8_t Endianness; /* Endian Data selection */
uint8_t AccFull_Scale; /* Full Scale selection */
uint8_t Communication_Mode;
}ACCELERO_InitTypeDef;

/* ACCELERO High Pass Filter struct */
typedef struct
{
uint8_t HighPassFilter_Mode_Selection; /* Internal filter mode */
uint8_t HighPassFilter_CutOff_Frequency; /* High pass filter cut-off frequency */
uint8_t HighPassFilter_AOI1; /* HPF_enabling/disabling for AOI function on interrupt 1 */
uint8_t HighPassFilter_AOI2; /* HPF_enabling/disabling for AOI function on interrupt 2 */
uint8_t HighPassFilter_Data_Sel;
uint8_t HighPassFilter_Stat;
}ACCELERO_FilterConfigTypeDef;

/**
* @}
*/


/**
* @}
*/

/**
* @}
*/

/**
* @}
*/

/**
* @}
*/

#ifdef __cplusplus
}
#endif

#endif /* __ACCELERO_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/**
******************************************************************************
* @file audio.h
* @author MCD Application Team
* @version V4.0.1
* @date 21-July-2015
* @brief This header file contains the common defines and functions prototypes
* for the Audio driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
*
* 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. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDER OR CONTRIBUTORS 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.
*
******************************************************************************
*/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __AUDIO_H
#define __AUDIO_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include <stdint.h>

/** @addtogroup BSP
* @{
*/

/** @addtogroup Components
* @{
*/

/** @addtogroup AUDIO
* @{
*/

/** @defgroup AUDIO_Exported_Constants
* @{
*/

/* Codec audio Standards */
#define CODEC_STANDARD 0x04
#define I2S_STANDARD I2S_STANDARD_PHILIPS

/**
* @}
*/

/** @defgroup AUDIO_Exported_Types
* @{
*/

/** @defgroup AUDIO_Driver_structure Audio Driver structure
* @{
*/
typedef struct
{
uint32_t (*Init)(uint16_t, uint16_t, uint8_t, uint32_t);
void (*DeInit)(void);
uint32_t (*ReadID)(uint16_t);
uint32_t (*Play)(uint16_t, uint16_t*, uint16_t);
uint32_t (*Pause)(uint16_t);
uint32_t (*Resume)(uint16_t);
uint32_t (*Stop)(uint16_t, uint32_t);
uint32_t (*SetFrequency)(uint16_t, uint32_t);
uint32_t (*SetVolume)(uint16_t, uint8_t);
uint32_t (*SetMute)(uint16_t, uint32_t);
uint32_t (*SetOutputMode)(uint16_t, uint8_t);
uint32_t (*Reset)(uint16_t);
}AUDIO_DrvTypeDef;
/**
* @}
*/

/**
* @}
*/

/**
* @}
*/

/**
* @}
*/

/**
* @}
*/

#ifdef __cplusplus
}
#endif

#endif /* __AUDIO_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Loading

0 comments on commit c00c365

Please sign in to comment.