Skip to content

Commit

Permalink
[stm32] Adapt and enable flash driver for STM32G4
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmuskleist authored and rleh committed Mar 16, 2022
1 parent 21ba120 commit c67fcbc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">○</td>
<td align="center">✅</td>
<td align="center"></td>
<td align="center"></td>
<td align="center">○</td>
<td align="center">○</td>
<td align="center">○</td>
Expand Down
3 changes: 2 additions & 1 deletion src/modm/platform/flash/stm32/flash.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Flash::erase(uint8_t index)
FLASH->CR = FLASH_CR_STRT | FLASH_CR_SER | uint32_t(size) |
((index << FLASH_CR_SNB_Pos) & FLASH_CR_SNB_Msk);
%% else
%% if family == "g0"
%% if family in ["g0","g4"]
FLASH->CR = FLASH_CR_STRT | FLASH_CR_PER |
((index << FLASH_CR_PNB_Pos) & FLASH_CR_PNB_Msk);
%% else
Expand Down Expand Up @@ -154,6 +154,7 @@ Flash::program(uintptr_t addr, MaxWordType data)
FLASH->CR &= ~FLASH_CR_PG;
return FLASH->SR & FLASH_SR_PGERR;
%% else
FLASH->SR |= FLASH_SR_EOP;
FLASH->CR = 0;
return FLASH->SR & FLASH_SR_ERR;
%% endif
Expand Down
1 change: 0 additions & 1 deletion src/modm/platform/flash/stm32/flash.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public:
%% if not has_sectors and family == "g0"
Rcc::disable<Peripheral::Flash>();
%% endif

}

static bool
Expand Down
6 changes: 5 additions & 1 deletion src/modm/platform/flash/stm32/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def init(module):

def prepare(module, options):
device = options[":target"]
if device.identifier.family not in ["g0", "f1", "f4"]:
if device.identifier.family not in ["g0","g4", "f1", "f4"]:
return False
if not device.has_driver("flash:stm32*"):
return False
Expand All @@ -44,6 +44,10 @@ def build(env):
block_shift = 11
ftype = "page"
busy_bit = "FLASH_SR_BSY1"
elif target.family in ["g4"]:
block_shift = 11
ftype = "page"
busy_bit = "FLASH_SR_BSY"

env.substitutions = {
"start": int(flash["start"], 16),
Expand Down

0 comments on commit c67fcbc

Please sign in to comment.