blob: 589587af031159b436a3a9c449836b412a547f47 [file] [log] [blame]
/******************************************************************************
* @file flash_mid14325e.c
*
* @brief for TLSR chips
*
* @author public@telink-semi.com;
* @date Sep. 30, 2010
*
* @attention
*
* Copyright (C) 2019-2020 Telink Semiconductor (Shanghai) Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*****************************************************************************/
#include "flash_type.h"
/**
* @brief This function reads the status of flash.
* @return the value of status.
* @note Attention: Before calling the FLASH function, please check the power supply voltage of the chip.
* Only if the detected voltage is greater than the safe voltage value, the FLASH function can be called.
* Taking into account the factors such as power supply fluctuations, the safe voltage value needs to be greater
* than the minimum chip operating voltage. For the specific value, please make a reasonable setting according
* to the specific application and hardware circuit.
*
* Risk description: When the chip power supply voltage is relatively low, due to the unstable power supply,
* there may be a risk of error in the operation of the flash (especially for the write and erase operations.
* If an abnormality occurs, the firmware and user data may be rewritten, resulting in the final Product failure)
*/
unsigned char flash_read_status_mid14325e(void)
{
return flash_read_status(FLASH_READ_STATUS_CMD_LOWBYTE);
}
/**
* @brief This function write the status of flash.
* @param[in] data - the value of status.
* @param[in] bit - the range of bits to be modified when writing status.
* @return none.
* @note Attention: Before calling the FLASH function, please check the power supply voltage of the chip.
* Only if the detected voltage is greater than the safe voltage value, the FLASH function can be called.
* Taking into account the factors such as power supply fluctuations, the safe voltage value needs to be greater
* than the minimum chip operating voltage. For the specific value, please make a reasonable setting according
* to the specific application and hardware circuit.
*
* Risk description: When the chip power supply voltage is relatively low, due to the unstable power supply,
* there may be a risk of error in the operation of the flash (especially for the write and erase operations.
* If an abnormality occurs, the firmware and user data may be rewritten, resulting in the final Product failure)
*/
void flash_write_status_mid14325e(unsigned char data, mid14325e_write_status_bit_e bit)
{
unsigned char status = flash_read_status(FLASH_READ_STATUS_CMD_LOWBYTE);
data |= (status & ~(bit));
flash_write_status(FLASH_TYPE_8BIT_STATUS, data);
}
/**
* @brief This function serves to set the protection area of the flash.
* @param[in] data - refer to the protection area definition in the .h file.
* @return none.
* @note Attention: Before calling the FLASH function, please check the power supply voltage of the chip.
* Only if the detected voltage is greater than the safe voltage value, the FLASH function can be called.
* Taking into account the factors such as power supply fluctuations, the safe voltage value needs to be greater
* than the minimum chip operating voltage. For the specific value, please make a reasonable setting according
* to the specific application and hardware circuit.
*
* Risk description: When the chip power supply voltage is relatively low, due to the unstable power supply,
* there may be a risk of error in the operation of the flash (especially for the write and erase operations.
* If an abnormality occurs, the firmware and user data may be rewritten, resulting in the final Product failure)
*/
void flash_lock_mid14325e(mid14325e_lock_block_e data)
{
flash_write_status_mid14325e(data, FLASH_WRITE_STATUS_BP_MID14325E);
}
/**
* @brief This function serves to flash release protection.
* @return none.
* @note Attention: Before calling the FLASH function, please check the power supply voltage of the chip.
* Only if the detected voltage is greater than the safe voltage value, the FLASH function can be called.
* Taking into account the factors such as power supply fluctuations, the safe voltage value needs to be greater
* than the minimum chip operating voltage. For the specific value, please make a reasonable setting according
* to the specific application and hardware circuit.
*
* Risk description: When the chip power supply voltage is relatively low, due to the unstable power supply,
* there may be a risk of error in the operation of the flash (especially for the write and erase operations.
* If an abnormality occurs, the firmware and user data may be rewritten, resulting in the final Product failure)
*/
void flash_unlock_mid14325e(void)
{
flash_write_status_mid14325e(FLASH_LOCK_NONE_MID14325E, FLASH_WRITE_STATUS_BP_MID14325E);
}