Files
TencentOS-tiny/board/RHF76_STM32L072CBxx_Lora/Src/eeprom-board.c
supowang edb2879617 first commit for opensource
first commit for opensource
2019-09-16 13:19:50 +08:00

74 lines
2.0 KiB
C

/*!
* \file eeprom-board.c
*
* \brief Target board EEPROM driver implementation
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2017 Semtech
*
* \endcode
*
* \author Miguel Luis ( Semtech )
*
* \author Gregory Cristian ( Semtech )
*/
#include "stm32l0xx.h"
#include "utilities.h"
#include "eeprom-board.h"
uint8_t EepromMcuWriteBuffer( uint16_t addr, uint8_t *buffer, uint16_t size )
{
uint8_t status = LORA_FAIL;
assert_param( ( DATA_EEPROM_BASE + addr ) >= DATA_EEPROM_BASE );
assert_param( buffer != NULL );
assert_param( size < ( DATA_EEPROM_BANK2_END - DATA_EEPROM_BASE ) );
if( HAL_FLASHEx_DATAEEPROM_Unlock( ) == HAL_OK )
{
for( uint16_t i = 0; i < size; i++ )
{
if( HAL_FLASHEx_DATAEEPROM_Program( FLASH_TYPEPROGRAMDATA_BYTE,
( DATA_EEPROM_BASE + addr + i ),
buffer[i] ) != HAL_OK )
{
// Failed to write EEPROM
break;
}
}
status = LORA_SUCCESS;
}
HAL_FLASHEx_DATAEEPROM_Lock( );
return status;
}
uint8_t EepromMcuReadBuffer( uint16_t addr, uint8_t *buffer, uint16_t size )
{
assert_param( ( DATA_EEPROM_BASE + addr ) >= DATA_EEPROM_BASE );
assert_param( buffer != NULL );
assert_param( size < ( DATA_EEPROM_BANK2_END - DATA_EEPROM_BASE ) );
memcpy1( buffer, ( uint8_t* )( DATA_EEPROM_BASE + addr ), size );
return LORA_SUCCESS;
}
void EepromMcuSetDeviceAddr( uint8_t addr )
{
assert_param( LORA_FAIL );
}
uint8_t EepromMcuGetDeviceAddr( void )
{
assert_param( LORA_FAIL );
return 0;
}