Минимальный функционал
flashwrapper.cpp@0:0f5e5690b713, 2020-06-25 (annotated)
- Committer:
- nikmaos
- Date:
- Thu Jun 25 08:28:04 2020 +0000
- Revision:
- 0:0f5e5690b713
minimal func
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nikmaos | 0:0f5e5690b713 | 1 | /* |
nikmaos | 0:0f5e5690b713 | 2 | * flashwrapper.c |
nikmaos | 0:0f5e5690b713 | 3 | * |
nikmaos | 0:0f5e5690b713 | 4 | * Author: spookee |
nikmaos | 0:0f5e5690b713 | 5 | */ |
nikmaos | 0:0f5e5690b713 | 6 | |
nikmaos | 0:0f5e5690b713 | 7 | #include "stm32f4xx_hal.h" |
nikmaos | 0:0f5e5690b713 | 8 | |
nikmaos | 0:0f5e5690b713 | 9 | #include "flashwrapper.h" |
nikmaos | 0:0f5e5690b713 | 10 | |
nikmaos | 0:0f5e5690b713 | 11 | |
nikmaos | 0:0f5e5690b713 | 12 | uint32_t flashRead(uint32_t address) { |
nikmaos | 0:0f5e5690b713 | 13 | return (*(uint32_t*)(address+START_ADRESS)); |
nikmaos | 0:0f5e5690b713 | 14 | } |
nikmaos | 0:0f5e5690b713 | 15 | |
nikmaos | 0:0f5e5690b713 | 16 | void flashWrite(uint32_t address, uint32_t *p_data, uint16_t size) { |
nikmaos | 0:0f5e5690b713 | 17 | HAL_FLASH_Unlock(); |
nikmaos | 0:0f5e5690b713 | 18 | __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR); |
nikmaos | 0:0f5e5690b713 | 19 | FLASH_Erase_Sector(FLASH_SECTOR_12, VOLTAGE_RANGE_3); |
nikmaos | 0:0f5e5690b713 | 20 | for (int i = 0; i < size; i++) { |
nikmaos | 0:0f5e5690b713 | 21 | HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, START_ADRESS+address + i*4, p_data[i]); |
nikmaos | 0:0f5e5690b713 | 22 | } |
nikmaos | 0:0f5e5690b713 | 23 | HAL_FLASH_Lock(); |
nikmaos | 0:0f5e5690b713 | 24 | } |
nikmaos | 0:0f5e5690b713 | 25 |