Добавлены проверки на режим прерывания (пока ниче не работает)
This commit is contained in:
@@ -69,10 +69,16 @@ uint8_t write_buff[20] = {0x14,0x13,0x12,0x11,0x10,
|
||||
0x0A,0x09,0x08,0x07,0x06,
|
||||
0x05,0x04,0x03,0x02,0x01};
|
||||
|
||||
uint32_t FLASH_write = 0; // where start writting (except MCU App - MCU App writing on 0x0)
|
||||
uint32_t FLASH_write = 0x1000; // where start writting (except MCU App - MCU App writing on 0x0)
|
||||
uint32_t FLASH_mcu_size = 0x2000; // how many bytes from app write to flash
|
||||
uint32_t FLASH_read = 0x100; // where read
|
||||
uint32_t FLASH_read = 0x1100; // where read
|
||||
uint32_t Timeout = 1000; // timeout for examples in while(1)
|
||||
|
||||
void SPI2_IRQHandler(void)
|
||||
{
|
||||
MEMSPI_Handler(&hmemspi);
|
||||
}
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/**
|
||||
@@ -107,16 +113,16 @@ int main(void)
|
||||
MX_RNG_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
// FLASH MEMSPI INIT
|
||||
hmemspi.hspi.Instance = SPI2;
|
||||
hmemspi.hspi.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128;
|
||||
hmemspi.GPIOs.CS_GPIOx = GPIOA;
|
||||
hmemspi.GPIOs.CS_PIN = GPIO_PIN_4;
|
||||
hmemspi.GPIOs.CLK_GPIOx = GPIOB;
|
||||
hmemspi.GPIOs.CLK_PIN = GPIO_PIN_13;
|
||||
hmemspi.GPIOs.MISO_GPIOx = GPIOC;
|
||||
hmemspi.GPIOs.MISO_PIN = GPIO_PIN_2;
|
||||
hmemspi.GPIOs.MOSI_GPIOx = GPIOC;
|
||||
hmemspi.GPIOs.MOSI_PIN = GPIO_PIN_3;
|
||||
hmemspi.sspi.hspi.Instance = SPI2;
|
||||
hmemspi.sspi.hspi.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128;
|
||||
hmemspi.CS_GPIOx = GPIOA;
|
||||
hmemspi.CS_PIN = GPIO_PIN_4;
|
||||
hmemspi.sspi.CLK_GPIOx = GPIOB;
|
||||
hmemspi.sspi.CLK_PIN = GPIO_PIN_13;
|
||||
hmemspi.sspi.MISO_GPIOx = GPIOB;
|
||||
hmemspi.sspi.MISO_PIN = GPIO_PIN_14;
|
||||
hmemspi.sspi.MOSI_GPIOx = GPIOB;
|
||||
hmemspi.sspi.MOSI_PIN = GPIO_PIN_15;
|
||||
MEMSPI_Base_Init(&hmemspi);
|
||||
|
||||
/* USER CODE END 2 */
|
||||
@@ -124,48 +130,68 @@ int main(void)
|
||||
/* Infinite loop */
|
||||
/* USER CODE BEGIN WHILE */
|
||||
|
||||
// Example for FLASH: using manufactire info CMD
|
||||
uint32_t memspi_ID = MEMSPI_CMD_Read_JEDEC_ID(&hmemspi, 100);
|
||||
uint64_t memspi_unique_ID = MEMSPI_CMD_Read_Device_ID(&hmemspi, 100);
|
||||
#ifdef EXT_FLASH
|
||||
// Example fpr FLASH: writting MCU Program to external FLASH
|
||||
writeInit.fSavePrevoisData = 1;
|
||||
writeInit.pDataPtr = write_buff;
|
||||
writeInit.Data_Address = 0xfb;
|
||||
writeInit.Data_Size = 1;
|
||||
writeInit.Sector_Address = 0xf9;
|
||||
writeInit.Sector_Size = 15;
|
||||
// Example for FLASH (interrupt): using manufactire info CMD
|
||||
uint32_t memspi_ID;
|
||||
uint64_t memspi_unique_ID;
|
||||
MEMSPI_CMD_Read_JEDEC_ID_IT(&hmemspi, &memspi_ID);
|
||||
HAL_Delay(100);
|
||||
MEMSPI_CMD_Read_Device_ID_IT(&hmemspi, &memspi_unique_ID);
|
||||
HAL_Delay(100);
|
||||
|
||||
// Example for FLASH (interrupt/blocking): erase/program/read functions
|
||||
// writting on two pages:
|
||||
// writing 15 bytes at 0xf9 - its writting 7 bytes at first page, and 8 bytes at second page
|
||||
MEMSPI_RES = MEMSPI_FLASH_Erase(&hmemspi, 0, 1, 1000, 100);
|
||||
MEMSPI_RES = MEMSPI_FLASH_Program(&hmemspi, 0xf9, write_buff, 15, 100, 1);
|
||||
MEMSPI_RES = MEMSPI_Read_Memory_IT(&hmemspi, 0xf9, read_buff, 15);
|
||||
MEMSPI_WaitOnFlagsUntilTimeout(&hmemspi, MEMSPI_SR_BUSY, 0, NULL, NULL);
|
||||
|
||||
|
||||
// Example for FLASH (blocking): using manufactire info CMD
|
||||
memspi_ID = MEMSPI_CMD_Read_JEDEC_ID(&hmemspi, 100);
|
||||
memspi_unique_ID = MEMSPI_CMD_Read_Device_ID(&hmemspi, 100);
|
||||
MEMSPI_RES = MEMSPI_CMD_Write_Status_Register(&hmemspi, 0, 100);
|
||||
#ifdef EXT_FLASH
|
||||
// Example fpr FLASH (blocking): writting MCU Program to external FLASH
|
||||
MCUFlashToExternalFlashInit.pDataPtr = (uint8_t *)FLASH_BASE;
|
||||
MCUFlashToExternalFlashInit.Data_Address = 0;
|
||||
MCUFlashToExternalFlashInit.Data_Address = FLASH_write;
|
||||
MCUFlashToExternalFlashInit.Data_Size = FLASH_mcu_size;
|
||||
MCUFlashToExternalFlashInit.Sector_Address = 0;
|
||||
MCUFlashToExternalFlashInit.Sector_Address = FLASH_write;
|
||||
MCUFlashToExternalFlashInit.Sector_Size = FLASH_mcu_size;
|
||||
MEMSPI_RES = MEMSPI_FLASH_Write(&hmemspi, &MCUFlashToExternalFlashInit, 5000, 1);
|
||||
MEMSPI_RES = MEMSPI_Read_Memory(&hmemspi, FLASH_read, read_buff, 15, 100);
|
||||
|
||||
// Example for FLASH: erase/program/read functions
|
||||
// Example for FLASH (blocking): erase/program/read functions
|
||||
// writting on two pages:
|
||||
// writing 15 bytes at 0xf9 - its writting 7 bytes at first page, and 8 bytes at second page
|
||||
MEMSPI_RES = MEMSPI_FLASH_Erase(&hmemspi, 0, 1, 1000, 1);
|
||||
MEMSPI_RES = MEMSPI_FLASH_Program(&hmemspi, 0xf9, write_buff, 15, 100, 1);
|
||||
MEMSPI_RES = MEMSPI_Read_Memory(&hmemspi, 0xf9, read_buff, 15, 100);
|
||||
|
||||
// Example for FLASH (blocking) (while(1)): write/read functions
|
||||
#endif
|
||||
#ifdef EXT_EEPROM
|
||||
// Example for EEPROM: writting MCU Program to external EEPROM
|
||||
MEMSPI_RES = MEMSPI_EEPROM_Write(&hmemspi, 0, (uint8_t *)FLASH_BASE, FLASH_mcu_size, 2000, 0);
|
||||
// Example for EEPROM (blocking): writting MCU Program to external EEPROM
|
||||
MEMSPI_RES = MEMSPI_EEPROM_Write(&hmemspi, FLASH_write, (uint8_t *)FLASH_BASE, FLASH_mcu_size, 2000, 0);
|
||||
MEMSPI_RES = MEMSPI_Read_Memory(&hmemspi, FLASH_read, read_buff, 15, 100);
|
||||
FLASH_read = 0x0;
|
||||
#endif
|
||||
while (1)
|
||||
{
|
||||
FLASH_read = FLASH_write;
|
||||
#ifdef EXT_FLASH
|
||||
// Example for FLASH: write/read functions
|
||||
MEMSPI_RES = MEMSPI_FLASH_Write(&hmemspi, &writeInit, Timeout, 1);
|
||||
MEMSPI_RES = MEMSPI_Read_Memory(&hmemspi, 0xf9, read_buff, 15, Timeout);
|
||||
// Example for FLASH (blocking): write/read functions
|
||||
writeInit.fSavePrevoisData = 1;
|
||||
writeInit.pDataPtr = write_buff;
|
||||
writeInit.Data_Address = FLASH_write;
|
||||
writeInit.Data_Size = 1;
|
||||
writeInit.Sector_Address = FLASH_write;
|
||||
writeInit.Sector_Size = 15;
|
||||
// MEMSPI_RES = MEMSPI_FLASH_Write(&hmemspi, &writeInit, Timeout, 1);
|
||||
// MEMSPI_RES = MEMSPI_Read_Memory(&hmemspi, FLASH_read, read_buff, 15, Timeout);
|
||||
#endif
|
||||
#ifdef EXT_EEPROM
|
||||
// Example for EEPROM: write/read functions
|
||||
// Example for EEPROM (blocking): write/read functions
|
||||
MEMSPI_RES = MEMSPI_EEPROM_Write(&hmemspi, FLASH_write, write_buff, 15, Timeout, 1);
|
||||
MEMSPI_RES = MEMSPI_Read_Memory(&hmemspi, 0+FLASH_read, read_buff, 15, Timeout);
|
||||
#endif
|
||||
|
||||
@@ -152,9 +152,9 @@
|
||||
<Bp>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>156</LineNumber>
|
||||
<LineNumber>151</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134230216</Address>
|
||||
<Address>134236100</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
@@ -163,14 +163,14 @@
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>../Core/Src/main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\flash_eeprom_Example\../Core/Src/main.c\156</Expression>
|
||||
<Expression>\\flash_eeprom_Example\../Core/Src/main.c\151</Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>1</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>160</LineNumber>
|
||||
<LineNumber>146</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134230308</Address>
|
||||
<Address>134236064</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
@@ -179,14 +179,14 @@
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>../Core/Src/main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\flash_eeprom_Example\../Core/Src/main.c\160</Expression>
|
||||
<Expression>\\flash_eeprom_Example\../Core/Src/main.c\146</Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>2</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>169</LineNumber>
|
||||
<LineNumber>144</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134230310</Address>
|
||||
<Address>134235990</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
@@ -195,7 +195,7 @@
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>../Core/Src/main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\flash_eeprom_Example\../Core/Src/main.c\169</Expression>
|
||||
<Expression>\\flash_eeprom_Example\../Core/Src/main.c\144</Expression>
|
||||
</Bp>
|
||||
</Breakpoint>
|
||||
<WatchWindow1>
|
||||
@@ -212,7 +212,7 @@
|
||||
<Ww>
|
||||
<count>2</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>MEMSPI_RES</ItemText>
|
||||
<ItemText>memspi_unique_ID</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>3</count>
|
||||
@@ -286,12 +286,22 @@
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>&0x20000760</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>6</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>sector_buff</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>7</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>hspi</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow2>
|
||||
<MemoryWindow1>
|
||||
<Mm>
|
||||
<WinNumber>1</WinNumber>
|
||||
<SubType>0</SubType>
|
||||
<ItemText>0x08001532</ItemText>
|
||||
<ItemText>0x08000100</ItemText>
|
||||
<AccSizeX>0</AccSizeX>
|
||||
</Mm>
|
||||
</MemoryWindow1>
|
||||
@@ -299,7 +309,7 @@
|
||||
<Mm>
|
||||
<WinNumber>2</WinNumber>
|
||||
<SubType>0</SubType>
|
||||
<ItemText>0x20000708</ItemText>
|
||||
<ItemText>0x20001778</ItemText>
|
||||
<AccSizeX>0</AccSizeX>
|
||||
</Mm>
|
||||
</MemoryWindow2>
|
||||
@@ -803,6 +813,30 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>33</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\GENERAL\spi_general.c</PathWithFileName>
|
||||
<FilenameWithoutPath>spi_general.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>34</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\GENERAL\spi_general.h</PathWithFileName>
|
||||
<FilenameWithoutPath>spi_general.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
|
||||
@@ -621,6 +621,16 @@
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\..\GENERAL\periph_general.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>spi_general.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\GENERAL\spi_general.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>spi_general.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\..\GENERAL\spi_general.h</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
||||
@@ -11,7 +11,7 @@ Mcu.IP0=CRC
|
||||
Mcu.IP1=NVIC
|
||||
Mcu.IP2=RCC
|
||||
Mcu.IP3=RNG
|
||||
Mcu.IP4=SPI1
|
||||
Mcu.IP4=SPI2
|
||||
Mcu.IP5=SYS
|
||||
Mcu.IPNb=6
|
||||
Mcu.Name=STM32F407V(E-G)Tx
|
||||
@@ -20,9 +20,9 @@ Mcu.Pin0=PH0-OSC_IN
|
||||
Mcu.Pin1=PH1-OSC_OUT
|
||||
Mcu.Pin10=VP_RNG_VS_RNG
|
||||
Mcu.Pin11=VP_SYS_VS_Systick
|
||||
Mcu.Pin2=PA5
|
||||
Mcu.Pin3=PA6
|
||||
Mcu.Pin4=PA7
|
||||
Mcu.Pin2=PB13
|
||||
Mcu.Pin3=PB14
|
||||
Mcu.Pin4=PB15
|
||||
Mcu.Pin5=PD12
|
||||
Mcu.Pin6=PD13
|
||||
Mcu.Pin7=PD14
|
||||
@@ -45,12 +45,15 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_0
|
||||
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
|
||||
NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:false
|
||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
|
||||
PA5.Mode=Full_Duplex_Master
|
||||
PA5.Signal=SPI1_SCK
|
||||
PA6.Mode=Full_Duplex_Master
|
||||
PA6.Signal=SPI1_MISO
|
||||
PA7.Mode=Full_Duplex_Master
|
||||
PA7.Signal=SPI1_MOSI
|
||||
PB13.Locked=true
|
||||
PB13.Mode=Full_Duplex_Master
|
||||
PB13.Signal=SPI2_SCK
|
||||
PB14.Locked=true
|
||||
PB14.Mode=Full_Duplex_Master
|
||||
PB14.Signal=SPI2_MISO
|
||||
PB15.Locked=true
|
||||
PB15.Mode=Full_Duplex_Master
|
||||
PB15.Signal=SPI2_MOSI
|
||||
PD12.Locked=true
|
||||
PD12.Signal=GPIO_Output
|
||||
PD13.Locked=true
|
||||
@@ -125,11 +128,11 @@ RCC.VCOI2SOutputFreq_Value=384000000
|
||||
RCC.VCOInputFreq_Value=2000000
|
||||
RCC.VCOOutputFreq_Value=128000000
|
||||
RCC.VcooutputI2S=192000000
|
||||
SPI1.CalculateBaudRate=4.0 MBits/s
|
||||
SPI1.Direction=SPI_DIRECTION_2LINES
|
||||
SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate
|
||||
SPI1.Mode=SPI_MODE_MASTER
|
||||
SPI1.VirtualType=VM_MASTER
|
||||
SPI2.CalculateBaudRate=4.0 MBits/s
|
||||
SPI2.Direction=SPI_DIRECTION_2LINES
|
||||
SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate
|
||||
SPI2.Mode=SPI_MODE_MASTER
|
||||
SPI2.VirtualType=VM_MASTER
|
||||
VP_CRC_VS_CRC.Mode=CRC_Activate
|
||||
VP_CRC_VS_CRC.Signal=CRC_VS_CRC
|
||||
VP_RNG_VS_RNG.Mode=RNG_Activate
|
||||
|
||||
Reference in New Issue
Block a user