From 541a0bcafbde6057995cdcea1ce7669828ef36d7 Mon Sep 17 00:00:00 2001 From: strongercjd Date: Thu, 23 Jul 2020 21:36:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=A8=A1=E6=8B=9FSPI?= =?UTF-8?q?=E8=AF=BB=E5=8F=96norflash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 12-SPI-Simulation/EWARM/Project.ewd | 1352 +++++++++++++++++++ 12-SPI-Simulation/EWARM/Project.ewp | 1074 +++++++++++++++ 12-SPI-Simulation/EWARM/Project.eww | 10 + 12-SPI-Simulation/EWARM/stm32f2xx_flash.icf | 31 + 12-SPI-Simulation/Ex_Flash.c | 510 +++++++ 12-SPI-Simulation/Ex_Flash.h | 82 ++ 12-SPI-Simulation/LCD_disp.c | 815 +++++++++++ 12-SPI-Simulation/LCD_disp.h | 70 + 12-SPI-Simulation/MDK-ARM/Project.uvopt | 726 ++++++++++ 12-SPI-Simulation/MDK-ARM/Project.uvproj | 629 +++++++++ 12-SPI-Simulation/README.md | 3 + 12-SPI-Simulation/main.c | 321 +++++ 12-SPI-Simulation/main.h | 45 + 12-SPI-Simulation/stm32f2xx_conf.h | 94 ++ 12-SPI-Simulation/stm32f2xx_it.c | 168 +++ 12-SPI-Simulation/stm32f2xx_it.h | 60 + 16 files changed, 5990 insertions(+) create mode 100644 12-SPI-Simulation/EWARM/Project.ewd create mode 100644 12-SPI-Simulation/EWARM/Project.ewp create mode 100644 12-SPI-Simulation/EWARM/Project.eww create mode 100644 12-SPI-Simulation/EWARM/stm32f2xx_flash.icf create mode 100644 12-SPI-Simulation/Ex_Flash.c create mode 100644 12-SPI-Simulation/Ex_Flash.h create mode 100644 12-SPI-Simulation/LCD_disp.c create mode 100644 12-SPI-Simulation/LCD_disp.h create mode 100644 12-SPI-Simulation/MDK-ARM/Project.uvopt create mode 100644 12-SPI-Simulation/MDK-ARM/Project.uvproj create mode 100644 12-SPI-Simulation/README.md create mode 100644 12-SPI-Simulation/main.c create mode 100644 12-SPI-Simulation/main.h create mode 100644 12-SPI-Simulation/stm32f2xx_conf.h create mode 100644 12-SPI-Simulation/stm32f2xx_it.c create mode 100644 12-SPI-Simulation/stm32f2xx_it.h 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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ARMSIM_ID + 2 + + 1 + 1 + 1 + + + + + + + + ANGEL_ID + 2 + + 0 + 1 + 1 + + + + + + + + + + + + CMSISDAP_ID + 2 + + 2 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GDBSERVER_ID + 2 + + 0 + 1 + 1 + + + + + + + + + + + IARROM_ID + 2 + + 1 + 1 + 1 + + + + + + + + + IJET_ID + 2 + + 3 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JLINK_ID + 2 + + 15 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LMIFTDI_ID + 2 + + 2 + 1 + 1 + + + + + + + + + + MACRAIGOR_ID + 2 + + 3 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + PEMICRO_ID + 2 + + 1 + 1 + 1 + + + + + + + + + + + + + + + + + + + RDI_ID + 2 + + 2 + 1 + 1 + + + + + + + + + + + + + + + + STLINK_ID + 2 + + 2 + 1 + 1 + + + + + + + + + + + THIRDPARTY_ID + 2 + + 0 + 1 + 1 + + + + + + + + XDS100_ID + 2 + + 2 + 1 + 1 + + + + + + + + + + + + + $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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 31 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 9 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 1 + + + + + + + + + CUSTOM + 3 + + + + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + ILINK + 0 + + 16 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 1 + + + + + + + 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****/