硬汉嵌入式论坛

 找回密码
 立即注册
查看: 1467|回复: 3
收起左侧

YModem源码开头这几句代码作用是啥

[复制链接]

100

主题

299

回帖

599

积分

金牌会员

123

积分
599
发表于 2022-6-20 13:53:50 | 显示全部楼层 |阅读模式
请教大家,YModem源码开头这几句代码作用是啥?好像我iap还没操作过stm32读写保护啊?




[C] 纯文本查看 复制代码
/* Get the number of block (4 or 2 pages) from where the user program will be loaded */
  BlockNbr = (FlashDestination - 0x08000000) >> 12;

  /* Compute the mask to test if the Flash memory, where the user program will be
     loaded, is write protected */
#if defined (STM32F10X_MD) || defined (STM32F10X_MD_VL)
  UserMemoryMask = ((uint32_t)~((1 << BlockNbr) - 1));
#else /* USE_STM3210E_EVAL */
  if (BlockNbr < 62)
  {
    UserMemoryMask = ((uint32_t)~((1 << BlockNbr) - 1));
  }
  else
  {
    UserMemoryMask = ((uint32_t)0x80000000);
  }
#endif /* (STM32F10X_MD) || (STM32F10X_MD_VL) */


  /* Test if any page of Flash memory where program user will be loaded is write protected */
  if ((FLASH_GetWriteProtectionOptionByte() & UserMemoryMask) != UserMemoryMask)
  {
    FlashProtection = 1;
  }
  else
  {
    FlashProtection = 0;
  }

回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
115661
QQ
发表于 2022-6-21 01:35:51 | 显示全部楼层
看注释应该就是通过选项字节判断扇区读写保护。
回复

使用道具 举报

100

主题

299

回帖

599

积分

金牌会员

123

积分
599
 楼主| 发表于 2022-6-21 10:29:33 | 显示全部楼层
eric2013 发表于 2022-6-21 01:35
看注释应该就是通过选项字节判断扇区读写保护。

之前我没加过写保护,应该去掉这些判断也行吧?

回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
115661
QQ
发表于 2022-6-21 10:44:35 | 显示全部楼层
ssssssss 发表于 2022-6-21 10:29
之前我没加过写保护,应该去掉这些判断也行吧?

用不到,直接删掉即可
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2025-5-10 10:57 , Processed in 0.237843 second(s), 24 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表