initial working (stm32f4-discovery)

This commit is contained in:
2026-07-31 19:07:15 +03:00
commit ce6632f48c
2214 changed files with 1264937 additions and 0 deletions
@@ -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 [lsm303agr](https://github.com/STMicroelectronics/lsm303agr/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 LSM303AGR 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 **lsm303agr** MCU component repository is one element **common to all** STM32Cube MCU embedded software packages, providing the **LSM303AGR** BSP MEMS component part.
## License
Copyright (c) 2014 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/lsm303agr/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/lsm303agr/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,609 @@
/**
******************************************************************************
* @file lsm303agr.c
* @author MCD Application Team
* @version V1.0.0
* @date 10-October-2016
* @brief This file provides a set of functions needed to manage the lsm303agr
* MEMS accelerometer.
******************************************************************************
* @attention
*
* Copyright (c) 2014 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 "lsm303agr.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup LSM303AGR
* @{
*/
/** @defgroup LSM303AGR_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup LSM303AGR_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup LSM303AGR_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup LSM303AGR_Private_Variables
* @{
*/
ACCELERO_DrvTypeDef Lsm303agrDrv =
{
LSM303AGR_AccInit,
LSM303AGR_AccDeInit,
LSM303AGR_AccReadID,
LSM303AGR_AccRebootCmd,
0,
LSM303AGR_AccZClickITConfig,
0,
0,
0,
0,
LSM303AGR_AccFilterConfig,
LSM303AGR_AccFilterCmd,
LSM303AGR_AccReadXYZ
};
uint8_t tmpreg2A[8] = {0x00};
uint8_t tmpreg3A = 0x00;
uint8_t tmpregcfgA = 0x00;
/**
* @}
*/
/** @defgroup LSM303AGR_Private_Functions
* @{
*/
/**
* @brief Set LSM303AGR Initialization.
* @param InitStruct: Init parameters
* @retval None
*/
void LSM303AGR_AccInit(uint16_t InitStruct)
{
uint8_t ctrl = 0x00;
/* Low level init */
COMPASSACCELERO_IO_Init();
/* Write value to ACC MEMS CTRL_REG1 register */
ctrl = (uint8_t) InitStruct;
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303AGR_CTRL_REG1_A, ctrl);
/* Write value to ACC MEMS CTRL_REG4 register */
ctrl = (uint8_t) (InitStruct << 8);
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303AGR_CTRL_REG4_A, ctrl);
}
/**
* @brief LSM303AGR De-initialization.
* @param None
* @retval None
*/
void LSM303AGR_AccDeInit(void)
{
}
/**
* @brief Read LSM303AGR ID.
* @param None
* @retval ID
*/
uint8_t LSM303AGR_AccReadID(void)
{
uint8_t ctrl = 0x00;
/* Low level init */
COMPASSACCELERO_IO_Init();
/* Read value at Who am I register address */
ctrl = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_WHO_AM_I_ADDR);
return ctrl;
}
/**
* @brief Reboot memory content of LSM303AGR
* @param None
* @retval None
*/
void LSM303AGR_AccRebootCmd(void)
{
uint8_t tmpreg;
/* Read CTRL_REG5 register */
tmpreg = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_CTRL_REG5_A);
/* Enable or Disable the reboot memory */
tmpreg |= LSM303AGR_BOOT_REBOOTMEMORY;
/* Write value to ACC MEMS CTRL_REG5 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303AGR_CTRL_REG5_A, tmpreg);
}
/**
* @brief Set High Pass Filter Modality
* @param FilterStruct: contains data for filter config
* @retval None
*/
void LSM303AGR_AccFilterConfig(uint8_t FilterStruct)
{
uint8_t tmpreg;
/* Read CTRL_REG2 register */
tmpreg = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_CTRL_REG2_A);
tmpreg &= 0x0C;
tmpreg |= FilterStruct;
/* Write value to ACC MEMS CTRL_REG2 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303AGR_CTRL_REG2_A, tmpreg);
}
/**
* @brief Enable or Disable High Pass Filter
* @param HighPassFilterState: new state of the High Pass Filter feature.
* This parameter can be:
* @arg: LSM303AGR_HIGHPASSFILTER_DISABLE
* @arg: LSM303AGR_HIGHPASSFILTER_ENABLE
* @retval None
*/
void LSM303AGR_AccFilterCmd(uint8_t HighPassFilterState)
{
uint8_t tmpreg;
/* Read CTRL_REG2 register */
tmpreg = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_CTRL_REG2_A);
tmpreg &= 0xF7;
tmpreg |= HighPassFilterState;
/* Write value to ACC MEMS CTRL_REG2 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303AGR_CTRL_REG2_A, tmpreg);
}
/**
* @brief Read X, Y & Z Acceleration values
* @param pData: Data out pointer
* @retval None
*/
void LSM303AGR_AccReadXYZ(int16_t* pData)
{
int16_t pnRawData[3];
uint8_t ctrlx[2]={0,0};
int8_t buffer[6];
uint8_t i = 0;
uint8_t sensitivity = LSM303AGR_ACC_SENSITIVITY_2G;
/* Read the acceleration control register content */
ctrlx[0] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_CTRL_REG4_A);
ctrlx[1] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_CTRL_REG5_A);
/* Read output register X, Y & Z acceleration */
buffer[0] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_OUT_X_L_A);
buffer[1] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_OUT_X_H_A);
buffer[2] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_OUT_Y_L_A);
buffer[3] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_OUT_Y_H_A);
buffer[4] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_OUT_Z_L_A);
buffer[5] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_OUT_Z_H_A);
/* Check in the control register4 the data alignment*/
if(!(ctrlx[0] & LSM303AGR_BLE_MSB))
{
for(i=0; i<3; i++)
{
pnRawData[i]=((int16_t)((uint16_t)buffer[2*i+1] << 8) + buffer[2*i]);
}
}
else /* Big Endian Mode */
{
for(i=0; i<3; i++)
{
pnRawData[i]=((int16_t)((uint16_t)buffer[2*i] << 8) + buffer[2*i+1]);
}
}
/* Normal mode */
/* Switch the sensitivity value set in the CRTL4 */
switch(ctrlx[0] & LSM303AGR_FULLSCALE_16G)
{
case LSM303AGR_FULLSCALE_2G:
sensitivity = LSM303AGR_ACC_SENSITIVITY_2G;
break;
case LSM303AGR_FULLSCALE_4G:
sensitivity = LSM303AGR_ACC_SENSITIVITY_4G;
break;
case LSM303AGR_FULLSCALE_8G:
sensitivity = LSM303AGR_ACC_SENSITIVITY_8G;
break;
case LSM303AGR_FULLSCALE_16G:
sensitivity = LSM303AGR_ACC_SENSITIVITY_16G;
break;
}
/* Obtain the mg value for the three axis */
for(i=0; i<3; i++)
{
pData[i]=(pnRawData[i] * sensitivity);
}
}
/**
* @brief Enable or Disable High Pass Filter on CLick
* @param HighPassFilterState: new state of the High Pass Filter feature.
* This parameter can be:
* @arg: LSM303AGR_HPF_CLICK_DISABLE
* @arg: LSM303AGR_HPF_CLICK_ENABLE
* @retval None
*/
void LSM303AGR_AccFilterClickCmd(uint8_t HighPassFilterClickState)
{
uint8_t tmpreg = 0x00;
/* Read CTRL_REG2 register */
tmpreg = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_CTRL_REG2_A);
tmpreg &= ~(LSM303AGR_HPF_CLICK_ENABLE);
tmpreg |= HighPassFilterClickState;
/* Write value to ACC MEMS CTRL_REG2 regsister */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303AGR_CTRL_REG2_A, tmpreg);
}
/**
* @brief Enable LSM303AGR Interrupt1
* @param LSM303AGR_IT: specifies the LSM303AGR interrupt source to be enabled.
* This parameter can be any combination of the following values:
* @arg LSM303AGR_IT1_CLICK
* @arg LSM303AGR_IT1_AOI1
* @arg LSM303AGR_IT1_AOI2
* @arg LSM303AGR_IT1_DRY1
* @arg LSM303AGR_IT1_DRY2
* @arg LSM303AGR_IT1_WTM
* @arg LSM303AGR_IT1_OVERRUN
* @retval None
*/
void LSM303AGR_AccIT1Enable(uint8_t LSM303AGR_IT)
{
uint8_t tmpval = 0x00;
/* Read CTRL_REG3 register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_CTRL_REG3_A);
/* Enable IT1 */
tmpval |= LSM303AGR_IT;
/* Write value to MEMS CTRL_REG3 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303AGR_CTRL_REG3_A, tmpval);
}
/**
* @brief Disable LSM303AGR Interrupt1
* @param LSM303AGR_IT: specifies the LSM303AGR interrupt source to be disabled.
* This parameter can be any combination of the following values:
* @arg LSM303AGR_IT1_CLICK
* @arg LSM303AGR_IT1_AOI1
* @arg LSM303AGR_IT1_AOI2
* @arg LSM303AGR_IT1_DRY1
* @arg LSM303AGR_IT1_DRY2
* @arg LSM303AGR_IT1_WTM
* @arg LSM303AGR_IT1_OVERRUN
* @retval None
*/
void LSM303AGR_AccIT1Disable(uint8_t LSM303AGR_IT)
{
uint8_t tmpval = 0x00;
/* Read CTRL_REG3 register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_CTRL_REG3_A);
/* Disable IT1 */
tmpval &= ~LSM303AGR_IT;
/* Write value to MEMS CTRL_REG3 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303AGR_CTRL_REG3_A, tmpval);
}
/**
* @brief Enable LSM303AGR Interrupt2
* @param LSM303AGR_IT: specifies the LSM303AGR interrupt source to be enabled.
* This parameter can be any combination of the following values:
* @arg LSM303AGR_IT2_CLICK
* @arg LSM303AGR_IT2_INT1
* @arg LSM303AGR_IT2_INT2
* @arg LSM303AGR_IT2_BOOT
* @arg LSM303AGR_IT2_ACT
* @arg LSM303AGR_IT2_HLACTIVE
* @retval None
*/
void LSM303AGR_AccIT2Enable(uint8_t LSM303AGR_IT)
{
uint8_t tmpval = 0x00;
/* Read CTRL_REG3 register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_CTRL_REG6_A);
/* Enable IT2 */
tmpval |= LSM303AGR_IT;
/* Write value to MEMS CTRL_REG3 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303AGR_CTRL_REG6_A, tmpval);
}
/**
* @brief Disable LSM303AGR Interrupt2
* @param LSM303AGR_IT: specifies the LSM303AGR interrupt source to be disabled.
* This parameter can be any combination of the following values:
* @arg LSM303AGR_IT2_CLICK
* @arg LSM303AGR_IT2_INT1
* @arg LSM303AGR_IT2_INT2
* @arg LSM303AGR_IT2_BOOT
* @arg LSM303AGR_IT2_ACT
* @arg LSM303AGR_IT2_HLACTIVE
* @retval None
*/
void LSM303AGR_AccIT2Disable(uint8_t LSM303AGR_IT)
{
uint8_t tmpval = 0x00;
/* Read CTRL_REG3 register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_CTRL_REG6_A);
/* Disable IT2 */
tmpval &= ~LSM303AGR_IT;
/* Write value to MEMS CTRL_REG3 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303AGR_CTRL_REG6_A, tmpval);
}
/**
* @brief INT1 interrupt enable
* @param ITCombination: Or or And combination
* ITAxes: Axes to be enabled
* @retval None
*/
void LSM303AGR_AccINT1InterruptEnable(uint8_t ITCombination, uint8_t ITAxes)
{
uint8_t tmpval = 0x00;
/* Read INT1_CFR register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_INT1_CFG_A);
/* Enable the selected interrupt */
tmpval |= (ITAxes | ITCombination);
/* Write value to MEMS INT1_CFR register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303AGR_INT1_CFG_A, tmpval);
}
/**
* @brief INT1 interrupt disable
* @param ITCombination: Or or And combination
* ITAxes: Axes to be enabled
* @retval None
*/
void LSM303AGR_AccINT1InterruptDisable(uint8_t ITCombination, uint8_t ITAxes)
{
uint8_t tmpval = 0x00;
/* Read INT1_CFR register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_INT1_CFG_A);
/* Disable the selected interrupt */
tmpval &= ~(ITAxes | ITCombination);
/* Write value to MEMS INT1_CFR register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303AGR_INT1_CFG_A, tmpval);
}
/**
* @brief INT2 interrupt enable
* @param ITCombination: Or or And combination
* ITAxes: axes to be enabled
* @retval None
*/
void LSM303AGR_AccINT2InterruptEnable(uint8_t ITCombination, uint8_t ITAxes)
{
uint8_t tmpval = 0x00;
/* Read INT2_CFR register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_INT2_CFG_A);
/* Enable the selected interrupt */
tmpval |= (ITAxes | ITCombination);
/* Write value to MEMS INT2_CFR register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303AGR_INT2_CFG_A, tmpval);
}
/**
* @brief INT2 interrupt config
* @param ITCombination: Or or And combination
* ITAxes: axes to be enabled
* @retval None
*/
void LSM303AGR_AccINT2InterruptDisable(uint8_t ITCombination, uint8_t ITAxes)
{
uint8_t tmpval = 0x00;
/* Read INT2_CFR register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_INT2_CFG_A);
/* Disable the selected interrupt */
tmpval &= ~(ITAxes | ITCombination);
/* Write value to MEMS INT2_CFR register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303AGR_INT2_CFG_A, tmpval);
}
/**
* @brief Click interrupt enable
* @param ITClick: the selected interrupt to enable
* @retval None
*/
void LSM303AGR_AccClickITEnable(uint8_t ITClick)
{
uint8_t tmpval = 0x00;
/* Read CLICK_CFR register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_CLICK_CFG_A);
/* Enable the selected interrupt */
tmpval |= ITClick;
/* Write value to MEMS CLICK CFG register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303AGR_CLICK_CFG_A, tmpval);
/* Configure Click Threshold on Z axis */
tmpval = 0x0A;
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303AGR_CLICK_THS_A, tmpval);
/* Configure Time Limit */
tmpval = 0x05;
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303AGR_TIME_LIMIT_A, tmpval);
/* Configure Latency */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303AGR_TIME_LATENCY_A, tmpval);
/* Configure Click Window */
tmpval = 0x32;
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303AGR_TIME_WINDOW_A, tmpval);
}
/**
* @brief Click interrupt disable
* @param ITClick: the selected click interrupt to disable
* @retval None
*/
void LSM303AGR_AccClickITDisable(uint8_t ITClick)
{
uint8_t tmpval = 0x00;
/* Read CLICK_CFR register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303AGR_CLICK_CFG_A);
/* Disable the selected interrupt */
tmpval &= ~ITClick;
/* Write value to MEMS CLICK_CFR register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303AGR_CLICK_CFG_A, tmpval);
}
/**
* @brief Click on Z axis interrupt config
* @param None
* @retval None
*/
void LSM303AGR_AccZClickITConfig(void)
{
/* Configure low level IT config */
COMPASSACCELERO_IO_ITConfig();
/* Select click IT as INT1 interrupt */
LSM303AGR_AccIT1Enable(LSM303AGR_IT1_CLICK);
/* Enable High pass filter for click IT */
LSM303AGR_AccFilterClickCmd(LSM303AGR_HPF_CLICK_ENABLE);
/* Enable simple click IT on Z axis, */
LSM303AGR_AccClickITEnable(LSM303AGR_Z_SINGLE_CLICK);
}
#ifdef MAGNET
/**
* @brief Set LSM303AGR Mag Initialization.
* @param LSM303AGR_InitStruct: pointer to a LSM303AGR_MagInitTypeDef structure
* that contains the configuration setting for the LSM303AGR.
* @retval None
*/
void LSM303AGR_MagInit(LSM303AGRMag_InitTypeDef *LSM303AGR_InitStruct)
{
uint8_t cra_regm = 0x00, crb_regm = 0x00, mr_regm = 0x00;
/* Configure MEMS: temp and Data rate */
cra_regm |= (uint8_t) (LSM303AGR_InitStruct->Temperature_Sensor | LSM303AGR_InitStruct->MagOutput_DataRate);
/* Configure MEMS: full Scale */
crb_regm |= (uint8_t) (LSM303AGR_InitStruct->MagFull_Scale);
/* Configure MEMS: working mode */
mr_regm |= (uint8_t) (LSM303AGR_InitStruct->Working_Mode);
/* Write value to Mag MEMS CRA_REG register */
COMPASSACCELERO_IO_Write(MAG_I2C_ADDRESS, LSM303AGR_CRA_REG_M, 1, &cra_regm);
/* Write value to Mag MEMS CRB_REG register */
COMPASSACCELERO_IO_Write(MAG_I2C_ADDRESS, LSM303AGR_CRB_REG_M, 1, &crb_regm);
/* Write value to Mag MEMS MR_REG register */
COMPASSACCELERO_IO_Write(MAG_I2C_ADDRESS, LSM303AGR_MR_REG_M, 1, &mr_regm);
}
/**
* @brief Get status for Mag LSM303AGR data
* @param None
* @retval Data status in a LSM303AGR Data register
*/
uint8_t LSM303AGR_MagGetDataStatus(void)
{
uint8_t tmpreg;
/* Read Mag STATUS register */
COMPASSACCELERO_IO_Read(MAG_I2C_ADDRESS, LSM303AGR_SR_REG_M, 1, &tmpreg);
return tmpreg;
}
#endif /* MAGNET */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
@@ -0,0 +1,502 @@
/**
******************************************************************************
* @file lsm303agr.h
* @author MCD Application Team
* @version V1.0.0
* @date 10-October-2016
* @brief This file contains all the functions prototypes for the lsm303agr.c driver.
******************************************************************************
* @attention
*
* Copyright (c) 2014 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 __LSM303AGR_H
#define __LSM303AGR_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/accelero.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup LSM303AGR
* @{
*/
/** @defgroup LSM303AGR_Exported_Types
* @{
*/
/**
* @}
*/
/******************************************************************************/
/*************************** START REGISTER MAPPING **************************/
/******************************************************************************/
/* Exported constant IO ------------------------------------------------------*/
#define ACC_I2C_ADDRESS 0x32
#define MAG_I2C_ADDRESS 0x3C
/* Temperature sensor Registers (New vs lsm303dlhc.h) */
#define LSM303AGR_STATUS_REG_AUX_A 0x07 /* status register */
#define LSM303AGR_OUT_TEMP_L_A 0x0C /* output temperature register */
#define LSM303AGR_OUT_TEMP_H_A 0x0D /* output temperature register */
#define LSM303AGR_IN_COUNTER_REG_A 0x0E /* register */
/* Acceleration Registers */
#define LSM303AGR_WHO_AM_I_ADDR 0x0F /* device identification register (0x33) */
#define LSM303AGR_WHO_AM_I_A LSM303AGR_WHO_AM_I_ADDR
/* Temperature sensor Registers (New vs lsm303dlhc.h) */
#define LSM303AGR_TEMP_CFG_REG_A 0x1F /* temperature configuration register */
/* Acceleration Registers */
#define LSM303AGR_CTRL_REG1_A 0x20 /* Control register 1 acceleration */
#define LSM303AGR_CTRL_REG2_A 0x21 /* Control register 2 acceleration */
#define LSM303AGR_CTRL_REG3_A 0x22 /* Control register 3 acceleration */
#define LSM303AGR_CTRL_REG4_A 0x23 /* Control register 4 acceleration */
#define LSM303AGR_CTRL_REG5_A 0x24 /* Control register 5 acceleration */
#define LSM303AGR_CTRL_REG6_A 0x25 /* Control register 6 acceleration */
#define LSM303AGR_REFERENCE_A 0x26 /* Reference register acceleration */
#define LSM303AGR_STATUS_REG_A 0x27 /* Status register acceleration */
#define LSM303AGR_OUT_X_L_A 0x28 /* Output Register X acceleration */
#define LSM303AGR_OUT_X_H_A 0x29 /* Output Register X acceleration */
#define LSM303AGR_OUT_Y_L_A 0x2A /* Output Register Y acceleration */
#define LSM303AGR_OUT_Y_H_A 0x2B /* Output Register Y acceleration */
#define LSM303AGR_OUT_Z_L_A 0x2C /* Output Register Z acceleration */
#define LSM303AGR_OUT_Z_H_A 0x2D /* Output Register Z acceleration */
#define LSM303AGR_FIFO_CTRL_REG_A 0x2E /* Fifo control Register acceleration */
#define LSM303AGR_FIFO_SRC_REG_A 0x2F /* Fifo src Register acceleration */
#define LSM303AGR_INT1_CFG_A 0x30 /* Interrupt 1 configuration Register acceleration */
#define LSM303AGR_INT1_SOURCE_A 0x31 /* Interrupt 1 source Register acceleration */
#define LSM303AGR_INT1_THS_A 0x32 /* Interrupt 1 Threshold register acceleration */
#define LSM303AGR_INT1_DURATION_A 0x33 /* Interrupt 1 DURATION register acceleration */
#define LSM303AGR_INT2_CFG_A 0x34 /* Interrupt 2 configuration Register acceleration */
#define LSM303AGR_INT2_SOURCE_A 0x35 /* Interrupt 2 source Register acceleration */
#define LSM303AGR_INT2_THS_A 0x36 /* Interrupt 2 Threshold register acceleration */
#define LSM303AGR_INT2_DURATION_A 0x37 /* Interrupt 2 DURATION register acceleration */
#define LSM303AGR_CLICK_CFG_A 0x38 /* Click configuration Register acceleration */
#define LSM303AGR_CLICK_SOURCE_A 0x39 /* Click 2 source Register acceleration */
#define LSM303AGR_CLICK_THS_A 0x3A /* Click 2 Threshold register acceleration */
#define LSM303AGR_TIME_LIMIT_A 0x3B /* Time Limit Register acceleration */
#define LSM303AGR_TIME_LATENCY_A 0x3C /* Time Latency Register acceleration */
#define LSM303AGR_TIME_WINDOW_A 0x3D /* Time window register acceleration */
/* System Registers(New vs lsm303dlhc.h) */
#define LSM303AGR_Act_THS_A 0x3E /* return to sleep activation threshold register */
#define LSM303AGR_Act_DUR_A 0x3F /* return to sleep duration register */
/* Magnetometer */
#define LSM303AGR_X_REG_L_M 0x45 /* Hard-iron X magnetic field */
#define LSM303AGR_X_REG_H_M 0x46 /* Hard-iron X magnetic field */
#define LSM303AGR_Y_REG_L_M 0x47 /* Hard-iron Y magnetic field */
#define LSM303AGR_Y_REG_H_M 0x48 /* Hard-iron Y magnetic field */
#define LSM303AGR_Z_REG_L_M 0x49 /* Hard-iron Z magnetic field */
#define LSM303AGR_Z_REH_H_M 0x4A /* Hard-iron Z magnetic field */
#define LSM303AGR_WHO_AM_I_M 0x4F /* Who am i register magnetic field (0x40) */
#define LSM303AGR_CFG_REG_A_M 0x60 /* Configuration register A magnetic field */
#define LSM303AGR_CFG_REG_B_M 0x61 /* Configuration register B magnetic field */
#define LSM303AGR_CFG_REG_C_M 0x62 /* Configuration register C magnetic field */
#define LSM303AGR_INT_CTRL_REG_M 0x63 /* interrupt control register magnetic field */
#define LSM303AGR_INT_SOURCE_REG_M 0x64 /* interrupt source register magnetic field */
#define LSM303AGR_INT_THS_L_REG_M 0x65 /* interrupt threshold register magnetic field */
#define LSM303AGR_INT_THS_H_REG_M 0x66 /* interrupt threshold register magnetic field*/
#define LSM303AGR_STATUS_REG_M 0x67 /* Status Register magnetic field */
#define LSM303AGR_OUTX_L_REG_M 0x68 /* Output Register X magnetic field */
#define LSM303AGR_OUTX_H_REG_M 0x69 /* Output Register X magnetic field */
#define LSM303AGR_OUTY_L_REG_M 0x6A /* Output Register X magnetic field */
#define LSM303AGR_OUTY_H_REG_M 0x6B /* Output Register X magnetic field */
#define LSM303AGR_OUTZ_L_REG_M 0x6C /* Output Register X magnetic field */
#define LSM303AGR_OUTZ_H_REG_M 0x6D /* Output Register X magnetic field */
/******************************************************************************/
/**************************** END REGISTER MAPPING ***************************/
/******************************************************************************/
#define I_AM_LSM303AGR ((uint8_t)0x33)
/** @defgroup Acc_Power_Mode_selection
* @{
*/
#define LSM303AGR_NORMAL_MODE ((uint8_t)0x00)
#define LSM303AGR_LOWPOWER_MODE ((uint8_t)0x08)
/**
* @}
*/
/** @defgroup Acc_OutPut_DataRate_Selection
* @{
*/
#define LSM303AGR_ODR_1_HZ ((uint8_t)0x10) /*!< Output Data Rate = 1 Hz */
#define LSM303AGR_ODR_10_HZ ((uint8_t)0x20) /*!< Output Data Rate = 10 Hz */
#define LSM303AGR_ODR_25_HZ ((uint8_t)0x30) /*!< Output Data Rate = 25 Hz */
#define LSM303AGR_ODR_50_HZ ((uint8_t)0x40) /*!< Output Data Rate = 50 Hz */
#define LSM303AGR_ODR_100_HZ ((uint8_t)0x50) /*!< Output Data Rate = 100 Hz */
#define LSM303AGR_ODR_200_HZ ((uint8_t)0x60) /*!< Output Data Rate = 200 Hz */
#define LSM303AGR_ODR_400_HZ ((uint8_t)0x70) /*!< Output Data Rate = 400 Hz */
#define LSM303AGR_ODR_1620_HZ_LP ((uint8_t)0x80) /*!< Output Data Rate = 1620 Hz only in Low Power Mode */
#define LSM303AGR_ODR_1344_HZ ((uint8_t)0x90) /*!< Output Data Rate = 1344 Hz in Normal mode and 5376 Hz in Low Power Mode */
/**
* @}
*/
/** @defgroup Acc_Axes_Selection
* @{
*/
#define LSM303AGR_X_ENABLE ((uint8_t)0x01)
#define LSM303AGR_Y_ENABLE ((uint8_t)0x02)
#define LSM303AGR_Z_ENABLE ((uint8_t)0x04)
#define LSM303AGR_AXES_ENABLE ((uint8_t)0x07)
#define LSM303AGR_AXES_DISABLE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Acc_High_Resolution
* @{
*/
#define LSM303AGR_HR_ENABLE ((uint8_t)0x08)
#define LSM303AGR_HR_DISABLE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Acc_Full_Scale_Selection
* @{
*/
#define LSM303AGR_FULLSCALE_2G ((uint8_t)0x00) /*!< ±2 g */
#define LSM303AGR_FULLSCALE_4G ((uint8_t)0x10) /*!< ±4 g */
#define LSM303AGR_FULLSCALE_8G ((uint8_t)0x20) /*!< ±8 g */
#define LSM303AGR_FULLSCALE_16G ((uint8_t)0x30) /*!< ±16 g */
/**
* @}
*/
/** @defgroup Acc_Full_Scale_Selection
* @{
*/
#define LSM303AGR_ACC_SENSITIVITY_2G ((uint8_t)1) /*!< accelerometer sensitivity with 2 g full scale [mg/LSB] */
#define LSM303AGR_ACC_SENSITIVITY_4G ((uint8_t)2) /*!< accelerometer sensitivity with 4 g full scale [mg/LSB] */
#define LSM303AGR_ACC_SENSITIVITY_8G ((uint8_t)4) /*!< accelerometer sensitivity with 8 g full scale [mg/LSB] */
#define LSM303AGR_ACC_SENSITIVITY_16G ((uint8_t)12) /*!< accelerometer sensitivity with 12 g full scale [mg/LSB] */
/**
* @}
*/
/** @defgroup Acc_Block_Data_Update
* @{
*/
#define LSM303AGR_BlockUpdate_Continous ((uint8_t)0x00) /*!< Continuos Update */
#define LSM303AGR_BlockUpdate_Single ((uint8_t)0x80) /*!< Single Update: output registers not updated until MSB and LSB reading */
/**
* @}
*/
/** @defgroup Acc_Endian_Data_selection
* @{
*/
#define LSM303AGR_BLE_LSB ((uint8_t)0x00) /*!< Little Endian: data LSB @ lower address */
#define LSM303AGR_BLE_MSB ((uint8_t)0x40) /*!< Big Endian: data MSB @ lower address */
/**
* @}
*/
/** @defgroup Acc_Boot_Mode_selection
* @{
*/
#define LSM303AGR_BOOT_NORMALMODE ((uint8_t)0x00)
#define LSM303AGR_BOOT_REBOOTMEMORY ((uint8_t)0x80)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_Mode
* @{
*/
#define LSM303AGR_HPM_NORMAL_MODE_RES ((uint8_t)0x00)
#define LSM303AGR_HPM_REF_SIGNAL ((uint8_t)0x40)
#define LSM303AGR_HPM_NORMAL_MODE ((uint8_t)0x80)
#define LSM303AGR_HPM_AUTORESET_INT ((uint8_t)0xC0)
/**
* @}
*/
/** @defgroup Acc_High_Pass_CUT OFF_Frequency
* @{
*/
#define LSM303AGR_HPFCF_8 ((uint8_t)0x00)
#define LSM303AGR_HPFCF_16 ((uint8_t)0x10)
#define LSM303AGR_HPFCF_32 ((uint8_t)0x20)
#define LSM303AGR_HPFCF_64 ((uint8_t)0x30)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_status
* @{
*/
#define LSM303AGR_HIGHPASSFILTER_DISABLE ((uint8_t)0x00)
#define LSM303AGR_HIGHPASSFILTER_ENABLE ((uint8_t)0x08)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_Click_status
* @{
*/
#define LSM303AGR_HPF_CLICK_DISABLE ((uint8_t)0x00)
#define LSM303AGR_HPF_CLICK_ENABLE ((uint8_t)0x04)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_AOI1_status
* @{
*/
#define LSM303AGR_HPF_AOI1_DISABLE ((uint8_t)0x00)
#define LSM303AGR_HPF_AOI1_ENABLE ((uint8_t)0x01)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_AOI2_status
* @{
*/
#define LSM303AGR_HPF_AOI2_DISABLE ((uint8_t)0x00)
#define LSM303AGR_HPF_AOI2_ENABLE ((uint8_t)0x02)
/**
* @}
*/
/** @defgroup Acc_Interrupt1_Configuration_definition
* @{
*/
#define LSM303AGR_IT1_CLICK ((uint8_t)0x80)
#define LSM303AGR_IT1_AOI1 ((uint8_t)0x40)
#define LSM303AGR_IT1_AOI2 ((uint8_t)0x20)
#define LSM303AGR_IT1_DRY1 ((uint8_t)0x10)
#define LSM303AGR_IT1_DRY2 ((uint8_t)0x08)
#define LSM303AGR_IT1_WTM ((uint8_t)0x04)
#define LSM303AGR_IT1_OVERRUN ((uint8_t)0x02)
/**
* @}
*/
/** @defgroup Acc_Interrupt2_Configuration_definition
* @{
*/
#define LSM303AGR_IT2_CLICK ((uint8_t)0x80)
#define LSM303AGR_IT2_INT1 ((uint8_t)0x40)
#define LSM303AGR_IT2_INT2 ((uint8_t)0x20)
#define LSM303AGR_IT2_BOOT ((uint8_t)0x10)
#define LSM303AGR_IT2_ACT ((uint8_t)0x08)
#define LSM303AGR_IT2_HLACTIVE ((uint8_t)0x02)
/**
* @}
*/
/** @defgroup Acc_INT_Combination_Status
* @{
*/
#define LSM303AGR_OR_COMBINATION ((uint8_t)0x00) /*!< OR combination of enabled IRQs */
#define LSM303AGR_AND_COMBINATION ((uint8_t)0x80) /*!< AND combination of enabled IRQs */
#define LSM303AGR_MOV_RECOGNITION ((uint8_t)0x40) /*!< 6D movement recognition */
#define LSM303AGR_POS_RECOGNITION ((uint8_t)0xC0) /*!< 6D position recognition */
/**
* @}
*/
/** @defgroup Acc_INT_Axes
* @{
*/
#define LSM303AGR_Z_HIGH ((uint8_t)0x20) /*!< Z High enabled IRQs */
#define LSM303AGR_Z_LOW ((uint8_t)0x10) /*!< Z low enabled IRQs */
#define LSM303AGR_Y_HIGH ((uint8_t)0x08) /*!< Y High enabled IRQs */
#define LSM303AGR_Y_LOW ((uint8_t)0x04) /*!< Y low enabled IRQs */
#define LSM303AGR_X_HIGH ((uint8_t)0x02) /*!< X High enabled IRQs */
#define LSM303AGR_X_LOW ((uint8_t)0x01) /*!< X low enabled IRQs */
/**
* @}
*/
/** @defgroup Acc_INT_Click
* @{
*/
#define LSM303AGR_Z_DOUBLE_CLICK ((uint8_t)0x20) /*!< Z double click IRQs */
#define LSM303AGR_Z_SINGLE_CLICK ((uint8_t)0x10) /*!< Z single click IRQs */
#define LSM303AGR_Y_DOUBLE_CLICK ((uint8_t)0x08) /*!< Y double click IRQs */
#define LSM303AGR_Y_SINGLE_CLICK ((uint8_t)0x04) /*!< Y single click IRQs */
#define LSM303AGR_X_DOUBLE_CLICK ((uint8_t)0x02) /*!< X double click IRQs */
#define LSM303AGR_X_SINGLE_CLICK ((uint8_t)0x01) /*!< X single click IRQs */
/**
* @}
*/
/** @defgroup Acc_INT1_Interrupt_status
* @{
*/
#define LSM303AGR_INT1INTERRUPT_DISABLE ((uint8_t)0x00)
#define LSM303AGR_INT1INTERRUPT_ENABLE ((uint8_t)0x80)
/**
* @}
*/
/** @defgroup Acc_INT1_Interrupt_ActiveEdge
* @{
*/
#define LSM303AGR_INT1INTERRUPT_LOW_EDGE ((uint8_t)0x20)
#define LSM303AGR_INT1INTERRUPT_HIGH_EDGE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Mag_Data_Rate
* @{
*/
#define LSM303AGR_ODR_0_75_HZ ((uint8_t) 0x00) /*!< Output Data Rate = 0.75 Hz */
#define LSM303AGR_ODR_1_5_HZ ((uint8_t) 0x04) /*!< Output Data Rate = 1.5 Hz */
#define LSM303AGR_ODR_3_0_HZ ((uint8_t) 0x08) /*!< Output Data Rate = 3 Hz */
#define LSM303AGR_ODR_7_5_HZ ((uint8_t) 0x0C) /*!< Output Data Rate = 7.5 Hz */
#define LSM303AGR_ODR_15_HZ ((uint8_t) 0x10) /*!< Output Data Rate = 15 Hz */
#define LSM303AGR_ODR_30_HZ ((uint8_t) 0x14) /*!< Output Data Rate = 30 Hz */
#define LSM303AGR_ODR_75_HZ ((uint8_t) 0x18) /*!< Output Data Rate = 75 Hz */
#define LSM303AGR_ODR_220_HZ ((uint8_t) 0x1C) /*!< Output Data Rate = 220 Hz */
/**
* @}
*/
/** @defgroup Mag_Full_Scale
* @{
*/
#define LSM303AGR_FS_1_3_GA ((uint8_t) 0x20) /*!< Full scale = ±1.3 Gauss */
#define LSM303AGR_FS_1_9_GA ((uint8_t) 0x40) /*!< Full scale = ±1.9 Gauss */
#define LSM303AGR_FS_2_5_GA ((uint8_t) 0x60) /*!< Full scale = ±2.5 Gauss */
#define LSM303AGR_FS_4_0_GA ((uint8_t) 0x80) /*!< Full scale = ±4.0 Gauss */
#define LSM303AGR_FS_4_7_GA ((uint8_t) 0xA0) /*!< Full scale = ±4.7 Gauss */
#define LSM303AGR_FS_5_6_GA ((uint8_t) 0xC0) /*!< Full scale = ±5.6 Gauss */
#define LSM303AGR_FS_8_1_GA ((uint8_t) 0xE0) /*!< Full scale = ±8.1 Gauss */
/**
* @}
*/
/**
* @defgroup Magnetometer_Sensitivity
* @{
*/
#define LSM303AGR_M_SENSITIVITY_XY_1_3Ga 1100 /*!< magnetometer X Y axes sensitivity for 1.3 Ga full scale [LSB/Ga] */
#define LSM303AGR_M_SENSITIVITY_XY_1_9Ga 855 /*!< magnetometer X Y axes sensitivity for 1.9 Ga full scale [LSB/Ga] */
#define LSM303AGR_M_SENSITIVITY_XY_2_5Ga 670 /*!< magnetometer X Y axes sensitivity for 2.5 Ga full scale [LSB/Ga] */
#define LSM303AGR_M_SENSITIVITY_XY_4Ga 450 /*!< magnetometer X Y axes sensitivity for 4 Ga full scale [LSB/Ga] */
#define LSM303AGR_M_SENSITIVITY_XY_4_7Ga 400 /*!< magnetometer X Y axes sensitivity for 4.7 Ga full scale [LSB/Ga] */
#define LSM303AGR_M_SENSITIVITY_XY_5_6Ga 330 /*!< magnetometer X Y axes sensitivity for 5.6 Ga full scale [LSB/Ga] */
#define LSM303AGR_M_SENSITIVITY_XY_8_1Ga 230 /*!< magnetometer X Y axes sensitivity for 8.1 Ga full scale [LSB/Ga] */
#define LSM303AGR_M_SENSITIVITY_Z_1_3Ga 980 /*!< magnetometer Z axis sensitivity for 1.3 Ga full scale [LSB/Ga] */
#define LSM303AGR_M_SENSITIVITY_Z_1_9Ga 760 /*!< magnetometer Z axis sensitivity for 1.9 Ga full scale [LSB/Ga] */
#define LSM303AGR_M_SENSITIVITY_Z_2_5Ga 600 /*!< magnetometer Z axis sensitivity for 2.5 Ga full scale [LSB/Ga] */
#define LSM303AGR_M_SENSITIVITY_Z_4Ga 400 /*!< magnetometer Z axis sensitivity for 4 Ga full scale [LSB/Ga] */
#define LSM303AGR_M_SENSITIVITY_Z_4_7Ga 355 /*!< magnetometer Z axis sensitivity for 4.7 Ga full scale [LSB/Ga] */
#define LSM303AGR_M_SENSITIVITY_Z_5_6Ga 295 /*!< magnetometer Z axis sensitivity for 5.6 Ga full scale [LSB/Ga] */
#define LSM303AGR_M_SENSITIVITY_Z_8_1Ga 205 /*!< magnetometer Z axis sensitivity for 8.1 Ga full scale [LSB/Ga] */
/**
* @}
*/
/** @defgroup Mag_Working_Mode
* @{
*/
#define LSM303AGR_CONTINUOS_CONVERSION ((uint8_t) 0x00) /*!< Continuous-Conversion Mode */
#define LSM303AGR_SINGLE_CONVERSION ((uint8_t) 0x01) /*!< Single-Conversion Mode */
#define LSM303AGR_SLEEP ((uint8_t) 0x02) /*!< Sleep Mode */
/**
* @}
*/
/** @defgroup Mag_Temperature_Sensor
* @{
*/
#define LSM303AGR_TEMPSENSOR_ENABLE ((uint8_t) 0x80) /*!< Temp sensor Enable */
#define LSM303AGR_TEMPSENSOR_DISABLE ((uint8_t) 0x00) /*!< Temp sensor Disable */
/**
* @}
*/
/** @defgroup LSM303AGR_Exported_Functions
* @{
*/
/* ACC functions */
void LSM303AGR_AccInit(uint16_t InitStruct);
void LSM303AGR_AccDeInit(void);
uint8_t LSM303AGR_AccReadID(void);
void LSM303AGR_AccRebootCmd(void);
void LSM303AGR_AccFilterConfig(uint8_t FilterStruct);
void LSM303AGR_AccFilterCmd(uint8_t HighPassFilterState);
void LSM303AGR_AccReadXYZ(int16_t* pData);
void LSM303AGR_AccFilterClickCmd(uint8_t HighPassFilterClickState);
void LSM303AGR_AccIT1Enable(uint8_t LSM303AGR_IT);
void LSM303AGR_AccIT1Disable(uint8_t LSM303AGR_IT);
void LSM303AGR_AccIT2Enable(uint8_t LSM303AGR_IT);
void LSM303AGR_AccIT2Disable(uint8_t LSM303AGR_IT);
void LSM303AGR_AccINT1InterruptEnable(uint8_t ITCombination, uint8_t ITAxes);
void LSM303AGR_AccINT1InterruptDisable(uint8_t ITCombination, uint8_t ITAxes);
void LSM303AGR_AccINT2InterruptEnable(uint8_t ITCombination, uint8_t ITAxes);
void LSM303AGR_AccINT2InterruptDisable(uint8_t ITCombination, uint8_t ITAxes);
void LSM303AGR_AccClickITEnable(uint8_t ITClick);
void LSM303AGR_AccClickITDisable(uint8_t ITClick);
void LSM303AGR_AccZClickITConfig(void);
#if 0
/* MAG functions */
void LSM303AGR_MagInit(LSM303AGRMag_InitTypeDef *LSM303AGR_InitStruct);
uint8_t LSM303AGR_MagGetDataStatus(void);
void LSM303AGR_CompassReadAcc(int16_t* pData);
#endif
/* COMPASS / ACCELERO IO functions */
void COMPASSACCELERO_IO_Init(void);
void COMPASSACCELERO_IO_ITConfig(void);
void COMPASSACCELERO_IO_Write(uint16_t DeviceAddr, uint8_t RegisterAddr, uint8_t Value);
uint8_t COMPASSACCELERO_IO_Read(uint16_t DeviceAddr, uint8_t RegisterAddr);
/* ACC driver structure */
extern ACCELERO_DrvTypeDef Lsm303agrDrv;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __LSM303AGR_H */