Чуть структурирован проект example
This commit is contained in:
@@ -61,11 +61,18 @@ HAL_StatusTypeDef MEMSPI_RES;
|
|||||||
MEMSPI_WriteInitTypeDef writeInit;
|
MEMSPI_WriteInitTypeDef writeInit;
|
||||||
MEMSPI_WriteInitTypeDef MCUFlashToExternalFlashInit;
|
MEMSPI_WriteInitTypeDef MCUFlashToExternalFlashInit;
|
||||||
|
|
||||||
|
// buff to read
|
||||||
uint8_t read_buff[20] = {0};
|
uint8_t read_buff[20] = {0};
|
||||||
|
// what writting in examples in while(1)
|
||||||
uint8_t write_buff[20] = {0x14,0x13,0x12,0x11,0x10,
|
uint8_t write_buff[20] = {0x14,0x13,0x12,0x11,0x10,
|
||||||
0x0F,0x0E,0x0D,0x0C,0x0B,
|
0x0F,0x0E,0x0D,0x0C,0x0B,
|
||||||
0x0A,0x09,0x08,0x07,0x06,
|
0x0A,0x09,0x08,0x07,0x06,
|
||||||
0x05,0x04,0x03,0x02,0x01};
|
0x05,0x04,0x03,0x02,0x01};
|
||||||
|
|
||||||
|
uint32_t FLASH_write = 0; // 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 Timeout = 1000; // timeout for examples in while(1)
|
||||||
/* USER CODE END 0 */
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,9 +118,17 @@ int main(void)
|
|||||||
hmemspi.GPIOs.MOSI_GPIOx = GPIOC;
|
hmemspi.GPIOs.MOSI_GPIOx = GPIOC;
|
||||||
hmemspi.GPIOs.MOSI_PIN = GPIO_PIN_3;
|
hmemspi.GPIOs.MOSI_PIN = GPIO_PIN_3;
|
||||||
MEMSPI_Base_Init(&hmemspi);
|
MEMSPI_Base_Init(&hmemspi);
|
||||||
// Example for FLASH: write area functions init
|
|
||||||
// writting on two pages:
|
/* USER CODE END 2 */
|
||||||
// writing 15 bytes at 0xf9 - its writting 7 bytes at first page, and 8 bytes at second page
|
|
||||||
|
/* 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.fSavePrevoisData = 1;
|
||||||
writeInit.pDataPtr = write_buff;
|
writeInit.pDataPtr = write_buff;
|
||||||
writeInit.Data_Address = 0xfb;
|
writeInit.Data_Address = 0xfb;
|
||||||
@@ -121,46 +136,38 @@ int main(void)
|
|||||||
writeInit.Sector_Address = 0xf9;
|
writeInit.Sector_Address = 0xf9;
|
||||||
writeInit.Sector_Size = 15;
|
writeInit.Sector_Size = 15;
|
||||||
|
|
||||||
/* USER CODE END 2 */
|
|
||||||
|
|
||||||
/* Infinite loop */
|
|
||||||
/* USER CODE BEGIN WHILE */
|
|
||||||
// Example for FLASH/EPROM: 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
|
|
||||||
MCUFlashToExternalFlashInit.pDataPtr = (uint8_t *)FLASH_BASE;
|
MCUFlashToExternalFlashInit.pDataPtr = (uint8_t *)FLASH_BASE;
|
||||||
MCUFlashToExternalFlashInit.Data_Address = 0;
|
MCUFlashToExternalFlashInit.Data_Address = 0;
|
||||||
MCUFlashToExternalFlashInit.Data_Size = 0x2000;
|
MCUFlashToExternalFlashInit.Data_Size = FLASH_mcu_size;
|
||||||
MCUFlashToExternalFlashInit.Sector_Address = 0;
|
MCUFlashToExternalFlashInit.Sector_Address = 0;
|
||||||
MCUFlashToExternalFlashInit.Sector_Size = 0x2000;
|
MCUFlashToExternalFlashInit.Sector_Size = FLASH_mcu_size;
|
||||||
MEMSPI_RES = MEMSPI_FLASH_Write(&hmemspi, &MCUFlashToExternalFlashInit, 5000);
|
MEMSPI_RES = MEMSPI_FLASH_Write(&hmemspi, &MCUFlashToExternalFlashInit, 5000, 1);
|
||||||
uint32_t FLASH_shift = 0;
|
MEMSPI_RES = MEMSPI_Read_Memory(&hmemspi, FLASH_read, read_buff, 15, 100);
|
||||||
MEMSPI_RES = MEMSPI_Read_Memory(&hmemspi, 0x0000+FLASH_shift, read_buff, 15, 100);
|
|
||||||
|
|
||||||
// Example for FLASH: erase/program/read functions
|
// Example for FLASH: erase/program/read functions
|
||||||
MEMSPI_RES = MEMSPI_FLASH_Erase(&hmemspi, 0, 1, 1000);
|
// writting on two pages:
|
||||||
MEMSPI_RES = MEMSPI_FLASH_Program(&hmemspi, 0xf9, write_buff, 15, 100);
|
// 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);
|
MEMSPI_RES = MEMSPI_Read_Memory(&hmemspi, 0xf9, read_buff, 15, 100);
|
||||||
#endif
|
#endif
|
||||||
#ifdef EXT_EEPROM
|
#ifdef EXT_EEPROM
|
||||||
// Example for EEPROM: writting MCU Program to external EEPROM
|
// Example for EEPROM: writting MCU Program to external EEPROM
|
||||||
MEMSPI_RES = MEMSPI_EEPROM_Write(&hmemspi, 0, (uint8_t *)FLASH_BASE, 0x2000, 2000);
|
MEMSPI_RES = MEMSPI_EEPROM_Write(&hmemspi, 0, (uint8_t *)FLASH_BASE, FLASH_mcu_size, 2000, 0);
|
||||||
MEMSPI_RES = MEMSPI_Read_Memory(&hmemspi, 0, read_buff, 15, 100);
|
MEMSPI_RES = MEMSPI_Read_Memory(&hmemspi, FLASH_read, read_buff, 15, 100);
|
||||||
|
FLASH_read = 0x0;
|
||||||
#endif
|
#endif
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
#ifdef EXT_FLASH
|
#ifdef EXT_FLASH
|
||||||
// Example for FLASH: write area functions
|
// Example for FLASH: write/read functions
|
||||||
MEMSPI_RES = MEMSPI_FLASH_Write(&hmemspi, &writeInit, 1000);
|
MEMSPI_RES = MEMSPI_FLASH_Write(&hmemspi, &writeInit, Timeout, 1);
|
||||||
MEMSPI_RES = MEMSPI_Read_Memory(&hmemspi, 0xf9, read_buff, 15, 100);
|
MEMSPI_RES = MEMSPI_Read_Memory(&hmemspi, 0xf9, read_buff, 15, Timeout);
|
||||||
#endif
|
#endif
|
||||||
#ifdef EXT_EEPROM
|
#ifdef EXT_EEPROM
|
||||||
// Example for EEPROM: write/read functions
|
// Example for EEPROM: write/read functions
|
||||||
MEMSPI_RES = MEMSPI_EEPROM_Write(&hmemspi, 0xf9, write_buff, 15, 100);
|
MEMSPI_RES = MEMSPI_EEPROM_Write(&hmemspi, FLASH_write, write_buff, 15, Timeout, 1);
|
||||||
MEMSPI_RES = MEMSPI_Read_Memory(&hmemspi, 0xf9, read_buff, 15, 100);
|
MEMSPI_RES = MEMSPI_Read_Memory(&hmemspi, 0+FLASH_read, read_buff, 15, Timeout);
|
||||||
#endif
|
#endif
|
||||||
/* USER CODE END WHILE */
|
/* USER CODE END WHILE */
|
||||||
|
|
||||||
|
|||||||
@@ -152,9 +152,9 @@
|
|||||||
<Bp>
|
<Bp>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
<Type>0</Type>
|
<Type>0</Type>
|
||||||
<LineNumber>150</LineNumber>
|
<LineNumber>156</LineNumber>
|
||||||
<EnabledFlag>1</EnabledFlag>
|
<EnabledFlag>1</EnabledFlag>
|
||||||
<Address>134229526</Address>
|
<Address>134230216</Address>
|
||||||
<ByteObject>0</ByteObject>
|
<ByteObject>0</ByteObject>
|
||||||
<HtxType>0</HtxType>
|
<HtxType>0</HtxType>
|
||||||
<ManyObjects>0</ManyObjects>
|
<ManyObjects>0</ManyObjects>
|
||||||
@@ -163,14 +163,14 @@
|
|||||||
<BreakIfRCount>1</BreakIfRCount>
|
<BreakIfRCount>1</BreakIfRCount>
|
||||||
<Filename>../Core/Src/main.c</Filename>
|
<Filename>../Core/Src/main.c</Filename>
|
||||||
<ExecCommand></ExecCommand>
|
<ExecCommand></ExecCommand>
|
||||||
<Expression>\\flash_eeprom_Example\../Core/Src/main.c\150</Expression>
|
<Expression>\\flash_eeprom_Example\../Core/Src/main.c\156</Expression>
|
||||||
</Bp>
|
</Bp>
|
||||||
<Bp>
|
<Bp>
|
||||||
<Number>1</Number>
|
<Number>1</Number>
|
||||||
<Type>0</Type>
|
<Type>0</Type>
|
||||||
<LineNumber>153</LineNumber>
|
<LineNumber>160</LineNumber>
|
||||||
<EnabledFlag>1</EnabledFlag>
|
<EnabledFlag>1</EnabledFlag>
|
||||||
<Address>134229722</Address>
|
<Address>134230308</Address>
|
||||||
<ByteObject>0</ByteObject>
|
<ByteObject>0</ByteObject>
|
||||||
<HtxType>0</HtxType>
|
<HtxType>0</HtxType>
|
||||||
<ManyObjects>0</ManyObjects>
|
<ManyObjects>0</ManyObjects>
|
||||||
@@ -179,7 +179,23 @@
|
|||||||
<BreakIfRCount>1</BreakIfRCount>
|
<BreakIfRCount>1</BreakIfRCount>
|
||||||
<Filename>../Core/Src/main.c</Filename>
|
<Filename>../Core/Src/main.c</Filename>
|
||||||
<ExecCommand></ExecCommand>
|
<ExecCommand></ExecCommand>
|
||||||
<Expression>\\flash_eeprom_Example\../Core/Src/main.c\153</Expression>
|
<Expression>\\flash_eeprom_Example\../Core/Src/main.c\160</Expression>
|
||||||
|
</Bp>
|
||||||
|
<Bp>
|
||||||
|
<Number>2</Number>
|
||||||
|
<Type>0</Type>
|
||||||
|
<LineNumber>169</LineNumber>
|
||||||
|
<EnabledFlag>1</EnabledFlag>
|
||||||
|
<Address>134230310</Address>
|
||||||
|
<ByteObject>0</ByteObject>
|
||||||
|
<HtxType>0</HtxType>
|
||||||
|
<ManyObjects>0</ManyObjects>
|
||||||
|
<SizeOfObject>0</SizeOfObject>
|
||||||
|
<BreakByAccess>0</BreakByAccess>
|
||||||
|
<BreakIfRCount>1</BreakIfRCount>
|
||||||
|
<Filename>../Core/Src/main.c</Filename>
|
||||||
|
<ExecCommand></ExecCommand>
|
||||||
|
<Expression>\\flash_eeprom_Example\../Core/Src/main.c\169</Expression>
|
||||||
</Bp>
|
</Bp>
|
||||||
</Breakpoint>
|
</Breakpoint>
|
||||||
<WatchWindow1>
|
<WatchWindow1>
|
||||||
@@ -216,22 +232,27 @@
|
|||||||
<Ww>
|
<Ww>
|
||||||
<count>6</count>
|
<count>6</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>writebuff</ItemText>
|
<ItemText>FLASH_write</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>7</count>
|
<count>7</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>Timeout</ItemText>
|
<ItemText>FLASH_mcu_size</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>8</count>
|
<count>8</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>tickstart</ItemText>
|
<ItemText>FLASH_read</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>9</count>
|
<count>9</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>tickstart+Timeout</ItemText>
|
<ItemText>Timeout</ItemText>
|
||||||
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>10</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>\\flash_eeprom_Example\../Core/Src/main.c\read_buff</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
</WatchWindow1>
|
</WatchWindow1>
|
||||||
<WatchWindow2>
|
<WatchWindow2>
|
||||||
@@ -270,7 +291,7 @@
|
|||||||
<Mm>
|
<Mm>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<SubType>0</SubType>
|
<SubType>0</SubType>
|
||||||
<ItemText>0x08000000</ItemText>
|
<ItemText>0x08001532</ItemText>
|
||||||
<AccSizeX>0</AccSizeX>
|
<AccSizeX>0</AccSizeX>
|
||||||
</Mm>
|
</Mm>
|
||||||
</MemoryWindow1>
|
</MemoryWindow1>
|
||||||
|
|||||||
Reference in New Issue
Block a user