RT。。。。。
单片机源程序如下:
- /******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
- * File Name : LIS2DW12_ACC_driver.c
- * Author : MEMS Application Team
- * Version : v1.1
- * Date : 11 May 2017
- * Description : EKSTM32 main file
- *
- ********************************************************************************
- * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
- * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
- * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
- * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
- * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
- * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
- *
- * THIS SOFTWARE IS SPECIFICALLY DESIGNED FOR EXCLUSIVE USE WITH ST PARTS.
- *******************************************************************************/
- /* Includes ------------------------------------------------------------------*/
- #include "LIS2DW12_ACC_driver.h"
- #include "spi.h"
- /* Private typedef -----------------------------------------------------------*/
- /* Private define ------------------------------------------------------------*/
- /* Private macro -------------------------------------------------------------*/
- /* Private variables ---------------------------------------------------------*/
- /* Private functions ---------------------------------------------------------*/
- /************** Generic Function *******************/
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_WriteReg
- * Description : Generic Writing function. It must be fullfilled with either
- * : I2C or SPI writing function
- * Input : Register Address, ptr to buffer to be written,
- * length of buffer
- * Output : None
- * Return : None
- *******************************************************************************/
- status_t LIS2DW12_ACC_WriteReg(void *handle, u8_t Reg, u8_t *Bufp, u16_t len)
- {
- /* Example
- HAL_GPIO_WritePin(CS_DEV_GPIO_Port, CS_DEV_Pin, GPIO_PIN_RESET);
- HAL_SPI_Transmit(&hspi2, &Reg, 1, 1000);
- HAL_SPI_Transmit(&hspi2, Bufp, len, 1000);
- HAL_GPIO_WritePin(CS_DEV_GPIO_Port, CS_DEV_Pin, GPIO_PIN_SET);
- */
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_ReadReg
- * Description : Generic Reading function. It must be fullfilled with either
- * : I2C or SPI writing function
- * Input : Register Address, ptr to buffer to be read,
- * length of buffer
- * Output : None
- * Return : None
- *******************************************************************************/
- status_t LIS2DW12_ACC_ReadReg(void *handle, u8_t Reg, u8_t *Bufp, u16_t len)
- {
- /* Example
- HAL_GPIO_WritePin(CS_DEV_GPIO_Port, CS_DEV_Pin, GPIO_PIN_RESET);
- uint8_t dummy = Reg|0x80;
- HAL_SPI_Transmit(&hspi2, &dummy, 1, 1000);
- HAL_SPI_Receive(&hspi2, Bufp, len, 1000);
- HAL_GPIO_WritePin(CS_DEV_GPIO_Port, CS_DEV_Pin, GPIO_PIN_SET);
- */
- return MEMS_SUCCESS;
- }
- /**************** Base Function *******************/
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_R_WhoAmI
- * Description : Read WHO_AM_I_BIT
- * Input : Pointer to u8_t
- * Output : Status of WHO_AM_I_BIT
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_R_WhoAmI(void *handle, u8_t *value)
- {
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_WHO_AM_I_REG, (u8_t *)value , 1) )
- return MEMS_ERROR;
-
- *value &= LIS2DW12_ACC_WHO_AM_I_BIT_MASK; //coerce
- *value = *value >> LIS2DW12_ACC_WHO_AM_I_BIT_POSITION; //mask
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_W_OutputDataRate
- * Description : Write ODR
- * Input : LIS2DW12_ACC_ODR_t
- * Output : None
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_W_OutputDataRate(void *handle, LIS2DW12_ACC_ODR_t newValue)
- {
- u8_t value;
-
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL1, &value, 1) )
- return MEMS_ERROR;
-
- value &= ~LIS2DW12_ACC_ODR_MASK;
- value |= newValue;
-
- if( !LIS2DW12_ACC_WriteReg(handle, LIS2DW12_ACC_CTRL1, &value, 1) )
- return MEMS_ERROR;
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_R_OutputDataRate
- * Description : Read ODR
- * Input : Pointer to LIS2DW12_ACC_ODR_t
- * Output : Status of ODR see LIS2DW12_ACC_ODR_t
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_R_OutputDataRate(void *handle, LIS2DW12_ACC_ODR_t *value)
- {
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL1, (u8_t *)value , 1) )
- return MEMS_ERROR;
-
- *value &= LIS2DW12_ACC_ODR_MASK; //mask
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_W_FullScaleSelection
- * Description : Write FS
- * Input : LIS2DW12_ACC_FS_t
- * Output : None
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_W_FullScaleSelection(void *handle, LIS2DW12_ACC_FS_t newValue)
- {
- u8_t value;
-
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL6, &value, 1) )
- return MEMS_ERROR;
-
- value &= ~LIS2DW12_ACC_FS_MASK;
- value |= newValue;
-
- if( !LIS2DW12_ACC_WriteReg(handle, LIS2DW12_ACC_CTRL6, &value, 1) )
- return MEMS_ERROR;
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_R_FullScaleSelection
- * Description : Read FS
- * Input : Pointer to LIS2DW12_ACC_FS_t
- * Output : Status of FS see LIS2DW12_ACC_FS_t
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_R_FullScaleSelection(void *handle, LIS2DW12_ACC_FS_t *value)
- {
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL6, (u8_t *)value , 1) )
- return MEMS_ERROR;
-
- *value &= LIS2DW12_ACC_FS_MASK; //mask
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_W_BlockDataUpdate
- * Description : Write BDU
- * Input : LIS2DW12_ACC_BDU_t
- * Output : None
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_W_BlockDataUpdate(void *handle, LIS2DW12_ACC_BDU_t newValue)
- {
- u8_t value;
-
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL2, &value, 1) )
- return MEMS_ERROR;
-
- value &= ~LIS2DW12_ACC_BDU_MASK;
- value |= newValue;
-
- if( !LIS2DW12_ACC_WriteReg(handle, LIS2DW12_ACC_CTRL2, &value, 1) )
- return MEMS_ERROR;
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_R_BlockDataUpdate
- * Description : Read BDU
- * Input : Pointer to LIS2DW12_ACC_BDU_t
- * Output : Status of BDU see LIS2DW12_ACC_BDU_t
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_R_BlockDataUpdate(void *handle, LIS2DW12_ACC_BDU_t *value)
- {
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL2, (u8_t *)value , 1) )
- return MEMS_ERROR;
-
- *value &= LIS2DW12_ACC_BDU_MASK; //mask
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : status_t LIS2DW12_ACC_Get_Acceleration(u8_t *buff)
- * Description : Read Acceleration output register
- * Input : pointer to [u8_t]
- * Output : Acceleration buffer u8_t
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_Get_Acceleration(void *handle, u8_t *buff)
- {
- u8_t i, j, k;
- u8_t numberOfByteForDimension;
-
- numberOfByteForDimension=6/3;
-
- k=0;
- for (i=0; i<3;i++ )
- {
- for (j=0; j<numberOfByteForDimension;j++ )
- {
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_OUT_X_L+k, &buff[k], 1))
- return MEMS_ERROR;
- k++;
- }
- }
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : status_t LIS2DW12_ACC_Get_Temperature(u8_t *buff)
- * Description : Read Temperature output register
- * Input : pointer to [u8_t]
- * Output : Temperature buffer u8_t
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_Get_Temperature(void *handle, u8_t *buff)
- {
- u8_t i, j, k;
- u8_t numberOfByteForDimension;
-
- numberOfByteForDimension=2/1;
-
- k=0;
- for (i=0; i<1;i++ )
- {
- for (j=0; j<numberOfByteForDimension;j++ )
- {
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_OUT_T_L+k, &buff[k], 1))
- return MEMS_ERROR;
- k++;
- }
- }
-
- return MEMS_SUCCESS;
- }
- /**************** Advanced Function *******************/
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_W_LowPowerModeSelection
- * Description : Write LP_MODE
- * Input : LIS2DW12_ACC_LP_MODE_t
- * Output : None
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_W_LowPowerModeSelection(void *handle, LIS2DW12_ACC_LP_MODE_t newValue)
- {
- u8_t value;
-
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL1, &value, 1) )
- return MEMS_ERROR;
-
- value &= ~LIS2DW12_ACC_LP_MODE_MASK;
- value |= newValue;
-
- if( !LIS2DW12_ACC_WriteReg(handle, LIS2DW12_ACC_CTRL1, &value, 1) )
- return MEMS_ERROR;
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_R_LowPowerModeSelection
- * Description : Read LP_MODE
- * Input : Pointer to LIS2DW12_ACC_LP_MODE_t
- * Output : Status of LP_MODE see LIS2DW12_ACC_LP_MODE_t
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_R_LowPowerModeSelection(void *handle, LIS2DW12_ACC_LP_MODE_t *value)
- {
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL1, (u8_t *)value , 1) )
- return MEMS_ERROR;
-
- *value &= LIS2DW12_ACC_LP_MODE_MASK; //mask
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_W_ModeSelection
- * Description : Write MODE
- * Input : LIS2DW12_ACC_MODE_t
- * Output : None
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_W_ModeSelection(void *handle, LIS2DW12_ACC_MODE_t newValue)
- {
- u8_t value;
-
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL1, &value, 1) )
- return MEMS_ERROR;
-
- value &= ~LIS2DW12_ACC_MODE_MASK;
- value |= newValue;
-
- if( !LIS2DW12_ACC_WriteReg(handle, LIS2DW12_ACC_CTRL1, &value, 1) )
- return MEMS_ERROR;
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_R_ModeSelection
- * Description : Read MODE
- * Input : Pointer to LIS2DW12_ACC_MODE_t
- * Output : Status of MODE see LIS2DW12_ACC_MODE_t
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_R_ModeSelection(void *handle, LIS2DW12_ACC_MODE_t *value)
- {
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL1, (u8_t *)value , 1) )
- return MEMS_ERROR;
-
- *value &= LIS2DW12_ACC_MODE_MASK; //mask
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_W_SPI_mode_selection
- * Description : Write SIM
- * Input : LIS2DW12_ACC_SIM_t
- * Output : None
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_W_SPI_mode_selection(void *handle, LIS2DW12_ACC_SIM_t newValue)
- {
- u8_t value;
-
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL2, &value, 1) )
- return MEMS_ERROR;
-
- value &= ~LIS2DW12_ACC_SIM_MASK;
- value |= newValue;
-
- if( !LIS2DW12_ACC_WriteReg(handle, LIS2DW12_ACC_CTRL2, &value, 1) )
- return MEMS_ERROR;
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_R_SPI_mode_selection
- * Description : Read SIM
- * Input : Pointer to LIS2DW12_ACC_SIM_t
- * Output : Status of SIM see LIS2DW12_ACC_SIM_t
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_R_SPI_mode_selection(void *handle, LIS2DW12_ACC_SIM_t *value)
- {
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL2, (u8_t *)value , 1) )
- return MEMS_ERROR;
-
- *value &= LIS2DW12_ACC_SIM_MASK; //mask
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_W_I2C_status
- * Description : Write I2C_DISABLE
- * Input : LIS2DW12_ACC_I2C_DISABLE_t
- * Output : None
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_W_I2C_status(void *handle, LIS2DW12_ACC_I2C_DISABLE_t newValue)
- {
- u8_t value;
-
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL2, &value, 1) )
- return MEMS_ERROR;
-
- value &= ~LIS2DW12_ACC_I2C_DISABLE_MASK;
- value |= newValue;
-
- if( !LIS2DW12_ACC_WriteReg(handle, LIS2DW12_ACC_CTRL2, &value, 1) )
- return MEMS_ERROR;
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_R_I2C_status
- * Description : Read I2C_DISABLE
- * Input : Pointer to LIS2DW12_ACC_I2C_DISABLE_t
- * Output : Status of I2C_DISABLE see LIS2DW12_ACC_I2C_DISABLE_t
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_R_I2C_status(void *handle, LIS2DW12_ACC_I2C_DISABLE_t *value)
- {
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL2, (u8_t *)value , 1) )
- return MEMS_ERROR;
-
- *value &= LIS2DW12_ACC_I2C_DISABLE_MASK; //mask
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_W_AutoIncrementedWithMultipleAccess
- * Description : Write IF_ADD_INC
- * Input : LIS2DW12_ACC_IF_ADD_INC_t
- * Output : None
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_W_AutoIncrementedWithMultipleAccess(void *handle, LIS2DW12_ACC_IF_ADD_INC_t newValue)
- {
- u8_t value;
-
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL2, &value, 1) )
- return MEMS_ERROR;
-
- value &= ~LIS2DW12_ACC_IF_ADD_INC_MASK;
- value |= newValue;
-
- if( !LIS2DW12_ACC_WriteReg(handle, LIS2DW12_ACC_CTRL2, &value, 1) )
- return MEMS_ERROR;
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_R_AutoIncrementedWithMultipleAccess
- * Description : Read IF_ADD_INC
- * Input : Pointer to LIS2DW12_ACC_IF_ADD_INC_t
- * Output : Status of IF_ADD_INC see LIS2DW12_ACC_IF_ADD_INC_t
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_R_AutoIncrementedWithMultipleAccess(void *handle, LIS2DW12_ACC_IF_ADD_INC_t *value)
- {
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL2, (u8_t *)value , 1) )
- return MEMS_ERROR;
-
- *value &= LIS2DW12_ACC_IF_ADD_INC_MASK; //mask
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_W_SoftReset
- * Description : Write SOFT_RESET
- * Input : LIS2DW12_ACC_SOFT_RESET_t
- * Output : None
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_W_SoftReset(void *handle, LIS2DW12_ACC_SOFT_RESET_t newValue)
- {
- u8_t value;
-
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL2, &value, 1) )
- return MEMS_ERROR;
-
- value &= ~LIS2DW12_ACC_SOFT_RESET_MASK;
- value |= newValue;
-
- if( !LIS2DW12_ACC_WriteReg(handle, LIS2DW12_ACC_CTRL2, &value, 1) )
- return MEMS_ERROR;
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_R_SoftReset
- * Description : Read SOFT_RESET
- * Input : Pointer to LIS2DW12_ACC_SOFT_RESET_t
- * Output : Status of SOFT_RESET see LIS2DW12_ACC_SOFT_RESET_t
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_R_SoftReset(void *handle, LIS2DW12_ACC_SOFT_RESET_t *value)
- {
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL2, (u8_t *)value , 1) )
- return MEMS_ERROR;
-
- *value &= LIS2DW12_ACC_SOFT_RESET_MASK; //mask
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_W_Reboot
- * Description : Write BOOT
- * Input : LIS2DW12_ACC_BOOT_t
- * Output : None
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_W_Reboot(void *handle, LIS2DW12_ACC_BOOT_t newValue)
- {
- u8_t value;
-
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL2, &value, 1) )
- return MEMS_ERROR;
-
- value &= ~LIS2DW12_ACC_BOOT_MASK;
- value |= newValue;
-
- if( !LIS2DW12_ACC_WriteReg(handle, LIS2DW12_ACC_CTRL2, &value, 1) )
- return MEMS_ERROR;
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_R_Reboot
- * Description : Read BOOT
- * Input : Pointer to LIS2DW12_ACC_BOOT_t
- * Output : Status of BOOT see LIS2DW12_ACC_BOOT_t
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_R_Reboot(void *handle, LIS2DW12_ACC_BOOT_t *value)
- {
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL2, (u8_t *)value , 1) )
- return MEMS_ERROR;
-
- *value &= LIS2DW12_ACC_BOOT_MASK; //mask
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_W_SingleLowPowerMode
- * Description : Write SLP_MODE_1
- * Input : LIS2DW12_ACC_SLP_MODE_1_t
- * Output : None
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_W_SingleLowPowerMode(void *handle, LIS2DW12_ACC_SLP_MODE_1_t newValue)
- {
- u8_t value;
-
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL3, &value, 1) )
- return MEMS_ERROR;
-
- value &= ~LIS2DW12_ACC_SLP_MODE_1_MASK;
- value |= newValue;
-
- if( !LIS2DW12_ACC_WriteReg(handle, LIS2DW12_ACC_CTRL3, &value, 1) )
- return MEMS_ERROR;
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_R_SingleLowPowerMode
- * Description : Read SLP_MODE_1
- * Input : Pointer to LIS2DW12_ACC_SLP_MODE_1_t
- * Output : Status of SLP_MODE_1 see LIS2DW12_ACC_SLP_MODE_1_t
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_R_SingleLowPowerMode(void *handle, LIS2DW12_ACC_SLP_MODE_1_t *value)
- {
- if( !LIS2DW12_ACC_ReadReg(handle, LIS2DW12_ACC_CTRL3, (u8_t *)value , 1) )
- return MEMS_ERROR;
-
- *value &= LIS2DW12_ACC_SLP_MODE_1_MASK; //mask
-
- return MEMS_SUCCESS;
- }
- /*******************************************************************************
- * Function Name : LIS2DW12_ACC_W_SingleLowPowerModeSource
- * Description : Write SLP_MODE_SEL
- * Input : LIS2DW12_ACC_SLP_MODE_SEL_t
- * Output : None
- * Return : Status [MEMS_ERROR, MEMS_SUCCESS]
- *******************************************************************************/
- status_t LIS2DW12_ACC_W_SingleLowPowerModeSource(void *handle, LIS2DW12_ACC_SLP_MODE_SEL_t newValue)
- {
- u8_t value;
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
LIS2DW12_ver1.1.zip
(21.41 KB, 下载次数: 106)
|