Files
TencentOS-tiny/board/NUCLEO_STM32L073RZ/BSP/HardWare/Common/bsp.c
Winfred LIN 47d6313ba1 added reading flash functions for stm32l0xx series
1. implemented HAL_StatusTypeDef HAL_FLASH_ReadWord(uint32_t Address, uint32_t* Data); and HAL_StatusTypeDef HAL_FLASH_ReadHalfWord(uint32_t Address, uint16_t* Data); which allows user to read the internal FLASH (with out read protection)

2. implemeted device_config struct to store device configurations, e.g. magnetometer fullscale, report period, etc.

3. added demonstration code of using flash reading apis in lora_demo.c, in which the configuration sent from the cloud is stored into the internal Data EEPROM bank1, and each time when the device is booted, the configurations would be loaded from the Data EEPROM and used to initialize the application.
2020-04-03 18:21:16 +11:00

37 lines
1.0 KiB
C

/**
******************************************************************************
* @file bsp.c
* @author jieranzhi
* @brief provide high level interfaces to manage the sensors on the
* application
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "bsp.h"
void BSP_Sensor_Init(DeviceConfig_TypeDef config)
{
/* Initialize sensors */
HTS221_Init();
LPS22HB_Init();
LIS3MDL_Init();
LIS3MDL_Set_FullScale((LIS3MDL_FullScaleTypeDef)config.magn_fullscale);
}
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;
}