\hypertarget{bsp__flash_8c_source}{}\doxysection{bsp\+\_\+flash.\+c}
\label{bsp__flash_8c_source}\index{D:/gitt/MicrochipFor32/bsp\_Device/bsp\_flash.c@{D:/gitt/MicrochipFor32/bsp\_Device/bsp\_flash.c}}
\mbox{\hyperlink{bsp__flash_8c}{浏览该文件的文档.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00001}00001 \textcolor{comment}{/*-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00002}00002 \textcolor{comment}{ \#}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00003}00003 \textcolor{comment}{ \#  Copyright (c) 2022 Yuankang Liang(XerolySkinner)}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00004}00004 \textcolor{comment}{ \#}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00005}00005 \textcolor{comment}{ \#  本软件按原样提供,无任何明示或暗示}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00006}00006 \textcolor{comment}{ \#  在任何情况下,作者都不承担任何损害赔偿责任}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00007}00007 \textcolor{comment}{ \#}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00008}00008 \textcolor{comment}{ \#  使用的许可声明:}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00009}00009 \textcolor{comment}{ \#  1.  不得歪曲本软件的来源,你不能声称你编写了原始软件.}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00010}00010 \textcolor{comment}{ \#  2.  免费授予以任何目的,前提是版权声明出现在所有副本中.}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00011}00011 \textcolor{comment}{ \#      并且版权声明和许可声明同时出现.}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00012}00012 \textcolor{comment}{ \#  3.  你有使用,复制,修改,分发,和销售本软件的许可.}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00013}00013 \textcolor{comment}{ \#  4.  如果你在产品中使用,产品文档中的声明是赞赏的但不是必须的.}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00014}00014 \textcolor{comment}{ \#  5.  本通知不得从任何来源删除或更改.}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00015}00015 \textcolor{comment}{ \#}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00016}00016 \textcolor{comment}{ \#  Yuankang Liang(XerolySkinner)}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00017}00017 \textcolor{comment}{ \#      E-\/mail:zabbcccbbaz@163.com}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00018}00018 \textcolor{comment}{ \#      QQ:2715099320}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00019}00019 \textcolor{comment}{ \#      Mobile Phone:13005636215}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00020}00020 \textcolor{comment}{ \#}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00021}00021 \textcolor{comment}{ \#  All rights reserved.}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00022}00022 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00023}00023 }
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00035}00035 \textcolor{preprocessor}{\#include "{}main.h"{}}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00036}\mbox{\hyperlink{bsp__flash_8c_a37cd1b57193a374f9a86b6cf1277cd0a}{00036}} uint32\_t \mbox{\hyperlink{bsp__flash_8c_a37cd1b57193a374f9a86b6cf1277cd0a}{FlashAddr}} = 0x08010000;                                   }
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00037}00037 \textcolor{comment}{//-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00038}00038 \textcolor{preprocessor}{\#pragma pack(4)}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00043}\mbox{\hyperlink{structstruct__bsp___flash___pack}{00043}} \textcolor{keyword}{struct }\mbox{\hyperlink{structstruct__bsp___flash___pack}{struct\_bsp\_Flash\_Pack}}\{}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00044}\mbox{\hyperlink{structstruct__bsp___flash___pack_aea6e531775263f158f23d2295f759dd7}{00044}}     \textcolor{keywordtype}{char}    \mbox{\hyperlink{structstruct__bsp___flash___pack_aea6e531775263f158f23d2295f759dd7}{Var0}};}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00045}\mbox{\hyperlink{structstruct__bsp___flash___pack_aff73ebf1f2eaf5930d7187aa5f502075}{00045}}     \textcolor{keywordtype}{short}   \mbox{\hyperlink{structstruct__bsp___flash___pack_aff73ebf1f2eaf5930d7187aa5f502075}{Var1}};}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00046}\mbox{\hyperlink{structstruct__bsp___flash___pack_adc2edcdadc2b2be3d18334cd196e049c}{00046}}     \textcolor{keywordtype}{int}     \mbox{\hyperlink{structstruct__bsp___flash___pack_adc2edcdadc2b2be3d18334cd196e049c}{Var2}};}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00047}\mbox{\hyperlink{bsp__flash_8c_a2c0639c4d50bba3762a4295a56a06af8}{00047}} \}\mbox{\hyperlink{bsp__flash_8c_a2c0639c4d50bba3762a4295a56a06af8}{bsp\_Flash\_Pack}}=\{0,0,0\};}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00048}00048 \textcolor{preprocessor}{\#pragma pack()}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00049}00049 \textcolor{comment}{//-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00056}\mbox{\hyperlink{bsp__flash_8c_af1304997d797af3400074bdb68e5de1c}{00056}} \textcolor{comment}{}uint32\_t \mbox{\hyperlink{bsp__flash_8c_af1304997d797af3400074bdb68e5de1c}{bsp\_WriteFlashOnePage}}(uint32\_t *dat,uint32\_t num)\{}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00057}00057     FLASH\_EraseInitTypeDef f;}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00058}00058     uint32\_t PageError = 0;                                         \textcolor{comment}{//错误号7}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00059}00059     HAL\_FLASH\_Unlock();                                             \textcolor{comment}{//解锁FLASH}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00060}00060     f.TypeErase = FLASH\_TYPEERASE\_PAGES;                            \textcolor{comment}{//Flash擦除}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00061}00061     f.PageAddress = \mbox{\hyperlink{bsp__flash_8c_a37cd1b57193a374f9a86b6cf1277cd0a}{FlashAddr}};                                     \textcolor{comment}{//擦除地址(起始页)}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00062}00062     f.NbPages = 1;                                                  \textcolor{comment}{//擦除1页}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00063}00063     HAL\_FLASHEx\_Erase(\&f,\&PageError);                               \textcolor{comment}{//调用擦除函数}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00064}00064     \textcolor{keywordflow}{for}(\textcolor{keywordtype}{int} i=0;i<num;i++)}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00065}00065         HAL\_FLASH\_Program(TYPEPROGRAM\_WORD,\mbox{\hyperlink{bsp__flash_8c_a37cd1b57193a374f9a86b6cf1277cd0a}{FlashAddr}}+i*4,dat[i]);  \textcolor{comment}{//对FLASH烧写}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00066}00066     HAL\_FLASH\_Lock();                                               \textcolor{comment}{//锁住FLASH}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00067}00067     \textcolor{keywordflow}{return} PageError;\}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00068}00068 \textcolor{comment}{//-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00075}\mbox{\hyperlink{bsp__flash_8c_a734a679e19a8af2c7ddfa86f4310a13d}{00075}} \textcolor{comment}{}\textcolor{keywordtype}{void} \mbox{\hyperlink{bsp__flash_8c_a734a679e19a8af2c7ddfa86f4310a13d}{bsp\_ReadFlash}}(uint32\_t *dat,uint32\_t num)\{                        \textcolor{comment}{//读入一串数据}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00076}00076     \textcolor{keywordflow}{for}(\textcolor{keywordtype}{int} i=0;i<num;i++)}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00077}00077         dat[i]=*(\_\_IO uint32\_t*)(\mbox{\hyperlink{bsp__flash_8c_a37cd1b57193a374f9a86b6cf1277cd0a}{FlashAddr}}+i*4);\}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00078}00078 \textcolor{comment}{//-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00083}\mbox{\hyperlink{bsp__flash_8c_aa1a1ff74b284a19aa3872b6f3d6abd11}{00083}} \textcolor{comment}{}\textcolor{keywordtype}{void} \mbox{\hyperlink{bsp__flash_8c_aa1a1ff74b284a19aa3872b6f3d6abd11}{bsp\_WriteFlash\_Pack}}(\textcolor{keywordtype}{void})\{}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00084}00084     \mbox{\hyperlink{bsp__flash_8c_af1304997d797af3400074bdb68e5de1c}{bsp\_WriteFlashOnePage}}((uint32\_t*)(\&\mbox{\hyperlink{bsp__flash_8c_a2c0639c4d50bba3762a4295a56a06af8}{bsp\_Flash\_Pack}}),\textcolor{keyword}{sizeof}(\textcolor{keyword}{struct} \mbox{\hyperlink{structstruct__bsp___flash___pack}{struct\_bsp\_Flash\_Pack}}));}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00085}00085     \textcolor{keywordflow}{return};\}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00086}00086 \textcolor{comment}{//-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00091}\mbox{\hyperlink{bsp__flash_8c_a45549058e1315d29263c0b26816bcffb}{00091}} \textcolor{comment}{}\textcolor{keywordtype}{void} \mbox{\hyperlink{bsp__flash_8c_a45549058e1315d29263c0b26816bcffb}{bsp\_ReadFlash\_Pack}}(\textcolor{keywordtype}{void})\{}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00092}00092     \mbox{\hyperlink{bsp__flash_8c_a734a679e19a8af2c7ddfa86f4310a13d}{bsp\_ReadFlash}}((uint32\_t*)(\&\mbox{\hyperlink{bsp__flash_8c_a2c0639c4d50bba3762a4295a56a06af8}{bsp\_Flash\_Pack}}),\textcolor{keyword}{sizeof}(\textcolor{keyword}{struct} \mbox{\hyperlink{structstruct__bsp___flash___pack}{struct\_bsp\_Flash\_Pack}}));}
\DoxyCodeLine{\Hypertarget{bsp__flash_8c_source_l00093}00093     \textcolor{keywordflow}{return};\}}

\end{DoxyCode}
