initial working (stm32f4-discovery)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
---
|
||||
name: 'Bug report'
|
||||
about: 'Create a report to help us improve the quality of our software'
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
**Caution**
|
||||
|
||||
The Issues are strictly limited for the reporting of problem encountered with the software provided in this project.
|
||||
For any other problem related to the STM32 product, the performance, the hardware characteristics and boards, the tools the environment in general, please post your report to the **ST Community** in the STM32 MCUs dedicated [page](https://community.st.com/s/group/0F90X000000AXsASAW/stm32-mcus).
|
||||
|
||||
**Describe the set-up**
|
||||
|
||||
* The board (either ST RPN reference or your custom board)
|
||||
* IDE or at least the compiler and its version
|
||||
|
||||
**Describe the bug (skip if none)**
|
||||
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**How to reproduce the bug (skip if none)**
|
||||
|
||||
1. Indicate the global behavior of your application project
|
||||
2. List the modules that you suspect to be the cause of the problem (Drivers, BSP, MW...)
|
||||
3. Describe the use case that generates the problem
|
||||
4. How we can reproduce the problem
|
||||
|
||||
|
||||
**Additional context**
|
||||
|
||||
If you have a first analysis, an enhancement, a fix or a patch, thank you to share your proposal.
|
||||
|
||||
**Screenshots**
|
||||
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
@@ -0,0 +1,3 @@
|
||||
## IMPORTANT INFORMATION
|
||||
|
||||
Pull-requests are **not** accepted on this repository. Please use issues to report any bug or request.
|
||||
@@ -0,0 +1,73 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team via this [link](https://www.st.com/content/st_com/en/contact-us.html).
|
||||
All complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 1.4,
|
||||
available [here](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html).
|
||||
|
||||
For answers to common questions about this code of conduct, see the [FAQ section](https://www.contributor-covenant.org/faq).
|
||||
@@ -0,0 +1,28 @@
|
||||
## Contributing guide
|
||||
|
||||
This document serves as a checklist before contributing to this repository.
|
||||
It includes links to read up on if topics are unclear to you.
|
||||
|
||||
This guide mainly focuses on steps to be followed to submit an issue or a pull-request.
|
||||
|
||||
### 1. Before opening an issue
|
||||
|
||||
To report a bug or a request please file an issue in the right repository
|
||||
(example for [lis302dl](https://github.com/STMicroelectronics/lis302dl/issues/new/choose)).
|
||||
|
||||
Please check the following boxes before posting an issue:
|
||||
- [ ] `Make sure you are using the latest commit (major releases are tagged, but corrections are available as new commits).`
|
||||
- [ ] `Make sure your issue is a question/feedback/suggestions RELATED TO the software provided in this repository.` Otherwise, it should be submitted to the ST Community under the MCU topic [page](https://community.st.com/s/group/0F90X000000AXsASAW/stm32-mcus).
|
||||
- [ ] `Make sure your issue is not already reported/fixed on GitHub or discussed on a previous issue.` Please refer to this [dashboard](https://github.com/orgs/STMicroelectronics/projects/2) for the list of issues and pull-requests. Do not forget to browse into the **closed** issues.
|
||||
|
||||
### 2. Posting the issue
|
||||
When you have checked the previous boxes. You will find two templates (Bug Report or Other Issue) available in the **Issues** tab of the repository.
|
||||
|
||||
### 3. Pull Requests
|
||||
Pull-requests are **not** accepted on this repository. Please use **issues** to report any bug or request.
|
||||
|
||||
### 4. How to proceed
|
||||
|
||||
* We recommend to engage first a communication thru an issue, in order to present your proposal. Just to confirm that it corresponds to STMicroelectronics domain or scope.
|
||||
* Then fork the project to your GitHub account to further develop your contribution. Please use the latest commit version.
|
||||
* Please, submit one Pull Request for one new feature or proposal. This will ease the analysis and the final merge if accepted.
|
||||
@@ -0,0 +1,27 @@
|
||||
Copyright 2017 STMicroelectronics.
|
||||
All rights reserved.
|
||||
|
||||
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 the copyright holder 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.
|
||||
@@ -0,0 +1,40 @@
|
||||
# BSP LIS302DL Component
|
||||
|
||||
## Overview
|
||||
|
||||
**STM32Cube** is an STMicroelectronics original initiative to ease the developers life by reducing efforts, time and cost.
|
||||
|
||||
**STM32Cube** covers the overall STM32 products portfolio. It includes a comprehensive embedded software platform delivered for each STM32 series.
|
||||
* The CMSIS modules (core and device) corresponding to the ARM(tm) core implemented in this STM32 product.
|
||||
* The STM32 HAL-LL drivers, an abstraction layer offering a set of APIs ensuring maximized portability across the STM32 portfolio.
|
||||
* The BSP drivers of each evaluation, demonstration or nucleo board provided for this STM32 series.
|
||||
* A consistent set of middleware components such as RTOS, USB, FatFS, graphics, touch sensing library...
|
||||
* A full set of software projects (basic examples, applications, and demonstrations) for each board provided for this STM32 series.
|
||||
|
||||
Two models of publication are proposed for the STM32Cube embedded software:
|
||||
* The monolithic **MCU Package**: all STM32Cube software modules of one STM32 series are present (Drivers, Middleware, Projects, Utilities) in the repository (usual name **STM32Cubexx**, xx corresponding to the STM32 series).
|
||||
* The **MCU component**: each STM32Cube software module being part of the STM32Cube MCU Package, is delivered as an individual repository, allowing the user to select and get only the required software functions.
|
||||
|
||||
## Description
|
||||
|
||||
This **lis302dl** MCU component repository is one element **common to all** STM32Cube MCU embedded software packages, providing the **LIS302DL** BSP MEMS component part.
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2015 STMicroelectronics
|
||||
|
||||
This software component is licensed by STMicroelectronics under the **BSD-3-Clause** license. You may not use this software except in compliance with this license. You may obtain a copy of the license [here](https://opensource.org/licenses/BSD-3-Clause).
|
||||
|
||||
## Release note
|
||||
|
||||
Details about the content of this release are available in the release note [here](https://htmlpreview.github.io/?https://github.com/STMicroelectronics/lis302dl/blob/main/Release_Notes.html).
|
||||
|
||||
## Compatibility information
|
||||
|
||||
Please refer to the repository of the BSP **board** driver you are using to know which version of this BSP component driver to use. It is **crucial** that you use a consistent set of versions.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If you have any issue with the **software content** of this repository, you can file an issue [here](https://github.com/STMicroelectronics/lis302dl/issues/new/choose).
|
||||
|
||||
For any other question related to the product, the tools, the environment, you can submit a topic to the [ST Community](https://community.st.com/s/).
|
||||
@@ -0,0 +1,31 @@
|
||||
# Report potential product security vulnerabilities
|
||||
|
||||
ST places a high priority on security, and our Product Security Incident
|
||||
Response Team (PSIRT) is committed to rapidly addressing potential security
|
||||
vulnerabilities affecting our products. PSIRT's long history and vast experience
|
||||
in security allows ST to perform clear analyses and provide appropriate guidance
|
||||
on mitigations and solutions when applicable.
|
||||
|
||||
If you wish to report potential security vulnerabilities regarding our products,
|
||||
**please do not report them through public GitHub issues.** Instead, we
|
||||
encourage you to report them to our ST PSIRT following the process described at:
|
||||
**https://www.st.com/content/st_com/en/security/report-vulnerabilities.html**
|
||||
|
||||
### IMPORTANT - READ CAREFULLY:
|
||||
|
||||
STMicroelectronics International N.V., on behalf of itself, its affiliates and
|
||||
subsidiaries, (collectively “ST”) takes all potential security vulnerability
|
||||
reports or other related communications (“Report(s)”) seriously. In order to
|
||||
review Your Report (the terms “You” and “Yours” include your employer, and all
|
||||
affiliates, subsidiaries and related persons or entities) and take actions as
|
||||
deemed appropriate, ST requires that we have the rights and Your permission to
|
||||
do so.
|
||||
|
||||
As such, by submitting Your Report to ST, You agree that You have the right to
|
||||
do so, and You grant to ST the rights to use the Report for purposes related to
|
||||
security vulnerability analysis, testing, correction, patching, reporting and
|
||||
any other related purpose or function.
|
||||
|
||||
By submitting Your Report, You agree that ST’s
|
||||
[Privacy Policy](https://www.st.com/content/st_com/en/common/privacy-portal.html)
|
||||
applies to all related communications.
|
||||
@@ -0,0 +1,404 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file lis302dl.c
|
||||
* @author MCD Application Team
|
||||
* @version V2.0.0
|
||||
* @date 03-August-2015
|
||||
* @brief This file provides a set of functions needed to manage the LIS302DL
|
||||
* MEMS accelerometer.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2015 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "lis302dl.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup Components
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup LIS302DL
|
||||
* @brief This file includes the motion sensor driver for LIS302DL motion sensor
|
||||
* devices.
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup LIS302DL_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LIS302DL_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LIS302DL_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LIS302DL_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
ACCELERO_DrvTypeDef Lis302dlDrv =
|
||||
{
|
||||
LIS302DL_Init,
|
||||
LIS302DL_DeInit,
|
||||
LIS302DL_ReadID,
|
||||
LIS302DL_RebootCmd,
|
||||
LIS302DL_Click_IntConfig,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
LIS302DL_Click_IntClear,
|
||||
LIS302DL_FilterConfig,
|
||||
0,
|
||||
LIS302DL_ReadACC,
|
||||
};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LIS302DL_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LIS302DL_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Set LIS302DL Initialization.
|
||||
* @param InitStruct: contains mask of different init parameters
|
||||
* @retval None
|
||||
*/
|
||||
void LIS302DL_Init(uint16_t InitStruct)
|
||||
{
|
||||
uint8_t ctrl = 0x00;
|
||||
|
||||
/* Configure the low level interface */
|
||||
ACCELERO_IO_Init();
|
||||
|
||||
ctrl = (uint8_t) InitStruct;
|
||||
|
||||
/* Write value to MEMS CTRL_REG1 register */
|
||||
ACCELERO_IO_Write(&ctrl, LIS302DL_CTRL_REG1_ADDR, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief LIS302DL De-Initialization.
|
||||
* @param None
|
||||
* @retval None.
|
||||
*/
|
||||
void LIS302DL_DeInit(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read LIS302DL device ID.
|
||||
* @param None
|
||||
* @retval The Device ID (two bytes).
|
||||
*/
|
||||
uint8_t LIS302DL_ReadID(void)
|
||||
{
|
||||
uint8_t tmp = 0;
|
||||
|
||||
/* Configure the low level interface */
|
||||
ACCELERO_IO_Init();
|
||||
|
||||
/* Read WHO_AM_I register */
|
||||
ACCELERO_IO_Read(&tmp, LIS302DL_WHO_AM_I_ADDR, 1);
|
||||
|
||||
/* Return the ID */
|
||||
return (uint16_t)tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set LIS302DL Internal High Pass Filter configuration.
|
||||
* @param FilterStruct: contains data for filter config
|
||||
* @retval None
|
||||
*/
|
||||
void LIS302DL_FilterConfig(uint8_t FilterStruct)
|
||||
{
|
||||
uint8_t ctrl = 0x00;
|
||||
|
||||
/* Read CTRL_REG2 register */
|
||||
ACCELERO_IO_Read(&ctrl, LIS302DL_CTRL_REG2_ADDR, 1);
|
||||
|
||||
/* Clear high pass filter cut-off level, interrupt and data selection bits */
|
||||
ctrl &= (uint8_t)~(LIS302DL_FILTEREDDATASELECTION_OUTPUTREGISTER | \
|
||||
LIS302DL_HIGHPASSFILTER_LEVEL_3 | \
|
||||
LIS302DL_HIGHPASSFILTERINTERRUPT_1_2);
|
||||
|
||||
ctrl |= FilterStruct;
|
||||
|
||||
/* Write value to MEMS CTRL_REG2 register */
|
||||
ACCELERO_IO_Write(&ctrl, LIS302DL_CTRL_REG2_ADDR, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set LIS302DL Interrupt configuration.
|
||||
* @param LIS302DL_InterruptConfig_TypeDef: pointer to a LIS302DL_InterruptConfig_TypeDef
|
||||
* structure that contains the configuration setting for the LIS302DL Interrupt.
|
||||
* @retval None
|
||||
*/
|
||||
void LIS302DL_InterruptConfig(LIS302DL_InterruptConfigTypeDef *LIS302DL_IntConfigStruct)
|
||||
{
|
||||
uint8_t ctrl = 0x00;
|
||||
|
||||
/* Read CLICK_CFG register */
|
||||
ACCELERO_IO_Read(&ctrl, LIS302DL_CLICK_CFG_REG_ADDR, 1);
|
||||
|
||||
/* Configure latch Interrupt request, click interrupts and double click interrupts */
|
||||
ctrl = (uint8_t)(LIS302DL_IntConfigStruct->Latch_Request| \
|
||||
LIS302DL_IntConfigStruct->SingleClick_Axes | \
|
||||
LIS302DL_IntConfigStruct->DoubleClick_Axes);
|
||||
|
||||
/* Write value to MEMS CLICK_CFG register */
|
||||
ACCELERO_IO_Write(&ctrl, LIS302DL_CLICK_CFG_REG_ADDR, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set LIS302DL Interrupt configuration
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void LIS302DL_Click_IntConfig(void)
|
||||
{
|
||||
uint8_t ctrl = 0x00;
|
||||
LIS302DL_InterruptConfigTypeDef LIS302DL_InterruptStruct;
|
||||
|
||||
ACCELERO_IO_ITConfig();
|
||||
|
||||
/* Set configuration of Internal High Pass Filter of LIS302DL */
|
||||
LIS302DL_InterruptStruct.Latch_Request = LIS302DL_INTERRUPTREQUEST_LATCHED;
|
||||
LIS302DL_InterruptStruct.SingleClick_Axes = LIS302DL_CLICKINTERRUPT_Z_ENABLE;
|
||||
LIS302DL_InterruptStruct.DoubleClick_Axes = LIS302DL_DOUBLECLICKINTERRUPT_Z_ENABLE;
|
||||
LIS302DL_InterruptConfig(&LIS302DL_InterruptStruct);
|
||||
|
||||
/* Configure Interrupt control register: enable Click interrupt on INT1 and
|
||||
INT2 on Z axis high event */
|
||||
ctrl = 0x3F;
|
||||
ACCELERO_IO_Write(&ctrl, LIS302DL_CTRL_REG3_ADDR, 1);
|
||||
|
||||
/* Enable Interrupt generation on click on Z axis */
|
||||
ctrl = 0x50;
|
||||
ACCELERO_IO_Write(&ctrl, LIS302DL_CLICK_CFG_REG_ADDR, 1);
|
||||
|
||||
/* Configure Click Threshold on X/Y axis (10 x 0.5g) */
|
||||
ctrl = 0xAA;
|
||||
ACCELERO_IO_Write(&ctrl, LIS302DL_CLICK_THSY_X_REG_ADDR, 1);
|
||||
|
||||
/* Configure Click Threshold on Z axis (10 x 0.5g) */
|
||||
ctrl = 0x0A;
|
||||
ACCELERO_IO_Write(&ctrl, LIS302DL_CLICK_THSZ_REG_ADDR, 1);
|
||||
|
||||
/* Enable interrupt on Y axis high event */
|
||||
ctrl = 0x4C;
|
||||
ACCELERO_IO_Write(&ctrl, LIS302DL_FF_WU_CFG1_REG_ADDR, 1);
|
||||
|
||||
/* Configure Time Limit */
|
||||
ctrl = 0x03;
|
||||
ACCELERO_IO_Write(&ctrl, LIS302DL_CLICK_TIMELIMIT_REG_ADDR, 1);
|
||||
|
||||
/* Configure Latency */
|
||||
ctrl = 0x7F;
|
||||
ACCELERO_IO_Write(&ctrl, LIS302DL_CLICK_LATENCY_REG_ADDR, 1);
|
||||
|
||||
/* Configure Click Window */
|
||||
ctrl = 0x7F;
|
||||
ACCELERO_IO_Write(&ctrl, LIS302DL_CLICK_WINDOW_REG_ADDR, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear LIS302DL click Interrupt
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void LIS302DL_Click_IntClear(void)
|
||||
{
|
||||
uint8_t buffer[6], clickreg = 0;
|
||||
|
||||
/* Read click and status registers if the available MEMS Accelerometer is LIS302DL */
|
||||
ACCELERO_IO_Read(&clickreg, LIS302DL_CLICK_SRC_REG_ADDR, 1);
|
||||
ACCELERO_IO_Read(buffer, LIS302DL_STATUS_REG_ADDR, 6);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Change the lowpower mode for LIS302DL
|
||||
* @param LowPowerMode: New state for the low power mode.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LIS302DL_LOWPOWERMODE_POWERDOWN: Power down mode
|
||||
* @arg LIS302DL_LOWPOWERMODE_ACTIVE: Active mode
|
||||
* @retval None
|
||||
*/
|
||||
void LIS302DL_LowpowerCmd(uint8_t LowPowerMode)
|
||||
{
|
||||
uint8_t tmpreg;
|
||||
|
||||
/* Read CTRL_REG1 register */
|
||||
ACCELERO_IO_Read(&tmpreg, LIS302DL_CTRL_REG1_ADDR, 1);
|
||||
|
||||
/* Set new low power mode configuration */
|
||||
tmpreg &= (uint8_t)~LIS302DL_LOWPOWERMODE_ACTIVE;
|
||||
tmpreg |= LowPowerMode;
|
||||
|
||||
/* Write value to MEMS CTRL_REG1 register */
|
||||
ACCELERO_IO_Write(&tmpreg, LIS302DL_CTRL_REG1_ADDR, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Data Rate command
|
||||
* @param DataRateValue: Data rate value
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LIS302DL_DATARATE_100: 100 Hz output data rate
|
||||
* @arg LIS302DL_DATARATE_400: 400 Hz output data rate
|
||||
* @retval None
|
||||
*/
|
||||
void LIS302DL_DataRateCmd(uint8_t DataRateValue)
|
||||
{
|
||||
uint8_t tmpreg;
|
||||
|
||||
/* Read CTRL_REG1 register */
|
||||
ACCELERO_IO_Read(&tmpreg, LIS302DL_CTRL_REG1_ADDR, 1);
|
||||
|
||||
/* Set new Data rate configuration */
|
||||
tmpreg &= (uint8_t)~LIS302DL_DATARATE_400;
|
||||
tmpreg |= DataRateValue;
|
||||
|
||||
/* Write value to MEMS CTRL_REG1 register */
|
||||
ACCELERO_IO_Write(&tmpreg, LIS302DL_CTRL_REG1_ADDR, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Change the Full Scale of LIS302DL
|
||||
* @param FS_value: new full scale value.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LIS302DL_FULLSCALE_2_3: +-2.3g
|
||||
* @arg LIS302DL_FULLSCALE_9_2: +-9.2g
|
||||
* @retval None
|
||||
*/
|
||||
void LIS302DL_FullScaleCmd(uint8_t FS_value)
|
||||
{
|
||||
uint8_t tmpreg;
|
||||
|
||||
/* Read CTRL_REG1 register */
|
||||
ACCELERO_IO_Read(&tmpreg, LIS302DL_CTRL_REG1_ADDR, 1);
|
||||
|
||||
/* Set new full scale configuration */
|
||||
tmpreg &= (uint8_t)~LIS302DL_FULLSCALE_9_2;
|
||||
tmpreg |= FS_value;
|
||||
|
||||
/* Write value to MEMS CTRL_REG1 register */
|
||||
ACCELERO_IO_Write(&tmpreg, LIS302DL_CTRL_REG1_ADDR, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reboot memory content of LIS302DL.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void LIS302DL_RebootCmd(void)
|
||||
{
|
||||
uint8_t tmpreg;
|
||||
/* Read CTRL_REG2 register */
|
||||
ACCELERO_IO_Read(&tmpreg, LIS302DL_CTRL_REG2_ADDR, 1);
|
||||
|
||||
/* Enable or Disable the reboot memory */
|
||||
tmpreg |= LIS302DL_BOOT_REBOOTMEMORY;
|
||||
|
||||
/* Write value to MEMS CTRL_REG2 register */
|
||||
ACCELERO_IO_Write(&tmpreg, LIS302DL_CTRL_REG2_ADDR, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read LIS302DL output register, and calculate the acceleration
|
||||
* ACC[mg]=SENSITIVITY* (out_h*256+out_l)/16 (12 bit rappresentation)
|
||||
* @param pfData: Data out pointer
|
||||
* @retval None
|
||||
*/
|
||||
void LIS302DL_ReadACC(int16_t *pData)
|
||||
{
|
||||
int8_t buffer[6];
|
||||
int16_t pnRawData[3];
|
||||
uint8_t sensitivity = LIS302DL_SENSITIVITY_2_3G;
|
||||
uint8_t crtl, i = 0x00;
|
||||
|
||||
ACCELERO_IO_Read(&crtl, LIS302DL_CTRL_REG1_ADDR, 1);
|
||||
ACCELERO_IO_Read((uint8_t*)buffer, LIS302DL_OUT_X_ADDR, 6);
|
||||
|
||||
for(i=0; i<3; i++)
|
||||
{
|
||||
pnRawData[i] = buffer[2*i];
|
||||
}
|
||||
|
||||
switch(crtl & LIS302DL_FULLSCALE_9_2)
|
||||
{
|
||||
/* FS bit = 0 ==> Sensitivity typical value = 18milligals/digit*/
|
||||
case LIS302DL_FULLSCALE_2_3:
|
||||
sensitivity = LIS302DL_SENSITIVITY_2_3G;
|
||||
break;
|
||||
|
||||
/* FS bit = 1 ==> Sensitivity typical value = 72milligals/digit*/
|
||||
case LIS302DL_FULLSCALE_9_2:
|
||||
sensitivity = LIS302DL_SENSITIVITY_9_2G;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Obtain the mg value for the three axis */
|
||||
for(i=0; i<3; i++)
|
||||
{
|
||||
pData[i]=(pnRawData[i] * sensitivity);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,701 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file lis302dl.h
|
||||
* @author MCD Application Team
|
||||
* @version V2.0.0
|
||||
* @date 03-August-2015
|
||||
* @brief This file contains all the functions prototypes for the lis302dl.c
|
||||
* firmware driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2015 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __LIS302DL_H
|
||||
#define __LIS302DL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "../Common/accelero.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup Components
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup LIS302DL
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup LIS302DL_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
/* LIS302DL struct */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t Power_Mode; /* Power-down/Active Mode */
|
||||
uint8_t Output_DataRate; /* OUT data rate 100 Hz / 400 Hz */
|
||||
uint8_t Axes_Enable; /* Axes enable */
|
||||
uint8_t Full_Scale; /* Full scale */
|
||||
uint8_t Self_Test; /* Self test */
|
||||
}LIS302DL_InitTypeDef;
|
||||
|
||||
/* Interrupt struct */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t Latch_Request; /* Latch interrupt request into CLICK_SRC register*/
|
||||
uint8_t SingleClick_Axes; /* Single Click Axes Interrupts */
|
||||
uint8_t DoubleClick_Axes; /* Double Click Axes Interrupts */
|
||||
}LIS302DL_InterruptConfigTypeDef;
|
||||
|
||||
/* High Pass Filter struct */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t HighPassFilter_Data_Selection; /* Internal filter bypassed or data from internal filter send to output register*/
|
||||
uint8_t HighPassFilter_CutOff_Frequency; /* High pass filter cut-off frequency */
|
||||
uint8_t HighPassFilter_Interrupt; /* High pass filter enabled for Freefall/WakeUp #1 or #2 */
|
||||
}LIS302DL_FilterConfigTypeDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LIS302DL_Exported_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/******************************************************************************/
|
||||
/*************************** START REGISTER MAPPING **************************/
|
||||
/******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* WHO_AM_I Register: Device Identification Register
|
||||
* Read only register
|
||||
* Default value: 0x3B
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_WHO_AM_I_ADDR 0x0F
|
||||
|
||||
/*******************************************************************************
|
||||
* CTRL_REG1 Register: Control Register 1
|
||||
* Read Write register
|
||||
* Default value: 0x07
|
||||
* 7 DR: Data Rate selection.
|
||||
* 0 - 100 Hz output data rate
|
||||
* 1 - 400 Hz output data rate
|
||||
* 6 PD: Power Down control.
|
||||
* 0 - power down mode
|
||||
* 1 - active mode
|
||||
* 5 FS: Full Scale selection.
|
||||
* 0 - Typical measurement range 2.3
|
||||
* 1 - Typical measurement range 9.2
|
||||
* 4:3 STP-STM Self Test Enable:
|
||||
* STP | STM | mode
|
||||
* ----------------------------
|
||||
* 0 | 0 | Normal mode
|
||||
* 0 | 1 | Self Test M
|
||||
* 1 | 0 | Self Test P
|
||||
* 2 Zen: Z axis enable.
|
||||
* 0 - Z axis disabled
|
||||
* 1- Z axis enabled
|
||||
* 1 Yen: Y axis enable.
|
||||
* 0 - Y axis disabled
|
||||
* 1- Y axis enabled
|
||||
* 0 Xen: X axis enable.
|
||||
* 0 - X axis disabled
|
||||
* 1- X axis enabled
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_CTRL_REG1_ADDR 0x20
|
||||
|
||||
/*******************************************************************************
|
||||
* CTRL_REG2 Regsiter: Control Register 2
|
||||
* Read Write register
|
||||
* Default value: 0x00
|
||||
* 7 SIM: SPI Serial Interface Mode Selection.
|
||||
* 0 - 4 wire interface
|
||||
* 1 - 3 wire interface
|
||||
* 6 BOOT: Reboot memory content
|
||||
* 0 - normal mode
|
||||
* 1 - reboot memory content
|
||||
* 5 Reserved
|
||||
* 4 FDS: Filtered data selection.
|
||||
* 0 - internal filter bypassed
|
||||
* 1 - data from internal filter sent to output register
|
||||
* 3 HP FF_WU2: High pass filter enabled for FreeFall/WakeUp#2.
|
||||
* 0 - filter bypassed
|
||||
* 1 - filter enabled
|
||||
* 2 HP FF_WU1: High pass filter enabled for FreeFall/WakeUp#1.
|
||||
* 0 - filter bypassed
|
||||
* 1 - filter enabled
|
||||
* 1:0 HP coeff2-HP coeff1 High pass filter cut-off frequency (ft) configuration.
|
||||
* ft= ODR[hz]/6*HP coeff
|
||||
* HP coeff2 | HP coeff1 | HP coeff
|
||||
* -------------------------------------------
|
||||
* 0 | 0 | 8
|
||||
* 0 | 1 | 16
|
||||
* 1 | 0 | 32
|
||||
* 1 | 1 | 64
|
||||
* HP coeff | ft[hz] | ft[hz] |
|
||||
* |ODR 100Hz | ODR 400Hz |
|
||||
* --------------------------------------------
|
||||
* 00 | 2 | 8 |
|
||||
* 01 | 1 | 4 |
|
||||
* 10 | 0.5 | 2 |
|
||||
* 11 | 0.25 | 1 |
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_CTRL_REG2_ADDR 0x21
|
||||
|
||||
/*******************************************************************************
|
||||
* CTRL_REG3 Register: Interrupt Control Register
|
||||
* Read Write register
|
||||
* Default value: 0x00
|
||||
* 7 IHL active: Interrupt active high/low.
|
||||
* 0 - active high
|
||||
* 1 - active low
|
||||
* 6 PP_OD: push-pull/open-drain.
|
||||
* 0 - push-pull
|
||||
* 1 - open-drain
|
||||
* 5:3 I2_CFG2 - I2_CFG0 Data signal on INT2 pad control bits
|
||||
* 2:0 I1_CFG2 - I1_CFG0 Data signal on INT1 pad control bits
|
||||
* I1(2)_CFG2 | I1(2)_CFG1 | I1(2)_CFG0 | INT1(2) Pad
|
||||
* ----------------------------------------------------------
|
||||
* 0 | 0 | 0 | GND
|
||||
* 0 | 0 | 1 | FreeFall/WakeUp#1
|
||||
* 0 | 1 | 0 | FreeFall/WakeUp#2
|
||||
* 0 | 1 | 1 | FreeFall/WakeUp#1 or FreeFall/WakeUp#2
|
||||
* 1 | 0 | 0 | Data ready
|
||||
* 1 | 1 | 1 | Click interrupt
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_CTRL_REG3_ADDR 0x22
|
||||
|
||||
/*******************************************************************************
|
||||
* HP_FILTER_RESET Register: Dummy register. Reading at this address zeroes
|
||||
* instantaneously the content of the internal high pass filter. If the high pass
|
||||
* filter is enabled all three axes are instantaneously set to 0g.
|
||||
* This allows to overcome the settling time of the high pass filter.
|
||||
* Read only register
|
||||
* Default value: Dummy
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_HP_FILTER_RESET_REG_ADDR 0x23
|
||||
|
||||
/*******************************************************************************
|
||||
* STATUS_REG Register: Status Register
|
||||
* Default value: 0x00
|
||||
* 7 ZYXOR: X, Y and Z axis data overrun.
|
||||
* 0: no overrun has occurred
|
||||
* 1: new data has overwritten the previous one before it was read
|
||||
* 6 ZOR: Z axis data overrun.
|
||||
* 0: no overrun has occurred
|
||||
* 1: new data for Z-axis has overwritten the previous one before it was read
|
||||
* 5 yOR: y axis data overrun.
|
||||
* 0: no overrun has occurred
|
||||
* 1: new data for y-axis has overwritten the previous one before it was read
|
||||
* 4 XOR: X axis data overrun.
|
||||
* 0: no overrun has occurred
|
||||
* 1: new data for X-axis has overwritten the previous one before it was read
|
||||
* 3 ZYXDA: X, Y and Z axis new data available
|
||||
* 0: a new set of data is not yet available
|
||||
* 1: a new set of data is available
|
||||
* 2 ZDA: Z axis new data available.
|
||||
* 0: a new set of data is not yet available
|
||||
* 1: a new data for Z axis is available
|
||||
* 1 YDA: Y axis new data available
|
||||
* 0: a new set of data is not yet available
|
||||
* 1: a new data for Y axis is available
|
||||
* 0 XDA: X axis new data available
|
||||
* 0: a new set of data is not yet available
|
||||
* 1: a new data for X axis is available
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_STATUS_REG_ADDR 0x27
|
||||
|
||||
/*******************************************************************************
|
||||
* OUT_X Register: X-axis output Data
|
||||
* Read only register
|
||||
* Default value: output
|
||||
* 7:0 XD7-XD0: X-axis output Data
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_OUT_X_ADDR 0x29
|
||||
|
||||
/*******************************************************************************
|
||||
* OUT_Y Register: Y-axis output Data
|
||||
* Read only register
|
||||
* Default value: output
|
||||
* 7:0 YD7-YD0: Y-axis output Data
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_OUT_Y_ADDR 0x2B
|
||||
|
||||
/*******************************************************************************
|
||||
* OUT_Z Register: Z-axis output Data
|
||||
* Read only register
|
||||
* Default value: output
|
||||
* 7:0 ZD7-ZD0: Z-axis output Data
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_OUT_Z_ADDR 0x2D
|
||||
|
||||
/*******************************************************************************
|
||||
* FF_WW_CFG_1 Register: Configuration register for Interrupt 1 source.
|
||||
* Read write register
|
||||
* Default value: 0x00
|
||||
* 7 AOI: AND/OR combination of Interrupt events.
|
||||
* 0: OR combination of interrupt events
|
||||
* 1: AND combination of interrupt events
|
||||
* 6 LIR: Latch/not latch interrupt request
|
||||
* 0: interrupt request not latched
|
||||
* 1: interrupt request latched
|
||||
* 5 ZHIE: Enable interrupt generation on Z high event.
|
||||
* 0: disable interrupt request
|
||||
* 1: enable interrupt request on measured accel. value higher than preset threshold
|
||||
* 4 ZLIE: Enable interrupt generation on Z low event.
|
||||
* 0: disable interrupt request
|
||||
* 1: enable interrupt request on measured accel. value lower than preset threshold
|
||||
* 3 YHIE: Enable interrupt generation on Y high event.
|
||||
* 0: disable interrupt request
|
||||
* 1: enable interrupt request on measured accel. value higher than preset threshold
|
||||
* 2 YLIE: Enable interrupt generation on Y low event.
|
||||
* 0: disable interrupt request
|
||||
* 1: enable interrupt request on measured accel. value lower than preset threshold
|
||||
* 1 XHIE: Enable interrupt generation on X high event.
|
||||
* 0: disable interrupt request
|
||||
* 1: enable interrupt request on measured accel. value higher than preset threshold
|
||||
* 0 XLIE: Enable interrupt generation on X low event.
|
||||
* 0: disable interrupt request
|
||||
* 1: enable interrupt request on measured accel. value lower than preset threshold
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_FF_WU_CFG1_REG_ADDR 0x30
|
||||
|
||||
/*******************************************************************************
|
||||
* FF_WU_SRC_1 Register: Interrupt 1 source register.
|
||||
* Reading at this address clears FF_WU_SRC_1 register and the FF, WU 1 interrupt
|
||||
* and allow the refreshment of data in the FF_WU_SRC_1 register if the latched option
|
||||
* was chosen.
|
||||
* Read only register
|
||||
* Default value: 0x00
|
||||
* 7 Reserved
|
||||
* 6 IA: Interrupt active.
|
||||
* 0: no interrupt has been generated
|
||||
* 1: one or more interrupts have been generated
|
||||
* 5 ZH: Z high.
|
||||
* 0: no interrupt
|
||||
* 1: ZH event has occurred
|
||||
* 4 ZL: Z low.
|
||||
* 0: no interrupt
|
||||
* 1: ZL event has occurred
|
||||
* 3 YH: Y high.
|
||||
* 0: no interrupt
|
||||
* 1: YH event has occurred
|
||||
* 2 YL: Y low.
|
||||
* 0: no interrupt
|
||||
* 1: YL event has occurred
|
||||
* 1 YH: X high.
|
||||
* 0: no interrupt
|
||||
* 1: XH event has occurred
|
||||
* 0 YL: X low.
|
||||
* 0: no interrupt
|
||||
* 1: XL event has occurred
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_FF_WU_SRC1_REG_ADDR 0x31
|
||||
|
||||
/*******************************************************************************
|
||||
* FF_WU_THS_1 Register: Threshold register
|
||||
* Read Write register
|
||||
* Default value: 0x00
|
||||
* 7 DCRM: Reset mode selection.
|
||||
* 0 - counter resetted
|
||||
* 1 - counter decremented
|
||||
* 6 THS6-THS0: Free-fall/wake-up threshold value.
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_FF_WU_THS1_REG_ADDR 0x32
|
||||
|
||||
/*******************************************************************************
|
||||
* FF_WU_DURATION_1 Register: duration Register
|
||||
* Read Write register
|
||||
* Default value: 0x00
|
||||
* 7:0 D7-D0 Duration value. (Duration steps and maximum values depend on the ODR chosen)
|
||||
******************************************************************************/
|
||||
#define LIS302DL_FF_WU_DURATION1_REG_ADDR 0x33
|
||||
|
||||
/*******************************************************************************
|
||||
* FF_WW_CFG_2 Register: Configuration register for Interrupt 2 source.
|
||||
* Read write register
|
||||
* Default value: 0x00
|
||||
* 7 AOI: AND/OR combination of Interrupt events.
|
||||
* 0: OR combination of interrupt events
|
||||
* 1: AND combination of interrupt events
|
||||
* 6 LIR: Latch/not latch interrupt request
|
||||
* 0: interrupt request not latched
|
||||
* 1: interrupt request latched
|
||||
* 5 ZHIE: Enable interrupt generation on Z high event.
|
||||
* 0: disable interrupt request
|
||||
* 1: enable interrupt request on measured accel. value higher than preset threshold
|
||||
* 4 ZLIE: Enable interrupt generation on Z low event.
|
||||
* 0: disable interrupt request
|
||||
* 1: enable interrupt request on measured accel. value lower than preset threshold
|
||||
* 3 YHIE: Enable interrupt generation on Y high event.
|
||||
* 0: disable interrupt request
|
||||
* 1: enable interrupt request on measured accel. value higher than preset threshold
|
||||
* 2 YLIE: Enable interrupt generation on Y low event.
|
||||
* 0: disable interrupt request
|
||||
* 1: enable interrupt request on measured accel. value lower than preset threshold
|
||||
* 1 XHIE: Enable interrupt generation on X high event.
|
||||
* 0: disable interrupt request
|
||||
* 1: enable interrupt request on measured accel. value higher than preset threshold
|
||||
* 0 XLIE: Enable interrupt generation on X low event.
|
||||
* 0: disable interrupt request
|
||||
* 1: enable interrupt request on measured accel. value lower than preset threshold
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_FF_WU_CFG2_REG_ADDR 0x34
|
||||
|
||||
/*******************************************************************************
|
||||
* FF_WU_SRC_2 Register: Interrupt 2 source register.
|
||||
* Reading at this address clears FF_WU_SRC_2 register and the FF, WU 2 interrupt
|
||||
* and allow the refreshment of data in the FF_WU_SRC_2 register if the latched option
|
||||
* was chosen.
|
||||
* Read only register
|
||||
* Default value: 0x00
|
||||
* 7 Reserved
|
||||
* 6 IA: Interrupt active.
|
||||
* 0: no interrupt has been generated
|
||||
* 1: one or more interrupts have been generated
|
||||
* 5 ZH: Z high.
|
||||
* 0: no interrupt
|
||||
* 1: ZH event has occurred
|
||||
* 4 ZL: Z low.
|
||||
* 0: no interrupt
|
||||
* 1: ZL event has occurred
|
||||
* 3 YH: Y high.
|
||||
* 0: no interrupt
|
||||
* 1: YH event has occurred
|
||||
* 2 YL: Y low.
|
||||
* 0: no interrupt
|
||||
* 1: YL event has occurred
|
||||
* 1 YH: X high.
|
||||
* 0: no interrupt
|
||||
* 1: XH event has occurred
|
||||
* 0 YL: X low.
|
||||
* 0: no interrupt
|
||||
* 1: XL event has occurred
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_FF_WU_SRC2_REG_ADDR 0x35
|
||||
|
||||
/*******************************************************************************
|
||||
* FF_WU_THS_2 Register: Threshold register
|
||||
* Read Write register
|
||||
* Default value: 0x00
|
||||
* 7 DCRM: Reset mode selection.
|
||||
* 0 - counter resetted
|
||||
* 1 - counter decremented
|
||||
* 6 THS6-THS0: Free-fall/wake-up threshold value.
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_FF_WU_THS2_REG_ADDR 0x36
|
||||
|
||||
/*******************************************************************************
|
||||
* FF_WU_DURATION_2 Register: duration Register
|
||||
* Read Write register
|
||||
* Default value: 0x00
|
||||
* 7:0 D7-D0 Duration value. (Duration steps and maximum values depend on the ODR chosen)
|
||||
******************************************************************************/
|
||||
#define LIS302DL_FF_WU_DURATION2_REG_ADDR 0x37
|
||||
|
||||
/******************************************************************************
|
||||
* CLICK_CFG Register: click Register
|
||||
* Read Write register
|
||||
* Default value: 0x00
|
||||
* 7 Reserved
|
||||
* 6 LIR: Latch Interrupt request.
|
||||
* 0: interrupt request not latched
|
||||
* 1: interrupt request latched
|
||||
* 5 Double_Z: Enable interrupt generation on double click event on Z axis.
|
||||
* 0: disable interrupt request
|
||||
* 1: enable interrupt request
|
||||
* 4 Single_Z: Enable interrupt generation on single click event on Z axis.
|
||||
* 0: disable interrupt request
|
||||
* 1: enable interrupt request
|
||||
* 3 Double_Y: Enable interrupt generation on double click event on Y axis.
|
||||
* 0: disable interrupt request
|
||||
* 1: enable interrupt request
|
||||
* 2 Single_Y: Enable interrupt generation on single click event on Y axis.
|
||||
* 0: disable interrupt request
|
||||
* 1: enable interrupt request
|
||||
* 1 Double_X: Enable interrupt generation on double click event on X axis.
|
||||
* 0: disable interrupt request
|
||||
* 1: enable interrupt request
|
||||
* 0 Single_y: Enable interrupt generation on single click event on X axis.
|
||||
* 0: disable interrupt request
|
||||
* 1: enable interrupt request
|
||||
******************************************************************************/
|
||||
#define LIS302DL_CLICK_CFG_REG_ADDR 0x38
|
||||
|
||||
/******************************************************************************
|
||||
* CLICK_SRC Register: click status Register
|
||||
* Read only register
|
||||
* Default value: 0x00
|
||||
* 7 Reserved
|
||||
* 6 IA: Interrupt active.
|
||||
* 0: no interrupt has been generated
|
||||
* 1: one or more interrupts have been generated
|
||||
* 5 Double_Z: Double click on Z axis event.
|
||||
* 0: no interrupt
|
||||
* 1: Double Z event has occurred
|
||||
* 4 Single_Z: Z low.
|
||||
* 0: no interrupt
|
||||
* 1: Single Z event has occurred
|
||||
* 3 Double_Y: Y high.
|
||||
* 0: no interrupt
|
||||
* 1: Double Y event has occurred
|
||||
* 2 Single_Y: Y low.
|
||||
* 0: no interrupt
|
||||
* 1: Single Y event has occurred
|
||||
* 1 Double_X: X high.
|
||||
* 0: no interrupt
|
||||
* 1: Double X event has occurred
|
||||
* 0 Single_X: X low.
|
||||
* 0: no interrupt
|
||||
* 1: Single X event has occurred
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_CLICK_SRC_REG_ADDR 0x39
|
||||
|
||||
/*******************************************************************************
|
||||
* CLICK_THSY_X Register: Click threshold Y and X register
|
||||
* Read Write register
|
||||
* Default value: 0x00
|
||||
* 7:4 THSy3-THSy0: Click threshold on Y axis, step 0.5g
|
||||
* 3:0 THSx3-THSx0: Click threshold on X axis, step 0.5g
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_CLICK_THSY_X_REG_ADDR 0x3B
|
||||
|
||||
/*******************************************************************************
|
||||
* CLICK_THSZ Register: Click threshold Z register
|
||||
* Read Write register
|
||||
* Default value: 0x00
|
||||
* 7:4 Reserved
|
||||
* 3:0 THSz3-THSz0: Click threshold on Z axis, step 0.5g
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_CLICK_THSZ_REG_ADDR 0x3C
|
||||
|
||||
/*******************************************************************************
|
||||
* CLICK_TimeLimit Register: Time Limit register
|
||||
* Read Write register
|
||||
* Default value: 0x00
|
||||
* 7:0 Dur7-Dur0: Time Limit value, step 0.5g
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_CLICK_TIMELIMIT_REG_ADDR 0x3D
|
||||
|
||||
/*******************************************************************************
|
||||
* CLICK_Latency Register: Latency register
|
||||
* Read Write register
|
||||
* Default value: 0x00
|
||||
* 7:0 Lat7-Lat0: Latency value, step 1msec
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_CLICK_LATENCY_REG_ADDR 0x3E
|
||||
|
||||
/*******************************************************************************
|
||||
* CLICK_Window Register: Window register
|
||||
* Read Write register
|
||||
* Default value: 0x00
|
||||
* 7:0 Win7-Win0: Window value, step 1msec
|
||||
*******************************************************************************/
|
||||
#define LIS302DL_CLICK_WINDOW_REG_ADDR 0x3F
|
||||
|
||||
/******************************************************************************/
|
||||
/**************************** END REGISTER MAPPING ***************************/
|
||||
/******************************************************************************/
|
||||
#define I_AM_LIS302DL 0x3B
|
||||
|
||||
#define LIS302DL_SENSITIVITY_2_3G 18 /* 18 mg/digit*/
|
||||
#define LIS302DL_SENSITIVITY_9_2G 72 /* 72 mg/digit*/
|
||||
|
||||
/** @defgroup Data_Rate_selection
|
||||
* @{
|
||||
*/
|
||||
#define LIS302DL_DATARATE_100 ((uint8_t)0x00)
|
||||
#define LIS302DL_DATARATE_400 ((uint8_t)0x80)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup Power_Mode_selection
|
||||
* @{
|
||||
*/
|
||||
#define LIS302DL_LOWPOWERMODE_POWERDOWN ((uint8_t)0x00)
|
||||
#define LIS302DL_LOWPOWERMODE_ACTIVE ((uint8_t)0x40)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup Full_Scale_selection
|
||||
* @{
|
||||
*/
|
||||
#define LIS302DL_FULLSCALE_2_3 ((uint8_t)0x00)
|
||||
#define LIS302DL_FULLSCALE_9_2 ((uint8_t)0x20)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup Self_Test_selection
|
||||
* @{
|
||||
*/
|
||||
#define LIS302DL_SELFTEST_NORMAL ((uint8_t)0x00)
|
||||
#define LIS302DL_SELFTEST_P ((uint8_t)0x10)
|
||||
#define LIS302DL_SELFTEST_M ((uint8_t)0x08)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup Direction_XYZ_selection
|
||||
* @{
|
||||
*/
|
||||
#define LIS302DL_X_ENABLE ((uint8_t)0x01)
|
||||
#define LIS302DL_Y_ENABLE ((uint8_t)0x02)
|
||||
#define LIS302DL_Z_ENABLE ((uint8_t)0x04)
|
||||
#define LIS302DL_XYZ_ENABLE ((uint8_t)0x07)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_Serial_Interface_Mode_selection
|
||||
* @{
|
||||
*/
|
||||
#define LIS302DL_SERIALINTERFACE_4WIRE ((uint8_t)0x00)
|
||||
#define LIS302DL_SERIALINTERFACE_3WIRE ((uint8_t)0x80)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup Boot_Mode_selection
|
||||
* @{
|
||||
*/
|
||||
#define LIS302DL_BOOT_NORMALMODE ((uint8_t)0x00)
|
||||
#define LIS302DL_BOOT_REBOOTMEMORY ((uint8_t)0x40)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup Filtered_Data_Selection_Mode_selection
|
||||
* @{
|
||||
*/
|
||||
#define LIS302DL_FILTEREDDATASELECTION_BYPASSED ((uint8_t)0x00)
|
||||
#define LIS302DL_FILTEREDDATASELECTION_OUTPUTREGISTER ((uint8_t)0x20)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup High_Pass_Filter_Interrupt_selection
|
||||
* @{
|
||||
*/
|
||||
#define LIS302DL_HIGHPASSFILTERINTERRUPT_OFF ((uint8_t)0x00)
|
||||
#define LIS302DL_HIGHPASSFILTERINTERRUPT_1 ((uint8_t)0x04)
|
||||
#define LIS302DL_HIGHPASSFILTERINTERRUPT_2 ((uint8_t)0x08)
|
||||
#define LIS302DL_HIGHPASSFILTERINTERRUPT_1_2 ((uint8_t)0x0C)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup High_Pass_Filter_selection
|
||||
* @{
|
||||
*/
|
||||
#define LIS302DL_HIGHPASSFILTER_LEVEL_0 ((uint8_t)0x00)
|
||||
#define LIS302DL_HIGHPASSFILTER_LEVEL_1 ((uint8_t)0x01)
|
||||
#define LIS302DL_HIGHPASSFILTER_LEVEL_2 ((uint8_t)0x02)
|
||||
#define LIS302DL_HIGHPASSFILTER_LEVEL_3 ((uint8_t)0x03)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup latch_Interrupt_Request_selection
|
||||
* @{
|
||||
*/
|
||||
#define LIS302DL_INTERRUPTREQUEST_NOTLATCHED ((uint8_t)0x00)
|
||||
#define LIS302DL_INTERRUPTREQUEST_LATCHED ((uint8_t)0x40)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup Click_Interrupt_XYZ_selection
|
||||
* @{
|
||||
*/
|
||||
#define LIS302DL_CLICKINTERRUPT_XYZ_DISABLE ((uint8_t)0x00)
|
||||
#define LIS302DL_CLICKINTERRUPT_X_ENABLE ((uint8_t)0x01)
|
||||
#define LIS302DL_CLICKINTERRUPT_Y_ENABLE ((uint8_t)0x04)
|
||||
#define LIS302DL_CLICKINTERRUPT_Z_ENABLE ((uint8_t)0x10)
|
||||
#define LIS302DL_CLICKINTERRUPT_XYZ_ENABLE ((uint8_t)0x15)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup Double_Click_Interrupt_XYZ_selection
|
||||
* @{
|
||||
*/
|
||||
#define LIS302DL_DOUBLECLICKINTERRUPT_XYZ_DISABLE ((uint8_t)0x00)
|
||||
#define LIS302DL_DOUBLECLICKINTERRUPT_X_ENABLE ((uint8_t)0x02)
|
||||
#define LIS302DL_DOUBLECLICKINTERRUPT_Y_ENABLE ((uint8_t)0x08)
|
||||
#define LIS302DL_DOUBLECLICKINTERRUPT_Z_ENABLE ((uint8_t)0x20)
|
||||
#define LIS302DL_DOUBLECLICKINTERRUPT_XYZ_ENABLE ((uint8_t)0x2A)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LIS302DL_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
void LIS302DL_Init(uint16_t InitStruct);
|
||||
void LIS302DL_DeInit(void);
|
||||
uint8_t LIS302DL_ReadID(void);
|
||||
void LIS302DL_FilterConfig(uint8_t FilterStruct);
|
||||
void LIS302DL_InterruptConfig(LIS302DL_InterruptConfigTypeDef *LIS302DL_IntConfigStruct);
|
||||
void LIS302DL_Click_IntConfig(void);
|
||||
void LIS302DL_Click_IntClear(void);
|
||||
void LIS302DL_LowpowerCmd(uint8_t LowPowerMode);
|
||||
void LIS302DL_FullScaleCmd(uint8_t FS_value);
|
||||
void LIS302DL_DataRateCmd(uint8_t DataRateValue);
|
||||
void LIS302DL_RebootCmd(void);
|
||||
void LIS302DL_ReadACC(int16_t *pData);
|
||||
|
||||
/* Accelerometer driver structure */
|
||||
extern ACCELERO_DrvTypeDef Lis302dlDrv;
|
||||
|
||||
/* Accelerometer IO functions */
|
||||
void ACCELERO_IO_Init(void);
|
||||
void ACCELERO_IO_ITConfig(void);
|
||||
void ACCELERO_IO_Write(uint8_t* pBuffer, uint8_t WriteAddr, uint16_t NumByteToWrite);
|
||||
void ACCELERO_IO_Read(uint8_t* pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __LIS302DL_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
Reference in New Issue
Block a user