diff --git a/12-SPI-Simulation/EWARM/Project.ewd b/12-SPI-Simulation/EWARM/Project.ewd
new file mode 100644
index 0000000..7a83448
--- /dev/null
+++ b/12-SPI-Simulation/EWARM/Project.ewd
@@ -0,0 +1,1352 @@
+
+
+
+ 2
+
+ SPI
+
+ ARM
+
+ 1
+
+ C-SPY
+ 2
+
+ 26
+ 1
+ 1
+
+ CInput
+ 1
+
+
+ CEndian
+ 1
+
+
+ CProcessor
+ 1
+
+
+ OCVariant
+ 0
+
+
+ MacOverride
+ 0
+
+
+ MacFile
+
+
+
+ MemOverride
+ 0
+
+
+ MemFile
+ $TOOLKIT_DIR$\CONFIG\debugger\ST\STM32F207VC.ddf
+
+
+ RunToEnable
+ 1
+
+
+ RunToName
+ main
+
+
+ CExtraOptionsCheck
+ 0
+
+
+ CExtraOptions
+
+
+
+ CFpuProcessor
+ 1
+
+
+ OCDDFArgumentProducer
+
+
+
+ OCDownloadSuppressDownload
+ 0
+
+
+ OCDownloadVerifyAll
+ 0
+
+
+ OCProductVersion
+ 5.30.0.51236
+
+
+ OCDynDriverList
+ JLINK_ID
+
+
+ OCLastSavedByProductVersion
+ 7.20.2.7418
+
+
+ OCDownloadAttachToProgram
+ 0
+
+
+ UseFlashLoader
+ 1
+
+
+ CLowLevel
+ 1
+
+
+ OCBE8Slave
+ 1
+
+
+ MacFile2
+
+
+
+ CDevice
+ 1
+
+
+ FlashLoadersV3
+ $TOOLKIT_DIR$\config\flashloader\ST\FlashSTM32F205xC.board
+
+
+ OCImagesSuppressCheck1
+ 0
+
+
+ OCImagesPath1
+
+
+
+ OCImagesSuppressCheck2
+ 0
+
+
+ OCImagesPath2
+
+
+
+ OCImagesSuppressCheck3
+ 0
+
+
+ OCImagesPath3
+
+
+
+ OverrideDefFlashBoard
+ 0
+
+
+ OCImagesOffset1
+
+
+
+ OCImagesOffset2
+
+
+
+ OCImagesOffset3
+
+
+
+ OCImagesUse1
+ 0
+
+
+ OCImagesUse2
+ 0
+
+
+ OCImagesUse3
+ 0
+
+
+ OCDeviceConfigMacroFile
+ 1
+
+
+ OCDebuggerExtraOption
+ 1
+
+
+ OCAllMTBOptions
+ 1
+
+
+ OCMulticoreNrOfCores
+ 1
+
+
+ OCMulticoreMaster
+ 0
+
+
+ OCMulticorePort
+ 53461
+
+
+ OCMulticoreWorkspace
+
+
+
+ OCMulticoreSlaveProject
+
+
+
+ OCMulticoreSlaveConfiguration
+
+
+
+
+
+ ARMSIM_ID
+ 2
+
+ 1
+ 1
+ 1
+
+ OCSimDriverInfo
+ 1
+
+
+ OCSimEnablePSP
+ 0
+
+
+ OCSimPspOverrideConfig
+ 0
+
+
+ OCSimPspConfigFile
+
+
+
+
+
+ ANGEL_ID
+ 2
+
+ 0
+ 1
+ 1
+
+ CCAngelHeartbeat
+ 1
+
+
+ CAngelCommunication
+ 1
+
+
+ CAngelCommBaud
+ 0
+ 3
+
+
+ CAngelCommPort
+ 0
+ 0
+
+
+ ANGELTCPIP
+ aaa.bbb.ccc.ddd
+
+
+ DoAngelLogfile
+ 0
+
+
+ AngelLogFile
+ $TOOLKIT_DIR$\cspycomm.log
+
+
+ OCDriverInfo
+ 1
+
+
+
+
+ CMSISDAP_ID
+ 2
+
+ 2
+ 1
+ 1
+
+ OCDriverInfo
+ 1
+
+
+ CMSISDAPAttachSlave
+ 1
+
+
+ OCIarProbeScriptFile
+ 1
+
+
+ CMSISDAPResetList
+ 1
+ 10
+
+
+ CMSISDAPHWResetDuration
+ 300
+
+
+ CMSISDAPHWResetDelay
+ 200
+
+
+ CMSISDAPDoLogfile
+ 0
+
+
+ CMSISDAPLogFile
+ $PROJ_DIR$\cspycomm.log
+
+
+ CMSISDAPInterfaceRadio
+ 0
+
+
+ CMSISDAPInterfaceCmdLine
+ 0
+
+
+ CMSISDAPMultiTargetEnable
+ 0
+
+
+ CMSISDAPMultiTarget
+ 0
+
+
+ CMSISDAPJtagSpeedList
+ 0
+ 0
+
+
+ CMSISDAPBreakpointRadio
+ 0
+
+
+ CMSISDAPRestoreBreakpointsCheck
+ 0
+
+
+ CMSISDAPUpdateBreakpointsEdit
+ _call_main
+
+
+ RDICatchReset
+ 0
+
+
+ RDICatchUndef
+ 1
+
+
+ RDICatchSWI
+ 0
+
+
+ RDICatchData
+ 1
+
+
+ RDICatchPrefetch
+ 1
+
+
+ RDICatchIRQ
+ 0
+
+
+ RDICatchFIQ
+ 0
+
+
+ CatchCORERESET
+ 0
+
+
+ CatchMMERR
+ 1
+
+
+ CatchNOCPERR
+ 1
+
+
+ CatchCHKERR
+ 1
+
+
+ CatchSTATERR
+ 1
+
+
+ CatchBUSERR
+ 1
+
+
+ CatchINTERR
+ 1
+
+
+ CatchHARDERR
+ 1
+
+
+ CatchDummy
+ 0
+
+
+ CMSISDAPMultiCPUEnable
+ 0
+
+
+ CMSISDAPMultiCPUNumber
+ 0
+
+
+ OCProbeCfgOverride
+ 0
+
+
+ OCProbeConfig
+
+
+
+ CMSISDAPProbeConfigRadio
+ 0
+
+
+ CMSISDAPSelectedCPUBehaviour
+ 0
+
+
+ ICpuName
+
+
+
+ OCJetEmuParams
+ 1
+
+
+
+
+ GDBSERVER_ID
+ 2
+
+ 0
+ 1
+ 1
+
+ OCDriverInfo
+ 1
+
+
+ TCPIP
+ aaa.bbb.ccc.ddd
+
+
+ DoLogfile
+ 0
+
+
+ LogFile
+ $TOOLKIT_DIR$\cspycomm.log
+
+
+ CCJTagBreakpointRadio
+ 0
+
+
+ CCJTagDoUpdateBreakpoints
+ 0
+
+
+ CCJTagUpdateBreakpoints
+ main
+
+
+
+
+ IARROM_ID
+ 2
+
+ 1
+ 1
+ 1
+
+ CRomLogFileCheck
+ 0
+
+
+ CRomLogFileEditB
+ $TOOLKIT_DIR$\cspycomm.log
+
+
+ CRomCommPort
+ 0
+ 0
+
+
+ CRomCommBaud
+ 0
+ 7
+
+
+ OCDriverInfo
+ 1
+
+
+
+
+ IJET_ID
+ 2
+
+ 3
+ 1
+ 1
+
+ OCDriverInfo
+ 1
+
+
+ IjetAttachSlave
+ 1
+
+
+ OCIarProbeScriptFile
+ 1
+
+
+ IjetResetList
+ 1
+ 10
+
+
+ IjetHWResetDuration
+ 300
+
+
+ IjetHWResetDelay
+ 200
+
+
+ IjetPowerFromProbe
+ 1
+
+
+ IjetPowerRadio
+ 0
+
+
+ IjetDoLogfile
+ 0
+
+
+ IjetLogFile
+ $PROJ_DIR$\cspycomm.log
+
+
+ IjetInterfaceRadio
+ 0
+
+
+ IjetInterfaceCmdLine
+ 0
+
+
+ IjetMultiTargetEnable
+ 0
+
+
+ IjetMultiTarget
+ 0
+
+
+ IjetScanChainNonARMDevices
+ 0
+
+
+ IjetIRLength
+ 0
+
+
+ IjetJtagSpeedList
+ 0
+ 0
+
+
+ IjetProtocolRadio
+ 0
+
+
+ IjetSwoPin
+ 0
+
+
+ IjetCpuClockEdit
+ 72.0
+
+
+ IjetSwoPrescalerList
+ 1
+ 0
+
+
+ IjetBreakpointRadio
+ 0
+
+
+ IjetRestoreBreakpointsCheck
+ 0
+
+
+ IjetUpdateBreakpointsEdit
+ _call_main
+
+
+ RDICatchReset
+ 0
+
+
+ RDICatchUndef
+ 1
+
+
+ RDICatchSWI
+ 0
+
+
+ RDICatchData
+ 1
+
+
+ RDICatchPrefetch
+ 1
+
+
+ RDICatchIRQ
+ 0
+
+
+ RDICatchFIQ
+ 0
+
+
+ CatchCORERESET
+ 0
+
+
+ CatchMMERR
+ 1
+
+
+ CatchNOCPERR
+ 1
+
+
+ CatchCHKERR
+ 1
+
+
+ CatchSTATERR
+ 1
+
+
+ CatchBUSERR
+ 1
+
+
+ CatchINTERR
+ 1
+
+
+ CatchHARDERR
+ 1
+
+
+ CatchDummy
+ 0
+
+
+ OCProbeCfgOverride
+ 0
+
+
+ OCProbeConfig
+
+
+
+ IjetProbeConfigRadio
+ 0
+
+
+ IjetMultiCPUEnable
+ 0
+
+
+ IjetMultiCPUNumber
+ 0
+
+
+ IjetSelectedCPUBehaviour
+ 0
+
+
+ ICpuName
+
+
+
+ OCJetEmuParams
+ 1
+
+
+
+
+ JLINK_ID
+ 2
+
+ 15
+ 1
+ 1
+
+ JLinkSpeed
+ 32
+
+
+ CCJLinkDoLogfile
+ 0
+
+
+ CCJLinkLogFile
+ $TOOLKIT_DIR$\cspycomm.log
+
+
+ CCJLinkHWResetDelay
+ 0
+
+
+ OCDriverInfo
+ 1
+
+
+ JLinkInitialSpeed
+ 32
+
+
+ CCDoJlinkMultiTarget
+ 0
+
+
+ CCScanChainNonARMDevices
+ 0
+
+
+ CCJLinkMultiTarget
+ 0
+
+
+ CCJLinkIRLength
+ 0
+
+
+ CCJLinkCommRadio
+ 0
+
+
+ CCJLinkTCPIP
+ aaa.bbb.ccc.ddd
+
+
+ CCJLinkSpeedRadioV2
+ 0
+
+
+ CCUSBDevice
+ 1
+ 1
+
+
+ CCRDICatchReset
+ 0
+
+
+ CCRDICatchUndef
+ 0
+
+
+ CCRDICatchSWI
+ 0
+
+
+ CCRDICatchData
+ 0
+
+
+ CCRDICatchPrefetch
+ 0
+
+
+ CCRDICatchIRQ
+ 0
+
+
+ CCRDICatchFIQ
+ 0
+
+
+ CCJLinkBreakpointRadio
+ 0
+
+
+ CCJLinkDoUpdateBreakpoints
+ 0
+
+
+ CCJLinkUpdateBreakpoints
+ main
+
+
+ CCJLinkInterfaceRadio
+ 1
+
+
+ OCJLinkAttachSlave
+ 1
+
+
+ CCJLinkResetList
+ 6
+ 7
+
+
+ CCJLinkInterfaceCmdLine
+ 0
+
+
+ CCCatchCORERESET
+ 0
+
+
+ CCCatchMMERR
+ 0
+
+
+ CCCatchNOCPERR
+ 0
+
+
+ CCCatchCHRERR
+ 0
+
+
+ CCCatchSTATERR
+ 0
+
+
+ CCCatchBUSERR
+ 0
+
+
+ CCCatchINTERR
+ 0
+
+
+ CCCatchHARDERR
+ 0
+
+
+ CCCatchDummy
+ 0
+
+
+ OCJLinkScriptFile
+ 1
+
+
+ CCJLinkUsbSerialNo
+
+
+
+ CCTcpIpAlt
+ 0
+ 0
+
+
+ CCJLinkTcpIpSerialNo
+
+
+
+ CCCpuClockEdit
+ 72.0
+
+
+ CCSwoClockAuto
+ 0
+
+
+ CCSwoClockEdit
+ 2000
+
+
+ OCJLinkTraceSource
+ 0
+
+
+ OCJLinkTraceSourceDummy
+ 0
+
+
+ OCJLinkDeviceName
+ 1
+
+
+
+
+ LMIFTDI_ID
+ 2
+
+ 2
+ 1
+ 1
+
+ OCDriverInfo
+ 1
+
+
+ LmiftdiSpeed
+ 500
+
+
+ CCLmiftdiDoLogfile
+ 0
+
+
+ CCLmiftdiLogFile
+ $PROJ_DIR$\cspycomm.log
+
+
+ CCLmiFtdiInterfaceRadio
+ 0
+
+
+ CCLmiFtdiInterfaceCmdLine
+ 0
+
+
+
+
+ MACRAIGOR_ID
+ 2
+
+ 3
+ 1
+ 1
+
+ jtag
+ 0
+ 0
+
+
+ EmuSpeed
+ 1
+
+
+ TCPIP
+ aaa.bbb.ccc.ddd
+
+
+ DoLogfile
+ 0
+
+
+ LogFile
+ $TOOLKIT_DIR$\cspycomm.log
+
+
+ DoEmuMultiTarget
+ 0
+
+
+ EmuMultiTarget
+ 0@ARM7TDMI
+
+
+ EmuHWReset
+ 0
+
+
+ CEmuCommBaud
+ 0
+ 4
+
+
+ CEmuCommPort
+ 0
+ 0
+
+
+ jtago
+ 0
+ 0
+
+
+ OCDriverInfo
+ 1
+
+
+ UnusedAddr
+ 0x00800000
+
+
+ CCMacraigorHWResetDelay
+
+
+
+ CCJTagBreakpointRadio
+ 0
+
+
+ CCJTagDoUpdateBreakpoints
+ 0
+
+
+ CCJTagUpdateBreakpoints
+ main
+
+
+ CCMacraigorInterfaceRadio
+ 0
+
+
+ CCMacraigorInterfaceCmdLine
+ 0
+
+
+
+
+ PEMICRO_ID
+ 2
+
+ 1
+ 1
+ 1
+
+ OCDriverInfo
+ 1
+
+
+ OCPEMicroAttachSlave
+ 1
+
+
+ CCPEMicroInterfaceList
+ 0
+ 0
+
+
+ CCPEMicroResetDelay
+
+
+
+ CCPEMicroJtagSpeed
+ #UNINITIALIZED#
+
+
+ CCJPEMicroShowSettings
+ 0
+
+
+ DoLogfile
+ 0
+
+
+ LogFile
+ $PROJ_DIR$\cspycomm.log
+
+
+ CCPEMicroUSBDevice
+ 0
+ 0
+
+
+ CCPEMicroSerialPort
+ 0
+ 0
+
+
+ CCJPEMicroTCPIPAutoScanNetwork
+ 1
+
+
+ CCPEMicroTCPIP
+ 10.0.0.1
+
+
+ CCPEMicroCommCmdLineProducer
+ 0
+
+
+ CCSTLinkInterfaceRadio
+ 0
+
+
+ CCSTLinkInterfaceCmdLine
+ 0
+
+
+
+
+ RDI_ID
+ 2
+
+ 2
+ 1
+ 1
+
+ CRDIDriverDll
+ Browse to your RDI driver
+
+
+ CRDILogFileCheck
+ 0
+
+
+ CRDILogFileEdit
+ $TOOLKIT_DIR$\cspycomm.log
+
+
+ CCRDIHWReset
+ 0
+
+
+ CCRDICatchReset
+ 0
+
+
+ CCRDICatchUndef
+ 0
+
+
+ CCRDICatchSWI
+ 0
+
+
+ CCRDICatchData
+ 0
+
+
+ CCRDICatchPrefetch
+ 0
+
+
+ CCRDICatchIRQ
+ 0
+
+
+ CCRDICatchFIQ
+ 0
+
+
+ OCDriverInfo
+ 1
+
+
+
+
+ STLINK_ID
+ 2
+
+ 2
+ 1
+ 1
+
+ OCDriverInfo
+ 1
+
+
+ CCSTLinkInterfaceRadio
+ 0
+
+
+ CCSTLinkInterfaceCmdLine
+ 0
+
+
+ CCSTLinkResetList
+ 1
+ 0
+
+
+ CCCpuClockEdit
+ 72.0
+
+
+ CCSwoClockAuto
+ 0
+
+
+ CCSwoClockEdit
+ 2000
+
+
+
+
+ THIRDPARTY_ID
+ 2
+
+ 0
+ 1
+ 1
+
+ CThirdPartyDriverDll
+ Browse to your third-party driver
+
+
+ CThirdPartyLogFileCheck
+ 0
+
+
+ CThirdPartyLogFileEditB
+ $TOOLKIT_DIR$\cspycomm.log
+
+
+ OCDriverInfo
+ 1
+
+
+
+
+ XDS100_ID
+ 2
+
+ 2
+ 1
+ 1
+
+ OCDriverInfo
+ 1
+
+
+ OCXDS100AttachSlave
+ 1
+
+
+ TIPackageOverride
+ 0
+
+
+ TIPackage
+
+
+
+ CCXds100InterfaceList
+ 2
+ 0
+
+
+ BoardFile
+
+
+
+ DoLogfile
+ 0
+
+
+ LogFile
+ $PROJ_DIR$\cspycomm.log
+
+
+
+
+
+ $TOOLKIT_DIR$\plugins\middleware\HCCWare\HCCWare.ewplugin
+ 0
+
+
+ $TOOLKIT_DIR$\plugins\rtos\AVIX\AVIX.ENU.ewplugin
+ 0
+
+
+ $TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin
+ 0
+
+
+ $TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin
+ 0
+
+
+ $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin
+ 0
+
+
+ $TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin
+ 0
+
+
+ $TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin
+ 0
+
+
+ $TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin
+ 0
+
+
+ $TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin
+ 0
+
+
+ $TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin
+ 0
+
+
+ $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin
+ 0
+
+
+ $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin
+ 0
+
+
+ $TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin
+ 0
+
+
+ $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin
+ 1
+
+
+ $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin
+ 0
+
+
+ $EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin
+ 1
+
+
+ $EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin
+ 0
+
+
+
+
+
+
diff --git a/12-SPI-Simulation/EWARM/Project.ewp b/12-SPI-Simulation/EWARM/Project.ewp
new file mode 100644
index 0000000..811ba6e
--- /dev/null
+++ b/12-SPI-Simulation/EWARM/Project.ewp
@@ -0,0 +1,1074 @@
+
+
+
+ 2
+
+ SPI
+
+ ARM
+
+ 1
+
+ General
+ 3
+
+ 22
+ 1
+ 1
+
+ ExePath
+ SPI\Exe
+
+
+ ObjPath
+ SPI\Obj
+
+
+ ListPath
+ SPI\List
+
+
+ Variant
+ 20
+ 38
+
+
+ GEndianMode
+ 0
+
+
+ Input variant
+ 3
+ 6
+
+
+ Input description
+ No specifier n, no float nor long long, no scan set, no assignment suppressing.
+
+
+ Output variant
+ 2
+ 5
+
+
+ Output description
+ No specifier a, A, no specifier n, no float nor long long.
+
+
+ GOutputBinary
+ 0
+
+
+ FPU
+ 2
+ 0
+
+
+ OGCoreOrChip
+ 1
+
+
+ GRuntimeLibSelect
+ 0
+ 2
+
+
+ GRuntimeLibSelectSlave
+ 0
+ 2
+
+
+ RTDescription
+ Use the full configuration of the C/C++ runtime library. Full locale interface, C locale, file descriptor support, multibytes in printf and scanf, and hex floats in strtod.
+
+
+ OGProductVersion
+ 4.41A
+
+
+ OGLastSavedByProductVersion
+ 7.20.2.7418
+
+
+ GeneralEnableMisra
+ 0
+
+
+ GeneralMisraVerbose
+ 0
+
+
+ OGChipSelectEditMenu
+ STM32F207VC ST STM32F207VC
+
+
+ GenLowLevelInterface
+ 1
+
+
+ GEndianModeBE
+ 1
+
+
+ OGBufferedTerminalOutput
+ 0
+
+
+ GenStdoutInterface
+ 0
+
+
+ GeneralMisraRules98
+ 0
+ 1000111110110101101110011100111111101110011011000101110111101101100111111111111100110011111001110111001111111111111111111111111
+
+
+ GeneralMisraVer
+ 0
+
+
+ GeneralMisraRules04
+ 0
+ 011111111111111110111111111111011111111111111011110100111111111111111111111111111111111111111111101111111111111011111111111111111111111111111
+
+
+ RTConfigPath2
+ $TOOLKIT_DIR$\INC\c\DLib_Config_Full.h
+
+
+ GFPUCoreSlave
+ 20
+ 38
+
+
+ GBECoreSlave
+ 20
+ 38
+
+
+ OGUseCmsis
+ 1
+
+
+ OGUseCmsisDspLib
+ 0
+
+
+ GRuntimeLibThreads
+ 0
+
+
+
+
+ ICCARM
+ 2
+
+ 31
+ 1
+ 1
+
+ CCOptimizationNoSizeConstraints
+ 0
+
+
+ CCDefines
+ USE_STDPERIPH_DRIVER
+ STM32F2XX
+
+
+ CCPreprocFile
+ 0
+
+
+ CCPreprocComments
+ 0
+
+
+ CCPreprocLine
+ 0
+
+
+ CCListCFile
+ 0
+
+
+ CCListCMnemonics
+ 0
+
+
+ CCListCMessages
+ 0
+
+
+ CCListAssFile
+ 0
+
+
+ CCListAssSource
+ 0
+
+
+ CCEnableRemarks
+ 0
+
+
+ CCDiagSuppress
+
+
+
+ CCDiagRemark
+
+
+
+ CCDiagWarning
+
+
+
+ CCDiagError
+
+
+
+ CCObjPrefix
+ 1
+
+
+ CCAllowList
+ 1
+ 00000000
+
+
+ CCDebugInfo
+ 1
+
+
+ IEndianMode
+ 1
+
+
+ IProcessor
+ 1
+
+
+ IExtraOptionsCheck
+ 0
+
+
+ IExtraOptions
+
+
+
+ CCLangConformance
+ 0
+
+
+ CCSignedPlainChar
+ 1
+
+
+ CCRequirePrototypes
+ 0
+
+
+ CCMultibyteSupport
+ 0
+
+
+ CCDiagWarnAreErr
+ 0
+
+
+ CCCompilerRuntimeInfo
+ 0
+
+
+ IFpuProcessor
+ 1
+
+
+ OutputFile
+ $FILE_BNAME$.o
+
+
+ CCLibConfigHeader
+ 1
+
+
+ PreInclude
+
+
+
+ CompilerMisraOverride
+ 0
+
+
+ CCIncludePath2
+ $PROJ_DIR$\..
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\inc
+ $PROJ_DIR$\..\..\01-Libraries\CMSIS\Device\ST\STM32F2xx\Include
+
+
+ CCStdIncCheck
+ 0
+
+
+ CCCodeSection
+ .text
+
+
+ IInterwork2
+ 0
+
+
+ IProcessorMode2
+ 1
+
+
+ CCOptLevel
+ 0
+
+
+ CCOptStrategy
+ 0
+ 1
+
+
+ CCOptLevelSlave
+ 0
+
+
+ CompilerMisraRules98
+ 0
+ 1000111110110101101110011100111111101110011011000101110111101101100111111111111100110011111001110111001111111111111111111111111
+
+
+ CompilerMisraRules04
+ 0
+ 111101110010111111111000110111111111111111111111111110010111101111010101111111111111111111111111101111111011111001111011111011111111111111111
+
+
+ CCPosIndRopi
+ 0
+
+
+ CCPosIndRwpi
+ 0
+
+
+ CCPosIndNoDynInit
+ 0
+
+
+ IccLang
+ 0
+
+
+ IccCDialect
+ 1
+
+
+ IccAllowVLA
+ 0
+
+
+ IccCppDialect
+ 1
+
+
+ IccExceptions
+ 1
+
+
+ IccRTTI
+ 1
+
+
+ IccStaticDestr
+ 1
+
+
+ IccCppInlineSemantics
+ 1
+
+
+ IccCmsis
+ 1
+
+
+ IccFloatSemantics
+ 0
+
+
+ CCNoLiteralPool
+ 0
+
+
+ CCOptStrategySlave
+ 0
+ 1
+
+
+ CCGuardCalls
+ 1
+
+
+
+
+ AARM
+ 2
+
+ 9
+ 1
+ 1
+
+ AObjPrefix
+ 1
+
+
+ AEndian
+ 1
+
+
+ ACaseSensitivity
+ 1
+
+
+ MacroChars
+ 0
+ 0
+
+
+ AWarnEnable
+ 0
+
+
+ AWarnWhat
+ 0
+
+
+ AWarnOne
+
+
+
+ AWarnRange1
+
+
+
+ AWarnRange2
+
+
+
+ ADebug
+ 1
+
+
+ AltRegisterNames
+ 0
+
+
+ ADefines
+
+
+
+ AList
+ 0
+
+
+ AListHeader
+ 1
+
+
+ AListing
+ 1
+
+
+ Includes
+ 0
+
+
+ MacDefs
+ 0
+
+
+ MacExps
+ 1
+
+
+ MacExec
+ 0
+
+
+ OnlyAssed
+ 0
+
+
+ MultiLine
+ 0
+
+
+ PageLengthCheck
+ 0
+
+
+ PageLength
+ 80
+
+
+ TabSpacing
+ 8
+
+
+ AXRef
+ 0
+
+
+ AXRefDefines
+ 0
+
+
+ AXRefInternal
+ 0
+
+
+ AXRefDual
+ 0
+
+
+ AProcessor
+ 1
+
+
+ AFpuProcessor
+ 1
+
+
+ AOutputFile
+ $FILE_BNAME$.o
+
+
+ AMultibyteSupport
+ 0
+
+
+ ALimitErrorsCheck
+ 0
+
+
+ ALimitErrorsEdit
+ 100
+
+
+ AIgnoreStdInclude
+ 0
+
+
+ AUserIncludes
+
+
+
+ AExtraOptionsCheckV2
+ 0
+
+
+ AExtraOptionsV2
+
+
+
+ AsmNoLiteralPool
+ 0
+
+
+
+
+ OBJCOPY
+ 0
+
+ 1
+ 1
+ 1
+
+ OOCOutputFormat
+ 2
+ 0
+
+
+ OCOutputOverride
+ 0
+
+
+ OOCOutputFile
+ Project.srec
+
+
+ OOCCommandLineProducer
+ 1
+
+
+ OOCObjCopyEnable
+ 0
+
+
+
+
+ CUSTOM
+ 3
+
+
+
+
+
+
+ BICOMP
+ 0
+
+
+
+ BUILDACTION
+ 1
+
+
+
+
+
+
+ ILINK
+ 0
+
+ 16
+ 1
+ 1
+
+ IlinkLibIOConfig
+ 1
+
+
+ XLinkMisraHandler
+ 0
+
+
+ IlinkInputFileSlave
+ 0
+
+
+ IlinkOutputFile
+ Project.out
+
+
+ IlinkDebugInfoEnable
+ 1
+
+
+ IlinkKeepSymbols
+
+
+
+ IlinkRawBinaryFile
+
+
+
+ IlinkRawBinarySymbol
+
+
+
+ IlinkRawBinarySegment
+
+
+
+ IlinkRawBinaryAlign
+
+
+
+ IlinkDefines
+
+
+
+ IlinkConfigDefines
+
+
+
+ IlinkMapFile
+ 1
+
+
+ IlinkLogFile
+ 0
+
+
+ IlinkLogInitialization
+ 0
+
+
+ IlinkLogModule
+ 0
+
+
+ IlinkLogSection
+ 0
+
+
+ IlinkLogVeneer
+ 0
+
+
+ IlinkIcfOverride
+ 1
+
+
+ IlinkIcfFile
+ $PROJ_DIR$\stm32f2xx_flash.icf
+
+
+ IlinkIcfFileSlave
+
+
+
+ IlinkEnableRemarks
+ 0
+
+
+ IlinkSuppressDiags
+
+
+
+ IlinkTreatAsRem
+
+
+
+ IlinkTreatAsWarn
+
+
+
+ IlinkTreatAsErr
+
+
+
+ IlinkWarningsAreErrors
+ 0
+
+
+ IlinkUseExtraOptions
+ 0
+
+
+ IlinkExtraOptions
+
+
+
+ IlinkLowLevelInterfaceSlave
+ 1
+
+
+ IlinkAutoLibEnable
+ 1
+
+
+ IlinkAdditionalLibs
+
+
+
+ IlinkOverrideProgramEntryLabel
+ 0
+
+
+ IlinkProgramEntryLabelSelect
+ 0
+
+
+ IlinkProgramEntryLabel
+ __iar_program_start
+
+
+ DoFill
+ 0
+
+
+ FillerByte
+ 0xFF
+
+
+ FillerStart
+ 0x0
+
+
+ FillerEnd
+ 0x0
+
+
+ CrcSize
+ 0
+ 1
+
+
+ CrcAlign
+ 1
+
+
+ CrcPoly
+ 0x11021
+
+
+ CrcCompl
+ 0
+ 0
+
+
+ CrcBitOrder
+ 0
+ 0
+
+
+ CrcInitialValue
+ 0x0
+
+
+ DoCrc
+ 0
+
+
+ IlinkBE8Slave
+ 1
+
+
+ IlinkBufferedTerminalOutput
+ 1
+
+
+ IlinkStdoutInterfaceSlave
+ 1
+
+
+ CrcFullSize
+ 0
+
+
+ IlinkIElfToolPostProcess
+ 0
+
+
+ IlinkLogAutoLibSelect
+ 0
+
+
+ IlinkLogRedirSymbols
+ 0
+
+
+ IlinkLogUnusedFragments
+ 0
+
+
+ IlinkCrcReverseByteOrder
+ 0
+
+
+ IlinkCrcUseAsInput
+ 1
+
+
+ IlinkOptInline
+ 0
+
+
+ IlinkOptExceptionsAllow
+ 1
+
+
+ IlinkOptExceptionsForce
+ 0
+
+
+ IlinkCmsis
+ 1
+
+
+ IlinkOptMergeDuplSections
+ 0
+
+
+ IlinkOptUseVfe
+ 1
+
+
+ IlinkOptForceVfe
+ 0
+
+
+ IlinkStackAnalysisEnable
+ 0
+
+
+ IlinkStackControlFile
+
+
+
+ IlinkStackCallGraphFile
+
+
+
+ CrcAlgorithm
+ 0
+ 1
+
+
+ CrcUnitSize
+ 0
+ 0
+
+
+ IlinkThreadsSlave
+ 1
+
+
+
+
+ IARCHIVE
+ 0
+
+ 0
+ 1
+ 1
+
+ IarchiveInputs
+
+
+
+ IarchiveOverride
+ 0
+
+
+ IarchiveOutput
+ ###Unitialized###
+
+
+
+
+ BILINK
+ 0
+
+
+
+
+ CMSIS
+
+ $PROJ_DIR$\..\..\01-Libraries\CMSIS\Device\ST\STM32F2xx\Source\Templates\system_stm32f2xx.c
+
+
+
+ EWARM
+
+ $PROJ_DIR$\..\..\01-Libraries\CMSIS\Device\ST\STM32F2xx\Source\Templates\iar\startup_stm32f2xx.s
+
+
+
+ STM32F2xx_StdPeriph_Driver
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\misc.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_adc.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_can.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_crc.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_cryp.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_cryp_aes.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_cryp_des.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_cryp_tdes.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_dac.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_dbgmcu.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_dcmi.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_dma.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_exti.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_flash.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_fsmc.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_gpio.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_hash.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_hash_md5.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_hash_sha1.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_i2c.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_iwdg.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_pwr.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_rcc.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_rng.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_rtc.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_sdio.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_spi.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_syscfg.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_tim.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_usart.c
+
+
+ $PROJ_DIR$\..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_wwdg.c
+
+
+
+ User
+
+ $PROJ_DIR$\..\Ex_Flash.c
+
+
+ $PROJ_DIR$\..\LCD_disp.c
+
+
+ $PROJ_DIR$\..\main.c
+
+
+ $PROJ_DIR$\..\stm32f2xx_it.c
+
+
+
+
+
diff --git a/12-SPI-Simulation/EWARM/Project.eww b/12-SPI-Simulation/EWARM/Project.eww
new file mode 100644
index 0000000..e0fd14b
--- /dev/null
+++ b/12-SPI-Simulation/EWARM/Project.eww
@@ -0,0 +1,10 @@
+
+
+
+
+ $WS_DIR$\Project.ewp
+
+
+
+
+
diff --git a/12-SPI-Simulation/EWARM/stm32f2xx_flash.icf b/12-SPI-Simulation/EWARM/stm32f2xx_flash.icf
new file mode 100644
index 0000000..a75ac83
--- /dev/null
+++ b/12-SPI-Simulation/EWARM/stm32f2xx_flash.icf
@@ -0,0 +1,31 @@
+/*###ICF### Section handled by ICF editor, don't touch! ****/
+/*-Editor annotation file-*/
+/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
+/*-Specials-*/
+define symbol __ICFEDIT_intvec_start__ = 0x08000000;
+/*-Memory Regions-*/
+define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
+define symbol __ICFEDIT_region_ROM_end__ = 0x080FFFFF;
+define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
+define symbol __ICFEDIT_region_RAM_end__ = 0x20020000;
+/*-Sizes-*/
+define symbol __ICFEDIT_size_cstack__ = 0x400;
+define symbol __ICFEDIT_size_heap__ = 0x200;
+/**** End of ICF editor section. ###ICF###*/
+
+
+define memory mem with size = 4G;
+define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
+define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
+
+define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
+define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
+
+initialize by copy { readwrite };
+do not initialize { section .noinit };
+
+place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
+
+place in ROM_region { readonly };
+place in RAM_region { readwrite,
+ block CSTACK, block HEAP };
\ No newline at end of file
diff --git a/12-SPI-Simulation/Ex_Flash.c b/12-SPI-Simulation/Ex_Flash.c
new file mode 100644
index 0000000..8df14f7
--- /dev/null
+++ b/12-SPI-Simulation/Ex_Flash.c
@@ -0,0 +1,510 @@
+#include "stm32f2xx.h"
+#include "Ex_Flash.h"
+#include
+
+uint8_t Sec_Data[Ex_FLASH_SecSize];
+EX_Flash_struct EX_Flash;
+
+/* ֲӿڡstart */
+
+extern uint8_t SPI_ReadWriteByte(uint8_t data);
+
+#define Ex_Flash_CS_Low() GPIO_ResetBits(GPIOE,GPIO_Pin_12);
+#define Ex_Flash_CS_High() GPIO_SetBits(GPIOE,GPIO_Pin_12);
+
+uint8_t MCU_ReadWriteByte(uint8_t TxData)
+{
+ return SPI_ReadWriteByte(TxData);
+}
+
+/* ֲӿڡend */
+
+
+
+/* ýӿڡstart */
+
+/*!
+* Function name EX_FLASH_init
+* @return NONE
+* @note
+*/
+Flash_enum EX_FLASH_init(void)
+{
+ uint32_t Flash_ID;
+ uint8_t temp;
+ Flash_ID = Ex_FLASH_ReadID();
+
+ temp = (uint8_t)((Flash_ID>>16)&0xff);
+ if(temp == 0xEF)
+ EX_Flash.Flash_stype = Winbond_Flash;
+ if(temp == 0xC8)
+ EX_Flash.Flash_stype = GD_Flash;
+
+ temp = (uint8_t)(Flash_ID&0xff);
+ if(temp == 0x15){
+ EX_Flash.Flash_Memory = Flash_2M;
+ EX_Flash.Flash_Memory_value = 512*Ex_FLASH_SecSize-1;
+ }else{
+ if(temp == 0x16){
+ EX_Flash.Flash_Memory = Flash_4M;
+ EX_Flash.Flash_Memory_value = 1024*Ex_FLASH_SecSize-1;
+ }else{
+ return (Ex_Flash_ERR);
+ }
+ }
+ return (Ex_Flash_OK);
+}
+/*!
+* Function name ExFlash_RD
+* Descriptions ⲿFlash
+* @param temp_addr ݵĵַ
+* @param data_cach ݵָ
+* @param data_len ݵݳ
+* @return NONE
+* @note
+*/
+Flash_enum ExFlash_RD(uint32_t temp_addr,uint8_t *data_cach,uint32_t data_len)
+{
+ if(temp_addr> 16);
+ /* Send SectorAddr medium nibble address byte */
+ MCU_ReadWriteByte((SectorAddr & 0xFF00) >> 8);
+ /* Send SectorAddr low nibble address byte */
+ MCU_ReadWriteByte(SectorAddr & 0xFF);
+ /* Deselect the FLASH: Chip Select high */
+ Ex_Flash_CS_High();
+
+ /* Wait the end of Flash writing */
+ Ex_FLASH_WaitForWriteEnd();
+
+ return Ex_Flash_OK;
+}
+
+/**
+ * @brief Read the Sector
+ * @param Sec_Num :Sector num
+ * @param RcvBuf :pointer to the buffer
+ * @retval Function execution result
+ */
+uint8_t Ex_Flash_RD_Sec(uint32_t Sec_Num,uint8_t* RcvBuf)
+{
+ uint32_t addr = 0;
+ uint32_t i;
+ addr = Sec_Num * Ex_FLASH_SecSize;
+
+ Ex_Flash_CS_Low();
+ MCU_ReadWriteByte(0x0B);
+ MCU_ReadWriteByte(((addr & 0xFFFFFF) >> 16));
+ MCU_ReadWriteByte(((addr & 0xFFFF) >> 8));
+ MCU_ReadWriteByte(addr & 0xFF);
+
+ MCU_ReadWriteByte(0xFF);
+ for (i = 0; i < Ex_FLASH_SecSize; i++)
+ {
+ RcvBuf[i] = MCU_ReadWriteByte(Dummy_Byte);
+ }
+ Ex_Flash_CS_High();
+ return (Ex_Flash_OK);
+}
+
+uint8_t Ex_Flash_RD(uint32_t ReadAddr,uint8_t* RcvBuf,uint32_t NByte)
+{
+ uint32_t i = 0;
+
+ Ex_Flash_CS_Low();
+ MCU_ReadWriteByte(0x0B);
+ MCU_ReadWriteByte(((ReadAddr & 0xFFFFFF) >> 16));
+ MCU_ReadWriteByte(((ReadAddr & 0xFFFF) >> 8));
+ MCU_ReadWriteByte(ReadAddr & 0xFF);
+
+ MCU_ReadWriteByte(0xFF);
+ for (i = 0; i < NByte; i++)
+ {
+ RcvBuf[i] = MCU_ReadWriteByte(Dummy_Byte);
+ }
+ Ex_Flash_CS_High();
+ return (Ex_Flash_OK);
+}
+ /**
+ * @brief Writes more than one byte to the FLASH(дСһҳ(256ֽ))
+ * @param WriteAddr : FLASH's internal address to write to
+ * @param pBuffer : pointer to the buffer
+ * @param NumByteToWrite : number of bytes to write to the FLASH
+ * @retval None
+ */
+uint8_t Ex_Flash_PageWrite(uint32_t WriteAddr,uint8_t* pBuffer, uint16_t NumByteToWrite)
+{
+ Ex_FLASH_WriteEnable();
+ Ex_Flash_CS_Low();
+ MCU_ReadWriteByte(WRITE);
+ /* Send WriteAddr high nibble address byte to write to */
+ MCU_ReadWriteByte((WriteAddr & 0xFF0000) >> 16);
+ /* Send WriteAddr medium nibble address byte to write to */
+ MCU_ReadWriteByte((WriteAddr & 0xFF00) >> 8);
+ /* Send WriteAddr low nibble address byte to write to */
+ MCU_ReadWriteByte(WriteAddr & 0xFF);
+
+ /* while there is data to be written on the FLASH */
+ while (NumByteToWrite--)
+ {
+ /* Send the current byte */
+ MCU_ReadWriteByte(*pBuffer);
+ /* Point on the next byte to be written */
+ pBuffer++;
+ }
+
+ /* Deselect the FLASH: Chip Select high */
+ Ex_Flash_CS_High();
+
+ /* Wait the end of Flash writing */
+ Ex_FLASH_WaitForWriteEnd();
+
+ return Ex_Flash_OK;
+}
+
+/**
+ * @brief Writes block of data to the FLASH(дݵFlashд֮ǰҪӦ)
+ * @param WriteAddr : FLASH's internal address to write to
+ * @param pBuffer : pointer to the buffer
+ * @param NumByteToWrite : number of bytes to write to the FLASH
+ * @retval None
+ */
+uint8_t Ex_FLASH_BufferWrite(uint32_t WriteAddr,uint8_t* pBuffer, uint16_t NumByteToWrite)
+{
+ uint8_t NumOfPage = 0, NumOfSingle = 0, Addr = 0, count = 0, temp = 0;
+
+ Addr = WriteAddr % Ex_FLASH_PageSize;
+ count = Ex_FLASH_PageSize - Addr;
+ NumOfPage = NumByteToWrite / Ex_FLASH_PageSize;
+ NumOfSingle = NumByteToWrite % Ex_FLASH_PageSize;
+ /* WriteAddr is Ex_FLASH_PageSize aligned */
+ if (Addr == 0)
+ {
+ /* NumByteToWrite < Ex_FLASH_PageSize */
+ if (NumOfPage == 0)
+ {
+ Ex_Flash_PageWrite( WriteAddr,pBuffer, NumByteToWrite);
+ }
+ else /* NumByteToWrite > Ex_FLASH_PageSize */
+ {
+ while (NumOfPage--)
+ {
+ Ex_Flash_PageWrite( WriteAddr,pBuffer, Ex_FLASH_PageSize);
+ WriteAddr += Ex_FLASH_PageSize;
+ pBuffer += Ex_FLASH_PageSize;
+ }
+ Ex_Flash_PageWrite(WriteAddr, pBuffer, NumOfSingle);
+ }
+ }
+ else /* WriteAddr is not Ex_FLASH_PageSize aligned */
+ {
+ if (NumOfPage == 0)
+ {
+ /* (NumByteToWrite + WriteAddr) > Ex_FLASH_PageSize */
+ if (NumOfSingle > count)
+ {
+ temp = NumOfSingle - count;
+ Ex_Flash_PageWrite( WriteAddr, pBuffer,count);
+ WriteAddr += count;
+ pBuffer += count;
+ Ex_Flash_PageWrite(WriteAddr, pBuffer, temp);
+ }
+ else
+ {
+ Ex_Flash_PageWrite(WriteAddr, pBuffer, NumByteToWrite);
+ }
+ }
+ else /* NumByteToWrite > Ex_FLASH_PageSize */
+ {
+ NumByteToWrite -= count;
+ NumOfPage = NumByteToWrite / Ex_FLASH_PageSize;
+ NumOfSingle = NumByteToWrite % Ex_FLASH_PageSize;
+
+ Ex_Flash_PageWrite(WriteAddr, pBuffer, count);
+ WriteAddr += count;
+ pBuffer += count;
+
+ while (NumOfPage--)
+ {
+ Ex_Flash_PageWrite(WriteAddr, pBuffer, Ex_FLASH_PageSize);
+ WriteAddr += Ex_FLASH_PageSize;
+ pBuffer += Ex_FLASH_PageSize;
+ }
+
+ if (NumOfSingle != 0)
+ {
+ Ex_Flash_PageWrite(WriteAddr, pBuffer, NumOfSingle);
+ }
+ }
+ }
+ return Ex_Flash_OK;
+}
+
+/**
+ * @brief Writes block of data to the FLASH(дݵFlash)
+ * @param WriteAddr : FLASH's internal address to write to
+ * @param pBuffer : pointer to the buffer
+ * @param NumByteToWrite : number of bytes to write to the FLASH
+ * @retval None
+ */
+uint8_t Ex_FLASH_Write(uint32_t WriteAddr,uint8_t* pBuffer, uint16_t NumByteToWrite)
+{
+ uint32_t Start_Addr;
+ uint32_t Sec_num;
+ uint32_t End_Addr;
+ uint32_t Sec_Off;
+ uint32_t i;
+
+ Start_Addr = WriteAddr % Ex_FLASH_SecSize;
+
+ if(Start_Addr ==0){
+ Sec_num = NumByteToWrite/Ex_FLASH_SecSize;
+ End_Addr = (WriteAddr+NumByteToWrite)%Ex_FLASH_SecSize;
+ }else {
+ if(NumByteToWrite ",30*/
+ {0x00,0x00,0x0E,0x00,0x12,0x00,0x10,0x0C,0x10,0x6C,0x10,0x80,0x0F,0x00,0x00,0x00},/*"?",31*/
+ {0x03,0xE0,0x0C,0x18,0x13,0xE4,0x14,0x24,0x17,0xC4,0x08,0x28,0x07,0xD0,0x00,0x00},/*"@",32*/
+ {0x00,0x04,0x00,0x3C,0x03,0xC4,0x1C,0x40,0x07,0x40,0x00,0xE4,0x00,0x1C,0x00,0x04},/*"A",33*/
+ {0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x04,0x11,0x04,0x0E,0x88,0x00,0x70,0x00,0x00},/*"B",34*/
+ {0x03,0xE0,0x0C,0x18,0x10,0x04,0x10,0x04,0x10,0x04,0x10,0x08,0x1C,0x10,0x00,0x00},/*"C",35*/
+ {0x10,0x04,0x1F,0xFC,0x10,0x04,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},/*"D",36*/
+ {0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x04,0x17,0xC4,0x10,0x04,0x08,0x18,0x00,0x00},/*"E",37*/
+ {0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x00,0x17,0xC0,0x10,0x00,0x08,0x00,0x00,0x00},/*"F",38*/
+ {0x03,0xE0,0x0C,0x18,0x10,0x04,0x10,0x04,0x10,0x44,0x1C,0x78,0x00,0x40,0x00,0x00},/*"G",39*/
+ {0x10,0x04,0x1F,0xFC,0x10,0x84,0x00,0x80,0x00,0x80,0x10,0x84,0x1F,0xFC,0x10,0x04},/*"H",40*/
+ {0x00,0x00,0x10,0x04,0x10,0x04,0x1F,0xFC,0x10,0x04,0x10,0x04,0x00,0x00,0x00,0x00},/*"I",41*/
+ {0x00,0x03,0x00,0x01,0x10,0x01,0x10,0x01,0x1F,0xFE,0x10,0x00,0x10,0x00,0x00,0x00},/*"J",42*/
+ {0x10,0x04,0x1F,0xFC,0x11,0x04,0x03,0x80,0x14,0x64,0x18,0x1C,0x10,0x04,0x00,0x00},/*"K",43*/
+ {0x10,0x04,0x1F,0xFC,0x10,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x0C,0x00,0x00},/*"L",44*/
+ {0x10,0x04,0x1F,0xFC,0x1F,0x00,0x00,0xFC,0x1F,0x00,0x1F,0xFC,0x10,0x04,0x00,0x00},/*"M",45*/
+ {0x10,0x04,0x1F,0xFC,0x0C,0x04,0x03,0x00,0x00,0xE0,0x10,0x18,0x1F,0xFC,0x10,0x00},/*"N",46*/
+ {0x07,0xF0,0x08,0x08,0x10,0x04,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},/*"O",47*/
+ {0x10,0x04,0x1F,0xFC,0x10,0x84,0x10,0x80,0x10,0x80,0x10,0x80,0x0F,0x00,0x00,0x00},/*"P",48*/
+ {0x07,0xF0,0x08,0x18,0x10,0x24,0x10,0x24,0x10,0x1C,0x08,0x0A,0x07,0xF2,0x00,0x00},/*"Q",49*/
+ {0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x00,0x11,0xC0,0x11,0x30,0x0E,0x0C,0x00,0x04},/*"R",50*/
+ {0x00,0x00,0x0E,0x1C,0x11,0x04,0x10,0x84,0x10,0x84,0x10,0x44,0x1C,0x38,0x00,0x00},/*"S",51*/
+ {0x18,0x00,0x10,0x00,0x10,0x04,0x1F,0xFC,0x10,0x04,0x10,0x00,0x18,0x00,0x00,0x00},/*"T",52*/
+ {0x10,0x00,0x1F,0xF8,0x10,0x04,0x00,0x04,0x00,0x04,0x10,0x04,0x1F,0xF8,0x10,0x00},/*"U",53*/
+ {0x10,0x00,0x1E,0x00,0x11,0xE0,0x00,0x1C,0x00,0x70,0x13,0x80,0x1C,0x00,0x10,0x00},/*"V",54*/
+ {0x1F,0xC0,0x10,0x3C,0x00,0xE0,0x1F,0x00,0x00,0xE0,0x10,0x3C,0x1F,0xC0,0x00,0x00},/*"W",55*/
+ {0x10,0x04,0x18,0x0C,0x16,0x34,0x01,0xC0,0x01,0xC0,0x16,0x34,0x18,0x0C,0x10,0x04},/*"X",56*/
+ {0x10,0x00,0x1C,0x00,0x13,0x04,0x00,0xFC,0x13,0x04,0x1C,0x00,0x10,0x00,0x00,0x00},/*"Y",57*/
+ {0x08,0x04,0x10,0x1C,0x10,0x64,0x10,0x84,0x13,0x04,0x1C,0x04,0x10,0x18,0x00,0x00},/*"Z",58*/
+ {0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFE,0x40,0x02,0x40,0x02,0x40,0x02,0x00,0x00},/*"[",59*/
+ {0x00,0x00,0x30,0x00,0x0C,0x00,0x03,0x80,0x00,0x60,0x00,0x1C,0x00,0x03,0x00,0x00},/*"\",60*/
+ {0x00,0x00,0x40,0x02,0x40,0x02,0x40,0x02,0x7F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00},/*"]",61*/
+ {0x00,0x00,0x00,0x00,0x20,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x00,0x00},/*"^",62*/
+ {0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01},/*"_",63*/
+ {0x00,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"`",64*/
+ {0x00,0x00,0x00,0x98,0x01,0x24,0x01,0x44,0x01,0x44,0x01,0x44,0x00,0xFC,0x00,0x04},/*"a",65*/
+ {0x10,0x00,0x1F,0xFC,0x00,0x88,0x01,0x04,0x01,0x04,0x00,0x88,0x00,0x70,0x00,0x00},/*"b",66*/
+ {0x00,0x00,0x00,0x70,0x00,0x88,0x01,0x04,0x01,0x04,0x01,0x04,0x00,0x88,0x00,0x00},/*"c",67*/
+ {0x00,0x00,0x00,0x70,0x00,0x88,0x01,0x04,0x01,0x04,0x11,0x08,0x1F,0xFC,0x00,0x04},/*"d",68*/
+ {0x00,0x00,0x00,0xF8,0x01,0x44,0x01,0x44,0x01,0x44,0x01,0x44,0x00,0xC8,0x00,0x00},/*"e",69*/
+ {0x00,0x00,0x01,0x04,0x01,0x04,0x0F,0xFC,0x11,0x04,0x11,0x04,0x11,0x00,0x18,0x00},/*"f",70*/
+ {0x00,0x00,0x00,0xD6,0x01,0x29,0x01,0x29,0x01,0x29,0x01,0xC9,0x01,0x06,0x00,0x00},/*"g",71*/
+ {0x10,0x04,0x1F,0xFC,0x00,0x84,0x01,0x00,0x01,0x00,0x01,0x04,0x00,0xFC,0x00,0x04},/*"h",72*/
+ {0x00,0x00,0x01,0x04,0x19,0x04,0x19,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00},/*"i",73*/
+ {0x00,0x00,0x00,0x03,0x00,0x01,0x01,0x01,0x19,0x01,0x19,0xFE,0x00,0x00,0x00,0x00},/*"j",74*/
+ {0x10,0x04,0x1F,0xFC,0x00,0x24,0x00,0x40,0x01,0xB4,0x01,0x0C,0x01,0x04,0x00,0x00},/*"k",75*/
+ {0x00,0x00,0x10,0x04,0x10,0x04,0x1F,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00},/*"l",76*/
+ {0x01,0x04,0x01,0xFC,0x01,0x04,0x01,0x00,0x01,0xFC,0x01,0x04,0x01,0x00,0x00,0xFC},/*"m",77*/
+ {0x01,0x04,0x01,0xFC,0x00,0x84,0x01,0x00,0x01,0x00,0x01,0x04,0x00,0xFC,0x00,0x04},/*"n",78*/
+ {0x00,0x00,0x00,0xF8,0x01,0x04,0x01,0x04,0x01,0x04,0x01,0x04,0x00,0xF8,0x00,0x00},/*"o",79*/
+ {0x01,0x01,0x01,0xFF,0x00,0x85,0x01,0x04,0x01,0x04,0x00,0x88,0x00,0x70,0x00,0x00},/*"p",80*/
+ {0x00,0x00,0x00,0x70,0x00,0x88,0x01,0x04,0x01,0x04,0x01,0x05,0x01,0xFF,0x00,0x01},/*"q",81*/
+ {0x01,0x04,0x01,0x04,0x01,0xFC,0x00,0x84,0x01,0x04,0x01,0x00,0x01,0x80,0x00,0x00},/*"r",82*/
+ {0x00,0x00,0x00,0xCC,0x01,0x24,0x01,0x24,0x01,0x24,0x01,0x24,0x01,0x98,0x00,0x00},/*"s",83*/
+ {0x00,0x00,0x01,0x00,0x01,0x00,0x07,0xF8,0x01,0x04,0x01,0x04,0x00,0x00,0x00,0x00},/*"t",84*/
+ {0x01,0x00,0x01,0xF8,0x00,0x04,0x00,0x04,0x00,0x04,0x01,0x08,0x01,0xFC,0x00,0x04},/*"u",85*/
+ {0x01,0x00,0x01,0x80,0x01,0x70,0x00,0x0C,0x00,0x10,0x01,0x60,0x01,0x80,0x01,0x00},/*"v",86*/
+ {0x01,0xF0,0x01,0x0C,0x00,0x30,0x01,0xC0,0x00,0x30,0x01,0x0C,0x01,0xF0,0x01,0x00},/*"w",87*/
+ {0x00,0x00,0x01,0x04,0x01,0x8C,0x00,0x74,0x01,0x70,0x01,0x8C,0x01,0x04,0x00,0x00},/*"x",88*/
+ {0x01,0x01,0x01,0x81,0x01,0x71,0x00,0x0E,0x00,0x18,0x01,0x60,0x01,0x80,0x01,0x00},/*"y",89*/
+ {0x00,0x00,0x01,0x84,0x01,0x0C,0x01,0x34,0x01,0x44,0x01,0x84,0x01,0x0C,0x00,0x00},/*"z",90*/
+ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x3E,0xFC,0x40,0x02,0x40,0x02},/*"{",91*/
+ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00},/*"|",92*/
+ {0x00,0x00,0x40,0x02,0x40,0x02,0x3E,0xFC,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"}",93*/
+ {0x00,0x00,0x60,0x00,0x80,0x00,0x80,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x20,0x00},/*"~",94*/
+};
+
+extern void SysCtlDelay(unsigned long ulCount);
+
+
+/**
+* @brief ʼ
+* @param
+* @retval
+*/
+void LCD_Init ( void )
+{
+ LMT028_Init ();
+}
+
+
+/**
+* @brief LMT028ʼõlcd Ҫøú
+* @param
+* @retval
+*/
+void LMT028_Init ( void )
+{
+ LMT028_GPIO_Config ();
+ LMT028_FSMC_Config ();
+
+ timer3_init();
+
+ LMT028_Rst ();
+ LMT028_REG_Config ();
+
+ Set_Pen_Color(LCD_red);
+ Set_Back_Color(LCD_black);
+}
+
+
+void LMT028_GPIO_Config ()
+{
+ GPIO_InitTypeDef GPIO_InitStructure;
+
+ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE,ENABLE);
+
+ /* ÿ
+ * PD14 :D0
+ * PD15 :D1
+ * PD0 :D2
+ * PD1 :D3
+ * PE7 :D4
+ * PE8 :D5
+ * PE9 :D6
+ * PE10 :D7
+ */
+
+ GPIO_InitStructure.GPIO_Pin=GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_14|GPIO_Pin_15;
+ GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
+ GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF;
+ GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
+ GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
+ GPIO_Init(GPIOD,&GPIO_InitStructure);
+
+ GPIO_PinAFConfig(GPIOD, GPIO_PinSource0 , GPIO_AF_FSMC);
+ GPIO_PinAFConfig(GPIOD, GPIO_PinSource1 , GPIO_AF_FSMC);
+ GPIO_PinAFConfig(GPIOD, GPIO_PinSource14 , GPIO_AF_FSMC);
+ GPIO_PinAFConfig(GPIOD, GPIO_PinSource15 , GPIO_AF_FSMC);
+
+
+ GPIO_InitStructure.GPIO_Pin=GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10;
+ GPIO_Init(GPIOE,&GPIO_InitStructure);
+
+ GPIO_PinAFConfig(GPIOE, GPIO_PinSource7 , GPIO_AF_FSMC);
+ GPIO_PinAFConfig(GPIOE, GPIO_PinSource8 , GPIO_AF_FSMC);
+ GPIO_PinAFConfig(GPIOE, GPIO_PinSource9 , GPIO_AF_FSMC);
+ GPIO_PinAFConfig(GPIOE, GPIO_PinSource10 , GPIO_AF_FSMC);
+
+ /* ÿ
+ * PD4-FSMC_NOE :LCD-RD
+ * PD5-FSMC_NWE :LCD-WR
+ * PD7-FSMC_NE1 :LCD-CS
+ * PD11-FSMC_A16 :LCD-DC
+ */
+
+
+ GPIO_InitStructure.GPIO_Pin=LCD_RD_Pin|LCD_WR_Pin|LCD_CS_Pin|LCD_DC_Pin;
+ GPIO_Init(GPIOD,&GPIO_InitStructure);
+
+ GPIO_PinAFConfig(GPIOD, GPIO_PinSource4 , GPIO_AF_FSMC);
+ GPIO_PinAFConfig(GPIOD, GPIO_PinSource5 , GPIO_AF_FSMC);
+ GPIO_PinAFConfig(GPIOD, GPIO_PinSource7 , GPIO_AF_FSMC);
+ GPIO_PinAFConfig(GPIOD, GPIO_PinSource11 , GPIO_AF_FSMC);
+
+ /* LCDλRSTý PC6*/
+ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC,ENABLE);
+ GPIO_InitStructure.GPIO_Pin=LCD_RST_Pin;
+ GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
+ GPIO_InitStructure.GPIO_Mode=GPIO_Mode_OUT;
+ GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
+ GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
+
+ GPIO_Init(GPIOC,&GPIO_InitStructure);
+
+
+ /* LCDBKý PC7*/
+
+ GPIO_PinAFConfig(GPIOC,LCD_BK_Pin,GPIO_AF_TIM3);
+
+ GPIO_InitStructure.GPIO_Pin=LCD_BK_Pin;
+ GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
+ GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF;
+ GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
+ GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
+
+ GPIO_Init(GPIOC,&GPIO_InitStructure);
+
+ /* Connect TIM3 pins to PC7 */
+ GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_TIM3);
+
+}
+
+
+
+void set_bk_value(uint16_t value)
+{
+ TIM_SetCompare2(TIM3,value);
+}
+
+
+/**
+* @brief LCD FSMC ģʽ
+* @param
+* @retval
+*/
+void LMT028_FSMC_Config ( void )
+{
+ FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
+ FSMC_NORSRAMTimingInitTypeDef readWriteTiming;
+
+ /* Enable FSMC clock */
+ RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE);
+
+
+ readWriteTiming.FSMC_AddressSetupTime = 0x02; //ַʱ䣨ADDSETΪ2HCLK 1/36M=27ns
+ readWriteTiming.FSMC_AddressHoldTime = 0x00; //ַʱ䣨ADDHLDģʽAδõ
+ readWriteTiming.FSMC_DataSetupTime = 0x05; // ݱʱΪ16HCLK,ΪҺICĶݵʱٶȲ̫죬1289IC
+ readWriteTiming.FSMC_BusTurnAroundDuration = 0x00;
+ readWriteTiming.FSMC_CLKDivision = 0x00;
+ readWriteTiming.FSMC_DataLatency = 0x00;
+ readWriteTiming.FSMC_AccessMode = FSMC_AccessMode_A; //ģʽA
+
+
+ FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;// ʹNE1 ҲͶӦBTCR[6],[7]
+ FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;// ݵַ
+ FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;// FSMC_MemoryType_SRAM; //SRAM
+ FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b;//洢ݿΪ8bit
+ FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;// FSMC_BurstAccessMode_Disable;
+ FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
+ FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
+ FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
+ FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
+ FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;// 洢дʹ
+ FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
+ FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;// дʹͬʱ
+ FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
+ FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readWriteTiming;//дʱ
+ FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &readWriteTiming;//дʱ
+
+
+ FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); //ʼFSMC
+
+ FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);
+}
+
+
+/**
+* @brief ΪLCDıPWM.
+* @param None
+* @retval None
+*/
+void timer3_init(void)
+{
+ TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
+ TIM_OCInitTypeDef TIM_OCInitStructure;
+
+ RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
+
+ TIM_TimeBaseStructure.TIM_Period = 500;
+ TIM_TimeBaseStructure.TIM_Prescaler = (uint16_t) ((SystemCoreClock /2) / 100000) - 1;
+ TIM_TimeBaseStructure.TIM_ClockDivision = 0;
+ TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
+
+ TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
+
+ /* PWM1 Mode configuration: Channel2 */
+ TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
+ TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
+ TIM_OCInitStructure.TIM_Pulse = 249;//CCR2_Val;
+ TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
+
+ TIM_OC2Init(TIM3, &TIM_OCInitStructure);
+
+ TIM_OC2PreloadConfig(TIM3, TIM_OCPreload_Enable);
+
+ TIM_Cmd(TIM3, ENABLE);
+
+}
+
+
+/**
+* @brief LMT028 λ
+* @param
+* @retval
+*/
+void LMT028_Rst ( void )
+{
+ GPIO_ResetBits ( LCD_RST_GPIO, LCD_RST_Pin );
+
+ Delay1ms(80);
+
+ GPIO_SetBits ( LCD_RST_GPIO, LCD_RST_Pin );
+
+ Delay1ms(80);
+}
+
+
+
+
+/**
+* @brief
+* @param X/Y:ʼ
+* @retval
+*/
+void set_coordinate(uint16_t x,uint16_t y )
+{
+ uint8_t x_l,x_h,y_l,y_h;
+
+ x_l=(x&0xff);
+ x_h=((x>>8)&0xff);
+ y_l=(y&0xff);
+ y_h=((y>>8)&0xff);
+
+ LMT028_Write_Cmd(0x2a);
+ LMT028_Write_Data(x_h);
+ LMT028_Write_Data(x_l);
+
+ LMT028_Write_Cmd(0x2b);
+ LMT028_Write_Data(y_h);
+ LMT028_Write_Data(y_l);
+}
+
+/**
+ * @brief ô
+ * @param X/Y:ʼ width height;߶
+ * @retval
+ */
+
+void set_windows(uint16_t X,uint16_t Y,uint16_t width,uint16_t height)
+{
+ uint8_t X_l,X_h,Y_l,Y_h;
+ uint8_t width_l,width_h,height_l,height_h;
+
+ X_l=(X&0xff);
+ X_h=((X>>8)&0xff);
+ Y_l=(Y&0xff);
+ Y_h=((Y>>8)&0xff);
+
+ width_l=((width+X)&0xff);
+ width_h=(((width+X)>>8)&0xff);
+ height_l=((height+Y)&0xff);
+ height_h=(((height+Y)>>8)&0xff);
+
+ // set column range as full screen
+ LMT028_Write_Cmd(0x2a);
+ LMT028_Write_Data(X_h);
+ LMT028_Write_Data(X_l);
+ LMT028_Write_Data(width_h);
+ LMT028_Write_Data(width_l);
+
+ // set row range as full screen
+ LMT028_Write_Cmd(0x2b);
+ LMT028_Write_Data(Y_h);
+ LMT028_Write_Data(Y_l);
+ LMT028_Write_Data(height_h);
+ LMT028_Write_Data(height_l);
+}
+
+/**
+ * @brief LMT028
+ * @param X/Y:ʼ width height;߶
+ * @retval
+ */
+void clear_lcd_area(uint16_t X,uint16_t Y,uint16_t width,uint16_t height)
+{
+ uint32_t dp_y;
+ uint32_t num;
+ set_windows(X,Y,width,height);
+ LMT028_Write_Cmd(0x2c);
+ num = width * height;
+ for(dp_y = 0;dp_y < num;dp_y++){
+ LMT028_Write_Data(0x00);
+ LMT028_Write_Data(0x00);
+ }
+}
+
+/**
+ * @brief ʼLMT028Ĵ
+ * @param
+ * @retval
+ */
+ void LMT028_REG_Config ( void )
+{
+ // LMT028_Rst();
+ LMT028_Write_Cmd ( 0x11 );
+ Delay1ms (150);
+
+//--------------------------------ST7789S Frame rate setting----------------------------------//
+ LMT028_Write_Cmd ( 0xB2 );
+ LMT028_Write_Data ( 0x0C );
+ LMT028_Write_Data ( 0x0C );
+ LMT028_Write_Data ( 0x00 );
+ LMT028_Write_Data ( 0x33 );
+ LMT028_Write_Data ( 0x33 );
+ LMT028_Write_Data ( 0xB7 );
+ LMT028_Write_Data ( 0x35 );
+
+////---------------------------------ST7789S Fmark setting--------------------------------------//
+//
+// LMT028_Write_Cmd ( 0xB3 );
+// LMT028_Write_Data ( 0x00 );
+// LMT028_Write_Data ( 0x0f );
+// LMT028_Write_Data ( 0x0f );
+//
+////
+// SysCtlDelay(500);
+// LMT028_Write_Cmd ( 0xC6 );
+// LMT028_Write_Data ( 0x1f);
+//
+//---------------------------------ST7789S Power setting--------------------------------------//
+ SysCtlDelay(500);
+ LMT028_Write_Cmd ( 0xBB);
+ LMT028_Write_Data ( 0x28 );
+
+ SysCtlDelay(500);
+ // mx,my,bgr,rev,ss,mh,mv,gs
+ LMT028_Write_Cmd ( 0xC0 );
+ LMT028_Write_Data ( 0x2C );
+
+ LMT028_Write_Cmd ( 0xC2 );
+ LMT028_Write_Data ( 0x0f );
+
+ SysCtlDelay(500);
+ //VRHS
+ LMT028_Write_Cmd ( 0xC3 );
+ LMT028_Write_Data ( 0x25);
+
+ SysCtlDelay(500);
+ //VDV SET
+ LMT028_Write_Cmd ( 0xC4 );
+ LMT028_Write_Data ( 0x20);
+
+ SysCtlDelay(500);
+ // FRCTR2
+ LMT028_Write_Cmd ( 0xC6 );
+ LMT028_Write_Data ( 0x0f);
+
+ SysCtlDelay(500);
+ //regsel2
+ LMT028_Write_Cmd (0xCA);
+ LMT028_Write_Data (0x0F );
+
+ SysCtlDelay(500);
+ //regsel1
+ LMT028_Write_Cmd ( 0xC8);
+ LMT028_Write_Data ( 0x08 );
+
+ SysCtlDelay(500);
+ // CABC
+ LMT028_Write_Cmd ( 0x55);
+ LMT028_Write_Data ( 0x90 );
+
+ SysCtlDelay(500);
+ //PWCTRL1
+ LMT028_Write_Cmd ( 0xd0);
+ LMT028_Write_Data ( 0xa4 );
+ LMT028_Write_Data ( 0xa1);
+
+ SysCtlDelay(500);
+ //--------------------------------ST7789S gamma setting---------------------------------------//
+ LMT028_Write_Cmd(0xe0);
+ LMT028_Write_Data(0xd0);
+ LMT028_Write_Data(0x03);
+ LMT028_Write_Data(0x08);
+ LMT028_Write_Data(0x0b);
+ LMT028_Write_Data(0x0f);
+ LMT028_Write_Data(0x2c);
+ LMT028_Write_Data(0x41);
+ LMT028_Write_Data(0x54);
+ LMT028_Write_Data(0x4e);
+ LMT028_Write_Data(0x07);
+ LMT028_Write_Data(0x0e);
+ LMT028_Write_Data(0x0c);
+ LMT028_Write_Data(0x1e);
+ LMT028_Write_Data(0x23);
+
+ SysCtlDelay(500);
+ LMT028_Write_Cmd(0xe1);
+ LMT028_Write_Data(0xd0);
+ LMT028_Write_Data(0x03);
+ LMT028_Write_Data(0x09);
+ LMT028_Write_Data(0x0b);
+ LMT028_Write_Data(0x0d);
+ LMT028_Write_Data(0x19);
+ LMT028_Write_Data(0x3c);
+ LMT028_Write_Data(0x54);
+ LMT028_Write_Data(0x4f);
+ LMT028_Write_Data(0x0e);
+ LMT028_Write_Data(0x1d);
+ LMT028_Write_Data(0x1c);
+ LMT028_Write_Data(0x20);
+ LMT028_Write_Data(0x22);
+
+ SysCtlDelay(500);
+ //65kɫ16bit
+ LMT028_Write_Cmd(0x3a);
+ LMT028_Write_Data(0x55);
+
+ SysCtlDelay(500);
+ //: MY=1, MX=1, MV=1(RowColEx), ML=0(normal), RGB=0(RGB)
+ LMT028_Write_Cmd(0x36);
+ //LMT028_Write_Data(0x60); //źұ ϵ
+ LMT028_Write_Data(0x60);
+
+ SysCtlDelay(500);
+ //˺Ӱ
+ LMT028_Write_Cmd(0x35);
+ LMT028_Write_Data(0x00);
+
+ SysCtlDelay(500);
+
+ //ʾ
+ LMT028_Write_Cmd(0x29);
+
+ SysCtlDelay(500);
+ clear_lcd_area(0,0,320,240);
+}
+
+
+/**
+* @brief lcdģʽ »渳ֵźΪұΪ
+* @param show_type ֵ
+* @retval
+*/
+
+void set_show_type(uint8_t show_type)
+{
+ switch(show_type)
+ {
+ //ϵ
+ case 1:
+ {
+ LMT028_Write_Cmd(0x36);
+ LMT028_Write_Data(0x60);
+ break;
+ }
+
+ //ϵ
+ case 2:
+ {
+ LMT028_Write_Cmd(0x36);
+ LMT028_Write_Data(0x40);
+ break;
+ }
+
+ //µ
+ case 3:
+ {
+ LMT028_Write_Cmd(0x36);
+ LMT028_Write_Data(0x00);
+ break;
+ }
+
+ //µ
+ case 4:
+ {
+ LMT028_Write_Cmd(0x36);
+ LMT028_Write_Data(0x80);
+ break;
+ }
+
+ }
+}
+
+
+/**
+* @brief Read the selected LCD register.
+* @param LCD_Reg: address of the selected register.
+* @retval LCD register value
+*/
+uint16_t LCD_ReadReg(uint8_t LCD_Reg)
+{
+ uint16_t data;
+ data = LCD->LCD_CMD;
+ return data;
+}
+
+
+
+/**
+* @brief LMT028д
+* @param usData :ҪдĴַ
+* @retval
+*/
+void LMT028_Write_Cmd ( uint8_t usCmd )
+{
+ LCD->LCD_CMD=usCmd;
+}
+
+
+/**
+* @brief LMT028д
+* @param usData :ҪдݣĴַ
+* @retval
+*/
+void LMT028_Write_Data ( uint8_t usData )
+{
+ LCD->LCD_DATA = usData;
+}
+/*!
+* @brief ûɫ
+* @param Pen_Color ɫ
+* @return NONE
+* @note NONE
+*/
+void Set_Pen_Color(uint16_t Pen_Color )
+{
+ POINT_COLOR=Pen_Color;
+}
+
+/*!
+* @brief ñɫ
+* @param Back_Color ɫ
+* @return NONE
+* @note NONE
+*/
+void Set_Back_Color(uint16_t Pen_Color)
+{
+ BACK_COLOR=Pen_Color;
+}
+
+/*!
+* @brief
+* @param x x
+* @param y y
+* @param color ɫ
+* @return NONE
+* @note NONE
+*/
+void LCD_DrawPoint(uint16_t x,uint16_t y,uint16_t color)
+{
+ uint8_t color_h,color_l;
+
+ color_h=(color>>8)&0xff;
+ color_l=color&0xff;
+
+ set_coordinate(x,y);//ùλ
+
+ LMT028_Write_Cmd(0x2c);
+ LMT028_Write_Data(color_h);
+ LMT028_Write_Data(color_l);
+}
+
+/*!
+* @brief
+* @param x1,y1:
+* @param x2,y2:
+* @param color:ɫ
+* @return NONE
+*/
+void LCD_DrawLine(u16 x1,u16 y1,u16 x2,u16 y2,u16 color)
+{
+ u16 t;
+ int xerr=0,yerr=0,delta_x,delta_y,distance;
+ int incx,incy,uRow,uCol;
+ delta_x=x2-x1; //
+ delta_y=y2-y1;
+ uRow=x1;
+ uCol=y1;
+ if(delta_x>0)
+ incx=1; //õ
+ else if(delta_x==0)
+ incx=0;//ֱ
+ else
+ {
+ incx=-1;
+ delta_x=-delta_x;
+ }
+ if(delta_y>0)incy=1;
+ else if(delta_y==0)
+ incy=0;//ˮƽ
+ else
+ {
+ incy=-1;
+ delta_y=-delta_y;
+ }
+ if( delta_x>delta_y)
+ distance=delta_x; //ѡȡ
+ else
+ distance=delta_y;
+ for(t=0;t<=distance+1;t++ )//
+ {
+ LCD_DrawPoint(uRow,uCol,color);//
+ xerr+=delta_x ;
+ yerr+=delta_y ;
+ if(xerr>distance)
+ {
+ xerr-=distance;
+ uRow+=incx;
+ }
+ if(yerr>distance)
+ {
+ yerr-=distance;
+ uCol+=incy;
+ }
+ }
+}
+
+
+/*!
+* @brief ʾַ
+* @param x,y:
+* @param width,height:С
+* @param *s:ַʼַ
+* @return NONE
+*/
+void LCD_ShowString(uint16_t x,uint16_t y, char *s)
+{
+ char x0=x;
+ while((*s<='~')&&(*s>=' '))//жDzǷǷַ
+ {
+ if(x>=320)
+ {
+ x=x0;y+=16;
+ }
+ if(y>=240)
+ break;//˳
+ LCD_ShowChar(x,y,*s,16,0);
+ x+=16/2;
+ s++;
+ }
+}
+
+/*!
+* @brief ƶλʾһַ
+* @param P ʼԼȸ߶
+* @param num:Ҫʾַ
+* @param size:С 12/16/24
+* @param mode:ӷʽ1 ǵӷʽ0
+* @return NONE
+*/
+void LCD_ShowChar(uint16_t x,uint16_t y,uint16_t num,uint16_t size,uint16_t mode)
+{
+ uint16_t temp,t1,t;
+ uint16_t y0=y;
+ uint16_t csize=(size/8+((size%8)?1:0))*(size/2); //õһַӦռֽ
+ num=num-' ';//õƫƺֵ
+ for(t=0;t
+
+
+ 1.0
+
+ ### uVision Project, (C) Keil Software
+
+
+ *.c
+ *.s*; *.src; *.a*
+ *.obj; *.o
+ *.lib
+ *.txt; *.h; *.inc
+ *.plm
+ *.cpp
+ 0
+
+
+
+ 0
+ 0
+
+
+
+ SPI
+ 0x4
+ ARM-ADS
+
+ 25000000
+
+ 1
+ 0
+ 1
+ 0
+ 0
+
+
+ 1
+ 65535
+ 0
+ 0
+ 0
+
+
+ 79
+ 66
+ 8
+ .\STM32F207VC\
+
+
+ 1
+ 1
+ 1
+ 0
+ 1
+ 1
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+
+
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 0
+ 0
+
+
+ 1
+ 0
+ 1
+
+ 255
+
+
+ 0
+ Data Sheet
+ DATASHTS\ST\STM32F2xx\CD00237391.PDF
+
+
+ 1
+ Reference Manual
+ DATASHTS\ST\STM32F2xx\CD00225773.PDF
+
+
+ 2
+ Technical Reference Manual
+ datashts\arm\cortex_m3\r2p0\DDI0337G_CORTEX_M3_R2P0_TRM.PDF
+
+
+ 3
+ Generic User Guide
+ datashts\arm\cortex_m3\r2p1\DUI0552A_CORTEX_M3_DGUG.PDF
+
+
+
+ 0
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 0
+ 1
+ 0
+ 1
+ 1
+ 0
+ 0
+ 1
+ 0
+ 0
+ 4
+
+
+
+
+
+
+
+
+
+
+ Segger\JL2CM3.dll
+
+
+
+ 0
+ DLGUARM
+
+
+
+ 0
+ ARMRTXEVENTFLAGS
+ -L70 -Z18 -C0 -M0 -T1
+
+
+ 0
+ JL2CM3
+ -U4294967295 -O2255 -S2 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(4) -TO18 -TC10000000 -TP21 -TDS8004 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC800 -FN1 -FF0STM32F2xx_1024 -FS08000000 -FL040000
+
+
+ 0
+ DLGTARM
+ (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)
+
+
+ 0
+ ARMDBGFLAGS
+
+
+
+ 0
+ UL2CM3
+ -UM0045BJE -O2191 -S0 -C0 -N00("ARM CoreSight JTAG-DP") -D00(4BA00477) -L00(4) -N01("Unknown JTAG device") -D01(06411041) -L01(5) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FN1 -FC800 -FD20000000 -FF0STM32F2xx_1024 -FL040000 -FS08000000
+
+
+
+
+
+ 0
+ 1
+ type
+
+
+
+
+ 1
+ 2
+ 0x40021000
+ 0
+
+
+
+
+ 2
+ 2
+ 0x40013800
+ 0
+
+
+
+
+ 3
+ 2
+ 0xE000E100
+ 0
+
+
+
+ 0
+
+
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+
+ 0
+ 0
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+ CMSIS
+ 1
+ 0
+ 0
+ 0
+
+ 1
+ 1
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\CMSIS\Device\ST\STM32F2xx\Source\Templates\system_stm32f2xx.c
+ system_stm32f2xx.c
+ 0
+ 0
+
+
+
+
+ STM32F2xx_StdPeriph_Driver
+ 0
+ 0
+ 0
+ 0
+
+ 2
+ 2
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\misc.c
+ misc.c
+ 0
+ 0
+
+
+ 2
+ 3
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_adc.c
+ stm32f2xx_adc.c
+ 0
+ 0
+
+
+ 2
+ 4
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_can.c
+ stm32f2xx_can.c
+ 0
+ 0
+
+
+ 2
+ 5
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_crc.c
+ stm32f2xx_crc.c
+ 0
+ 0
+
+
+ 2
+ 6
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_cryp.c
+ stm32f2xx_cryp.c
+ 0
+ 0
+
+
+ 2
+ 7
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_cryp_aes.c
+ stm32f2xx_cryp_aes.c
+ 0
+ 0
+
+
+ 2
+ 8
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_cryp_des.c
+ stm32f2xx_cryp_des.c
+ 0
+ 0
+
+
+ 2
+ 9
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_cryp_tdes.c
+ stm32f2xx_cryp_tdes.c
+ 0
+ 0
+
+
+ 2
+ 10
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_dac.c
+ stm32f2xx_dac.c
+ 0
+ 0
+
+
+ 2
+ 11
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_dbgmcu.c
+ stm32f2xx_dbgmcu.c
+ 0
+ 0
+
+
+ 2
+ 12
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_dcmi.c
+ stm32f2xx_dcmi.c
+ 0
+ 0
+
+
+ 2
+ 13
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_dma.c
+ stm32f2xx_dma.c
+ 0
+ 0
+
+
+ 2
+ 14
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_exti.c
+ stm32f2xx_exti.c
+ 0
+ 0
+
+
+ 2
+ 15
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_flash.c
+ stm32f2xx_flash.c
+ 0
+ 0
+
+
+ 2
+ 16
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_fsmc.c
+ stm32f2xx_fsmc.c
+ 0
+ 0
+
+
+ 2
+ 17
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_gpio.c
+ stm32f2xx_gpio.c
+ 0
+ 0
+
+
+ 2
+ 18
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_hash.c
+ stm32f2xx_hash.c
+ 0
+ 0
+
+
+ 2
+ 19
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_hash_md5.c
+ stm32f2xx_hash_md5.c
+ 0
+ 0
+
+
+ 2
+ 20
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_hash_sha1.c
+ stm32f2xx_hash_sha1.c
+ 0
+ 0
+
+
+ 2
+ 21
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_i2c.c
+ stm32f2xx_i2c.c
+ 0
+ 0
+
+
+ 2
+ 22
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_iwdg.c
+ stm32f2xx_iwdg.c
+ 0
+ 0
+
+
+ 2
+ 23
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_pwr.c
+ stm32f2xx_pwr.c
+ 0
+ 0
+
+
+ 2
+ 24
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_rcc.c
+ stm32f2xx_rcc.c
+ 0
+ 0
+
+
+ 2
+ 25
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_rng.c
+ stm32f2xx_rng.c
+ 0
+ 0
+
+
+ 2
+ 26
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_rtc.c
+ stm32f2xx_rtc.c
+ 0
+ 0
+
+
+ 2
+ 27
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_sdio.c
+ stm32f2xx_sdio.c
+ 0
+ 0
+
+
+ 2
+ 28
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_spi.c
+ stm32f2xx_spi.c
+ 0
+ 0
+
+
+ 2
+ 29
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_syscfg.c
+ stm32f2xx_syscfg.c
+ 0
+ 0
+
+
+ 2
+ 30
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_tim.c
+ stm32f2xx_tim.c
+ 0
+ 0
+
+
+ 2
+ 31
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_usart.c
+ stm32f2xx_usart.c
+ 0
+ 0
+
+
+ 2
+ 32
+ 1
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_wwdg.c
+ stm32f2xx_wwdg.c
+ 0
+ 0
+
+
+
+
+ MDK-ARM
+ 1
+ 0
+ 0
+ 0
+
+ 3
+ 33
+ 2
+ 0
+ 0
+ 0
+ ..\..\01-Libraries\CMSIS\Device\ST\STM32F2xx\Source\Templates\arm\startup_stm32f2xx.s
+ startup_stm32f2xx.s
+ 0
+ 0
+
+
+
+
+ User
+ 1
+ 0
+ 0
+ 0
+
+ 4
+ 34
+ 1
+ 0
+ 0
+ 0
+ ..\main.c
+ main.c
+ 0
+ 0
+
+
+ 4
+ 35
+ 1
+ 0
+ 0
+ 0
+ ..\stm32f2xx_it.c
+ stm32f2xx_it.c
+ 0
+ 0
+
+
+ 4
+ 36
+ 1
+ 0
+ 0
+ 0
+ ..\LCD_disp.c
+ LCD_disp.c
+ 0
+ 0
+
+
+ 4
+ 37
+ 1
+ 0
+ 0
+ 0
+ ..\Ex_Flash.c
+ Ex_Flash.c
+ 0
+ 0
+
+
+
+
diff --git a/12-SPI-Simulation/MDK-ARM/Project.uvproj b/12-SPI-Simulation/MDK-ARM/Project.uvproj
new file mode 100644
index 0000000..1ef2b10
--- /dev/null
+++ b/12-SPI-Simulation/MDK-ARM/Project.uvproj
@@ -0,0 +1,629 @@
+
+
+
+ 1.1
+
+ ### uVision Project, (C) Keil Software
+
+
+
+ SPI
+ 0x4
+ ARM-ADS
+ 5060750::V5.06 update 6 (build 750)::ARMCC
+ 0
+
+
+ STM32F207VC
+ STMicroelectronics
+ IRAM(0x20000000-0x2001FFFF) IROM(0x8000000-0x803FFFF) CLOCK(25000000) CPUTYPE("Cortex-M3")
+
+ "STARTUP\ST\STM32F2xx\startup_stm32f2xx.s" ("STM32F2xx Startup Code")
+ UL2CM3(-O14 -S0 -C0 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F2xx_1024 -FS08000000 -FL040000)
+ 5102
+ stm32f2xx.h
+
+
+
+
+
+
+
+
+
+ SFD\ST\STM32F2xx\STM32F20x.sfr
+ 0
+ 0
+
+
+
+ ST\STM32F2xx\
+ ST\STM32F2xx\
+
+ 0
+ 0
+ 0
+ 0
+ 1
+
+ .\STM32F207VC\
+ STM32F207VC
+ 1
+ 0
+ 0
+ 1
+ 1
+ .\STM32F207VC\
+ 1
+ 0
+ 0
+
+ 0
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+ 0
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+ 0
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+
+ 0
+
+
+
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 3
+
+
+ 1
+
+
+ SARMCM3.DLL
+ -MPU -REMAP
+ DCM.DLL
+ -pCM3
+ SARMCM3.DLL
+ -MPU
+ TCM.DLL
+ -pCM3
+
+
+
+ 1
+ 0
+ 0
+ 0
+ 16
+
+
+ 0
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 0
+ 1
+
+
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 0
+ 1
+ 0
+ 1
+
+ 0
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Segger\JL2CM3.dll
+
+
+
+
+ 1
+ 0
+ 0
+ 1
+ 1
+ 4100
+
+ 0
+ Segger\JL2CM3.dll
+ "" ()
+
+
+
+
+ 0
+
+
+
+ 0
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 0
+ 1
+ 1
+ 0
+ 1
+ 1
+ 0
+ 0
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 0
+ 0
+ "Cortex-M3"
+
+ 0
+ 0
+ 0
+ 1
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 8
+ 1
+ 0
+ 0
+ 0
+ 3
+ 3
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+
+
+ 0
+ 0x0
+ 0x0
+
+
+ 0
+ 0x0
+ 0x0
+
+
+ 0
+ 0x0
+ 0x0
+
+
+ 0
+ 0x0
+ 0x0
+
+
+ 0
+ 0x0
+ 0x0
+
+
+ 0
+ 0x0
+ 0x0
+
+
+ 0
+ 0x20000000
+ 0x20000
+
+
+ 1
+ 0x8000000
+ 0x40000
+
+
+ 0
+ 0x0
+ 0x0
+
+
+ 1
+ 0x0
+ 0x0
+
+
+ 1
+ 0x0
+ 0x0
+
+
+ 1
+ 0x0
+ 0x0
+
+
+ 1
+ 0x8000000
+ 0x40000
+
+
+ 1
+ 0x0
+ 0x0
+
+
+ 0
+ 0x0
+ 0x0
+
+
+ 0
+ 0x0
+ 0x0
+
+
+ 0
+ 0x0
+ 0x0
+
+
+ 0
+ 0x20000000
+ 0x20000
+
+
+ 0
+ 0x0
+ 0x0
+
+
+
+
+
+ 1
+ 1
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 2
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 1
+ 1
+ 1
+ 0
+ 0
+ 0
+
+
+ USE_STDPERIPH_DRIVER,STM32F2XX,
+
+ ..\..\01-Libraries\CMSIS\Include;..\..\01-Libraries\CMSIS\Device\ST\STM32F2xx\Include;..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\inc;..\
+
+
+
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+
+
+
+
+
+
+ 1
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0x08000000
+ 0x20000000
+
+
+
+
+
+
+
+
+
+
+
+
+ CMSIS
+
+
+ system_stm32f2xx.c
+ 1
+ ..\..\01-Libraries\CMSIS\Device\ST\STM32F2xx\Source\Templates\system_stm32f2xx.c
+
+
+
+
+ STM32F2xx_StdPeriph_Driver
+
+
+ misc.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\misc.c
+
+
+ stm32f2xx_adc.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_adc.c
+
+
+ stm32f2xx_can.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_can.c
+
+
+ stm32f2xx_crc.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_crc.c
+
+
+ stm32f2xx_cryp.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_cryp.c
+
+
+ stm32f2xx_cryp_aes.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_cryp_aes.c
+
+
+ stm32f2xx_cryp_des.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_cryp_des.c
+
+
+ stm32f2xx_cryp_tdes.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_cryp_tdes.c
+
+
+ stm32f2xx_dac.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_dac.c
+
+
+ stm32f2xx_dbgmcu.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_dbgmcu.c
+
+
+ stm32f2xx_dcmi.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_dcmi.c
+
+
+ stm32f2xx_dma.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_dma.c
+
+
+ stm32f2xx_exti.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_exti.c
+
+
+ stm32f2xx_flash.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_flash.c
+
+
+ stm32f2xx_fsmc.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_fsmc.c
+
+
+ stm32f2xx_gpio.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_gpio.c
+
+
+ stm32f2xx_hash.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_hash.c
+
+
+ stm32f2xx_hash_md5.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_hash_md5.c
+
+
+ stm32f2xx_hash_sha1.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_hash_sha1.c
+
+
+ stm32f2xx_i2c.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_i2c.c
+
+
+ stm32f2xx_iwdg.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_iwdg.c
+
+
+ stm32f2xx_pwr.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_pwr.c
+
+
+ stm32f2xx_rcc.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_rcc.c
+
+
+ stm32f2xx_rng.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_rng.c
+
+
+ stm32f2xx_rtc.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_rtc.c
+
+
+ stm32f2xx_sdio.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_sdio.c
+
+
+ stm32f2xx_spi.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_spi.c
+
+
+ stm32f2xx_syscfg.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_syscfg.c
+
+
+ stm32f2xx_tim.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_tim.c
+
+
+ stm32f2xx_usart.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_usart.c
+
+
+ stm32f2xx_wwdg.c
+ 1
+ ..\..\01-Libraries\STM32F2xx_StdPeriph_Driver\src\stm32f2xx_wwdg.c
+
+
+
+
+ MDK-ARM
+
+
+ startup_stm32f2xx.s
+ 2
+ ..\..\01-Libraries\CMSIS\Device\ST\STM32F2xx\Source\Templates\arm\startup_stm32f2xx.s
+
+
+
+
+ User
+
+
+ main.c
+ 1
+ ..\main.c
+
+
+ stm32f2xx_it.c
+ 1
+ ..\stm32f2xx_it.c
+
+
+ LCD_disp.c
+ 1
+ ..\LCD_disp.c
+
+
+ Ex_Flash.c
+ 1
+ ..\Ex_Flash.c
+
+
+
+
+
+
+
+
diff --git a/12-SPI-Simulation/README.md b/12-SPI-Simulation/README.md
new file mode 100644
index 0000000..24f7236
--- /dev/null
+++ b/12-SPI-Simulation/README.md
@@ -0,0 +1,3 @@
+# SPI-Simulation
+
+用模拟SPI读取norflash
diff --git a/12-SPI-Simulation/main.c b/12-SPI-Simulation/main.c
new file mode 100644
index 0000000..02cfad3
--- /dev/null
+++ b/12-SPI-Simulation/main.c
@@ -0,0 +1,321 @@
+/**
+ ******************************************************************************
+ * @file Project/STM32F2xx_StdPeriph_Template/main.c
+ * @author MCD Application Team
+ * @version V1.1.0
+ * @date 13-April-2012
+ * @brief Main program body
+ ******************************************************************************
+ * @attention
+ *
+ * © COPYRIGHT 2012 STMicroelectronics
+ *
+ * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.st.com/software_license_agreement_liberty_v2
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "main.h"
+#include "LCD_disp.h"
+#include "Ex_Flash.h"
+
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+static __IO uint32_t TimingDelay;
+
+void FLASH_GPIO_Init(void);
+void FLASH_SPIInit(void);
+
+extern EX_Flash_struct EX_Flash;
+
+
+void SysCtlDelay(unsigned long ulCount);
+
+
+#define MSPI_MOSI_H() GPIO_SetBits(GPIOB, GPIO_Pin_5)
+#define MSPI_MOSI_L() GPIO_ResetBits(GPIOB, GPIO_Pin_5)
+
+#define MSPI_CLK_H() GPIO_SetBits(GPIOA, GPIO_Pin_5)
+#define MSPI_CLK_L() GPIO_ResetBits(GPIOA, GPIO_Pin_5)
+
+#define MSPI_READ_IN() GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_6)
+
+#define MSPI_DELAY() SysCtlDelay(1) //!<ԼΪ Kb/s 1000*30
+
+/* Private function prototypes -----------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+/**
+ * @brief Main program.
+ * @param None
+ * @retval None
+ */
+int main(void)
+{
+ RCC_ClocksTypeDef RCC_Clocks;
+ GPIO_InitTypeDef GPIO_Init_s;
+ uint8_t uid[8];
+ uint32_t RDID_data;
+ uint32_t i;
+
+ uint8_t buf[200];
+ char str[200];
+
+ /* SysTickΪ1ms */
+ RCC_GetClocksFreq(&RCC_Clocks);
+ SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);
+
+ /* ʹGPIOE˿ʱ */
+ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE);
+
+ /* LEDܽ */
+ GPIO_Init_s.GPIO_Pin = GPIO_Pin_4;
+ GPIO_Init_s.GPIO_Mode = GPIO_Mode_OUT;
+ GPIO_Init_s.GPIO_OType = GPIO_OType_PP;
+ GPIO_Init_s.GPIO_Speed = GPIO_Speed_50MHz;
+ GPIO_Init_s.GPIO_PuPd = GPIO_PuPd_UP;
+ GPIO_Init(GPIOE, &GPIO_Init_s);
+
+ LCD_Init();
+ FLASH_SPIInit();
+ EX_FLASH_init();//ȵ1ΣȡFlashϢ
+
+ Ex_FLASH_ReadUID(uid);
+ sprintf(str,"UID of NOR Flash : %x%x%x%x%x%x%x%x\r\n",uid[0],uid[1],uid[2],uid[3],uid[4],uid[5],uid[6],uid[7]);
+ LCD_ShowString(0,16*0,(char*)str);
+
+ RDID_data = Ex_FLASH_ReadID();
+ sprintf(str,"RDID of NOR Flash : %x",RDID_data);
+ LCD_ShowString(0,16*1,(char*)str);
+
+ switch(EX_Flash.Flash_stype){
+ case Winbond_Flash:
+ sprintf(str,"Manufactor of NOR Flash is Winbond_Flash");
+ break;
+ case GD_Flash:
+ sprintf(str,"Manufactor of NOR Flash is Winbond_Flash");
+ break;
+ default:
+ sprintf(str,"Manufactor of NOR Flash is not know");
+ break;
+ }
+
+ LCD_ShowString(0,16*3,(char*)str);
+
+ switch(EX_Flash.Flash_Memory){
+ case Flash_2M:
+ sprintf(str,"Capacity of NOR Flash is 2M");
+ break;
+ case Flash_4M:
+ sprintf(str,"Capacity of NOR Flash is 4M");
+ break;
+ default:
+ sprintf(str,"Capacity of NOR Flash is not know");
+ break;
+ }
+ LCD_ShowString(0,16*4,(char*)str);
+
+
+ for(i=0;i<50;i++){
+ buf[i]='A';
+ }
+
+ ExFlash_Erase_Sec(0);
+ LCD_ShowString(0,16*6,"Erase sector 0");
+
+ ExFlash_WR_NByte(0,buf, 50);
+ LCD_ShowString(0,16*7,"Write 50 A to sector 0");
+
+ for(i=0;i<60;i++){
+ buf[i]=0x00;
+ }
+
+ ExFlash_RD(0,buf,50);
+ sprintf(str,"%s",buf);
+ LCD_ShowString(0,16*8,"The data read by sector 0 is ");
+ LCD_ShowString(0,16*9,(char*)str);
+
+ while (1)
+ {
+ GPIO_SetBits(GPIOE,GPIO_Pin_4); //ϨLED
+ Delay(500); //ʱ500ms
+ GPIO_ResetBits(GPIOE,GPIO_Pin_4);//LED
+ Delay(500); //ʱ500ms
+ }
+}
+
+/**
+ * @brief Sends a byte through the SPI interface and return the byte received
+ * from the SPI bus.
+ * @param byte: byte to send.
+ * @retval The value of the received byte.
+ */
+uint8_t SPI_ReadWriteByte(uint8_t data)
+{
+ uint8_t i,data_read = 0;
+ if(data!=0xA5){
+ for(i=0;i<8;i++){
+ MSPI_CLK_L();
+ if(data&0x80){
+ MSPI_MOSI_H();
+ }else{
+ MSPI_MOSI_L();
+ }
+ MSPI_DELAY();
+ data = data<<1;
+ MSPI_CLK_H();
+ MSPI_DELAY();
+ }
+ return data_read;
+ }else{
+ for(i=0;i<8;i++){
+ MSPI_CLK_L();
+ MSPI_DELAY();
+ data_read = data_read<<1;
+ MSPI_CLK_H();
+ if(MSPI_READ_IN()){
+ data_read |= 0x01;
+ }
+ MSPI_DELAY();
+ }
+ return data_read;
+ }
+}
+
+/**
+ * @brief Initializes the peripherals used by the SPI FLASH driver.
+ * @param None
+ * @retval None
+ */
+void FLASH_GPIO_Init(void)
+{
+ GPIO_InitTypeDef GPIO_InitStructure;
+
+ /*!< Enable GPIO clocks */
+ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
+ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
+ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE);
+
+ /*!< Configure sFLASH Card CS pin in output pushpull mode */
+ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
+ GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
+ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+ GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
+ GPIO_Init(GPIOE, &GPIO_InitStructure);
+
+ /*!< SPI SCK pin configuration */
+ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
+ GPIO_Init(GPIOA, &GPIO_InitStructure);
+ MSPI_CLK_H();
+
+ /*!< SPI MOSI pin configuration */
+ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
+ GPIO_Init(GPIOB, &GPIO_InitStructure);
+ MSPI_MOSI_H();
+
+ /*!< SPI MISO pin configuration */
+ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
+ GPIO_Init(GPIOA, &GPIO_InitStructure);
+}
+
+/**
+ * @brief Initializes the peripherals used by the SPI FLASH driver.
+ * @param None
+ * @retval None
+ */
+void FLASH_SPIInit(void)
+{
+
+ FLASH_GPIO_Init();
+
+ /*!< Deselect the FLASH: Chip Select high */
+ GPIO_SetBits(GPIOE,GPIO_Pin_12);
+}
+/**
+ * @brief Inserts a delay time.
+ * @param nTime: specifies the delay time length, in 10 ms.
+ * @retval None
+ */
+void Delay(__IO uint32_t nTime)
+{
+ TimingDelay = nTime;
+
+ while(TimingDelay != 0);
+}
+
+/**
+ * @brief Decrements the TimingDelay variable.
+ * @param None
+ * @retval None
+ */
+void TimingDelay_Decrement(void)
+{
+ if (TimingDelay != 0x00)
+ {
+ TimingDelay--;
+ }
+}
+
+
+/*120MhzʱʱulCountΪ1ʱʱ3ʱӣʱ=3*1/120us=1/40us*/
+/*
+SystemCoreClock=120000000
+
+usʱ,ʱn
+SysCtlDelay(n*(SystemCoreClock/3000000));
+
+msʱ,ʱn
+SysCtlDelay(n*(SystemCoreClock/3000));
+
+mʱ,ʱn
+SysCtlDelay(n*(SystemCoreClock/3));
+*/
+
+#if defined (__CC_ARM) /*!< ARM Compiler */
+__asm void
+SysCtlDelay(unsigned long ulCount)
+{
+ subs r0, #1;
+ bne SysCtlDelay;
+ bx lr;
+}
+#elif defined ( __ICCARM__ ) /*!< IAR Compiler */
+void
+SysCtlDelay(unsigned long ulCount)
+{
+ __asm(" subs r0, #1\n"
+ " bne.n SysCtlDelay\n"
+ " bx lr");
+}
+
+#elif defined (__GNUC__) /*!< GNU Compiler */
+void __attribute__((naked))
+SysCtlDelay(unsigned long ulCount)
+{
+ __asm(" subs r0, #1\n"
+ " bne SysCtlDelay\n"
+ " bx lr");
+}
+
+#elif defined (__TASKING__) /*!< TASKING Compiler */
+/**/
+#endif /* __CC_ARM */
+
+/**
+ * @}
+ */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/12-SPI-Simulation/main.h b/12-SPI-Simulation/main.h
new file mode 100644
index 0000000..930e8df
--- /dev/null
+++ b/12-SPI-Simulation/main.h
@@ -0,0 +1,45 @@
+/**
+ ******************************************************************************
+ * @file Project/STM32F2xx_StdPeriph_Template/main.h
+ * @author MCD Application Team
+ * @version V1.1.0
+ * @date 13-April-2012
+ * @brief Header for main.c module
+ ******************************************************************************
+ * @attention
+ *
+ * © COPYRIGHT 2012 STMicroelectronics
+ *
+ * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.st.com/software_license_agreement_liberty_v2
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __MAIN_H
+#define __MAIN_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f2xx.h"
+#include
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions ------------------------------------------------------- */
+void TimingDelay_Decrement(void);
+void Delay(__IO uint32_t nTime);
+
+#endif /* __MAIN_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/12-SPI-Simulation/stm32f2xx_conf.h b/12-SPI-Simulation/stm32f2xx_conf.h
new file mode 100644
index 0000000..8b1e7b5
--- /dev/null
+++ b/12-SPI-Simulation/stm32f2xx_conf.h
@@ -0,0 +1,94 @@
+/**
+ ******************************************************************************
+ * @file Project/STM32F2xx_StdPeriph_Template/stm32f2xx_conf.h
+ * @author MCD Application Team
+ * @version V1.1.0
+ * @date 13-April-2012
+ * @brief Library configuration file.
+ ******************************************************************************
+ * @attention
+ *
+ * © COPYRIGHT 2012 STMicroelectronics
+ *
+ * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.st.com/software_license_agreement_liberty_v2
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F2xx_CONF_H
+#define __STM32F2xx_CONF_H
+
+/* Includes ------------------------------------------------------------------*/
+/* Uncomment the line below to enable peripheral header file inclusion */
+#include "stm32f2xx_adc.h"
+#include "stm32f2xx_can.h"
+#include "stm32f2xx_crc.h"
+#include "stm32f2xx_cryp.h"
+#include "stm32f2xx_dac.h"
+#include "stm32f2xx_dbgmcu.h"
+#include "stm32f2xx_dcmi.h"
+#include "stm32f2xx_dma.h"
+#include "stm32f2xx_exti.h"
+#include "stm32f2xx_flash.h"
+#include "stm32f2xx_fsmc.h"
+#include "stm32f2xx_hash.h"
+#include "stm32f2xx_gpio.h"
+#include "stm32f2xx_i2c.h"
+#include "stm32f2xx_iwdg.h"
+#include "stm32f2xx_pwr.h"
+#include "stm32f2xx_rcc.h"
+#include "stm32f2xx_rng.h"
+#include "stm32f2xx_rtc.h"
+#include "stm32f2xx_sdio.h"
+#include "stm32f2xx_spi.h"
+#include "stm32f2xx_syscfg.h"
+#include "stm32f2xx_tim.h"
+#include "stm32f2xx_usart.h"
+#include "stm32f2xx_wwdg.h"
+#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* If an external clock source is used, then the value of the following define
+ should be set to the value of the external clock source, else, if no external
+ clock is used, keep this define commented */
+/*#define I2S_EXTERNAL_CLOCK_VAL 12288000 */ /* Value of the external clock in Hz */
+
+
+/* Uncomment the line below to expanse the "assert_param" macro in the
+ Standard Peripheral Library drivers code */
+/* #define USE_FULL_ASSERT 1 */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr: If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0)
+#endif /* USE_FULL_ASSERT */
+
+#endif /* __STM32F2xx_CONF_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/12-SPI-Simulation/stm32f2xx_it.c b/12-SPI-Simulation/stm32f2xx_it.c
new file mode 100644
index 0000000..acec750
--- /dev/null
+++ b/12-SPI-Simulation/stm32f2xx_it.c
@@ -0,0 +1,168 @@
+/**
+ ******************************************************************************
+ * @file Project/STM32F2xx_StdPeriph_Template/stm32f2xx_it.c
+ * @author MCD Application Team
+ * @version V1.1.0
+ * @date 13-April-2012
+ * @brief Main Interrupt Service Routines.
+ * This file provides template for all exceptions handler and
+ * peripherals interrupt service routine.
+ ******************************************************************************
+ * @attention
+ *
+ * © COPYRIGHT 2012 STMicroelectronics
+ *
+ * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.st.com/software_license_agreement_liberty_v2
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f2xx_it.h"
+#include "main.h"
+
+/** @addtogroup Template_Project
+ * @{
+ */
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+/* Private function prototypes -----------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+
+/******************************************************************************/
+/* Cortex-M3 Processor Exceptions Handlers */
+/******************************************************************************/
+
+/**
+ * @brief This function handles NMI exception.
+ * @param None
+ * @retval None
+ */
+void NMI_Handler(void)
+{
+}
+
+/**
+ * @brief This function handles Hard Fault exception.
+ * @param None
+ * @retval None
+ */
+void HardFault_Handler(void)
+{
+ /* Go to infinite loop when Hard Fault exception occurs */
+ while (1)
+ {
+ }
+}
+
+/**
+ * @brief This function handles Memory Manage exception.
+ * @param None
+ * @retval None
+ */
+void MemManage_Handler(void)
+{
+ /* Go to infinite loop when Memory Manage exception occurs */
+ while (1)
+ {
+ }
+}
+
+/**
+ * @brief This function handles Bus Fault exception.
+ * @param None
+ * @retval None
+ */
+void BusFault_Handler(void)
+{
+ /* Go to infinite loop when Bus Fault exception occurs */
+ while (1)
+ {
+ }
+}
+
+/**
+ * @brief This function handles Usage Fault exception.
+ * @param None
+ * @retval None
+ */
+void UsageFault_Handler(void)
+{
+ /* Go to infinite loop when Usage Fault exception occurs */
+ while (1)
+ {
+ }
+}
+
+/**
+ * @brief This function handles SVCall exception.
+ * @param None
+ * @retval None
+ */
+void SVC_Handler(void)
+{
+}
+
+/**
+ * @brief This function handles Debug Monitor exception.
+ * @param None
+ * @retval None
+ */
+void DebugMon_Handler(void)
+{
+}
+
+/**
+ * @brief This function handles PendSVC exception.
+ * @param None
+ * @retval None
+ */
+void PendSV_Handler(void)
+{
+}
+
+/**
+ * @brief This function handles SysTick Handler.
+ * @param None
+ * @retval None
+ */
+void SysTick_Handler(void)
+{
+ TimingDelay_Decrement();
+}
+
+/******************************************************************************/
+/* STM32F2xx Peripherals Interrupt Handlers */
+/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
+/* available peripheral interrupt handler's name please refer to the startup */
+/* file (startup_stm32f2xx.s). */
+/******************************************************************************/
+
+/**
+ * @brief This function handles PPP interrupt request.
+ * @param None
+ * @retval None
+ */
+/*void PPP_IRQHandler(void)
+{
+}*/
+
+/**
+ * @}
+ */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/12-SPI-Simulation/stm32f2xx_it.h b/12-SPI-Simulation/stm32f2xx_it.h
new file mode 100644
index 0000000..8ad5eb9
--- /dev/null
+++ b/12-SPI-Simulation/stm32f2xx_it.h
@@ -0,0 +1,60 @@
+/**
+ ******************************************************************************
+ * @file Project/STM32F2xx_StdPeriph_Template/stm32f2xx_it.h
+ * @author MCD Application Team
+ * @version V1.1.0
+ * @date 13-April-2012
+ * @brief This file contains the headers of the interrupt handlers.
+ ******************************************************************************
+ * @attention
+ *
+ * © COPYRIGHT 2012 STMicroelectronics
+ *
+ * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.st.com/software_license_agreement_liberty_v2
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F2xx_IT_H
+#define __STM32F2xx_IT_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f2xx.h"
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions ------------------------------------------------------- */
+
+void NMI_Handler(void);
+void HardFault_Handler(void);
+void MemManage_Handler(void);
+void BusFault_Handler(void);
+void UsageFault_Handler(void);
+void SVC_Handler(void);
+void DebugMon_Handler(void);
+void PendSV_Handler(void);
+void SysTick_Handler(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F2xx_IT_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/