Merge pull request #126 from jieranzhi/master
for NUCLEO_STM32L073RZ board, added lorawan example in IAR, and added support for LIS3MDL and LPS22…
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -32,3 +32,5 @@ board/*/MDK-ARM/*.uvguix.*
|
|||||||
board/*/MDK-ARM/EventRecorderStub.scvd
|
board/*/MDK-ARM/EventRecorderStub.scvd
|
||||||
board/*/MDK-ARM/*/*.htm
|
board/*/MDK-ARM/*/*.htm
|
||||||
board/*/MDK-ARM/*/*.build_log.htm
|
board/*/MDK-ARM/*/*.build_log.htm
|
||||||
|
Obj/*
|
||||||
|
Debug/*
|
||||||
|
35
board/NUCLEO_STM32L073RZ/BSP/HardWare/Common/bsp.c
Normal file
35
board/NUCLEO_STM32L073RZ/BSP/HardWare/Common/bsp.c
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file bsp.c
|
||||||
|
* @author jieranzhi
|
||||||
|
* @brief provide high level interfaces to manage the sensors on the
|
||||||
|
* application, this is a modified version of the official api
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "bsp.h"
|
||||||
|
|
||||||
|
void BSP_Sensor_Init(void)
|
||||||
|
{
|
||||||
|
/* Initialize sensors */
|
||||||
|
HTS221_Init();
|
||||||
|
LPS22HB_Init();
|
||||||
|
LIS3MDL_Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BSP_Sensor_Read(sensor_data_t *sensor_data)
|
||||||
|
{
|
||||||
|
sensor_tempnhumi_t tempnhumi_sensor;
|
||||||
|
sensor_press_t press_sensor;
|
||||||
|
sensor_magn_t magn_sensor;
|
||||||
|
|
||||||
|
HTS221_Get_TemperatureAndHumidity(&tempnhumi_sensor);
|
||||||
|
LPS22HB_Get_Press(&press_sensor);
|
||||||
|
LIS3MDL_Get_Magn(&magn_sensor);
|
||||||
|
|
||||||
|
sensor_data->sensor_press = press_sensor;
|
||||||
|
sensor_data->sensor_tempnhumi = tempnhumi_sensor;
|
||||||
|
sensor_data->sensor_magn = magn_sensor;
|
||||||
|
}
|
||||||
|
|
89
board/NUCLEO_STM32L073RZ/BSP/HardWare/Common/bsp.h
Normal file
89
board/NUCLEO_STM32L073RZ/BSP/HardWare/Common/bsp.h
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
/ _____) _ | |
|
||||||
|
( (____ _____ ____ _| |_ _____ ____| |__
|
||||||
|
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||||
|
_____) ) ____| | | || |_| ____( (___| | | |
|
||||||
|
(______/|_____)_|_|_| \__)_____)\____)_| |_|
|
||||||
|
(C)2013 Semtech
|
||||||
|
|
||||||
|
Description: contains all hardware driver
|
||||||
|
|
||||||
|
License: Revised BSD License, see LICENSE.TXT file include in the project
|
||||||
|
|
||||||
|
Maintainer: Miguel Luis and Gregory Cristian
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file bsp.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief contains all hardware driver
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2018 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under Ultimate Liberty license
|
||||||
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at:
|
||||||
|
* www.st.com/SLA0044
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __BSP_H__
|
||||||
|
#define __BSP_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "HTS221.h"
|
||||||
|
#include "LPS22HB.h"
|
||||||
|
#include "LIS3MDL.h"
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
sensor_press_t sensor_press; /* pressure sensor */
|
||||||
|
sensor_tempnhumi_t sensor_tempnhumi; /* temperature and humidity */
|
||||||
|
sensor_magn_t sensor_magn; /* magnetometer */
|
||||||
|
|
||||||
|
//--------------------------- accelerator and gyroscope -------------------//
|
||||||
|
int16_t accel_x; /* in g */
|
||||||
|
int16_t accel_y; /* in g */
|
||||||
|
int16_t accel_z; /* in g */
|
||||||
|
int16_t gyro_x; /* in degree/s */
|
||||||
|
int16_t gyro_y; /* in degree/s */
|
||||||
|
int16_t gyro_z; /* in degree/s */
|
||||||
|
|
||||||
|
} sensor_data_t;
|
||||||
|
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/* External variables --------------------------------------------------------*/
|
||||||
|
/* Exported macros -----------------------------------------------------------*/
|
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
/**
|
||||||
|
* @brief initialises the sensor
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void BSP_Sensor_Init(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief sensor read.
|
||||||
|
*
|
||||||
|
* @note none
|
||||||
|
* @retval sensor_data
|
||||||
|
*/
|
||||||
|
void BSP_Sensor_Read(sensor_data_t *sensor_data);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __BSP_H__ */
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@@ -2,7 +2,8 @@
|
|||||||
* @breif HTS221<32><31><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
* @breif HTS221<32><31><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||||
* @author Mculover666(www.mculover666.cn)
|
* @author Mculover666(www.mculover666.cn)
|
||||||
* @date 2019-12-27
|
* @date 2019-12-27
|
||||||
* @version 1.0.0
|
* @modified by jieranzhi 2020/03/23
|
||||||
|
* @version 1.0.1
|
||||||
********************************************/
|
********************************************/
|
||||||
|
|
||||||
#include <HTS221.h>
|
#include <HTS221.h>
|
||||||
@@ -15,7 +16,7 @@ void HTS221_Init()
|
|||||||
|
|
||||||
//<2F><><EFBFBD>÷ֱ<C3B7><D6B1><EFBFBD>
|
//<2F><><EFBFBD>÷ֱ<C3B7><D6B1><EFBFBD>
|
||||||
cmd = 0x3F;
|
cmd = 0x3F;
|
||||||
HAL_I2C_Mem_Write(&hi2c1, HTS221_ADDR_WR, 0x10, I2C_MEMADD_SIZE_8BIT, &cmd, 1, 0xFFFF);
|
HAL_I2C_Mem_Write(&hi2c1, HTS221_ADDR_WR, HTS221_AV_CONF, I2C_MEMADD_SIZE_8BIT, &cmd, 1, 0xFFFF);
|
||||||
|
|
||||||
//<2F><><EFBFBD>õ<EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//<2F><><EFBFBD>õ<EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
cmd = 0x84;
|
cmd = 0x84;
|
||||||
@@ -57,11 +58,11 @@ uint8_t HTS221_Get_Temperature(int16_t* temperature)
|
|||||||
int32_t tmp32;
|
int32_t tmp32;
|
||||||
|
|
||||||
/*1. <20><>ȡT0_degC_x8 <20><> T1_degC_x8 У<><D0A3>ֵ */
|
/*1. <20><>ȡT0_degC_x8 <20><> T1_degC_x8 У<><D0A3>ֵ */
|
||||||
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, 0x32, I2C_MEMADD_SIZE_8BIT, &T0_degC_x8, 1, 0xFFFF);
|
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, HTS221_T0_degC_x8, I2C_MEMADD_SIZE_8BIT, &T0_degC_x8, 1, 0xFFFF);
|
||||||
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, 0x33, I2C_MEMADD_SIZE_8BIT, &T1_degC_x8, 1, 0xFFFF);
|
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, HTS221_T1_degC_x8, I2C_MEMADD_SIZE_8BIT, &T1_degC_x8, 1, 0xFFFF);
|
||||||
|
|
||||||
/*2. <20><>ȡT1_degC <20><> T0_degC <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ*/
|
/*2. <20><>ȡT1_degC <20><> T0_degC <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ*/
|
||||||
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, 0x35, I2C_MEMADD_SIZE_8BIT, &tmp, 1, 0xFFFF);
|
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, HTS221_T1_T0_msb, I2C_MEMADD_SIZE_8BIT, &tmp, 1, 0xFFFF);
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD>T0_degC and T1_degC ֵ */
|
// <20><><EFBFBD><EFBFBD>T0_degC and T1_degC ֵ */
|
||||||
T0_degC_x8_u16 = (((uint16_t)(tmp & 0x03)) << 8) | ((uint16_t)T0_degC_x8);
|
T0_degC_x8_u16 = (((uint16_t)(tmp & 0x03)) << 8) | ((uint16_t)T0_degC_x8);
|
||||||
@@ -70,10 +71,10 @@ uint8_t HTS221_Get_Temperature(int16_t* temperature)
|
|||||||
T1_degC = T1_degC_x8_u16>>3;
|
T1_degC = T1_degC_x8_u16>>3;
|
||||||
|
|
||||||
/*3. <20><>ȡ T0_OUT <20><> T1_OUT ֵ */
|
/*3. <20><>ȡ T0_OUT <20><> T1_OUT ֵ */
|
||||||
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, 0x3C, I2C_MEMADD_SIZE_8BIT, &buffer[0], 1, 0xFFFF);
|
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, HTS221_T0_OUT_L, I2C_MEMADD_SIZE_8BIT, &buffer[0], 1, 0xFFFF);
|
||||||
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, 0x3D, I2C_MEMADD_SIZE_8BIT, &buffer[1], 1, 0xFFFF);
|
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, HTS221_T0_OUT_H, I2C_MEMADD_SIZE_8BIT, &buffer[1], 1, 0xFFFF);
|
||||||
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, 0x3E, I2C_MEMADD_SIZE_8BIT, &buffer[0], 1, 0xFFFF);
|
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, HTS221_T1_OUT_L, I2C_MEMADD_SIZE_8BIT, &buffer[0], 1, 0xFFFF);
|
||||||
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, 0x3F, I2C_MEMADD_SIZE_8BIT, &buffer[1], 1, 0xFFFF);
|
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, HTS221_T1_OUT_H, I2C_MEMADD_SIZE_8BIT, &buffer[1], 1, 0xFFFF);
|
||||||
|
|
||||||
T0_out = (((uint16_t)buffer[1])<<8) | (uint16_t)buffer[0];
|
T0_out = (((uint16_t)buffer[1])<<8) | (uint16_t)buffer[0];
|
||||||
T1_out = (((uint16_t)buffer[3])<<8) | (uint16_t)buffer[2];
|
T1_out = (((uint16_t)buffer[3])<<8) | (uint16_t)buffer[2];
|
||||||
@@ -90,8 +91,8 @@ uint8_t HTS221_Get_Temperature(int16_t* temperature)
|
|||||||
T_out = (((uint16_t)buffer[1])<<8) | (uint16_t)buffer[0];
|
T_out = (((uint16_t)buffer[1])<<8) | (uint16_t)buffer[0];
|
||||||
|
|
||||||
/* 5. ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>㵱ǰ<E3B5B1><C7B0>Ӧ<EFBFBD><D3A6><EFBFBD>¶<EFBFBD>ֵ */
|
/* 5. ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>㵱ǰ<E3B5B1><C7B0>Ӧ<EFBFBD><D3A6><EFBFBD>¶<EFBFBD>ֵ */
|
||||||
tmp32 = ((int32_t)(T_out - T0_out)) * ((int32_t)(T1_degC - T0_degC)*10);
|
tmp32 = ((int32_t)(T_out - T0_out)) * ((int32_t)(T1_degC - T0_degC));
|
||||||
*temperature = tmp32 /(T1_out - T0_out) + T0_degC*10;
|
*temperature = tmp32*10 /(T1_out - T0_out) + T0_degC*10;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -108,24 +109,24 @@ uint8_t HTS221_Get_Humidity(int16_t* humidity)
|
|||||||
|
|
||||||
|
|
||||||
/* 1. <20><>ȡH0_rH and H1_rH У<><D0A3>ֵ */
|
/* 1. <20><>ȡH0_rH and H1_rH У<><D0A3>ֵ */
|
||||||
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, 0x30, I2C_MEMADD_SIZE_8BIT, &buffer[0], 1, 0xFFFF);
|
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, HTS221_H0_rH_x2, I2C_MEMADD_SIZE_8BIT, &buffer[0], 1, 0xFFFF);
|
||||||
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, 0x31, I2C_MEMADD_SIZE_8BIT, &buffer[1], 1, 0xFFFF);
|
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, HTS221_H1_rH_x2, I2C_MEMADD_SIZE_8BIT, &buffer[1], 1, 0xFFFF);
|
||||||
H0_rh = buffer[0] >> 1;
|
H0_rh = buffer[0] >> 1;
|
||||||
H1_rh = buffer[1] >> 1;
|
H1_rh = buffer[1] >> 1;
|
||||||
|
|
||||||
/*2. <20><>ȡ H0_T0_OUT У<><D0A3>ֵ */
|
/*2. <20><>ȡ H0_T0_OUT У<><D0A3>ֵ */
|
||||||
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, 0x36, I2C_MEMADD_SIZE_8BIT, &buffer[0], 1, 0xFFFF);
|
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, HTS221_H0_T0_OUT_L, I2C_MEMADD_SIZE_8BIT, &buffer[0], 1, 0xFFFF);
|
||||||
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, 0x37, I2C_MEMADD_SIZE_8BIT, &buffer[1], 1, 0xFFFF);
|
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, HTS221_H0_T0_OUT_H, I2C_MEMADD_SIZE_8BIT, &buffer[1], 1, 0xFFFF);
|
||||||
H0_T0_out = (((uint16_t)buffer[1])<<8) | (uint16_t)buffer[0];
|
H0_T0_out = (((uint16_t)buffer[1])<<8) | (uint16_t)buffer[0];
|
||||||
|
|
||||||
/*3. <20><>ȡ H1_T0_OUT У<><D0A3>ֵ */
|
/*3. <20><>ȡ H1_T0_OUT У<><D0A3>ֵ */
|
||||||
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, 0x3A, I2C_MEMADD_SIZE_8BIT, &buffer[0], 1, 0xFFFF);
|
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, HTS221_H1_T0_OUT_L, I2C_MEMADD_SIZE_8BIT, &buffer[0], 1, 0xFFFF);
|
||||||
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, 0x3B, I2C_MEMADD_SIZE_8BIT, &buffer[1], 1, 0xFFFF);
|
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, HTS221_H1_T0_OUT_H, I2C_MEMADD_SIZE_8BIT, &buffer[1], 1, 0xFFFF);
|
||||||
H1_T0_out = (((uint16_t)buffer[1])<<8) | (uint16_t)buffer[0];
|
H1_T0_out = (((uint16_t)buffer[1])<<8) | (uint16_t)buffer[0];
|
||||||
|
|
||||||
/*4. <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD>ȡת<C8A1><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ */
|
/*4. <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD>ȡת<C8A1><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ */
|
||||||
HTS221_Start();
|
HTS221_Start();
|
||||||
while(status_dat != 0x03)
|
while(status_dat != (HTS221_T_DA|HTS221_H_DA))
|
||||||
{
|
{
|
||||||
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, HTS221_STATUS_REG, I2C_MEMADD_SIZE_8BIT, &status_dat, 1, 0xFFFF);
|
HAL_I2C_Mem_Read(&hi2c1, HTS221_ADDR_RD, HTS221_STATUS_REG, I2C_MEMADD_SIZE_8BIT, &status_dat, 1, 0xFFFF);
|
||||||
}
|
}
|
||||||
@@ -145,3 +146,20 @@ uint8_t HTS221_Get_Humidity(int16_t* humidity)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* <20><>ȡHT221<32><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>sensor<6F><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
|
uint8_t HTS221_Get_TemperatureAndHumidity(sensor_tempnhumi_t* tempnhumi_sensor)
|
||||||
|
{
|
||||||
|
int16_t temperature;
|
||||||
|
int16_t humidity;
|
||||||
|
|
||||||
|
HTS221_Get_Temperature(&temperature);
|
||||||
|
HTS221_Get_Humidity(&humidity);
|
||||||
|
|
||||||
|
tempnhumi_sensor->temp_sensitivity = 64;
|
||||||
|
tempnhumi_sensor->temperature = temperature;
|
||||||
|
tempnhumi_sensor->humi_sensitivity = 256;
|
||||||
|
tempnhumi_sensor->humidity = humidity;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#define HTS221_CTRL_REG2 0x21
|
#define HTS221_CTRL_REG2 0x21
|
||||||
#define HTS221_CTRL_REG3 0x22
|
#define HTS221_CTRL_REG3 0x22
|
||||||
|
|
||||||
|
#define HTS221_AV_CONF 0x10
|
||||||
#define HTS221_STATUS_REG 0x27
|
#define HTS221_STATUS_REG 0x27
|
||||||
|
|
||||||
#define HTS221_HUMIDITY_OUT_L 0x28
|
#define HTS221_HUMIDITY_OUT_L 0x28
|
||||||
@@ -17,9 +18,45 @@
|
|||||||
#define HTS221_TEMP_OUT_L 0x2A
|
#define HTS221_TEMP_OUT_L 0x2A
|
||||||
#define HTS221_TEMP_OUT_H 0x2B
|
#define HTS221_TEMP_OUT_H 0x2B
|
||||||
|
|
||||||
void HTS221_Init(void);
|
#define HTS221_H0_rH_x2 0x30
|
||||||
|
#define HTS221_H1_rH_x2 0x31
|
||||||
|
#define HTS221_H0_T0_OUT_L 0x36
|
||||||
|
#define HTS221_H0_T0_OUT_H 0x37
|
||||||
|
#define HTS221_H1_T0_OUT_L 0x3A
|
||||||
|
#define HTS221_H1_T0_OUT_H 0x3B
|
||||||
|
|
||||||
|
#define HTS221_T0_degC_x8 0x32
|
||||||
|
#define HTS221_T1_degC_x8 0x33
|
||||||
|
#define HTS221_T1_T0_msb 0x35
|
||||||
|
#define HTS221_T0_OUT_L 0x3C
|
||||||
|
#define HTS221_T0_OUT_H 0x3D
|
||||||
|
#define HTS221_T1_OUT_L 0x3E
|
||||||
|
#define HTS221_T1_OUT_H 0x3F
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief temperature & humidity sensor structures definition
|
||||||
|
* added by jieranzhi, 2020/03/29
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t temp_sensitivity;
|
||||||
|
int16_t temperature;
|
||||||
|
uint16_t humi_sensitivity;
|
||||||
|
int16_t humidity;
|
||||||
|
}sensor_tempnhumi_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief STATUS structures definition
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
HTS221_T_DA = 0x01U, /*!< temperature data available */
|
||||||
|
HTS221_H_DA = 0x02U, /*!< humidity data available */
|
||||||
|
}HTS221_StatusTypeDef;
|
||||||
|
|
||||||
|
void HTS221_Init(void);
|
||||||
uint8_t HTS221_Get_Temperature(int16_t* temperature);
|
uint8_t HTS221_Get_Temperature(int16_t* temperature);
|
||||||
uint8_t HTS221_Get_Humidity(int16_t* humidity);
|
uint8_t HTS221_Get_Humidity(int16_t* humidity);
|
||||||
|
uint8_t HTS221_Get_TemperatureAndHumidity(sensor_tempnhumi_t* tempnhumi_sensor);
|
||||||
|
|
||||||
#endif /* _HTS221_H_ */
|
#endif /* _HTS221_H_ */
|
||||||
|
136
board/NUCLEO_STM32L073RZ/BSP/HardWare/LIS3MDL/LIS3MDL.c
Normal file
136
board/NUCLEO_STM32L073RZ/BSP/HardWare/LIS3MDL/LIS3MDL.c
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file LIS3MDL.c
|
||||||
|
* @author jieranzhi
|
||||||
|
* @update 2020/03/23 19:00 CST
|
||||||
|
* @brief This file provides code for the LIS3MDL Initialization
|
||||||
|
* and data output codes.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* 1. this code is used as one of the examples in TencentOS_tiny project, it's
|
||||||
|
* just a simple implementation of the sensor functionalities, to implement
|
||||||
|
* more functions, please refer to the datasheet or the official software
|
||||||
|
* package provided by ST (STM32CubeExpansion_LRWAN_V1.3.1)
|
||||||
|
*
|
||||||
|
* 2. in this file the host MCU will to read the output persistently, which is
|
||||||
|
* NOT of power efficient.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LIS3MDL.h>
|
||||||
|
#include <i2c.h>
|
||||||
|
|
||||||
|
// initialization of LIS3MDL
|
||||||
|
void LIS3MDL_Init()
|
||||||
|
{
|
||||||
|
uint8_t cmd = 0;
|
||||||
|
|
||||||
|
// enable temperature sensor(temperature compensation);X and Y axes operative
|
||||||
|
// mode(Medium-performance); Output data rate(10Hz); disable high data rate
|
||||||
|
// disable Self-test
|
||||||
|
cmd = 0xB0;
|
||||||
|
HAL_I2C_Mem_Write(&hi2c1, LIS3MDL_ADDR_WR, LIS3MDL_CTRL_REG1, I2C_MEMADD_SIZE_8BIT, &cmd, 1, 0xFFFF);
|
||||||
|
|
||||||
|
// Full-scale:+/-4gauss; Reboot memory(normal)
|
||||||
|
cmd = 0x00;
|
||||||
|
HAL_I2C_Mem_Write(&hi2c1, LIS3MDL_ADDR_WR, LIS3MDL_CTRL_REG2, I2C_MEMADD_SIZE_8BIT, &cmd, 1, 0xFFFF);
|
||||||
|
|
||||||
|
// disable lowpower mode; Operating mode (continuous mode)
|
||||||
|
cmd = 0x00;
|
||||||
|
HAL_I2C_Mem_Write(&hi2c1, LIS3MDL_ADDR_WR, LIS3MDL_CTRL_REG3, I2C_MEMADD_SIZE_8BIT, &cmd, 1, 0xFFFF);
|
||||||
|
|
||||||
|
// Z-axis operative mode (Medium-performance)
|
||||||
|
cmd = 0x04;
|
||||||
|
HAL_I2C_Mem_Write(&hi2c1, LIS3MDL_ADDR_WR, LIS3MDL_CTRL_REG4, I2C_MEMADD_SIZE_8BIT, &cmd, 1, 0xFFFF);
|
||||||
|
|
||||||
|
// disable FAST READ; data block update(continuous)
|
||||||
|
cmd = 0x40;
|
||||||
|
HAL_I2C_Mem_Write(&hi2c1, LIS3MDL_ADDR_WR, LIS3MDL_CTRL_REG5, I2C_MEMADD_SIZE_8BIT, &cmd, 1, 0xFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get fullscale configuration
|
||||||
|
LIS3MDL_FullScaleTypeDef LIS3MDL_Get_FullScale()
|
||||||
|
{
|
||||||
|
uint8_t fullscale;
|
||||||
|
HAL_I2C_Mem_Read(&hi2c1, LIS3MDL_ADDR_RD, LIS3MDL_CTRL_REG2, I2C_MEMADD_SIZE_8BIT, &fullscale, 1, 0xFFFF);
|
||||||
|
fullscale = (fullscale<<1)>>6;
|
||||||
|
return (LIS3MDL_FullScaleTypeDef)fullscale;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set fullscale of the sensor
|
||||||
|
void LIS3MDL_Set_FullScale(LIS3MDL_FullScaleTypeDef fullscale)
|
||||||
|
{
|
||||||
|
uint8_t ctrl_reg2_value;
|
||||||
|
uint8_t fullscale_config = (uint8_t)fullscale;
|
||||||
|
HAL_I2C_Mem_Read(&hi2c1, LIS3MDL_ADDR_RD, LIS3MDL_CTRL_REG2, I2C_MEMADD_SIZE_8BIT, &ctrl_reg2_value, 1, 0xFFFF);
|
||||||
|
fullscale_config = (ctrl_reg2_value&0x9F)|(fullscale_config<<5);
|
||||||
|
HAL_I2C_Mem_Write(&hi2c1, LIS3MDL_ADDR_WR, LIS3MDL_CTRL_REG2, I2C_MEMADD_SIZE_8BIT, &fullscale_config, 1, 0xFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculate the sensitivity per fullscale
|
||||||
|
uint16_t LIS3MDL_Get_Sensitivity(LIS3MDL_FullScaleTypeDef fullscale)
|
||||||
|
{
|
||||||
|
uint16_t sensitivity = 1;
|
||||||
|
switch(fullscale)
|
||||||
|
{
|
||||||
|
case FULLSCALE_4:{
|
||||||
|
sensitivity = 6842;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FULLSCALE_8:{
|
||||||
|
sensitivity = 3421;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FULLSCALE_12:{
|
||||||
|
sensitivity = 2281;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FULLSCALE_16:{
|
||||||
|
sensitivity = 1711;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:{
|
||||||
|
sensitivity = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sensitivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
// start a new acquisition by enabling the one-shot bit in the LIS3MDL_CTRL_REG2
|
||||||
|
// and read the magnetic field from the sensor
|
||||||
|
uint8_t LIS3MDL_Get_Magn(sensor_magn_t* magn_sensor)
|
||||||
|
{
|
||||||
|
uint8_t status_dat = 0;
|
||||||
|
uint8_t magn_x_out_l = 0;
|
||||||
|
uint8_t magn_x_out_h = 0;
|
||||||
|
uint8_t magn_y_out_l = 0;
|
||||||
|
uint8_t magn_y_out_h = 0;
|
||||||
|
uint8_t magn_z_out_l = 0;
|
||||||
|
uint8_t magn_z_out_h = 0;
|
||||||
|
|
||||||
|
// get fullscale and sensitivity
|
||||||
|
LIS3MDL_FullScaleTypeDef fullscale = LIS3MDL_Get_FullScale();
|
||||||
|
magn_sensor->fullscale = (uint8_t)fullscale;
|
||||||
|
magn_sensor->sensitivity = LIS3MDL_Get_Sensitivity(fullscale);
|
||||||
|
|
||||||
|
// wait until the data is ready
|
||||||
|
while((status_dat&LIS3MDL_ZYXDA) != LIS3MDL_ZYXDA)
|
||||||
|
{
|
||||||
|
HAL_I2C_Mem_Read(&hi2c1, LIS3MDL_ADDR_RD, LIS3MDL_STATUS_REG, I2C_MEMADD_SIZE_8BIT, &status_dat, 1, 0xFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
HAL_I2C_Mem_Read(&hi2c1, LIS3MDL_ADDR_RD, LIS3MDL_X_OUT_L, I2C_MEMADD_SIZE_8BIT, &magn_x_out_l, 1, 0xFFFF);
|
||||||
|
HAL_I2C_Mem_Read(&hi2c1, LIS3MDL_ADDR_RD, LIS3MDL_X_OUT_H, I2C_MEMADD_SIZE_8BIT, &magn_x_out_h, 1, 0xFFFF);
|
||||||
|
HAL_I2C_Mem_Read(&hi2c1, LIS3MDL_ADDR_RD, LIS3MDL_Y_OUT_L, I2C_MEMADD_SIZE_8BIT, &magn_y_out_l, 1, 0xFFFF);
|
||||||
|
HAL_I2C_Mem_Read(&hi2c1, LIS3MDL_ADDR_RD, LIS3MDL_Y_OUT_H, I2C_MEMADD_SIZE_8BIT, &magn_y_out_h, 1, 0xFFFF);
|
||||||
|
HAL_I2C_Mem_Read(&hi2c1, LIS3MDL_ADDR_RD, LIS3MDL_Z_OUT_L, I2C_MEMADD_SIZE_8BIT, &magn_z_out_l, 1, 0xFFFF);
|
||||||
|
HAL_I2C_Mem_Read(&hi2c1, LIS3MDL_ADDR_RD, LIS3MDL_Z_OUT_H, I2C_MEMADD_SIZE_8BIT, &magn_z_out_h, 1, 0xFFFF);
|
||||||
|
|
||||||
|
magn_sensor->magn_x = (uint16_t)magn_x_out_h<<8|magn_x_out_l;
|
||||||
|
magn_sensor->magn_y = (uint16_t)magn_y_out_h<<8|magn_y_out_l;
|
||||||
|
magn_sensor->magn_z = (uint16_t)magn_z_out_h<<8|magn_z_out_l;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
93
board/NUCLEO_STM32L073RZ/BSP/HardWare/LIS3MDL/LIS3MDL.h
Normal file
93
board/NUCLEO_STM32L073RZ/BSP/HardWare/LIS3MDL/LIS3MDL.h
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @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 <20><>1<EFBFBD><31> (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
|
||||||
|
{
|
||||||
|
FULLSCALE_4 = 0x00U,
|
||||||
|
FULLSCALE_8 = 0x01U,
|
||||||
|
FULLSCALE_12 = 0x02U,
|
||||||
|
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_ */
|
79
board/NUCLEO_STM32L073RZ/BSP/HardWare/LPS22HB/LPS22HB.c
Normal file
79
board/NUCLEO_STM32L073RZ/BSP/HardWare/LPS22HB/LPS22HB.c
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file LPS22HB.c
|
||||||
|
* @author jieranzhi
|
||||||
|
* @update 2020/03/23 19:00 CST
|
||||||
|
* @brief This file provides code for the LPS22HB Initialization
|
||||||
|
* and data output codes.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* 1. this code is used as one of the examples in TencentOS_tiny project, it's
|
||||||
|
* just a simple implementation of the sensor functionalities, to implement
|
||||||
|
* more functions, please refer to the datasheet or the official software
|
||||||
|
* package provided by ST (STM32CubeExpansion_LRWAN_V1.3.1)
|
||||||
|
*
|
||||||
|
* 2. in this file the host MCU need to read the output persistently, which is
|
||||||
|
* not of power efficient, to achieve better power consumption performance,
|
||||||
|
* it is recommended to use FIFO.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LPS22HB.h>
|
||||||
|
#include <i2c.h>
|
||||||
|
|
||||||
|
// initialization of LPS22HB
|
||||||
|
void LPS22HB_Init()
|
||||||
|
{
|
||||||
|
uint8_t cmd = 0;
|
||||||
|
|
||||||
|
// reset the Low-power mode configuration
|
||||||
|
cmd = 0x00;
|
||||||
|
HAL_I2C_Mem_Write(&hi2c1, LPS22HB_ADDR_WR, LPS22HB_RES_CONF_REG, I2C_MEMADD_SIZE_8BIT, &cmd, 1, 0xFFFF);
|
||||||
|
|
||||||
|
// setup data rate(power down, 000); disable lowpass filter (we use one-shot in this case); Block data update(continuous)
|
||||||
|
cmd = 0x00;
|
||||||
|
HAL_I2C_Mem_Write(&hi2c1, LPS22HB_ADDR_WR, LPS22HB_CTRL_REG1, I2C_MEMADD_SIZE_8BIT, &cmd, 1, 0xFFFF);
|
||||||
|
|
||||||
|
// reboot mode(normal); disable FIFO; enable IF_ADD_INC; enable I2C; software reset mode(normal); one-shot mode(idle)
|
||||||
|
cmd = 0x10;
|
||||||
|
HAL_I2C_Mem_Write(&hi2c1, LPS22HB_ADDR_WR, LPS22HB_CTRL_REG2, I2C_MEMADD_SIZE_8BIT, &cmd, 1, 0xFFFF);
|
||||||
|
|
||||||
|
// interupt control: set to default value (0x00)
|
||||||
|
cmd = 0x00;
|
||||||
|
HAL_I2C_Mem_Write(&hi2c1, LPS22HB_ADDR_WR, LPS22HB_CTRL_REG3, I2C_MEMADD_SIZE_8BIT, &cmd, 1, 0xFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
// enable one-shot to start a new acquisition (conversion)
|
||||||
|
static void LPS22HB_Start()
|
||||||
|
{
|
||||||
|
uint8_t cmd = 0;
|
||||||
|
HAL_I2C_Mem_Read(&hi2c1, LPS22HB_ADDR_RD, LPS22HB_CTRL_REG2, I2C_MEMADD_SIZE_8BIT, &cmd, 1, 0xFFFF);
|
||||||
|
cmd |= 0x01;
|
||||||
|
HAL_I2C_Mem_Write(&hi2c1, LPS22HB_ADDR_WR, LPS22HB_CTRL_REG2, I2C_MEMADD_SIZE_8BIT, &cmd, 1, 0xFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
// start a new acquisition by enabling the one-shot bit in the LPS22HB_CTRL_REG2
|
||||||
|
// and read the pressure from the sensor
|
||||||
|
uint8_t LPS22HB_Get_Press(sensor_press_t* press_sensor)
|
||||||
|
{
|
||||||
|
uint8_t status_dat = 0;
|
||||||
|
uint8_t pressure_out_l = 0;
|
||||||
|
uint8_t pressure_out_h = 0;
|
||||||
|
uint8_t pressure_out_xl = 0;
|
||||||
|
press_sensor->sensitivity = 4096;
|
||||||
|
|
||||||
|
LPS22HB_Start();
|
||||||
|
while((status_dat&LPS22HB_P_DA) != LPS22HB_P_DA)
|
||||||
|
{
|
||||||
|
HAL_I2C_Mem_Read(&hi2c1, LPS22HB_ADDR_RD, LPS22HB_STATUS_REG, I2C_MEMADD_SIZE_8BIT, &status_dat, 1, 0xFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
HAL_I2C_Mem_Read(&hi2c1, LPS22HB_ADDR_RD, LPS22HB_PRESS_OUT_XL, I2C_MEMADD_SIZE_8BIT, &pressure_out_xl, 1, 0xFFFF);
|
||||||
|
HAL_I2C_Mem_Read(&hi2c1, LPS22HB_ADDR_RD, LPS22HB_PRESS_OUT_L, I2C_MEMADD_SIZE_8BIT, &pressure_out_l, 1, 0xFFFF);
|
||||||
|
HAL_I2C_Mem_Read(&hi2c1, LPS22HB_ADDR_RD, LPS22HB_PRESS_OUT_H, I2C_MEMADD_SIZE_8BIT, &pressure_out_h, 1, 0xFFFF);
|
||||||
|
|
||||||
|
press_sensor->pressure = (((uint32_t)pressure_out_h<<16) | ((uint16_t)pressure_out_l<<8) | pressure_out_xl);
|
||||||
|
return 0;
|
||||||
|
}
|
68
board/NUCLEO_STM32L073RZ/BSP/HardWare/LPS22HB/LPS22HB.h
Normal file
68
board/NUCLEO_STM32L073RZ/BSP/HardWare/LPS22HB/LPS22HB.h
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file LPS22HB.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 LPS22HB 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 <20><>1<EFBFBD><31> (address 1011101b)
|
||||||
|
*
|
||||||
|
* 3. for more information, please refer to the datasheet
|
||||||
|
* (https://www.st.com/resource/en/datasheet/dm00140895.pdf)
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
#ifndef _LPS22HB_H_
|
||||||
|
#define _LPS22HB_H_
|
||||||
|
|
||||||
|
#include <stm32l0xx_hal.h>
|
||||||
|
|
||||||
|
/* Registers -----------------------------------------------------------------*/
|
||||||
|
#define LPS22HB_ADDR_WR 0xBA
|
||||||
|
#define LPS22HB_ADDR_RD 0xBB
|
||||||
|
|
||||||
|
#define LPS22HB_CTRL_REG1 0x10
|
||||||
|
#define LPS22HB_CTRL_REG2 0x11
|
||||||
|
#define LPS22HB_CTRL_REG3 0x12
|
||||||
|
|
||||||
|
#define LPS22HB_RES_CONF_REG 0x1A
|
||||||
|
#define LPS22HB_STATUS_REG 0x27
|
||||||
|
|
||||||
|
#define LPS22HB_PRESS_OUT_XL 0x28
|
||||||
|
#define LPS22HB_PRESS_OUT_L 0x29
|
||||||
|
#define LPS22HB_PRESS_OUT_H 0x2A
|
||||||
|
|
||||||
|
/* Enumeration ---------------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* @brief STATUS structures definition
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
LPS22HB_T_OR = 0x20, /*!< temperature overrun */
|
||||||
|
LPS22HB_P_OR = 0x10, /*!< pressure overrun */
|
||||||
|
LPS22HB_T_DA = 0x02, /*!< new temperature data available */
|
||||||
|
LPS22HB_P_DA = 0x01, /*!< new pressure data available */
|
||||||
|
}LPS22HB_StatusTypeDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief pressure sensor structures definition
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint16_t sensitivity; // sensitivity per fullscale
|
||||||
|
uint32_t pressure; // X-magnetic value in LSB
|
||||||
|
}sensor_press_t;
|
||||||
|
|
||||||
|
/* Functions -----------------------------------------------------------------*/
|
||||||
|
void LPS22HB_Init(void);
|
||||||
|
uint8_t LPS22HB_Get_Press(sensor_press_t* press_sensor);
|
||||||
|
|
||||||
|
#endif /* _LPS22HB_H_ */
|
@@ -1,6 +1,7 @@
|
|||||||
#include "lora_demo.h"
|
#include "lora_demo.h"
|
||||||
#include "HTS221.h"
|
|
||||||
#include "RHF76.h"
|
#include "RHF76.h"
|
||||||
|
#include <Math.h>
|
||||||
|
#include "bsp.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==================================================================================
|
==================================================================================
|
||||||
@@ -54,9 +55,18 @@
|
|||||||
uint16_t report_period = 10;
|
uint16_t report_period = 10;
|
||||||
|
|
||||||
typedef struct device_data_st {
|
typedef struct device_data_st {
|
||||||
uint8_t temperature;
|
uint8_t magn_fullscale; // fullscale of magnetometer
|
||||||
uint8_t humidity;
|
uint8_t temp_sensitivity;
|
||||||
|
uint16_t humi_sensitivity;
|
||||||
|
uint16_t press_sensitivity;
|
||||||
|
uint16_t magn_sensitivity; // sensitivity per fullscale
|
||||||
|
int16_t temperature;
|
||||||
|
int16_t humidity;
|
||||||
|
int16_t magn_x; // X-magnetic value in LSB
|
||||||
|
int16_t magn_y; // Y-magnetic value in LSB
|
||||||
|
int16_t magn_z; // Z-magnetic value in LSB
|
||||||
uint16_t period;
|
uint16_t period;
|
||||||
|
uint32_t pressure;
|
||||||
} __PACKED__ dev_data_t;
|
} __PACKED__ dev_data_t;
|
||||||
|
|
||||||
typedef struct device_data_wrapper_st {
|
typedef struct device_data_wrapper_st {
|
||||||
@@ -86,29 +96,103 @@ void recv_callback(uint8_t *data, uint8_t len)
|
|||||||
printf("report_period: %d\n", report_period);
|
printf("report_period: %d\n", report_period);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_to_screen(sensor_data_t sensor_data)
|
||||||
|
{
|
||||||
|
float pressure = sensor_data.sensor_press.pressure*1.0/sensor_data.sensor_press.sensitivity;
|
||||||
|
float altitude = (pow(1013.25/pressure,1.0/5.257) - 1)*((int16_t)sensor_data.sensor_tempnhumi.temperature/10.0+273.15)/0.0065;
|
||||||
|
printf("temperature: %2.2f\n", (int16_t)sensor_data.sensor_tempnhumi.temperature / 10.0);
|
||||||
|
printf("humidity : %2.2f\n", sensor_data.sensor_tempnhumi.humidity / 10.0);
|
||||||
|
printf("pressure : %2.2f,\t altitude: %2.2f\n", pressure, altitude);
|
||||||
|
printf("magn : %2.3f, %2.3f, %2.3f\n",
|
||||||
|
(int16_t)sensor_data.sensor_magn.magn_x*1.0/sensor_data.sensor_magn.sensitivity,
|
||||||
|
(int16_t)sensor_data.sensor_magn.magn_y*1.0/sensor_data.sensor_magn.sensitivity,
|
||||||
|
(int16_t)sensor_data.sensor_magn.magn_z*1.0/sensor_data.sensor_magn.sensitivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief application entry
|
||||||
|
* @modified by jieranzhi 2020/03/31
|
||||||
|
* @note following javascript code snippet demonstrate how to correctly
|
||||||
|
* decode the data passed to Tencent cloud
|
||||||
|
****************************** CODE START *****************************
|
||||||
|
function RawToProtocol(fPort, bytes)
|
||||||
|
{
|
||||||
|
var data ={
|
||||||
|
"method": "report",
|
||||||
|
"clientToken": new Date(),
|
||||||
|
"params": {}
|
||||||
|
}
|
||||||
|
var magnFullscale = bytes[0];
|
||||||
|
switch(magnFullscale)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
data.params.magnFullscale = 4;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
data.params.magnFullscale = 8;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
data.params.magnFullscale = 12;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
data.params.magnFullscale = 16;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
var tempSensitivity = bytes[1];
|
||||||
|
var humiSensitivity = bytes[2] | (bytes[3]<<8);
|
||||||
|
var presSensitivity = bytes[4] | (bytes[5]<<8);
|
||||||
|
var magnSensitivity = bytes[6] | (bytes[7]<<8);
|
||||||
|
|
||||||
|
data.params.temperature = (convertToInt16(bytes[8] | (bytes[9]<<8))*1.0/10).toFixed(2);
|
||||||
|
data.params.humidity = ((bytes[10] | (bytes[11]<<8))*1.0/10).toFixed(2);
|
||||||
|
data.params.magnX = (convertToInt16(bytes[12] | (bytes[13]<<8))*1.0/magnSensitivity).toFixed(2);
|
||||||
|
data.params.magnY = (convertToInt16(bytes[14] | (bytes[15]<<8))*1.0/magnSensitivity).toFixed(2);
|
||||||
|
data.params.magnZ = (convertToInt16(bytes[16] | (bytes[17]<<8))*1.0/magnSensitivity).toFixed(2);
|
||||||
|
data.params.period = bytes[18] | (bytes[19]<<8);
|
||||||
|
data.params.pressure = ((bytes[20] | (bytes[21]<<8) | (bytes[22]<<16) | (bytes[23]<<24))*1.0/presSensitivity).toFixed(2);
|
||||||
|
data.params.altitude = ((Math.pow(1017.92/data.params.pressure,1.0/5.257) - 1)*(data.params.temperature/10.0+273.15)/0.0065).toFixed(2);
|
||||||
|
data.params.fPort = fPort;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function convertToInt16(num)
|
||||||
|
{
|
||||||
|
var intNum = num;
|
||||||
|
if ((num & 0x8000) > 0) {
|
||||||
|
intNum = num - 0x10000;
|
||||||
|
}
|
||||||
|
return intNum;
|
||||||
|
}
|
||||||
|
****************************** CODE END *****************************
|
||||||
|
*/
|
||||||
void application_entry(void *arg)
|
void application_entry(void *arg)
|
||||||
{
|
{
|
||||||
int16_t temperature;
|
sensor_data_t sensor_data;
|
||||||
int16_t humidity;
|
|
||||||
|
|
||||||
HTS221_Init();
|
// initialization of sensors
|
||||||
|
BSP_Sensor_Init();
|
||||||
|
|
||||||
rhf76_lora_init(HAL_UART_PORT_1);
|
rhf76_lora_init(HAL_UART_PORT_1);
|
||||||
tos_lora_module_recvcb_register(recv_callback);
|
tos_lora_module_recvcb_register(recv_callback);
|
||||||
|
tos_lora_module_join_otaa("8cf957200000f53c", "8cf957200000f52c6d09aaaaad205a72");
|
||||||
tos_lora_module_join_otaa("8cf957200000fa57", "8cf957200000fa572059aaaaad204a72");
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
HTS221_Get_Temperature(&temperature);
|
BSP_Sensor_Read(&sensor_data);
|
||||||
HTS221_Get_Humidity(&humidity);
|
print_to_screen(sensor_data);
|
||||||
|
// generate data frame
|
||||||
printf("temperature: %2.1f\n", temperature / 10.0);
|
dev_data_wrapper.u.dev_data.magn_fullscale = (uint8_t)(sensor_data.sensor_magn.fullscale);
|
||||||
printf("humidity : %2.1f\n", humidity / 10.0);
|
dev_data_wrapper.u.dev_data.temp_sensitivity = (uint8_t)(sensor_data.sensor_tempnhumi.temp_sensitivity);
|
||||||
|
dev_data_wrapper.u.dev_data.humi_sensitivity = (uint16_t)(sensor_data.sensor_tempnhumi.humi_sensitivity);
|
||||||
dev_data_wrapper.u.dev_data.temperature = temperature / 10;
|
dev_data_wrapper.u.dev_data.press_sensitivity = (uint16_t)(sensor_data.sensor_press.sensitivity);
|
||||||
dev_data_wrapper.u.dev_data.humidity = humidity / 10;
|
dev_data_wrapper.u.dev_data.magn_sensitivity = (uint16_t)(sensor_data.sensor_magn.sensitivity);
|
||||||
dev_data_wrapper.u.dev_data.period = report_period;
|
dev_data_wrapper.u.dev_data.temperature = (int16_t)(sensor_data.sensor_tempnhumi.temperature);
|
||||||
|
dev_data_wrapper.u.dev_data.humidity = (int16_t)(sensor_data.sensor_tempnhumi.humidity);
|
||||||
|
dev_data_wrapper.u.dev_data.magn_x = (int16_t)(sensor_data.sensor_magn.magn_x);
|
||||||
|
dev_data_wrapper.u.dev_data.magn_y = (int16_t)(sensor_data.sensor_magn.magn_y);
|
||||||
|
dev_data_wrapper.u.dev_data.magn_z = (int16_t)(sensor_data.sensor_magn.magn_z);
|
||||||
|
dev_data_wrapper.u.dev_data.pressure = (uint32_t)(sensor_data.sensor_press.pressure);
|
||||||
|
dev_data_wrapper.u.dev_data.period = report_period;
|
||||||
|
// send data to the server (via gateway)
|
||||||
tos_lora_module_send(dev_data_wrapper.u.serialize, sizeof(dev_data_t));
|
tos_lora_module_send(dev_data_wrapper.u.serialize, sizeof(dev_data_t));
|
||||||
tos_task_delay(report_period * 1000);
|
tos_task_delay(report_period * 1000);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -66,7 +66,7 @@
|
|||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>OGLastSavedByProductVersion</name>
|
<name>OGLastSavedByProductVersion</name>
|
||||||
<state>8.32.1.18618</state>
|
<state>8.30.1.17146</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>GeneralEnableMisra</name>
|
<name>GeneralEnableMisra</name>
|
||||||
@@ -215,17 +215,12 @@
|
|||||||
<name>ICCARM</name>
|
<name>ICCARM</name>
|
||||||
<archiveVersion>2</archiveVersion>
|
<archiveVersion>2</archiveVersion>
|
||||||
<data>
|
<data>
|
||||||
<version>35</version>
|
<version>34</version>
|
||||||
<wantNonLocal>1</wantNonLocal>
|
<wantNonLocal>1</wantNonLocal>
|
||||||
<debug>1</debug>
|
<debug>1</debug>
|
||||||
<option>
|
|
||||||
<name>CCOptimizationNoSizeConstraints</name>
|
|
||||||
<state>0</state>
|
|
||||||
</option>
|
|
||||||
<option>
|
<option>
|
||||||
<name>CCDefines</name>
|
<name>CCDefines</name>
|
||||||
<state>USE_HAL_DRIVER</state>
|
<state></state>
|
||||||
<state>STM32L073xx</state>
|
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>CCPreprocFile</name>
|
<name>CCPreprocFile</name>
|
||||||
@@ -237,7 +232,7 @@
|
|||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>CCPreprocLine</name>
|
<name>CCPreprocLine</name>
|
||||||
<state>0</state>
|
<state>1</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>CCListCFile</name>
|
<name>CCListCFile</name>
|
||||||
@@ -286,7 +281,7 @@
|
|||||||
<option>
|
<option>
|
||||||
<name>CCAllowList</name>
|
<name>CCAllowList</name>
|
||||||
<version>1</version>
|
<version>1</version>
|
||||||
<state>11111110</state>
|
<state>00000000</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>CCDebugInfo</name>
|
<name>CCDebugInfo</name>
|
||||||
@@ -334,7 +329,7 @@
|
|||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>OutputFile</name>
|
<name>OutputFile</name>
|
||||||
<state>$FILE_BNAME$.o</state>
|
<state></state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>CCLibConfigHeader</name>
|
<name>CCLibConfigHeader</name>
|
||||||
@@ -350,18 +345,7 @@
|
|||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>CCIncludePath2</name>
|
<name>CCIncludePath2</name>
|
||||||
<state>$PROJ_DIR$\..\..\BSP\Inc</state>
|
<state></state>
|
||||||
<state>$PROJ_DIR$\..\..\..\..\platform\vendor_bsp\st\STM32L0xx_HAL_Driver\Inc</state>
|
|
||||||
<state>$PROJ_DIR$\..\..\..\..\platform\vendor_bsp\st\STM32L0xx_HAL_Driver\Inc\Legacy</state>
|
|
||||||
<state>$PROJ_DIR$\..\..\..\..\platform\vendor_bsp\st\CMSIS\Device\ST\STM32L0xx\Include</state>
|
|
||||||
<state>$PROJ_DIR$\..\..\..\..\platform\vendor_bsp\st\CMSIS\Include</state>
|
|
||||||
<state>$PROJ_DIR$\..\..\..\..\arch\arm\arm-v7m\common\include</state>
|
|
||||||
<state>$PROJ_DIR$\..\..\..\..\arch\arm\arm-v7m\cortex-m0+\iccarm</state>
|
|
||||||
<state>$PROJ_DIR$\..\..\..\..\kernel\core\include</state>
|
|
||||||
<state>$PROJ_DIR$\..\..\..\..\kernel\pm\include</state>
|
|
||||||
<state>$PROJ_DIR$\..\..\..\..\osal\cmsis_os</state>
|
|
||||||
<state>$PROJ_DIR$\..\..\TOS_CONFIG</state>
|
|
||||||
<state>$PROJ_DIR$\..\..\..\..\examples\helloworld</state>
|
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>CCStdIncCheck</name>
|
<name>CCStdIncCheck</name>
|
||||||
@@ -377,16 +361,16 @@
|
|||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>CCOptLevel</name>
|
<name>CCOptLevel</name>
|
||||||
<state>3</state>
|
<state>1</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>CCOptStrategy</name>
|
<name>CCOptStrategy</name>
|
||||||
<version>0</version>
|
<version>0</version>
|
||||||
<state>1</state>
|
<state>0</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>CCOptLevelSlave</name>
|
<name>CCOptLevelSlave</name>
|
||||||
<state>3</state>
|
<state>1</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>CompilerMisraRules98</name>
|
<name>CompilerMisraRules98</name>
|
||||||
@@ -424,7 +408,7 @@
|
|||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>IccStaticDestr</name>
|
<name>IccStaticDestr</name>
|
||||||
<state>0</state>
|
<state>1</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>IccCppInlineSemantics</name>
|
<name>IccCppInlineSemantics</name>
|
||||||
@@ -438,6 +422,10 @@
|
|||||||
<name>IccFloatSemantics</name>
|
<name>IccFloatSemantics</name>
|
||||||
<state>0</state>
|
<state>0</state>
|
||||||
</option>
|
</option>
|
||||||
|
<option>
|
||||||
|
<name>CCOptimizationNoSizeConstraints</name>
|
||||||
|
<state>0</state>
|
||||||
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>CCNoLiteralPool</name>
|
<name>CCNoLiteralPool</name>
|
||||||
<state>0</state>
|
<state>0</state>
|
||||||
@@ -445,7 +433,7 @@
|
|||||||
<option>
|
<option>
|
||||||
<name>CCOptStrategySlave</name>
|
<name>CCOptStrategySlave</name>
|
||||||
<version>0</version>
|
<version>0</version>
|
||||||
<state>1</state>
|
<state>0</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>CCGuardCalls</name>
|
<name>CCGuardCalls</name>
|
||||||
@@ -475,10 +463,6 @@
|
|||||||
<name>IccRTTI2</name>
|
<name>IccRTTI2</name>
|
||||||
<state>0</state>
|
<state>0</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
|
||||||
<name>OICompilerExtraOption</name>
|
|
||||||
<state>1</state>
|
|
||||||
</option>
|
|
||||||
</data>
|
</data>
|
||||||
</settings>
|
</settings>
|
||||||
<settings>
|
<settings>
|
||||||
@@ -699,7 +683,7 @@
|
|||||||
<name>ILINK</name>
|
<name>ILINK</name>
|
||||||
<archiveVersion>0</archiveVersion>
|
<archiveVersion>0</archiveVersion>
|
||||||
<data>
|
<data>
|
||||||
<version>22</version>
|
<version>21</version>
|
||||||
<wantNonLocal>1</wantNonLocal>
|
<wantNonLocal>1</wantNonLocal>
|
||||||
<debug>1</debug>
|
<debug>1</debug>
|
||||||
<option>
|
<option>
|
||||||
@@ -776,11 +760,11 @@
|
|||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>IlinkIcfOverride</name>
|
<name>IlinkIcfOverride</name>
|
||||||
<state>1</state>
|
<state>0</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>IlinkIcfFile</name>
|
<name>IlinkIcfFile</name>
|
||||||
<state>$PROJ_DIR$/stm32l073xx_flash.icf</state>
|
<state>lnk0t.icf</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>IlinkIcfFileSlave</name>
|
<name>IlinkIcfFileSlave</name>
|
||||||
@@ -840,7 +824,7 @@
|
|||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>IlinkProgramEntryLabel</name>
|
<name>IlinkProgramEntryLabel</name>
|
||||||
<state>__iar_program_start</state>
|
<state></state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>DoFill</name>
|
<name>DoFill</name>
|
||||||
@@ -1015,10 +999,6 @@
|
|||||||
<name>IlinkTrustzoneImportLibraryOut</name>
|
<name>IlinkTrustzoneImportLibraryOut</name>
|
||||||
<state>###Unitialized###</state>
|
<state>###Unitialized###</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
|
||||||
<name>OILinkExtraOption</name>
|
|
||||||
<state>1</state>
|
|
||||||
</option>
|
|
||||||
</data>
|
</data>
|
||||||
</settings>
|
</settings>
|
||||||
<settings>
|
<settings>
|
||||||
|
1383
board/NUCLEO_STM32L073RZ/IAR/hello_world/TencentOS_tiny.ewt
Normal file
1383
board/NUCLEO_STM32L073RZ/IAR/hello_world/TencentOS_tiny.ewt
Normal file
File diff suppressed because it is too large
Load Diff
1476
board/NUCLEO_STM32L073RZ/IAR/lorawan/TencentOS_tiny.ewd
Normal file
1476
board/NUCLEO_STM32L073RZ/IAR/lorawan/TencentOS_tiny.ewd
Normal file
File diff suppressed because it is too large
Load Diff
1291
board/NUCLEO_STM32L073RZ/IAR/lorawan/TencentOS_tiny.ewp
Normal file
1291
board/NUCLEO_STM32L073RZ/IAR/lorawan/TencentOS_tiny.ewp
Normal file
File diff suppressed because it is too large
Load Diff
1425
board/NUCLEO_STM32L073RZ/IAR/lorawan/TencentOS_tiny.ewt
Normal file
1425
board/NUCLEO_STM32L073RZ/IAR/lorawan/TencentOS_tiny.ewt
Normal file
File diff suppressed because it is too large
Load Diff
8
board/NUCLEO_STM32L073RZ/IAR/lorawan/TencentOS_tiny.eww
Normal file
8
board/NUCLEO_STM32L073RZ/IAR/lorawan/TencentOS_tiny.eww
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
|
|
||||||
|
<workspace>
|
||||||
|
<project>
|
||||||
|
<path>$WS_DIR$\TencentOS_tiny.ewp</path>
|
||||||
|
</project>
|
||||||
|
<batchBuild/>
|
||||||
|
</workspace>
|
346
board/NUCLEO_STM32L073RZ/IAR/lorawan/startup_stm32l073xx.s
Normal file
346
board/NUCLEO_STM32L073RZ/IAR/lorawan/startup_stm32l073xx.s
Normal file
@@ -0,0 +1,346 @@
|
|||||||
|
;/******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
|
||||||
|
;* File Name : startup_stm32l073xx.s
|
||||||
|
;* Author : MCD Application Team
|
||||||
|
;* Description : STM32L073xx Ultra Low Power Devices vector
|
||||||
|
;* This module performs:
|
||||||
|
;* - Set the initial SP
|
||||||
|
;* - Set the initial PC == _iar_program_start,
|
||||||
|
;* - Set the vector table entries with the exceptions ISR
|
||||||
|
;* address.
|
||||||
|
;* - Configure the system clock
|
||||||
|
;* - Branches to main in the C library (which eventually
|
||||||
|
;* calls main()).
|
||||||
|
;* After Reset the Cortex-M0+ processor is in Thread mode,
|
||||||
|
;* priority is Privileged, and the Stack is set to Main.
|
||||||
|
;********************************************************************************
|
||||||
|
;*
|
||||||
|
;* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
;* are permitted provided that the following conditions are met:
|
||||||
|
;* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
;* this list of conditions and the following disclaimer.
|
||||||
|
;* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
;* this list of conditions and the following disclaimer in the documentation
|
||||||
|
;* and/or other materials provided with the distribution.
|
||||||
|
;* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||||
|
;* may be used to endorse or promote products derived from this software
|
||||||
|
;* without specific prior written permission.
|
||||||
|
;*
|
||||||
|
;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
;* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
;* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
;* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
;* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
;* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
;* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
;* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
;* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
;*
|
||||||
|
;*******************************************************************************/
|
||||||
|
;
|
||||||
|
;
|
||||||
|
; The modules in this file are included in the libraries, and may be replaced
|
||||||
|
; by any user-defined modules that define the PUBLIC symbol _program_start or
|
||||||
|
; a user defined start symbol.
|
||||||
|
; To override the cstartup defined in the library, simply add your modified
|
||||||
|
; version to the workbench project.
|
||||||
|
;
|
||||||
|
; The vector table is normally located at address 0.
|
||||||
|
; When debugging in RAM, it can be located in RAM, aligned to at least 2^6.
|
||||||
|
; The name "__vector_table" has special meaning for C-SPY:
|
||||||
|
; it is where the SP start value is found, and the NVIC vector
|
||||||
|
; table register (VTOR) is initialized to this address if != 0.
|
||||||
|
;
|
||||||
|
; Cortex-M version
|
||||||
|
;
|
||||||
|
|
||||||
|
MODULE ?cstartup
|
||||||
|
|
||||||
|
;; Forward declaration of sections.
|
||||||
|
SECTION CSTACK:DATA:NOROOT(3)
|
||||||
|
|
||||||
|
SECTION .intvec:CODE:NOROOT(2)
|
||||||
|
|
||||||
|
EXTERN __iar_program_start
|
||||||
|
EXTERN SystemInit
|
||||||
|
PUBLIC __vector_table
|
||||||
|
|
||||||
|
DATA
|
||||||
|
__vector_table
|
||||||
|
DCD sfe(CSTACK)
|
||||||
|
DCD Reset_Handler ; Reset Handler
|
||||||
|
|
||||||
|
DCD NMI_Handler ; NMI Handler
|
||||||
|
DCD HardFault_Handler ; Hard Fault Handler
|
||||||
|
DCD 0 ; Reserved
|
||||||
|
DCD 0 ; Reserved
|
||||||
|
DCD 0 ; Reserved
|
||||||
|
DCD 0 ; Reserved
|
||||||
|
DCD 0 ; Reserved
|
||||||
|
DCD 0 ; Reserved
|
||||||
|
DCD 0 ; Reserved
|
||||||
|
DCD SVC_Handler ; SVCall Handler
|
||||||
|
DCD 0 ; Reserved
|
||||||
|
DCD 0 ; Reserved
|
||||||
|
DCD PendSV_Handler ; PendSV Handler
|
||||||
|
DCD SysTick_Handler ; SysTick Handler
|
||||||
|
|
||||||
|
; External Interrupts
|
||||||
|
DCD WWDG_IRQHandler ; Window Watchdog
|
||||||
|
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
||||||
|
DCD RTC_IRQHandler ; RTC through EXTI Line
|
||||||
|
DCD FLASH_IRQHandler ; FLASH
|
||||||
|
DCD RCC_CRS_IRQHandler ; RCC_CRS
|
||||||
|
DCD EXTI0_1_IRQHandler ; EXTI Line 0 and 1
|
||||||
|
DCD EXTI2_3_IRQHandler ; EXTI Line 2 and 3
|
||||||
|
DCD EXTI4_15_IRQHandler ; EXTI Line 4 to 15
|
||||||
|
DCD TSC_IRQHandler ; TSC
|
||||||
|
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
||||||
|
DCD DMA1_Channel2_3_IRQHandler ; DMA1 Channel 2 and Channel 3
|
||||||
|
DCD DMA1_Channel4_5_6_7_IRQHandler ; DMA1 Channel 4, Channel 5, Channel 6 and Channel 7
|
||||||
|
DCD ADC1_COMP_IRQHandler ; ADC1, COMP1 and COMP2
|
||||||
|
DCD LPTIM1_IRQHandler ; LPTIM1
|
||||||
|
DCD USART4_5_IRQHandler ; USART4 and USART5
|
||||||
|
DCD TIM2_IRQHandler ; TIM2
|
||||||
|
DCD TIM3_IRQHandler ; TIM3
|
||||||
|
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC
|
||||||
|
DCD TIM7_IRQHandler ; TIM7
|
||||||
|
DCD 0 ; Reserved
|
||||||
|
DCD TIM21_IRQHandler ; TIM21
|
||||||
|
DCD I2C3_IRQHandler ; I2C3
|
||||||
|
DCD TIM22_IRQHandler ; TIM22
|
||||||
|
DCD I2C1_IRQHandler ; I2C1
|
||||||
|
DCD I2C2_IRQHandler ; I2C2
|
||||||
|
DCD SPI1_IRQHandler ; SPI1
|
||||||
|
DCD SPI2_IRQHandler ; SPI2
|
||||||
|
DCD USART1_IRQHandler ; USART1
|
||||||
|
DCD USART2_IRQHandler ; USART2
|
||||||
|
DCD RNG_LPUART1_IRQHandler ; RNG and LPUART1
|
||||||
|
DCD LCD_IRQHandler ; LCD
|
||||||
|
DCD USB_IRQHandler ; USB
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;;
|
||||||
|
;; Default interrupt handlers.
|
||||||
|
;;
|
||||||
|
THUMB
|
||||||
|
PUBWEAK Reset_Handler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(2)
|
||||||
|
Reset_Handler
|
||||||
|
LDR R0, =SystemInit
|
||||||
|
BLX R0
|
||||||
|
LDR R0, =__iar_program_start
|
||||||
|
BX R0
|
||||||
|
|
||||||
|
PUBWEAK NMI_Handler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
NMI_Handler
|
||||||
|
B NMI_Handler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK HardFault_Handler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
HardFault_Handler
|
||||||
|
B HardFault_Handler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK SVC_Handler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
SVC_Handler
|
||||||
|
B SVC_Handler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK PendSV_Handler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
PendSV_Handler
|
||||||
|
B PendSV_Handler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK SysTick_Handler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
SysTick_Handler
|
||||||
|
B SysTick_Handler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK WWDG_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
WWDG_IRQHandler
|
||||||
|
B WWDG_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK PVD_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
PVD_IRQHandler
|
||||||
|
B PVD_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK RTC_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
RTC_IRQHandler
|
||||||
|
B RTC_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK FLASH_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
FLASH_IRQHandler
|
||||||
|
B FLASH_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK RCC_CRS_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
RCC_CRS_IRQHandler
|
||||||
|
B RCC_CRS_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK EXTI0_1_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
EXTI0_1_IRQHandler
|
||||||
|
B EXTI0_1_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK EXTI2_3_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
EXTI2_3_IRQHandler
|
||||||
|
B EXTI2_3_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK EXTI4_15_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
EXTI4_15_IRQHandler
|
||||||
|
B EXTI4_15_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK TSC_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
TSC_IRQHandler
|
||||||
|
B TSC_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK DMA1_Channel1_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
DMA1_Channel1_IRQHandler
|
||||||
|
B DMA1_Channel1_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK DMA1_Channel2_3_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
DMA1_Channel2_3_IRQHandler
|
||||||
|
B DMA1_Channel2_3_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK DMA1_Channel4_5_6_7_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
DMA1_Channel4_5_6_7_IRQHandler
|
||||||
|
B DMA1_Channel4_5_6_7_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK ADC1_COMP_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
ADC1_COMP_IRQHandler
|
||||||
|
B ADC1_COMP_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK LPTIM1_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
LPTIM1_IRQHandler
|
||||||
|
B LPTIM1_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK USART4_5_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
USART4_5_IRQHandler
|
||||||
|
B USART4_5_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK TIM2_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
TIM2_IRQHandler
|
||||||
|
B TIM2_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK TIM3_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
TIM3_IRQHandler
|
||||||
|
B TIM3_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK TIM6_DAC_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
TIM6_DAC_IRQHandler
|
||||||
|
B TIM6_DAC_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK TIM7_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
TIM7_IRQHandler
|
||||||
|
B TIM7_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK TIM21_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
TIM21_IRQHandler
|
||||||
|
B TIM21_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK I2C3_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
I2C3_IRQHandler
|
||||||
|
B I2C3_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK TIM22_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
TIM22_IRQHandler
|
||||||
|
B TIM22_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK I2C1_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
I2C1_IRQHandler
|
||||||
|
B I2C1_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK I2C2_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
I2C2_IRQHandler
|
||||||
|
B I2C2_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK SPI1_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
SPI1_IRQHandler
|
||||||
|
B SPI1_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK SPI2_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
SPI2_IRQHandler
|
||||||
|
B SPI2_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK USART1_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
USART1_IRQHandler
|
||||||
|
B USART1_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK USART2_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
USART2_IRQHandler
|
||||||
|
B USART2_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK RNG_LPUART1_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
RNG_LPUART1_IRQHandler
|
||||||
|
B RNG_LPUART1_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK LCD_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
LCD_IRQHandler
|
||||||
|
B LCD_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK USB_IRQHandler
|
||||||
|
SECTION .text:CODE:NOROOT:REORDER(1)
|
||||||
|
USB_IRQHandler
|
||||||
|
B USB_IRQHandler
|
||||||
|
|
||||||
|
END
|
||||||
|
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
|
@@ -70,7 +70,7 @@ typedef enum lora_key_type {
|
|||||||
#define RHF76_ATCMD_SET_BAND_CN470 "AT+DR=CN470\r\n"
|
#define RHF76_ATCMD_SET_BAND_CN470 "AT+DR=CN470\r\n"
|
||||||
#define RHF76_ATCMD_REPLY_BAND_CN470 "+DR: CN470"
|
#define RHF76_ATCMD_REPLY_BAND_CN470 "+DR: CN470"
|
||||||
|
|
||||||
#define RHF76_ATCMD_SET_CHANNEL "at+ch=num,0-7\r\n"
|
#define RHF76_ATCMD_SET_CHANNEL "at+ch=num,80-87\r\n"
|
||||||
#define RHF76_ATCMD_SET_ADR_OFF "at+adr=off\r\n"
|
#define RHF76_ATCMD_SET_ADR_OFF "at+adr=off\r\n"
|
||||||
#define RHF76_ATCMD_JOIN "AT+join\r\n"
|
#define RHF76_ATCMD_JOIN "AT+join\r\n"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user