{"id":413237,"date":"2024-06-29T23:00:22","date_gmt":"2024-06-29T23:00:22","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=413237"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=413237","title":{"rendered":"<span>\u041e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 SPI \u0444\u043b\u044d\u0448\u0435\u043a\u2026 \u041d\u043e \u0443\u0436\u0435 \u0441 \u043a\u044d\u0448\u0435\u043c \u0438 \u00ab\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u00bb api<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u043b \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u043a\u0443\u0447\u0443 \u043f\u0440\u043e\u0441\u0442\u044b\u0445, \u0438 \u0434\u0430\u0436\u0435 \u043e\u0447\u0435\u043d\u044c, \u0441\u0442\u0430\u0442\u0435\u0435\u043a \u043d\u0430 \u0442\u0435\u043c\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432, \u0442\u043e\u0436\u0435 \u0440\u0435\u0448\u0438\u043b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435, \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0435, \u043d\u043e \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435.<\/p>\n<p>\u0414\u0430 \u043f\u0440\u043e\u0441\u0442\u044f\u0442 \u043c\u0435\u043d\u044f \u0431\u044b\u0432\u0430\u043b\u044b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0437\u0430 \u0441\u0435\u0439 \u0442\u0440\u0443\u0434, \u0434\u0430 \u0438 \u0445\u0435\u0439\u0442\u0435\u0440\u044b \u043f\u0443\u0441\u0442\u044c \u043f\u0440\u043e\u0449\u0430\u044e\u0442 \u0442\u043e\u0436\u0435?<\/p>\n<h2>\u041e\u00a0\u0447\u0451\u043c \u043f\u043e\u0439\u0434\u0435\u0442 \u0440\u0435\u0447\u044c<\/h2>\n<p>\u0411\u0443\u0434\u0435\u043c \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u044f\u0442\u044c \u0438 \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0444\u043b\u0435\u0448\u043a\u0438 \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0435\u0451 \u0440\u0435\u0441\u0443\u0440\u0441 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044f\u0445.<\/p>\n<h2>\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f \u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439<\/h2>\n<p>\u041f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u0430\u0441\u044c SPI \u0444\u043b\u044d\u0448\u043a\u0430 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u043e\u0435 \u041f\u041e \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. \u0422\u0438\u043f\u043e\u0432\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043c\u0435\u0441\u0442\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0447\u0438\u043f\u0430.<\/p>\n<p>\u041e\u0431\u044a\u0435\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0443\u0436\u0435\u043d \u0431\u044b\u043b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u043d\u043e \u043f\u0440\u0438\u043b\u0438\u0447\u043d\u044b\u0439, \u0447\u0442\u043e-\u0442\u043e \u0432  \u0440\u0430\u0439\u043e\u043d\u0435 8 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442.<\/p>\n<p>\u041a\u0430\u043a \u0438 \u0432\u0441\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b, \u0432\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u0438\u044f \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u0430, \u043f\u043e\u043b\u0435\u0437 \u0438\u0441\u043a\u0430\u0442\u044c \u0432 \u0441\u0435\u0442\u0438 (github, gitlab) \u0432 \u0438\u0442\u043e\u0433\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0440\u0438\u0433\u043b\u044f\u043d\u0443\u043b\u043e\u0441\u044c.<\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432:<\/p>\n<ol>\n<li>\n<p>\u0412\u0441\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0447\u0442\u0435\u043d\u0438\u044f \u043f\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c \u0438 \u0441\u0435\u043a\u0442\u043e\u0440\u0430\u043c. <\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0430\u0437\u0431\u0440\u043e\u0441\u0430\u043d \u043d\u0430 \u0434\u0432\u0430 \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u0435\u043a\u0442\u043e\u0440\u043e\u0432, \u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0434\u0430\u0436\u0435 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u0441\u0435\u043a\u0442\u043e\u0440\u0435 \u043f\u0440\u043e\u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0440\u0438\u0432\u0430\u044f \u043f\u043e \u0442\u0435\u043c \u0438\u043b\u0438 \u0438\u043d\u044b\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u043b\u043e\u0431. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0435\u0449\u0451 \u0441\u0432\u043e\u044e \u043e\u0431\u0435\u0440\u0442\u043a\u0443 \u043f\u0438\u0441\u0430\u0442\u044c \u0441 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043b\u043e\u0445\u043e\u0439 \u0441\u0442\u0438\u043b\u044c\/\u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430:<\/p>\n<ol>\n<li>\n<p>extern \u0432\u0435\u0437\u0434\u0435, \u0433\u0434\u0435 \u043d\u0443\u0436\u043d\u043e \u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e<\/p>\n<\/li>\n<li>\n<p>\u041a\u0443\u0447\u0430 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432, \u0433\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0431\u0435\u0437 \u043d\u0438\u0445, \u0435\u0449\u0451 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u00f3\u043b\u044c\u0448\u0438\u0439 \u043f\u0440\u043e\u0444\u0438\u0442.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0440\u0443\u0436\u0443 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u043e\u0434\u0443\u043b\u044f, \u2014 \u0442\u043e\u0440\u0447\u0430\u0449\u0438\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0438 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u0444\u0430\u0439\u043b\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 1 &#8212; \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0438 \u043a\u0440\u0438\u0442\u0438\u043a\u043e\u0439<\/summary>\n<div class=\"spoiler__content\">\n<p><a href=\"https:\/\/github.com\/nimaltd\/w25qxx\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/nimaltd\/w25qxx<\/a><\/p>\n<pre><code class=\"cpp\">\/\/... extern w25qxx_t w25qxx;  bool W25qxx_Init(void);  void W25qxx_EraseChip(void); void W25qxx_EraseSector(uint32_t SectorAddr); void W25qxx_EraseBlock(uint32_t BlockAddr);  uint32_t W25qxx_PageToSector(uint32_t PageAddress); uint32_t W25qxx_PageToBlock(uint32_t PageAddress); uint32_t W25qxx_SectorToBlock(uint32_t SectorAddress); uint32_t W25qxx_SectorToPage(uint32_t SectorAddress); uint32_t W25qxx_BlockToPage(uint32_t BlockAddress);  bool W25qxx_IsEmptyPage(uint32_t Page_Address, uint32_t OffsetInByte, uint32_t NumByteToCheck_up_to_PageSize); bool W25qxx_IsEmptySector(uint32_t Sector_Address, uint32_t OffsetInByte, uint32_t NumByteToCheck_up_to_SectorSize); bool W25qxx_IsEmptyBlock(uint32_t Block_Address, uint32_t OffsetInByte, uint32_t NumByteToCheck_up_to_BlockSize);  void W25qxx_WriteByte(uint8_t pBuffer, uint32_t Bytes_Address); void W25qxx_WritePage(uint8_t *pBuffer, uint32_t Page_Address, uint32_t OffsetInByte, uint32_t NumByteToWrite_up_to_PageSize); void W25qxx_WriteSector(uint8_t *pBuffer, uint32_t Sector_Address, uint32_t OffsetInByte, uint32_t NumByteToWrite_up_to_SectorSize); void W25qxx_WriteBlock(uint8_t *pBuffer, uint32_t Block_Address, uint32_t OffsetInByte, uint32_t NumByteToWrite_up_to_BlockSize);  void W25qxx_ReadByte(uint8_t *pBuffer, uint32_t Bytes_Address); void W25qxx_ReadBytes(uint8_t *pBuffer, uint32_t ReadAddr, uint32_t NumByteToRead); void W25qxx_ReadPage(uint8_t *pBuffer, uint32_t Page_Address, uint32_t OffsetInByte, uint32_t NumByteToRead_up_to_PageSize); void W25qxx_ReadSector(uint8_t *pBuffer, uint32_t Sector_Address, uint32_t OffsetInByte, uint32_t NumByteToRead_up_to_SectorSize); void W25qxx_ReadBlock(uint8_t *pBuffer, uint32_t Block_Address, uint32_t OffsetInByte, uint32_t NumByteToRead_up_to_BlockSize);<\/code><\/pre>\n<p>\u041a\u0443\u0447\u0430 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0432 \u0442\u0443\u043f\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d datasheet. \u0418\u0437 \u0432\u0441\u0435\u0433\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043b\u0438\u0448\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445. \u041d\u043e \u0442\u0435\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u044b \u043d\u0435\u0442.<\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0447\u0435\u043d\u044c \u0434\u043b\u0438\u043d\u043d\u044b\u0439 \u043a\u0443\u0441\u043e\u043a \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0443\u0436\u0435 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b, \u043d\u043e \u043e\u043d \u0432\u0441\u0451 \u0435\u0449\u0451 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0439.<\/p>\n<pre><code class=\"cpp\">switch (id &amp; 0x000000FF) { case 0x20: \/\/ w25q512     w25qxx.ID = W25Q512;     w25qxx.BlockCount = 1024;     break; case 0x19: \/\/ w25q256     w25qxx.ID = W25Q256;     w25qxx.BlockCount = 512;     break; case 0x18: \/\/ w25q128     w25qxx.ID = W25Q128;     w25qxx.BlockCount = 256;     break; case 0x17: \/\/w25q64     w25qxx.ID = W25Q64;     w25qxx.BlockCount = 128;     break; case 0x16: \/\/w25q32     w25qxx.ID = W25Q32;     w25qxx.BlockCount = 64;     break; case 0x15: \/\/w25q16     w25qxx.ID = W25Q16;     w25qxx.BlockCount = 32;     break; case 0x14: \/\/w25q80     w25qxx.ID = W25Q80;     w25qxx.BlockCount = 16;     break; case 0x13: \/\/w25q40     w25qxx.ID = W25Q40;     w25qxx.BlockCount = 8;     break; case 0x12: \/\/w25q20     w25qxx.ID = W25Q20;     w25qxx.BlockCount = 4;     break; case 0x11: \/\/w25q10     w25qxx.ID = W25Q10;     w25qxx.BlockCount = 2;     break; default:     w25qxx.Lock = 0;     return false; }  w25qxx.PageSize = 256; w25qxx.SectorSize = 0x1000; w25qxx.SectorCount = w25qxx.BlockCount * 16; w25qxx.PageCount = (w25qxx.SectorCount * w25qxx.SectorSize) \/ w25qxx.PageSize; w25qxx.BlockSize = w25qxx.SectorSize * 16; w25qxx.CapacityInKiloByte = (w25qxx.SectorCount * w25qxx.SectorSize) \/ 1024;<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043b\u0438 \u0443\u0431\u0440\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u0432 \u0436\u0438\u0437\u043d\u0438 \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0443\u0442 \u0432 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u043b\u0438\u0441\u0442\u0430\u0442\u044c \u0434\u043e 170 \u0441\u0442\u0440\u043e\u043a\u0438, \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0432\u0435\u0442\u0432\u0438 switch, \u0430 \u043f\u043e\u0442\u043e\u043c \u043d\u0435 \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0439 \u043a\u043e\u0434.<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 2 &#8212; \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043b\u043e\u044f\u043b\u044c\u043d\u0430\u044f \u043a\u0440\u0438\u0442\u0438\u043a\u0430, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0442\u043e\u0447\u043d\u043e<\/summary>\n<div class=\"spoiler__content\">\n<p><a href=\"https:\/\/github.com\/iammingge\/Driver_W25Qxx\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/iammingge\/Driver_W25Qxx<\/a><\/p>\n<p>\u0422\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 API. \u041d\u043e \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. \u0414\u0430 \u0438 \u0442\u043e \u043d\u0435 \u0441\u0430\u043c\u044b\u043c \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">\/\/.. \u044d\u0442\u043e 250 \u0441\u0442\u0440\u043e\u043a\u0430 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043a\u0443\u0447\u0430 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432. uint16_t W25Qxx_ID_Manufacturer(void); uint32_t W25Qxx_ID_JEDEC(void); uint64_t W25Qxx_ID_Unique(void);  void W25Qxx_Reset(void); void W25Qxx_PowerEnable(void); void W25Qxx_PowerDisable(void); void W25Qxx_VolatileSR_WriteEnable(void); void W25Qxx_WriteEnable(void); void W25Qxx_WriteDisable(void); void W25Qxx_4ByteMode(void); void W25Qxx_3ByteMode(void); void W25Qxx_Suspend(void); void W25Qxx_Resume(void);  void W25Qxx_ReadExtendedRegister(void); void W25Qxx_WriteExtendedRegister(uint8_t ExtendedAddr);  void W25Qxx_ReadStatusRegister(uint8_t Select_SR_1_2_3); void W25Qxx_WriteStatusRegister(uint8_t Select_SR_1_2_3, uint8_t Data); void W25Qxx_VolatileSR_WriteStatusRegister(uint8_t Select_SR_1_2_3, uint8_t Data); uint8_t W25Qxx_RBit_WEL(void); uint8_t W25Qxx_RBit_BUSY(void); uint8_t W25Qxx_RBit_SUS(void); uint8_t W25Qxx_RBit_ADS(void); void W25Qxx_WBit_SRP(W25Qxx_SRM srm, uint8_t bit); void W25Qxx_WBit_TB(W25Qxx_SRM srm, uint8_t bit); void W25Qxx_WBit_CMP(W25Qxx_SRM srm, uint8_t bit); void W25Qxx_WBit_QE(W25Qxx_SRM srm, uint8_t bit); void W25Qxx_WBit_SRL(W25Qxx_SRM srm, uint8_t bit); void W25Qxx_WBit_WPS(W25Qxx_SRM srm, uint8_t bit); void W25Qxx_WBit_DRV(W25Qxx_SRM srm, uint8_t bit); void W25Qxx_WBit_BP(W25Qxx_SRM srm, uint8_t bit); void W25Qxx_WBit_LB(W25Qxx_SRM srm, uint8_t bit); void W25Qxx_WBit_ADP(uint8_t bit); uint8_t W25Qxx_ReadStatus(void);  void W25Qxx_isStatus(uint8_t Select_Status, uint32_t timeout, W25Qxx_ERR *err);  void W25Qxx_Global_UnLock(W25Qxx_ERR *err); void W25Qxx_Global_Locked(W25Qxx_ERR *err); void W25Qxx_Individual_UnLock(uint32_t ByteAddr, W25Qxx_ERR *err); void W25Qxx_Individual_Locked(uint32_t ByteAddr, W25Qxx_ERR *err);  void W25Qxx_Erase_Chip(W25Qxx_ERR *err); void W25Qxx_Erase_Block64(uint32_t Block64Addr, W25Qxx_ERR *err); void W25Qxx_Erase_Block32(uint32_t Block32Addr, W25Qxx_ERR *err); void W25Qxx_Erase_Sector(uint32_t SectorAddr, W25Qxx_ERR *err); void W25Qxx_Erase_Security(uint32_t SectorAddr, W25Qxx_ERR *err); void W25Qxx_Read(uint8_t *pBuffer, uint32_t ByteAddr, uint16_t NumByteToRead, W25Qxx_ERR *err); void W25Qxx_Read_Security(uint8_t *pBuffer, uint32_t ByteAddr, uint16_t NumByteToRead, W25Qxx_ERR *err); void W25Qxx_Read_SFDP(uint8_t *pBuffer, uint32_t ByteAddr, uint16_t NumByteToRead, W25Qxx_ERR *err); void W25Qxx_DIR_Program_Page(uint8_t *pBuffer, uint32_t ByteAddr, uint16_t NumByteToWrite, W25Qxx_ERR *err); void W25Qxx_DIR_Program(uint8_t *pBuffer, uint32_t ByteAddr, uint32_t NumByteToWrite, W25Qxx_ERR *err); void W25Qxx_DIR_Program_Security(uint8_t *pBuffer, uint32_t ByteAddr, uint16_t NumByteToWrite, W25Qxx_ERR *err); void W25Qxx_Program(uint8_t *pBuffer, uint32_t ByteAddr, uint32_t NumByteToWrite, W25Qxx_ERR *err); void W25Qxx_Program_Security(uint8_t *pBuffer, uint32_t ByteAddr, uint16_t NumByteToWrite, W25Qxx_ERR *err);  W25QXX_EXT W25Qxx_t W25Qxx; void W25Qxx_QueryChip(W25Qxx_ERR *err); void W25Qxx_config(W25Qxx_ERR *err); void W25Qxx_SusResum_Erase_Sector(uint32_t SectorAddr, W25Qxx_ERR *err);<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e \u0441\u0442\u0438\u043b\u0438\u0441\u0442\u0438\u043a\u0435.<\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u0443\u0441\u043e\u0447\u0435\u043a \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435.<\/p>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c\u0430. \u041e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u0435, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043e\u043d\u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u043c\u0430\u043a\u0440\u043e\u0441\u0430\u043c\u0438, \u0430 \u043d\u0435 \u0432 \u0432\u0438\u0434\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0417\u0430\u0447\u0435\u043c \u0437\u0434\u0435\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0441\u0430\u043c\u043e\u0439 \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c\u0435, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0438\u0433\u0434\u0435 \u0432 \u044d\u0442\u043e\u043c API \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f, \u0430 \u043d\u0443\u0436\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439?<\/p>\n<blockquote>\n<p>\u0422\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0442\u0430\u043a \u043c\u0430\u043b\u043e \u043e\u0442\u0432\u0435\u0442\u043e\u0432&#8230;<\/p>\n<\/blockquote>\n<pre><code class=\"cpp\">#define W25Q_CMD_WEN              0x06 #define W25Q_CMD_VOLATILESREN         0x50 #define W25Q_CMD_WDEN             0x04  #define W25Q_CMD_POWEREN            0xAB #define W25Q_CMD_MANUFACTURER 0x90 #define W25Q_CMD_JEDECID          0x9F  #define W25Q_CMD_UNIQUEID             0x4B  #define W25Q_CMD_READ            0x03 #define W25Q_CMD_4BREAD               0x13 #define W25Q_CMD_FASTREAD             0x0B #define W25Q_CMD_4BFASTREAD           0x0C  \/**  * @brief W25Qxx SIZE  *\/ #define W25Qxx_PAGESIZE  0x00100 #define W25Qxx_PAGEPOWER 0x08 #define W25Qxx_SECTORSIZE  0x01000 #define W25Qxx_SECTORPOWER 0x0C #define W25Qxx_BLOCKSIZE  0x10000 #define W25Qxx_BLOCKPOWER 0x10 #define W25Qxx_SECTURITYSIZE 0x00300<\/code><\/pre>\n<p>\u041e\u0442 \u0441\u0435\u0431\u044f \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0432\u0441\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u0435\u043b\u0430\u044e\u0442\u0441\u044f \u0442\u0438\u043f\u044b, \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u043a \u043f\u043b\u043e\u0445\u043e.<\/p>\n<pre><code>typedef enum  {     UNKNOWN = 0x000000,     W25X05 = 0xEFFF10,     W25X10 = 0xEFFF11,     ... } W25Qxx_CHIP;<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u0432\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0443\u0434\u0430 \u0438\u043c\u044f \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u043f\u0443\u0441\u0442\u044c \u0434\u0430\u0436\u0435 <code>W25Qxx_CHIP<\/code>, \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0442\u0430\u043c, \u0433\u0434\u0435 \u043e\u043d \u0432\u0434\u0440\u0443\u0433 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f, \u0430 \u043d\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u0444\u0430\u0439\u043b. \u0414\u0430\u0436\u0435 \u0442\u0443\u043f\u043e \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0430 \u0432 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435 \u043a\u043e\u0434\u0430 \u0441\u0438\u043c\u043f\u0430\u0442\u0438\u0447\u043d\u0435\u0435.<\/p>\n<pre><code>typedef enum W25Qxx_CHIP W25Qxx_CHIP;<\/code><\/pre>\n<p>\u041f\u0440\u0430\u0432\u0434\u0430, \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0442\u0435\u043c\u0430&#8230;<\/p>\n<p>\u0423 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0435\u0441\u0442\u044c \u0438 \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u0447\u0435\u0440\u0442\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435, \u0447\u0435\u043c \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445: \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0441\u0442\u0438\u0440\u0430\u043d\u0438\u0435 \u0441\u0435\u043a\u0442\u043e\u0440\u0430.<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 3 &#8212; \u043d\u0443 \u0441\u043e\u0432\u0441\u0435\u043c \u043a\u043e\u0440\u043e\u0442\u043a\u043e<\/summary>\n<div class=\"spoiler__content\">\n<p><a href=\"https:\/\/github.com\/zoosmand\/Winbond-W25Qxx-EEPROM-SPI-with-DMA-on-STM32\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/zoosmand\/Winbond-W25Qxx-EEPROM-SPI-with-DMA-on-STM32<\/a><\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u0443\u0436\u0430\u0441:<\/p>\n<ol>\n<li>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0440\u0442\u043e\u0432 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041c\u0430\u043a\u0440\u043e\u0441\u044b-\u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u0432\u043d\u044f\u0442\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<\/li>\n<li>\n<p>\u0422\u043e\u0440\u0447\u0430\u0449\u0438\u0435 \u043d\u0430\u0440\u0443\u0436\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b.<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/aeb\/914\/9a5\/aeb9149a5c01e210ea83eacc736b2116.jpg\" alt=\"\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0435 \u0447\u0443\u0432\u0441\u0442\u0432\u0430\" title=\"\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0435 \u0447\u0443\u0432\u0441\u0442\u0432\u0430\" width=\"1024\" height=\"482\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/aeb\/914\/9a5\/aeb9149a5c01e210ea83eacc736b2116.jpg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0435 \u0447\u0443\u0432\u0441\u0442\u0432\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0447\u0435\u0433\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c:<\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 API. \u041f\u043e \u0441\u0443\u0442\u0438 \u043d\u0443\u0436\u0435\u043d \u043d\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c\u044b, \u0430 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u043f\u0430\u043c\u044f\u0442\u0438 \u0441 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u043c (\u0438 \u0440\u044b\u0431\u043a\u0443 \u0441\u044a\u0435\u0441\u0442\u044c, \u0438 \u2026 \u043a\u043e\u0441\u0442\u044c\u044e \u043d\u0435 \u043f\u043e\u0434\u0430\u0432\u0438\u0442\u044c\u0441\u044f).<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043b\u0435\u0433\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438 \u0442\u0438\u043f\u0430 FatFs \u0438 usb msc. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<ol>\n<li>\n<p>\u0427\u0442\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u0438 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0435\u043a\u0442\u043e\u0440\u0430<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u043f\u0430\u043c\u044f\u0442\u0438 (\u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u043f\u0430\u043c\u044f\u0442\u0438) &#8212; \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u044b\u0448\u0435 \u0441\u0442\u043e\u044f\u0449\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0435, \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u043d\u043e.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043b\u0435\u0433\u043a\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u0445\u043e\u0436\u0438\u0445 \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u0447\u0442\u0438 \u0432\u043e \u0432\u0441\u0435\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u0445, \u043d\u043e \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a\u0438\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 RTOS: \u0441\u0435\u043c\u0430\u0444\u043e\u0440\u044b \u0438\u043b\u0438 \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0411\u0435\u0437 \u043d\u0430\u0441\u0438\u043b\u044c\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043d\u0430\u0434 \u043f\u0430\u043c\u044f\u0442\u044c\u044e.<\/p>\n<\/li>\n<li>\n<p>\u0411\u044b\u0441\u0442\u0440\u044b\u043c \u0447\u0442\u0435\u043d\u0438\u0435\u043c \u0438 \u0437\u0430\u043f\u0438\u0441\u044c\u044e. \u0411\u044b\u0441\u0442\u0440\u0435\u0435 \u0438 \u0435\u0449\u0451 \u0431\u044b\u0441\u0442\u0440\u0435\u0435.<\/p>\n<\/li>\n<\/ol>\n<h2>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044e<\/h2>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u0441\u0440\u0430\u0437\u0443 \u0432\u0435\u0441\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u0444\u0430\u0439\u043b. \u041e\u043d \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u043b\u0438\u0448\u043d\u0435\u0433\u043e \u0432\u0440\u043e\u0434\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u043a\u043e\u043c\u0430\u043d\u0434, \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u0438\u043b\u0438 \u0435\u0449\u0451 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u043c\u0443\u0441\u043e\u0440\u0430, \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e (\u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432\u0432\u0438\u0434\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442).<\/p>\n<details class=\"spoiler\">\n<summary>mem.h<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">\/**  ************************************************************************************************  * @file    mem.h  * @copyright Copyright (C) 2023  ************************************************************************************************  *\/ #pragma once  #include &lt;stddef.h> #include &lt;stdint.h>  \/* ---------------------------------------------------------------------------------------------------------*\/ typedef enum mem_status_t {     MEM_OK = 0, \/\/ 0: Successful     MEM_ERROR,  \/\/ 1: R\/W Error     MEM_WRPRT,  \/\/ 2: Write Protected     MEM_NOTRDY, \/\/ 3: Not Ready \/ Busy     MEM_PARERR  \/\/ 4: Invalid Parameter } mem_status_t;  typedef enum mem_ioctl_cmd_t {     MEM_IOCTL_CTRL_SYNC = 0, \/\/ Complete pending write process     MEM_IOCTL_PAGES_COUNT,   \/\/ Get page size     MEM_IOCTL_PAGE_SIZE,     \/\/ Get page size     MEM_IOCTL_SECTOR_SIZE,   \/\/ Get erase block size     MEM_IOCTL_BURN,          \/\/ Write chache to memory } mem_ioctl_cmd_t;  \/* ---------------------------------------------------------------------------------------------------------*\/  mem_status_t mem_init(); mem_status_t mem_status(); mem_status_t mem_read_page(uint8_t* buff, uint32_t page, size_t count); mem_status_t mem_write_page(uint8_t* buff, uint32_t page, size_t count); mem_status_t mem_ioctl(mem_ioctl_cmd_t cmd, void* data); mem_status_t mem_deinit();  \/* ---------------------------------------------------------------------------------------------------------*\/ <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0435\u0441\u0442\u044c, \u043f\u043e\u0440\u0430 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041d\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0442\u043e\u0438\u0442 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u0432\u0441\u0451 \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<p><strong>\u0412\u0430\u0436\u043d\u043e\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/strong> \u0414\u0430\u043d\u043d\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0442\u0430\u043a, \u0447\u0442\u043e,  \u0435\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0448\u044c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0431\u0430\u0439\u0442, \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u0441\u0435\u043a\u0442\u043e\u0440. \u041d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e, \u0434\u0430? \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0435\u0442. \u041e\u0434\u043d\u0430\u043a\u043e&#8230;<\/p>\n<p><strong>\u0421\u0442\u0438\u0440\u0430\u0442\u044c<\/strong> \u043c\u043e\u0436\u043d\u043e \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0441\u0435\u043a\u0442\u043e\u0440 (<strong>4 \u043a\u0438\u043b\u043e\u0431\u0430\u0439\u0442\u0430<\/strong>), <strong>\u043f\u0438\u0441\u0430\u0442\u044c<\/strong> &#8212; \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 (<strong>256<\/strong> <strong>\u0431\u0430\u0439\u0442<\/strong>). \u0427\u0438\u0442\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0433\u043e\u0434\u043d\u043e, \u043d\u043e \u043d\u0430\u043c \u044d\u0442\u043e \u0438 \u043d\u0435 \u0432\u0430\u0436\u043d\u043e.<\/p>\n<p>\u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u0435\u043d \u0431\u0443\u0444\u0435\u0440 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0441 \u0441\u0435\u043a\u0442\u043e\u0440.<\/p>\n<p>\u0422\u0438\u043f\u043e\u0432\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u044d\u0442\u043e \u0435\u0441\u0442\u044c \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432:<\/p>\n<ol>\n<li>\n<p>\u0427\u0438\u0442\u0430\u0435\u043c \u0432\u0435\u0441\u044c \u0441\u0435\u043a\u0442\u043e\u0440<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u0431\u0443\u0444\u0435\u0440<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0438\u0440\u0430\u0435\u043c \u0441\u0435\u043a\u0442\u043e\u0440<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0431\u0443\u0444\u0435\u0440 \u0432 \u0441\u0435\u043a\u0442\u043e\u0440.<\/p>\n<\/li>\n<\/ol>\n<p><em>\u0427\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043f\u043b\u043e\u0445\u043e?<\/em><\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440: \u0445\u043e\u0442\u0438\u043c \u043c\u044b \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c 10 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0438 \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u043d\u0435 \u0441\u0440\u0430\u0437\u0443, \u0430 \u043f\u043e \u043e\u0434\u043d\u043e\u0439, \u043d\u0435 \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u0434\u0440\u044f\u0434 \u0438\u043b\u0438 \u0432 \u0445\u0430\u043e\u0442\u0438\u0447\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043c\u044b 10 \u0440\u0430\u0437 \u0441\u043e\u0442\u0440\u0451\u043c \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0435\u043a\u0442\u043e\u0440. \u041d\u0435\u0441\u043b\u0430\u0431\u043e, \u0434\u0430? <\/p>\n<p><em>\u041a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043b\u0443\u0447\u0448\u0435?<\/em><\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446: 1 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u0442\u0438\u0440\u0430\u043d\u0438\u044f \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0437\u0430\u043f\u0438\u0441\u0438, \u0447\u0442\u043e \u0443\u0436\u0435 \u0443\u0441\u043a\u043e\u0440\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0438 \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442 \u0436\u0438\u0437\u043d\u044c \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c\u0435.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u041f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0435\u043a\u0442\u043e\u0440 \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043e\u043d \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f: \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0441 \u043e\u0434\u043d\u0438\u043c \u0441\u0435\u043a\u0442\u043e\u0440\u043e\u043c, \u043f\u0435\u0440\u0435\u0448\u043b\u0438 \u043a \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u0441\u0435\u043a\u0442\u043e\u0440\u043e\u043c, \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u043f\u0440\u043e\u0432\u0435\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0430\u0435\u0442 \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430 \u0441\u0447\u0435\u0442 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/edb\/10b\/17d\/edb10b17df8289ca90545a42a8d617c4.png\" alt=\"\u0411\u043b\u043e\u043a \u0441\u0445\u0435\u043c\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0435\u043c\" title=\"\u0411\u043b\u043e\u043a \u0441\u0445\u0435\u043c\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0435\u043c\" width=\"339\" height=\"312\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/edb\/10b\/17d\/edb10b17df8289ca90545a42a8d617c4.png\"\/><\/p>\n<div><figcaption>\u0411\u043b\u043e\u043a \u0441\u0445\u0435\u043c\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0435\u043c<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u0444\u043b\u0430\u0433 \u0431\u044b\u043b \u043b\u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d \u043a\u044d\u0448. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0432 \u0432\u0435\u0442\u043a\u0435 &#171;\u0414\u0410&#187; \u0431\u043b\u043e\u043a \u0441 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u043f\u043e\u0439\u0434\u0435\u0442 \u0447\u0435\u0440\u0435\u0437 \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0435.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/727\/a56\/88d\/727a5688dfb67d4d3202f5f194dd93b9.png\" alt=\"\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u0437\u0430\u043f\u0438\u0441\u0438. \u0422\u0435\u043f\u0435\u0440\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.\" title=\"\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u0437\u0430\u043f\u0438\u0441\u0438. \u0422\u0435\u043f\u0435\u0440\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.\" width=\"268\" height=\"196\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/727\/a56\/88d\/727a5688dfb67d4d3202f5f194dd93b9.png\"\/><\/p>\n<div><figcaption>\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u0437\u0430\u043f\u0438\u0441\u0438. \u0422\u0435\u043f\u0435\u0440\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u043e \u0438 \u0437\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u043c\u0438\u043d\u0443\u0441\u044b: \u0435\u0441\u043b\u0438 \u0432\u0441\u0451 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043e\u0434\u043d\u0438\u043c \u0438 \u0442\u0435\u043c \u0436\u0435 \u0441\u0435\u043a\u0442\u043e\u0440\u043e\u043c \u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u0435\u0433\u043e \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c, \u0442\u043e \u043f\u0440\u0438 \u043e\u0431\u0440\u044b\u0432\u0435 \u043f\u0438\u0442\u0430\u043d\u0438\u044f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0447\u0442\u043e \u043d\u0430\u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043b\u0438. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0433\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u043a\u044d\u0448\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c. \u041a\u0430\u043a \u0447\u0430\u0441\u0442\u043e &#8212; \u0425\u0417, \u044d\u0442\u043e \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441 \u043c\u0435\u0436\u0434\u0443 \u043d\u0430\u0441\u0438\u043b\u0438\u0435\u043c \u0438 \u0441\u0442\u0440\u0430\u0445\u043e\u043c \u043f\u043e\u0442\u0435\u0440\u0438.<\/p>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c69\/cad\/e28\/c69cade28f1d97b2b62ca74c674cfcab.png\" alt=\"\u0420\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438\" title=\"\u0420\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438\" width=\"642\" height=\"127\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c69\/cad\/e28\/c69cade28f1d97b2b62ca74c674cfcab.png\"\/><\/p>\n<div><figcaption>\u0420\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u0432 4..7 \u0438 0,1 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u0445 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0438 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u0435\u043a\u0442\u043e\u0440\u0430, \u0437\u0430\u0442\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0433\u043e, \u0430 \u043f\u043e \u043f\u0443\u0442\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044c \u0438 \u0435\u0449\u0451 \u043e\u0434\u043d\u0443 \u0443\u0436\u0435 \u043f\u043e\u0442\u043e\u043c. <\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d49\/0c4\/4bd\/d490c44bdb887dca2eac0bf903a1af68.png\" alt=\"\u0411\u043b\u043e\u043a \u0441\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u044d\u0448\u0430\" title=\"\u0411\u043b\u043e\u043a \u0441\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u044d\u0448\u0430\" width=\"231\" height=\"441\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d49\/0c4\/4bd\/d490c44bdb887dca2eac0bf903a1af68.png\"\/><\/p>\n<div><figcaption>\u0411\u043b\u043e\u043a \u0441\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u044d\u0448\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e\u0447\u0442\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b. \u0412\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u0438\u0445 \u043a\u043e\u0434.<\/p>\n<pre><code class=\"cpp\">mem_status_t mem_read_page(uint8_t* buff, uint32_t page, size_t count) {     mem_mux_take();     mem_status_t status = mem_operation(buff, page, count, false);     mem_mux_give();     return status; }  mem_status_t mem_write_page(uint8_t* buff, uint32_t page, size_t count) {     mem_mux_take();     mem_status_t status = mem_operation(buff, page, count, true);     mem_mux_give();     return status; }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 <code>mem_mux_take()<\/code> \u0438 <code>mem_mux_give()<\/code> \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u044e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438. \u0422\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u043d\u0435 \u0432\u0435\u0437\u0434\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u043b \u0438\u0445 \u043a\u0430\u043a <code>weak<\/code>, \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u043d\u0438 \u043f\u0443\u0441\u0442\u044b\u0435, \u0430 \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u043a\u043e\u0434\u0430 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u0438\u043b\u0435\u043d\u044b.<\/p>\n<pre><code class=\"cpp\">void __attribute__((weak)) mem_mux_create() {} void __attribute__((weak)) mem_mux_take() {} void __attribute__((weak)) mem_mux_give() {}<\/code><\/pre>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"cpp\">static mem_status_t mem_operation(uint8_t* buf, uint32_t page, size_t count, bool write) {     if (mem_is_init == 0) return MEM_ERROR;     if ((page + count) > (dev->flash_size \/ dev->page_size) || (buf == NULL)) return MEM_PARERR;        mem_status_t status = MEM_OK;      int32_t sectorn = page \/ dev->pages_in_sector; \/\/ number operating sector      for (size_t npage = 0; npage &lt; count &amp;&amp; status == MEM_OK;)     {         \/\/  if sector has changed         if (current_sector != sectorn) status = mem_update_cache(sectorn);          \/\/ page number in sector         uint32_t pn_in_sector = page &amp; (dev->pages_in_sector - 1);          \/\/ pages count for operation         uint32_t pagec_op = (count - npage);          pagec_op = (pn_in_sector + pagec_op) > dev->pages_in_sector \/\/                        ? (dev->pages_in_sector - pn_in_sector)      \/\/                        : pagec_op;          size_t cahce_n   = dev->page_size * pn_in_sector; \/\/ byte number of cahce         size_t buff_n    = dev->page_size * npage;        \/\/ byte number of buffer         size_t data_size = dev->page_size * pagec_op;     \/\/ bytes quantity for operation          if (write)         {             sector_modify = true;             memcpy(&amp;mem_cache[ cahce_n ], &amp;buf[ buff_n ], data_size);         }         else         {             memcpy(&amp;buf[ buff_n ], &amp;mem_cache[ cahce_n ], data_size); \/\/         }          \/\/ pages of next sector if nessary         page += pagec_op;         npage += pagec_op;         sectorn++;     }      return status; }<\/code><\/pre>\n<p>\u0417\u0430\u043e\u0434\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438 \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u044d\u0448\u0435\u043c. \u042d\u0442\u043e \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0431\u0443\u0444\u0435\u0440 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u0434\u0435.<\/p>\n<pre><code class=\"cpp\">static volatile int32_t current_sector = -1; static volatile bool sector_modify     = false; static uint8_t mem_cache[ 1024 * 4 ]   = {0};<\/code><\/pre>\n<pre><code class=\"cpp\">static mem_status_t mem_update_cache(int32_t sector) {     mem_status_t status = MEM_OK;      if (sector_modify &amp;&amp; (current_sector != -1))     {         status = mem_erase_sector(current_sector * dev->sector_size);          for (size_t i = 0; i &lt; dev->pages_in_sector &amp;&amp; status == MEM_OK; i++)         {             uint32_t page_offset = i * dev->page_size;             if (mem_write_data((current_sector * dev->sector_size) + page_offset, \/\/ address                                mem_cache + page_offset,                           \/\/ data                                dev->page_size) != MEM_OK)             {                 status = MEM_ERROR;                 break;             }         }         sector_modify = false;     }      if (status == MEM_OK &amp;&amp; (current_sector != sector))     {         current_sector = sector;          status = mem_read_data(sector * dev->sector_size, mem_cache, dev->sector_size);     }     return status; }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 (\u0447\u0442\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u043f\u0438\u0441\u044c) \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b \u0438 \u043f\u043e\u0447\u0442\u0438 \u043a\u0430\u043a \u0443 \u0432\u0441\u0435\u0445. <\/p>\n<p>\u0410\u0434\u0440\u0435\u0441 \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u0438\u043f\u0438\u0447\u043d\u043e\u0439 \u0434\u043b\u044f ARM \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439 <a href=\"https:\/\/developer.arm.com\/documentation\/dui0473\/m\/arm-and-thumb-instructions\/rev\" rel=\"noopener noreferrer nofollow\">REV<\/a>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 4 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0430\u0434\u0440\u0435\u0441\u0430 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e \u0431\u0430\u0439\u0442\u0430\u043c \u0432 \u043d\u0443\u0436\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0438\u043b\u0438 \u0446\u0435\u043f\u043e\u0447\u043a\u043e\u0439 \u0441\u0434\u0432\u0438\u0433\u043e\u0432 \u0438 \u0434\u0438\u0437\u044a\u044e\u043d\u043a\u0446\u0438\u0439.<\/p>\n<pre><code class=\"cpp\">static mem_status_t mem_read_data(uint32_t addr, uint8_t* data, size_t len) {     if (addr > dev->flash_size || data == NULL) { return MEM_PARERR; }      mem_status_t status = MEM_OK;      spi_cs_activate();     {         uint32_t cmd = __REV(addr) | MEM_CMD_READ_DATA;         if (spi_tx(&amp;cmd, sizeof(cmd)) != SPI_OK || \/\/ send address             spi_rx(data, len) != SPI_OK)           \/\/ read data         {             status = MEM_ERROR;         }     }     spi_cs_deactivate();      return status; }  static mem_status_t mem_write_data(uint32_t addr, uint8_t* data, size_t len) {     if (addr > dev->flash_size || data == NULL || len > 256) { return MEM_PARERR; }     \/\/ needed before write     mem_status_t status = mem_send_cmd(MEM_CMD_WRITE_EN);      spi_cs_activate();     {         uint32_t cmd = __REV(addr) | MEM_CMD_WRITE_PAGE;         if (status != MEM_OK ||                    \/\/ write enable             spi_tx(&amp;cmd, sizeof(cmd)) != SPI_OK || \/\/ send address             spi_tx(data, len) != SPI_OK)           \/\/ write data         {             status = MEM_ERROR;         }     }     spi_cs_deactivate();      status = mem_wait_rdy(dev->timeout);      return status; }<\/code><\/pre>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c.<\/h3>\n<p>\u041d\u0443\u0436\u043d\u043e \u043b\u0438\u0448\u044c \u0432\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438:<\/p>\n<pre><code class=\"cpp\">static const mem_dev_t dev_table[] = {     \/\/ ZD25Q64B     {         .manufact_id = 0xBA,         .device_id   = 0x16,         .capacity_id = 0x17,         .memory_id   = 0x32,         \/\/         .flash_size      = 0x800000,         .page_size       = 0x100,         .sector_size     = 0x1000,         .pages_in_sector = 16,         .timeout         = 100,     }, };<\/code><\/pre>\n<p>\u0422\u0438\u043f \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d \u0432 \u0442\u043e\u043c \u0436\u0435 \u0444\u0430\u0439\u043b\u0435 <em>&#171;mem.c&#187;<\/em>, \u0447\u0442\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u0432\u043e \u0432\u043d\u0435\u0448\u043d\u044e\u044e \u0441\u0440\u0435\u0434\u0443.<\/p>\n<pre><code class=\"cpp\">typedef struct mem_dev_t {     uint8_t manufact_id; \/\/ Manufacturer ID     uint8_t device_id;   \/\/ Device ID     uint8_t capacity_id; \/\/ Capacity ID     uint8_t memory_id;   \/\/ Memory ID     \/\/     uint32_t flash_size;      \/\/ Total size, bytes     uint16_t page_size;       \/\/ Min program size, bytes     uint16_t sector_size;     \/\/ Min erase size, bytes     uint16_t pages_in_sector; \/\/ Pages quantity in sector, pieces     uint16_t timeout;         \/\/ Operation timeout, ms } mem_dev_t;<\/code><\/pre>\n<h2>\u0410 \u0447\u0442\u043e \u043d\u0430 \u0441\u0447\u0435\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0438 \u0432\u0441\u0435\u0433\u043e \u0442\u0430\u043a\u043e\u0433\u043e?<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0440\u0438\u0441\u0443\u043d\u043a\u0430 \u0432\u044b\u0448\u0435, \u0433\u0434\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<ul>\n<li>\n<p>2 \u0441\u0435\u043a\u0442\u043e\u0440\u0430<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0435\u043a\u0442\u043e\u0440\u0435 \u043f\u043e 8 \u0441\u0442\u0440\u0430\u043d\u0438\u0446<\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 4 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u0435\u043a\u0442\u043e\u0440\u0430, \u0430 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 1 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u0435\u043a\u0442\u043e\u0440\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u043c, \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e 6 (4 \u0432 \u043f\u0435\u0440\u0432\u043e\u043c + 2 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c).<\/p>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 1. \u041f\u043e \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0437\u0430 \u0440\u0430\u0437.<\/h3>\n<p>\u041d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432\u044b\u0445\u043e\u0434\u0438\u0442 8 \u0446\u0438\u043a\u043b\u043e\u0432 \u0437\u0430\u043f\u0438\u0441\u0438 (w) \u0438 1 \u0446\u0438\u043a\u043b \u0441\u0442\u0438\u0440\u0430\u043d\u0438\u044f (e), \u0446\u0438\u043a\u043b\u044b \u0447\u0442\u0435\u043d\u0438\u044f(r) \u043f\u043e\u0447\u0442\u0438 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b, \u043d\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0442\u043e\u0436\u0435 &#8212; 8. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0438\u043c\u0435\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"x = 8r + 8w + 1e\" alt=\"x = 8r + 8w + 1e\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0e7\/61a\/7e1\/0e761a7e17cc7d5397b8035ac2fc1cf4.svg\" width=\"144\" height=\"17\"\/><\/p>\n<p>\u0418\u0442\u043e\u0433\u043e \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u044d\u0448\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0432\u043d\u043e\u0435 <strong>6x<\/strong> (\u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446), \u0441 \u043a\u044d\u0448\u0435\u043c &#8212; <strong>2x <\/strong>(\u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0435\u043a\u0442\u043e\u0440\u043e\u0432)<strong>. <\/strong><\/p>\n<p>\u041d\u0435\u043f\u043b\u043e\u0445\u043e, \u0434\u0430?<\/p>\n<p>\u041c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e, \u0443\u043b\u0443\u0447\u0448\u0438\u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0431\u0435\u0437 \u043a\u044d\u0448\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u0431\u043b\u043e\u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u043a\u0442\u043e\u0440\u0430, \u043c\u044b \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u043c\u0441\u044f \u043a \u0442\u0435\u043c \u0436\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u0430\u043c, \u0447\u0442\u043e \u0438 \u0441 \u043a\u044d\u0448\u0435\u043c &#8212; <strong>2x<\/strong>. \u041c\u043e\u0436\u043d\u043e, \u043e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u043b\u0438\u0448\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. <\/p>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 2. \u0412\u043d\u0443\u0442\u0440\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0435\u043a\u0442\u043e\u0440\u0430.<\/h3>\n<p>\u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0301\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u0431\u0435\u0437 \u043a\u044d\u0448\u0430 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0432\u043d\u044b <strong>Nx<\/strong>, c \u043a\u044d\u0448\u0435\u043c &#8212; <strong>1x<\/strong>.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/255\/930\/507\/255930507224163363fae82abd4cea92.png\" alt=\"\u041e\u0436\u0438\u0434\u0430\u044e \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442 \u043f\u0430\u043c\u044f\u0442\u0438 \u0431\u0435\u0437 \u043a\u044d\u0448\u0430.\" title=\"\u041e\u0436\u0438\u0434\u0430\u044e \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442 \u043f\u0430\u043c\u044f\u0442\u0438 \u0431\u0435\u0437 \u043a\u044d\u0448\u0430.\" width=\"720\" height=\"405\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/255\/930\/507\/255930507224163363fae82abd4cea92.png\"\/><\/p>\n<div><figcaption>\u041e\u0436\u0438\u0434\u0430\u044e \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442 \u043f\u0430\u043c\u044f\u0442\u0438 \u0431\u0435\u0437 \u043a\u044d\u0448\u0430.<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u0445\u0443\u0434\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u043f\u0438\u0448\u0435\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0432 \u043d\u043e\u0432\u044b\u0439 \u0441\u0435\u043a\u0442\u043e\u0440, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u043e \u0437\u0430\u0442\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c\u043e\u043c\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u0435\u043d \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 \u0431\u0435\u0437 \u043a\u044d\u0448\u0430. \u0422\u0430\u043a \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u0435\u0433\u043e \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437 \u0443\u0436\u0435 \u0432\u044b\u0434\u0435\u043b\u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0431\u0443\u0444\u0435\u0440 \u043f\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c\u0435?<\/p>\n<h3>\u041d\u0435\u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/h3>\n<p>\u0412\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0437\u0430\u043c\u0435\u0442\u0438\u043b, \u0447\u0442\u043e \u0443\u043f\u043e\u0440 \u0441\u0434\u0435\u043b\u0430\u043d \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043b\u043e \u0435\u0449\u0451 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u043e\u0434\u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0438\u0437 \u0441\u0435\u043a\u0442\u043e\u0440\u0430, \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0447\u0438\u0442\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u0441\u0435\u043a\u0442\u043e\u0440 \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u0447\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e.<\/p>\n<p>\u042d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0430\u043a. \u041f\u0440\u0438\u0437\u043d\u0430\u044e\u0441\u044c, \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u043e, \u043f\u0440\u0438\u0448\u043b\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0431\u043e\u0440\u0430 \u044d\u0442\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430.<\/p>\n<p>\u0415\u0441\u0442\u044c \u043a\u0443\u0434\u0430 \u0440\u0430\u0441\u0442\u0438.<\/p>\n<h2>\u0412\u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u043e\u0432<\/h2>\n<ol>\n<li>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 API \u043f\u0440\u043e\u0441\u0442 \u0438 \u043f\u043e\u043d\u044f\u0442\u0435\u043d \u0434\u0430\u0436\u0435 \u0431\u0435\u0437 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 (\u043c\u043e\u0451 \u043b\u0438\u0447\u043d\u043e\u0435 \u043c\u043d\u0435\u043d\u0438\u0435)<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437 \u043c\u043e\u0434\u0443\u043b\u044f \u043d\u0430\u0440\u0443\u0436\u0443 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0442\u043e\u0440\u0447\u0438\u0442 (\u043c\u0430\u043a\u0440\u043e\u0441\u044b, \u0442\u0438\u043f\u044b, \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438)<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d \u0440\u0435\u0441\u0443\u0440\u0441 \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c\u044b \u043f\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0443 (\u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u0433\u043e\u0432\u043e\u0440\u043a\u0430\u043c\u0438)<\/p>\n<\/li>\n<li>\n<p>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0430 \u0434\u043e \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e\u0433\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430.<\/p>\n<p>\u041d\u043e \u0435\u0441\u0442\u044c \u043d\u044e\u0430\u043d\u0441 ?: \u043f\u0440\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 \u043a\u043e\u043c\u0430\u043d\u0434 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438, \u0441\u0442\u0438\u0440\u0430\u043d\u0438\u0439 \u0438 \u0441\u0430\u043c\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u0434\u043d\u044f\u0442\u0438\u044f \u0447\u0438\u043f \u0441\u0435\u043b\u0435\u043a\u0442\u0430 (CS) \u043f\u043e\u0434\u043e\u0436\u0434\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u0435\u0440\u0435\u0434 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439, \u0442\u0430\u043a\u043e\u0439 \u043a\u0430\u043a \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0437\u0430\u043d\u044f\u0442\u043e\u0441\u0442\u0438. \u041f\u043e\u043a\u0430 \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>HAL_Delay<\/code>. \u0417\u043d\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u0443\u043f\u043e, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0440\u0430\u0432\u043d\u043e\u0439 18 \u043c\u0435\u0433\u0430\u0431\u0438\u0442\u0430\u043c, \u043d\u043e \u043f\u043e\u043a\u0430 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e. <\/p>\n<p>\u0425\u043e\u0442\u044f \u0431\u044b\u043b\u0430 \u043c\u044b\u0441\u043b\u044c \u0431\u0435\u0437 \u043f\u0440\u0438\u0436\u0430\u0442\u043e\u0433\u043e CS \u0432\u0445\u043e\u043b\u043e\u0441\u0442\u0443\u044e \u043f\u0440\u043e\u0433\u043d\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0439\u0442\u043e\u0432 \u043f\u043e \u0448\u0438\u043d\u0435 SPI, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443, \u043d\u043e \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u043d\u0435 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043f\u043e\u0441\u044b\u043b\u043a\u0443.<\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043a\u0442\u043e-\u0442\u043e \u043f\u043e\u0434\u0441\u043a\u0430\u0436\u0435\u0442 \u043a\u0430\u043a \u043e\u0431\u043e\u0439\u0442\u0438 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443.<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u0434 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0442\u0438\u043f\u0430 HAL \u0438 \u0442\u043e\u043c\u0443 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445. \u0417\u0430 \u043e\u0434\u043d\u0438\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c: \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u043d\u0430\u0447\u0435, \u0445\u043e\u0447\u0443 \u0432 \u044d\u0442\u043e \u0432\u0435\u0440\u0438\u0442\u044c.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u043d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0451, \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0441\u044f \u043a \u043a\u0440\u0438\u0442\u0438\u043a\u0435 \u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c.<\/p>\n<p>\u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0437\u0434\u0435\u0441\u044c <a href=\"https:\/\/gitlab.com\/devprodest\/m25q64_mem_mng\" rel=\"noopener noreferrer nofollow\">https:\/\/gitlab.com\/devprodest\/m25q64_mem_mng<\/a><\/p>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0442\u0438\u043b\u0438\u0441\u0442\u0438\u043a\u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437, \u0435\u0441\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0435 \u043c\u043d\u0435\u043d\u0438\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u0447\u0443\u0432\u0430\u043a\u0430 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0432\u0430\u0448\u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u043e\u0432.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><\/p>\n<div class=\"tm-article-poll-container\"><!--[--><\/p>\n<div class=\"tm-article-poll tm-article-poll_variant-bordered\">\n<div class=\"tm-notice tm-notice_positive tm-article-poll__notice\"><!----><\/p>\n<div class=\"tm-notice__inner\"><!----><\/p>\n<div class=\"tm-notice__content\" data-test-id=\"notice-content\"><!--[--><span>\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a rel=\"nofollow\" href=\"\/kek\/v1\/auth\/habrahabr\/?back=\/ru\/articles\/730232\/&#038;hl=ru\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/span><!--]--><\/div>\n<\/div>\n<\/div>\n<p><!--[--><\/p>\n<div class=\"tm-article-poll__header\">\u041f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u043c\u044b\u0441\u043b\u0438 \u043f\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u043e-\u0441\u0442\u0438\u043b\u0435\u0432\u043e\u043c\u0443 \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u044e \u0441\u0438\u0448\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430?<\/div>\n<div class=\"tm-article-poll__answers\"><!--[--><\/p>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent tm-article-poll__answer-percent_winning\">82.69% <\/span><span class=\"tm-article-poll__answer-label\">\u041f\u0438\u0448\u0438<\/span><span class=\"tm-article-poll__answer-votes\">43<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress tm-article-poll__answer-progress_winning\" style=\"width: 82.69%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">17.31% <\/span><span class=\"tm-article-poll__answer-label\">\u041d\u0435\u0442, \u043f\u043e\u043b\u043d\u043e \u0443\u0436\u0435 \u0442\u0430\u043a\u0438\u0445<\/span><span class=\"tm-article-poll__answer-votes\">9<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 17.31%\"><\/div>\n<\/div>\n<\/div>\n<p><!--]--><\/div>\n<div class=\"tm-article-poll__stats\"> \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 52 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.    \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u043b\u0438\u0441\u044c 7 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. <\/div>\n<p><!--]--><\/div>\n<p><!--]--><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/730232\/\"> https:\/\/habr.com\/ru\/articles\/730232\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u043b \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u043a\u0443\u0447\u0443 \u043f\u0440\u043e\u0441\u0442\u044b\u0445, \u0438 \u0434\u0430\u0436\u0435 \u043e\u0447\u0435\u043d\u044c, \u0441\u0442\u0430\u0442\u0435\u0435\u043a \u043d\u0430 \u0442\u0435\u043c\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432, \u0442\u043e\u0436\u0435 \u0440\u0435\u0448\u0438\u043b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435, \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0435, \u043d\u043e \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435.<\/p>\n<p>\u0414\u0430 \u043f\u0440\u043e\u0441\u0442\u044f\u0442 \u043c\u0435\u043d\u044f \u0431\u044b\u0432\u0430\u043b\u044b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0437\u0430 \u0441\u0435\u0439 \u0442\u0440\u0443\u0434, \u0434\u0430 \u0438 \u0445\u0435\u0439\u0442\u0435\u0440\u044b \u043f\u0443\u0441\u0442\u044c \u043f\u0440\u043e\u0449\u0430\u044e\u0442 \u0442\u043e\u0436\u0435?<\/p>\n<h2>\u041e\u00a0\u0447\u0451\u043c \u043f\u043e\u0439\u0434\u0435\u0442 \u0440\u0435\u0447\u044c<\/h2>\n<p>\u0411\u0443\u0434\u0435\u043c \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u044f\u0442\u044c \u0438 \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0444\u043b\u0435\u0448\u043a\u0438 \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0435\u0451 \u0440\u0435\u0441\u0443\u0440\u0441 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044f\u0445.<\/p>\n<h2>\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f \u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439<\/h2>\n<p>\u041f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u0430\u0441\u044c SPI \u0444\u043b\u044d\u0448\u043a\u0430 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u043e\u0435 \u041f\u041e \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. \u0422\u0438\u043f\u043e\u0432\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043c\u0435\u0441\u0442\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0447\u0438\u043f\u0430.<\/p>\n<p>\u041e\u0431\u044a\u0435\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0443\u0436\u0435\u043d \u0431\u044b\u043b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u043d\u043e \u043f\u0440\u0438\u043b\u0438\u0447\u043d\u044b\u0439, \u0447\u0442\u043e-\u0442\u043e \u0432  \u0440\u0430\u0439\u043e\u043d\u0435 8 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442.<\/p>\n<p>\u041a\u0430\u043a \u0438 \u0432\u0441\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b, \u0432\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u0438\u044f \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u0430, \u043f\u043e\u043b\u0435\u0437 \u0438\u0441\u043a\u0430\u0442\u044c \u0432 \u0441\u0435\u0442\u0438 (github, gitlab) \u0432 \u0438\u0442\u043e\u0433\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0440\u0438\u0433\u043b\u044f\u043d\u0443\u043b\u043e\u0441\u044c.<\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432:<\/p>\n<ol>\n<li>\n<p>\u0412\u0441\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0447\u0442\u0435\u043d\u0438\u044f \u043f\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c \u0438 \u0441\u0435\u043a\u0442\u043e\u0440\u0430\u043c. <\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0430\u0437\u0431\u0440\u043e\u0441\u0430\u043d \u043d\u0430 \u0434\u0432\u0430 \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u0435\u043a\u0442\u043e\u0440\u043e\u0432, \u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0434\u0430\u0436\u0435 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u0441\u0435\u043a\u0442\u043e\u0440\u0435 \u043f\u0440\u043e\u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0440\u0438\u0432\u0430\u044f \u043f\u043e \u0442\u0435\u043c \u0438\u043b\u0438 \u0438\u043d\u044b\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u043b\u043e\u0431. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0435\u0449\u0451 \u0441\u0432\u043e\u044e \u043e\u0431\u0435\u0440\u0442\u043a\u0443 \u043f\u0438\u0441\u0430\u0442\u044c \u0441 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043b\u043e\u0445\u043e\u0439 \u0441\u0442\u0438\u043b\u044c\/\u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430:<\/p>\n<ol>\n<li>\n<p>extern \u0432\u0435\u0437\u0434\u0435, \u0433\u0434\u0435 \u043d\u0443\u0436\u043d\u043e \u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e<\/p>\n<\/li>\n<li>\n<p>\u041a\u0443\u0447\u0430 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432, \u0433\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0431\u0435\u0437 \u043d\u0438\u0445, \u0435\u0449\u0451 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u00f3\u043b\u044c\u0448\u0438\u0439 \u043f\u0440\u043e\u0444\u0438\u0442.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0440\u0443\u0436\u0443 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u043e\u0434\u0443\u043b\u044f, \u2014 \u0442\u043e\u0440\u0447\u0430\u0449\u0438\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0438 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u0444\u0430\u0439\u043b\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 1 &#8212; \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0438 \u043a\u0440\u0438\u0442\u0438\u043a\u043e\u0439<\/summary>\n<div class=\"spoiler__content\">\n<p><a href=\"https:\/\/github.com\/nimaltd\/w25qxx\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/nimaltd\/w25qxx<\/a><\/p>\n<pre><code class=\"cpp\">\/\/... extern w25qxx_t w25qxx;  bool W25qxx_Init(void);  void W25qxx_EraseChip(void); void W25qxx_EraseSector(uint32_t SectorAddr); void W25qxx_EraseBlock(uint32_t BlockAddr);  uint32_t W25qxx_PageToSector(uint32_t PageAddress); uint32_t W25qxx_PageToBlock(uint32_t PageAddress); uint32_t W25qxx_SectorToBlock(uint32_t SectorAddress); uint32_t W25qxx_SectorToPage(uint32_t SectorAddress); uint32_t W25qxx_BlockToPage(uint32_t BlockAddress);  bool W25qxx_IsEmptyPage(uint32_t Page_Address, uint32_t OffsetInByte, uint32_t NumByteToCheck_up_to_PageSize); bool W25qxx_IsEmptySector(uint32_t Sector_Address, uint32_t OffsetInByte, uint32_t NumByteToCheck_up_to_SectorSize); bool W25qxx_IsEmptyBlock(uint32_t Block_Address, uint32_t OffsetInByte, uint32_t NumByteToCheck_up_to_BlockSize);  void W25qxx_WriteByte(uint8_t pBuffer, uint32_t Bytes_Address); void W25qxx_WritePage(uint8_t *pBuffer, uint32_t Page_Address, uint32_t OffsetInByte, uint32_t NumByteToWrite_up_to_PageSize); void W25qxx_WriteSector(uint8_t *pBuffer, uint32_t Sector_Address, uint32_t OffsetInByte, uint32_t NumByteToWrite_up_to_SectorSize); void W25qxx_WriteBlock(uint8_t *pBuffer, uint32_t Block_Address, uint32_t OffsetInByte, uint32_t NumByteToWrite_up_to_BlockSize);  void W25qxx_ReadByte(uint8_t *pBuffer, uint32_t Bytes_Address); void W25qxx_ReadBytes(uint8_t *pBuffer, uint32_t ReadAddr, uint32_t NumByteToRead); void W25qxx_ReadPage(uint8_t *pBuffer, uint32_t Page_Address, uint32_t OffsetInByte, uint32_t NumByteToRead_up_to_PageSize); void W25qxx_ReadSector(uint8_t *pBuffer, uint32_t Sector_Address, uint32_t OffsetInByte, uint32_t NumByteToRead_up_to_SectorSize); void W25qxx_ReadBlock(uint8_t *pBuffer, uint32_t Block_Address, uint32_t OffsetInByte, uint32_t NumByteToRead_up_to_BlockSize);<\/code><\/pre>\n<p>\u041a\u0443\u0447\u0430 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0432 \u0442\u0443\u043f\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d datasheet. \u0418\u0437 \u0432\u0441\u0435\u0433\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043b\u0438\u0448\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445. \u041d\u043e \u0442\u0435\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u044b \u043d\u0435\u0442.<\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0447\u0435\u043d\u044c \u0434\u043b\u0438\u043d\u043d\u044b\u0439 \u043a\u0443\u0441\u043e\u043a \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0443\u0436\u0435 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b, \u043d\u043e \u043e\u043d \u0432\u0441\u0451 \u0435\u0449\u0451 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0439.<\/p>\n<pre><code class=\"cpp\">switch (id &amp; 0x000000FF) { case 0x20: \/\/ w25q512     w25qxx.ID = W25Q512;     w25qxx.BlockCount = 1024;     break; case 0x19: \/\/ w25q256     w25qxx.ID = W25Q256;     w25qxx.BlockCount = 512;     break; case 0x18: \/\/ w25q128     w25qxx.ID = W25Q128;     w25qxx.BlockCount = 256;     break; case 0x17: \/\/w25q64     w25qxx.ID = W25Q64;     w25qxx.BlockCount = 128;     break; case 0x16: \/\/w25q32     w25qxx.ID = W25Q32;     w25qxx.BlockCount = 64;     break; case 0x15: \/\/w25q16     w25qxx.ID = W25Q16;     w25qxx.BlockCount = 32;     break; case 0x14: \/\/w25q80     w25qxx.ID = W25Q80;     w25qxx.BlockCount = 16;     break; case 0x13: \/\/w25q40     w25qxx.ID = W25Q40;     w25qxx.BlockCount = 8;     break; case 0x12: \/\/w25q20     w25qxx.ID = W25Q20;     w25qxx.BlockCount = 4;     break; case 0x11: \/\/w25q10     w25qxx.ID = W25Q10;     w25qxx.BlockCount = 2;     break; default:     w25qxx.Lock = 0;     return false; }  w25qxx.PageSize = 256; w25qxx.SectorSize = 0x1000; w25qxx.SectorCount = w25qxx.BlockCount * 16; w25qxx.PageCount = (w25qxx.SectorCount * w25qxx.SectorSize) \/ w25qxx.PageSize; w25qxx.BlockSize = w25qxx.SectorSize * 16; w25qxx.CapacityInKiloByte = (w25qxx.SectorCount * w25qxx.SectorSize) \/ 1024;<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043b\u0438 \u0443\u0431\u0440\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u0432 \u0436\u0438\u0437\u043d\u0438 \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0443\u0442 \u0432 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u043b\u0438\u0441\u0442\u0430\u0442\u044c \u0434\u043e 170 \u0441\u0442\u0440\u043e\u043a\u0438, \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0432\u0435\u0442\u0432\u0438 switch, \u0430 \u043f\u043e\u0442\u043e\u043c \u043d\u0435 \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0439 \u043a\u043e\u0434.<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 2 &#8212; \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043b\u043e\u044f\u043b\u044c\u043d\u0430\u044f \u043a\u0440\u0438\u0442\u0438\u043a\u0430, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0442\u043e\u0447\u043d\u043e<\/summary>\n<div class=\"spoiler__content\">\n<p><a href=\"https:\/\/github.com\/iammingge\/Driver_W25Qxx\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/iammingge\/Driver_W25Qxx<\/a><\/p>\n<p>\u0422\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 API. \u041d\u043e \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. \u0414\u0430 \u0438 \u0442\u043e \u043d\u0435 \u0441\u0430\u043c\u044b\u043c \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">\/\/.. \u044d\u0442\u043e 250 \u0441\u0442\u0440\u043e\u043a\u0430 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043a\u0443\u0447\u0430 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432. uint16_t W25Qxx_ID_Manufacturer(void); uint32_t W25Qxx_ID_JEDEC(void); uint64_t W25Qxx_ID_Unique(void);  void W25Qxx_Reset(void); void W25Qxx_PowerEnable(void); void W25Qxx_PowerDisable(void); void W25Qxx_VolatileSR_WriteEnable(void); void W25Qxx_WriteEnable(void); void W25Qxx_WriteDisable(void); void W25Qxx_4ByteMode(void); void W25Qxx_3ByteMode(void); void W25Qxx_Suspend(void); void W25Qxx_Resume(void);  void W25Qxx_ReadExtendedRegister(void); void W25Qxx_WriteExtendedRegister(uint8_t ExtendedAddr);  void W25Qxx_ReadStatusRegister(uint8_t Select_SR_1_2_3); void W25Qxx_WriteStatusRegister(uint8_t Select_SR_1_2_3, uint8_t Data); void W25Qxx_VolatileSR_WriteStatusRegister(uint8_t Select_SR_1_2_3, uint8_t Data); uint8_t W25Qxx_RBit_WEL(void); uint8_t W25Qxx_RBit_BUSY(void); uint8_t W25Qxx_RBit_SUS(void); uint8_t W25Qxx_RBit_ADS(void); void W25Qxx_WBit_SRP(W25Qxx_SRM srm, uint8_t bit); void W25Qxx_WBit_TB(W25Qxx_SRM srm, uint8_t bit); void W25Qxx_WBit_CMP(W25Qxx_SRM srm, uint8_t bit); void W25Qxx_WBit_QE(W25Qxx_SRM srm, uint8_t bit); void W25Qxx_WBit_SRL(W25Qxx_SRM srm, uint8_t bit); void W25Qxx_WBit_WPS(W25Qxx_SRM srm, uint8_t bit); void W25Qxx_WBit_DRV(W25Qxx_SRM srm, uint8_t bit); void W25Qxx_WBit_BP(W25Qxx_SRM srm, uint8_t bit); void W25Qxx_WBit_LB(W25Qxx_SRM srm, uint8_t bit); void W25Qxx_WBit_ADP(uint8_t bit); uint8_t W25Qxx_ReadStatus(void);  void W25Qxx_isStatus(uint8_t Select_Status, uint32_t timeout, W25Qxx_ERR *err);  void W25Qxx_Global_UnLock(W25Qxx_ERR *err); void W25Qxx_Global_Locked(W25Qxx_ERR *err); void W25Qxx_Individual_UnLock(uint32_t ByteAddr, W25Qxx_ERR *err); void W25Qxx_Individual_Locked(uint32_t ByteAddr, W25Qxx_ERR *err);  void W25Qxx_Erase_Chip(W25Qxx_ERR *err); void W25Qxx_Erase_Block64(uint32_t Block64Addr, W25Qxx_ERR *err); void W25Qxx_Erase_Block32(uint32_t Block32Addr, W25Qxx_ERR *err); void W25Qxx_Erase_Sector(uint32_t SectorAddr, W25Qxx_ERR *err); void W25Qxx_Erase_Security(uint32_t SectorAddr, W25Qxx_ERR *err); void W25Qxx_Read(uint8_t *pBuffer, uint32_t ByteAddr, uint16_t NumByteToRead, W25Qxx_ERR *err); void W25Qxx_Read_Security(uint8_t *pBuffer, uint32_t ByteAddr, uint16_t NumByteToRead, W25Qxx_ERR *err); void W25Qxx_Read_SFDP(uint8_t *pBuffer, uint32_t ByteAddr, uint16_t NumByteToRead, W25Qxx_ERR *err); void W25Qxx_DIR_Program_Page(uint8_t *pBuffer, uint32_t ByteAddr, uint16_t NumByteToWrite, W25Qxx_ERR *err); void W25Qxx_DIR_Program(uint8_t *pBuffer, uint32_t ByteAddr, uint32_t NumByteToWrite, W25Qxx_ERR *err); void W25Qxx_DIR_Program_Security(uint8_t *pBuffer, uint32_t ByteAddr, uint16_t NumByteToWrite, W25Qxx_ERR *err); void W25Qxx_Program(uint8_t *pBuffer, uint32_t ByteAddr, uint32_t NumByteToWrite, W25Qxx_ERR *err); void W25Qxx_Program_Security(uint8_t *pBuffer, uint32_t ByteAddr, uint16_t NumByteToWrite, W25Qxx_ERR *err);  W25QXX_EXT W25Qxx_t W25Qxx; void W25Qxx_QueryChip(W25Qxx_ERR *err); void W25Qxx_config(W25Qxx_ERR *err); void W25Qxx_SusResum_Erase_Sector(uint32_t SectorAddr, W25Qxx_ERR *err);<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e \u0441\u0442\u0438\u043b\u0438\u0441\u0442\u0438\u043a\u0435.<\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u0443\u0441\u043e\u0447\u0435\u043a \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435.<\/p>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c\u0430. \u041e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u0435, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043e\u043d\u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u043c\u0430\u043a\u0440\u043e\u0441\u0430\u043c\u0438, \u0430 \u043d\u0435 \u0432 \u0432\u0438\u0434\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0417\u0430\u0447\u0435\u043c \u0437\u0434\u0435\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0441\u0430\u043c\u043e\u0439 \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c\u0435, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0438\u0433\u0434\u0435 \u0432 \u044d\u0442\u043e\u043c API \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f, \u0430 \u043d\u0443\u0436\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439?<\/p>\n<blockquote>\n<p>\u0422\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0442\u0430\u043a \u043c\u0430\u043b\u043e \u043e\u0442\u0432\u0435\u0442\u043e\u0432&#8230;<\/p>\n<\/blockquote>\n<pre><code class=\"cpp\">#define W25Q_CMD_WEN              0x06 #define W25Q_CMD_VOLATILESREN         0x50 #define W25Q_CMD_WDEN             0x04  #define W25Q_CMD_POWEREN            0xAB #define W25Q_CMD_MANUFACTURER 0x90 #define W25Q_CMD_JEDECID          0x9F  #define W25Q_CMD_UNIQUEID             0x4B  #define W25Q_CMD_READ            0x03 #define W25Q_CMD_4BREAD               0x13 #define W25Q_CMD_FASTREAD             0x0B #define W25Q_CMD_4BFASTREAD           0x0C  \/**  * @brief W25Qxx SIZE  *\/ #define W25Qxx_PAGESIZE  0x00100 #define W25Qxx_PAGEPOWER 0x08 #define W25Qxx_SECTORSIZE  0x01000 #define W25Qxx_SECTORPOWER 0x0C #define W25Qxx_BLOCKSIZE  0x10000 #define W25Qxx_BLOCKPOWER 0x10 #define W25Qxx_SECTURITYSIZE 0x00300<\/code><\/pre>\n<p>\u041e\u0442 \u0441\u0435\u0431\u044f \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0432\u0441\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u0435\u043b\u0430\u044e\u0442\u0441\u044f \u0442\u0438\u043f\u044b, \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u043a \u043f\u043b\u043e\u0445\u043e.<\/p>\n<pre><code>typedef enum  {     UNKNOWN = 0x000000,     W25X05 = 0xEFFF10,     W25X10 = 0xEFFF11,     ... } W25Qxx_CHIP;<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u0432\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0443\u0434\u0430 \u0438\u043c\u044f \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u043f\u0443\u0441\u0442\u044c \u0434\u0430\u0436\u0435 <code>W25Qxx_CHIP<\/code>, \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-413237","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/413237","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=413237"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/413237\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=413237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=413237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=413237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}