Files
TencentOS-tiny/board/NUCLEO_STM32L073RZ/BSP/HardWare/LIS3MDL/LIS3MDL.h
Winfred LIN b6cb7147cc added fuzzy matching feature to at_echo; added set some AT+ commands for RHF76; added support for LSM6DS3;
1. in tos_at.h, added int  fuzzy_matching; field into at_echo_st struct, if this field is set to K_TRUE, then if echo message contains the string in "echo_expect" field.
2. added __API__ int tos_at_echo_fuzzy_matching_create(at_echo_t *echo, char *buffer, size_t buffer_size, char *echo_expect_contains) api to tos_at.c, which will create an at_echo_t with fuzzy_matching = K_TRUE;
3. added RHF76_ATCMD_SET_DELAY and  rhf76_set_delay to RHF76.h to allow set/query RX delay config
4. added RHF76_ATCMD_SET_DATA_RATE and rhf76_set_data_rate to RHF76.h to allow set/query date rate config
5. added rhf76_at_cmd_exe for DEBUG purpose, so that user can execute any AT+ commands they want
6. added code in lora_demo.c to demonstrate package segmentation.
2020-04-06 23:11:48 +10:00

94 lines
3.2 KiB
C

/**
******************************************************************************
* @file LIS3MDL.h
* @author jieranzhi (the developer)
* @update 2020/03/23 19:00 CST
* @brief This file contains basic functions prototypes and pre-definitions
* of the register addresses
******************************************************************************
* @attention
*
* 1. the temperature sensor embedded in the LIS3MDL is intended to be embedded
* temperature compensation. Therefore, in this file we DO NOT include the
* temperature output
*
* 2. on the P-NUCLEO-LRWAN3, the SDO/SA0 pad is connected to voltage supply(
* via a resistor), LSb is ¡®1¡¯ (address 1011101b)
*
* 3. for more information, please refer to the datasheet
* (https://www.st.com/resource/en/datasheet/lis3mdl.pdf)
*
******************************************************************************
*/
#ifndef _LIS3MDL_H_
#define _LIS3MDL_H_
#include <stm32l0xx_hal.h>
/* Registers -----------------------------------------------------------------*/
#define LIS3MDL_ADDR_WR 0x3C
#define LIS3MDL_ADDR_RD 0x3D
#define LIS3MDL_CTRL_REG1 0x20
#define LIS3MDL_CTRL_REG2 0x21
#define LIS3MDL_CTRL_REG3 0x22
#define LIS3MDL_CTRL_REG4 0x23
#define LIS3MDL_CTRL_REG5 0x24
#define LIS3MDL_STATUS_REG 0x27
#define LIS3MDL_X_OUT_L 0x28
#define LIS3MDL_X_OUT_H 0x29
#define LIS3MDL_Y_OUT_L 0x2A
#define LIS3MDL_Y_OUT_H 0x2B
#define LIS3MDL_Z_OUT_L 0x2C
#define LIS3MDL_Z_OUT_H 0x2D
/* Enumeration ---------------------------------------------------------------*/
/**
* @brief STATUS structures definition
*/
typedef enum
{
LIS3MDL_ZYXOR = 0x80U, /*!< XYZ-axis data overrun */
LIS3MDL_ZOR = 0x40U, /*!< Z-axis data overrun */
LIS3MDL_YOR = 0x20U, /*!< Y-axis data overrun */
LIS3MDL_XOR = 0x10U, /*!< X-axis data overrun */
LIS3MDL_ZYXDA = 0x08U, /*!< XYZ-axis data available */
LIS3MDL_ZDA = 0x04U, /*!< Z-axis data available */
LIS3MDL_YDA = 0x02U, /*!< Y-axis data available */
LIS3MDL_XDA = 0x01U, /*!< X-axis data available */
}LIS3MDL_StatusTypeDef;
/**
* @brief STATUS structures definition
*/
typedef enum
{
MAGN_FULLSCALE_4 = 0x00U,
MAGN_FULLSCALE_8 = 0x01U,
MAGN_FULLSCALE_12 = 0x02U,
MAGN_FULLSCALE_16 = 0x03U
}LIS3MDL_FullScaleTypeDef;
/**
* @brief magnetic sensor structures definition
*/
typedef struct
{
uint8_t fullscale; // fullscale of magnetometer
uint16_t sensitivity; // sensitivity per fullscale
uint16_t magn_x; // X-magnetic value in LSB
uint16_t magn_y; // Y-magnetic value in LSB
uint16_t magn_z; // Z-magnetic value in LSB
}sensor_magn_t;
/* Functions -----------------------------------------------------------------*/
void LIS3MDL_Init(void);
void LIS3MDL_Set_FullScale(LIS3MDL_FullScaleTypeDef fullscale);
LIS3MDL_FullScaleTypeDef LIS3MDL_Get_FullScale(void);
uint16_t LIS3MDL_Get_Sensitivity(LIS3MDL_FullScaleTypeDef fullscale);
uint8_t LIS3MDL_Get_Magn(sensor_magn_t* magn_sensor);
#endif /* _LIS3MDL_H_ */