STM8s中这个FLASH_ReadOptionByte的库函数怎么写出来的?
时间:10-02
整理:3721RD
点击:
* 函数名:FLASH_ReadOptionByte
* 描述 :读取的选项字
* 输入 :无
*
* 输出 :无
* 返回 :选项字的值
* 调用 :内部调用 设置Beep的选项字函数调用
*************************************************************************/
static uint16_t FLASH_ReadOptionByte(uint16_t Address)
{
uint8_t value_optbyte, value_optbyte_complement = 0;
uint16_t res_value = 0;
value_optbyte = *((NEAR uint8_t*)Address); /* Read option byte *
value_optbyte_complement = *(((NEAR uint8_t*)Address) + 1); /* Read option byte complement */
if (value_optbyte == (uint8_t)(~value_optbyte_complement))
{
res_value = (uint16_t)((uint16_t)value_optbyte << 8);
res_value = res_value | (uint16_t)value_optbyte_complement;
}
else
{
res_value = FLASH_OPTIONBYTE_ERROR ((uint16_t)0x5555)
}
return(res_value);
}
* 描述 :读取的选项字
* 输入 :无
*
* 输出 :无
* 返回 :选项字的值
* 调用 :内部调用 设置Beep的选项字函数调用
*************************************************************************/
static uint16_t FLASH_ReadOptionByte(uint16_t Address)
{
uint8_t value_optbyte, value_optbyte_complement = 0;
uint16_t res_value = 0;
value_optbyte = *((NEAR uint8_t*)Address); /* Read option byte *
value_optbyte_complement = *(((NEAR uint8_t*)Address) + 1); /* Read option byte complement */
if (value_optbyte == (uint8_t)(~value_optbyte_complement))
{
res_value = (uint16_t)((uint16_t)value_optbyte << 8);
res_value = res_value | (uint16_t)value_optbyte_complement;
}
else
{
res_value = FLASH_OPTIONBYTE_ERROR ((uint16_t)0x5555)
}
return(res_value);
}
奖励1积分