Добавлен пример с выгрузкой программы МК в флеш
This commit is contained in:
@@ -59,6 +59,7 @@ void SystemClock_Config(void);
|
|||||||
W25_HandleTypeDef hw25;
|
W25_HandleTypeDef hw25;
|
||||||
HAL_StatusTypeDef W25_RES;
|
HAL_StatusTypeDef W25_RES;
|
||||||
W25_WriteInitTypeDef writeInit;
|
W25_WriteInitTypeDef writeInit;
|
||||||
|
W25_WriteInitTypeDef MCUFlashToExternalFlashInit;
|
||||||
|
|
||||||
uint8_t read_buff[20] = {0};
|
uint8_t read_buff[20] = {0};
|
||||||
uint8_t write_buff[20] = {0x14,0x13,0x12,0x11,0x10,
|
uint8_t write_buff[20] = {0x14,0x13,0x12,0x11,0x10,
|
||||||
@@ -110,32 +111,44 @@ int main(void)
|
|||||||
hw25.GPIOs.MISO_PIN = GPIO_PIN_2;
|
hw25.GPIOs.MISO_PIN = GPIO_PIN_2;
|
||||||
hw25.GPIOs.MOSI_PIN = GPIO_PIN_3;
|
hw25.GPIOs.MOSI_PIN = GPIO_PIN_3;
|
||||||
W25_Base_Init(&hw25);
|
W25_Base_Init(&hw25);
|
||||||
/* USER CODE END 2 */
|
|
||||||
|
|
||||||
/* Infinite loop */
|
|
||||||
/* USER CODE BEGIN WHILE */
|
|
||||||
|
|
||||||
// Example for FLASH: using manufactire info CMD
|
|
||||||
uint32_t w25_ID = W25_CMD_Read_JEDEC_ID(&hw25);
|
|
||||||
uint64_t w25_unique_ID = W25_CMD_Read_Device_ID(&hw25);
|
|
||||||
|
|
||||||
// Example for FLASH: erase/program/read functions
|
|
||||||
W25_RES = W25_FLASH_Erase_Sector(&hw25, 0, 1000);
|
|
||||||
W25_RES = W25_FLASH_Program_Area(&hw25, 0xf9, write_buff, 15, 100);
|
|
||||||
W25_CMD_Read_Data(&hw25, 0xf9, read_buff, 15);
|
|
||||||
|
|
||||||
// Example for FLASH: write area functions init
|
// Example for FLASH: write area functions init
|
||||||
|
// writting on two pages:
|
||||||
|
// writing 15 bytes at 0xf9 - its writting 7 bytes at first page, and 8 bytes at second page
|
||||||
|
writeInit.fSavePrevoisData = 1;
|
||||||
writeInit.pDataPtr = write_buff;
|
writeInit.pDataPtr = write_buff;
|
||||||
writeInit.Data_Address = 0xfb;
|
writeInit.Data_Address = 0xfb;
|
||||||
writeInit.Data_Size = 1;
|
writeInit.Data_Size = 1;
|
||||||
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: using manufactire info CMD
|
||||||
|
uint32_t w25_ID = W25_CMD_Read_JEDEC_ID(&hw25);
|
||||||
|
uint64_t w25_unique_ID = W25_CMD_Read_Device_ID(&hw25);
|
||||||
|
|
||||||
|
// Example fpr FLASH: writting MCU Program to external FLASH
|
||||||
|
MCUFlashToExternalFlashInit.pDataPtr = (uint8_t *)FLASH_BASE;
|
||||||
|
MCUFlashToExternalFlashInit.Data_Address = 0;
|
||||||
|
MCUFlashToExternalFlashInit.Data_Size = 0x2000;
|
||||||
|
MCUFlashToExternalFlashInit.Sector_Address = 0;
|
||||||
|
MCUFlashToExternalFlashInit.Sector_Size = 0x2000;
|
||||||
|
W25_RES = W25_FLASH_Write(&hw25, &MCUFlashToExternalFlashInit, 5000);
|
||||||
|
uint32_t FLASH_shift = 0;
|
||||||
|
W25_RES = W25_FLASH_Read(&hw25, 0x0000+FLASH_shift, read_buff, 15, 100);
|
||||||
|
|
||||||
|
// Example for FLASH: erase/program/read functions
|
||||||
|
W25_RES = W25_FLASH_Erase(&hw25, 0, 1, 1000);
|
||||||
|
W25_RES = W25_FLASH_Program(&hw25, 0xf9, write_buff, 15, 100);
|
||||||
|
W25_RES = W25_FLASH_Read(&hw25, 0xf9, read_buff, 15, 100);
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Example for FLASH: write area functions
|
// Example for FLASH: write area functions
|
||||||
W25_FLASH_Write_Area(&hw25, &writeInit, 1000);
|
W25_RES = W25_FLASH_Write(&hw25, &writeInit, 1000);
|
||||||
HAL_Delay(10);
|
W25_RES = W25_FLASH_Read(&hw25, 0xf9, read_buff, 15, 100);
|
||||||
W25_CMD_Read_Data(&hw25, 0xf9, read_buff, 15);
|
|
||||||
/* USER CODE END WHILE */
|
/* USER CODE END WHILE */
|
||||||
|
|
||||||
/* USER CODE BEGIN 3 */
|
/* USER CODE BEGIN 3 */
|
||||||
@@ -144,6 +157,7 @@ int main(void)
|
|||||||
uint32_t generated_rng;
|
uint32_t generated_rng;
|
||||||
HAL_RNG_GenerateRandomNumber(&hrng, &generated_rng);
|
HAL_RNG_GenerateRandomNumber(&hrng, &generated_rng);
|
||||||
write_buff[7] = generated_rng&0xFF;
|
write_buff[7] = generated_rng&0xFF;
|
||||||
|
write_buff[0] = (generated_rng>>16)&0xFF;
|
||||||
}
|
}
|
||||||
/* USER CODE END 3 */
|
/* USER CODE END 3 */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,9 +152,9 @@
|
|||||||
<Bp>
|
<Bp>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
<Type>0</Type>
|
<Type>0</Type>
|
||||||
<LineNumber>135</LineNumber>
|
<LineNumber>140</LineNumber>
|
||||||
<EnabledFlag>1</EnabledFlag>
|
<EnabledFlag>1</EnabledFlag>
|
||||||
<Address>134230152</Address>
|
<Address>134230654</Address>
|
||||||
<ByteObject>0</ByteObject>
|
<ByteObject>0</ByteObject>
|
||||||
<HtxType>0</HtxType>
|
<HtxType>0</HtxType>
|
||||||
<ManyObjects>0</ManyObjects>
|
<ManyObjects>0</ManyObjects>
|
||||||
@@ -163,12 +163,60 @@
|
|||||||
<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\135</Expression>
|
<Expression>\\flash_eeprom_Example\../Core/Src/main.c\140</Expression>
|
||||||
</Bp>
|
</Bp>
|
||||||
<Bp>
|
<Bp>
|
||||||
<Number>1</Number>
|
<Number>1</Number>
|
||||||
<Type>0</Type>
|
<Type>0</Type>
|
||||||
<LineNumber>136</LineNumber>
|
<LineNumber>138</LineNumber>
|
||||||
|
<EnabledFlag>1</EnabledFlag>
|
||||||
|
<Address>134230628</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\138</Expression>
|
||||||
|
</Bp>
|
||||||
|
<Bp>
|
||||||
|
<Number>2</Number>
|
||||||
|
<Type>0</Type>
|
||||||
|
<LineNumber>150</LineNumber>
|
||||||
|
<EnabledFlag>1</EnabledFlag>
|
||||||
|
<Address>134230760</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\150</Expression>
|
||||||
|
</Bp>
|
||||||
|
<Bp>
|
||||||
|
<Number>3</Number>
|
||||||
|
<Type>0</Type>
|
||||||
|
<LineNumber>198</LineNumber>
|
||||||
|
<EnabledFlag>1</EnabledFlag>
|
||||||
|
<Address>134229880</Address>
|
||||||
|
<ByteObject>0</ByteObject>
|
||||||
|
<HtxType>0</HtxType>
|
||||||
|
<ManyObjects>0</ManyObjects>
|
||||||
|
<SizeOfObject>0</SizeOfObject>
|
||||||
|
<BreakByAccess>0</BreakByAccess>
|
||||||
|
<BreakIfRCount>1</BreakIfRCount>
|
||||||
|
<Filename>..\..\spi_flash\spi_flash.c</Filename>
|
||||||
|
<ExecCommand></ExecCommand>
|
||||||
|
<Expression>\\flash_eeprom_Example\../../spi_flash/spi_flash.c\198</Expression>
|
||||||
|
</Bp>
|
||||||
|
<Bp>
|
||||||
|
<Number>4</Number>
|
||||||
|
<Type>0</Type>
|
||||||
|
<LineNumber>151</LineNumber>
|
||||||
<EnabledFlag>1</EnabledFlag>
|
<EnabledFlag>1</EnabledFlag>
|
||||||
<Address>0</Address>
|
<Address>0</Address>
|
||||||
<ByteObject>0</ByteObject>
|
<ByteObject>0</ByteObject>
|
||||||
@@ -177,7 +225,23 @@
|
|||||||
<SizeOfObject>0</SizeOfObject>
|
<SizeOfObject>0</SizeOfObject>
|
||||||
<BreakByAccess>0</BreakByAccess>
|
<BreakByAccess>0</BreakByAccess>
|
||||||
<BreakIfRCount>0</BreakIfRCount>
|
<BreakIfRCount>0</BreakIfRCount>
|
||||||
<Filename>../Core/Src/main.c</Filename>
|
<Filename>..\..\spi_flash\spi_flash.c</Filename>
|
||||||
|
<ExecCommand></ExecCommand>
|
||||||
|
<Expression></Expression>
|
||||||
|
</Bp>
|
||||||
|
<Bp>
|
||||||
|
<Number>5</Number>
|
||||||
|
<Type>0</Type>
|
||||||
|
<LineNumber>171</LineNumber>
|
||||||
|
<EnabledFlag>1</EnabledFlag>
|
||||||
|
<Address>0</Address>
|
||||||
|
<ByteObject>0</ByteObject>
|
||||||
|
<HtxType>0</HtxType>
|
||||||
|
<ManyObjects>0</ManyObjects>
|
||||||
|
<SizeOfObject>0</SizeOfObject>
|
||||||
|
<BreakByAccess>0</BreakByAccess>
|
||||||
|
<BreakIfRCount>0</BreakIfRCount>
|
||||||
|
<Filename>..\..\spi_flash\spi_flash.c</Filename>
|
||||||
<ExecCommand></ExecCommand>
|
<ExecCommand></ExecCommand>
|
||||||
<Expression></Expression>
|
<Expression></Expression>
|
||||||
</Bp>
|
</Bp>
|
||||||
@@ -186,37 +250,37 @@
|
|||||||
<Ww>
|
<Ww>
|
||||||
<count>0</count>
|
<count>0</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>w25_ID</ItemText>
|
<ItemText>hw25</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>1</count>
|
<count>1</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>w25_unique_ID</ItemText>
|
<ItemText>W25_RES</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>2</count>
|
<count>2</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>W25_RES</ItemText>
|
<ItemText>read_buff</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>3</count>
|
<count>3</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>read_buff</ItemText>
|
<ItemText>write_buff</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>4</count>
|
<count>4</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>write_buff</ItemText>
|
<ItemText>sector_buff</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>5</count>
|
<count>5</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>sector_buff</ItemText>
|
<ItemText>writeInit</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>6</count>
|
<count>6</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>writeInit</ItemText>
|
<ItemText>writebuff</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
</WatchWindow1>
|
</WatchWindow1>
|
||||||
<WatchWindow2>
|
<WatchWindow2>
|
||||||
@@ -240,7 +304,33 @@
|
|||||||
<WinNumber>2</WinNumber>
|
<WinNumber>2</WinNumber>
|
||||||
<ItemText>endsize</ItemText>
|
<ItemText>endsize</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>4</count>
|
||||||
|
<WinNumber>2</WinNumber>
|
||||||
|
<ItemText>&tickstart</ItemText>
|
||||||
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>5</count>
|
||||||
|
<WinNumber>2</WinNumber>
|
||||||
|
<ItemText>&0x20000760</ItemText>
|
||||||
|
</Ww>
|
||||||
</WatchWindow2>
|
</WatchWindow2>
|
||||||
|
<MemoryWindow1>
|
||||||
|
<Mm>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<SubType>0</SubType>
|
||||||
|
<ItemText>0x08000000</ItemText>
|
||||||
|
<AccSizeX>0</AccSizeX>
|
||||||
|
</Mm>
|
||||||
|
</MemoryWindow1>
|
||||||
|
<MemoryWindow2>
|
||||||
|
<Mm>
|
||||||
|
<WinNumber>2</WinNumber>
|
||||||
|
<SubType>0</SubType>
|
||||||
|
<ItemText>0x20000708</ItemText>
|
||||||
|
<AccSizeX>0</AccSizeX>
|
||||||
|
</Mm>
|
||||||
|
</MemoryWindow2>
|
||||||
<Tracepoint>
|
<Tracepoint>
|
||||||
<THDelay>0</THDelay>
|
<THDelay>0</THDelay>
|
||||||
</Tracepoint>
|
</Tracepoint>
|
||||||
|
|||||||
Reference in New Issue
Block a user