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.
This commit is contained in:
Winfred LIN
2020-04-03 18:21:16 +11:00
parent cafe9c8a87
commit 47d6313ba1
8 changed files with 313 additions and 64 deletions

View File

@@ -1,33 +1,9 @@
/*
/ _____) _ | |
( (____ _____ ____ _| |_ _____ ____| |__
\____ \| ___ | (_ _) ___ |/ ___) _ \
_____) ) ____| | | || |_| ____( (___| | | |
(______/|_____)_|_|_| \__)_____)\____)_| |_|
(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>&copy; 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
*
* @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
******************************************************************************
*/
@@ -40,6 +16,7 @@ extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
#include <stdbool.h>
#include "HTS221.h"
#include "LPS22HB.h"
#include "LIS3MDL.h"
@@ -61,6 +38,25 @@ typedef struct
} sensor_data_t;
// application configuration types
typedef enum{
DCT_IS_CONFIRM = 0x00U,
DCT_REPORT_PERIOD = 0x01U,
DCT_REPEAT_TIME = 0x02U,
DCT_MAGN_FULLSCALE = 0x03U,
DCT_DEFAULT = 0xFFU,
}DeviceConfigType_TypeDef;
// application configuration
typedef struct
{
uint32_t config_address;
uint16_t report_period;
uint8_t repeat_time;
LIS3MDL_FullScaleTypeDef magn_fullscale;
bool is_confirmed;
}DeviceConfig_TypeDef;
/* Exported constants --------------------------------------------------------*/
/* External variables --------------------------------------------------------*/
/* Exported macros -----------------------------------------------------------*/
@@ -71,7 +67,7 @@ typedef struct
* @note
* @retval None
*/
void BSP_Sensor_Init(void);
void BSP_Sensor_Init(DeviceConfig_TypeDef config);
/**
* @brief sensor read.