ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_flash_irq.c File Reference

MRAM IRQ enables + dispatcher and FSP r_mram parity surface – DANGEROUS. More...

#include <stdint.h>
#include "ra8_attributes.h"
#include "ra8_check.h"
#include "ra8_err.h"
#include "ra8_flash.h"
#include "ra8_flash_internal.h"
#include "ra8_flash_regs.h"
#include "ra8_log.h"
Include dependency graph for ra8_flash_irq.c:

Go to the source code of this file.

Enumerations

enum  ra8_flash_blank_const_t : uint8_t { k_ra8_flash_blank_byte = 0xFFU }
 Erase-pattern constants used by ra8_flash_blank_check. More...

Functions

static void internal_irq_rmw8 (uint16_t off, uint8_t bit, bool enable)
 Read-modify-write a single bit in an 8-bit register.
static void internal_apply_ecc_irq (uint16_t off, bool is_ted, bool enable)
 Apply enable/disable to an MRCRAEINT-style ECC IRQ.
static void internal_apply_extra_err_irq (bool err_kind, bool enable)
 Apply enable/disable to an MPAEINT bit.
ra8_err_t ra8_flash_set_irq_enable (ra8_flash_irq_src_t src, bool enable)
 Enable or disable MRAM-controller IRQs by source.
ra8_err_t ra8_flash_callback_set (ra8_flash_callback_t cb, void *user_ctx)
 Register the unified IRQ callback.
static void internal_deliver (ra8_flash_irq_src_t src, uint32_t fault_addr, uint32_t status_word)
 Deliver one IRQ event to the registered callback.
static uint32_t internal_dispatch_ecc (uint16_t status_off, uint16_t ted_addr_off, uint16_t dec_addr_off, ra8_flash_irq_src_t ted_src, ra8_flash_irq_src_t dec_src)
 Dispatch ECC TED/DEC events for one of the two MRAM regions.
uint32_t ra8_flash_dispatch_isr (void)
 Run the MRAM IRQ dispatcher (call from the BSP vector).
ra8_err_t ra8_flash_open (const ra8_flash_cfg_t *cfg)
 FSP-parity bring-up: equivalent to ra8_flash_init.
ra8_err_t ra8_flash_close (void)
 FSP-parity tear-down: equivalent to ra8_flash_deinit.
ra8_err_t ra8_flash_set_window (uintptr_t low, uintptr_t high)
 Configure the soft access window enforced by write/erase.
static ra8_err_t internal_validate_range (uintptr_t address, uint64_t total_len)
 Validate a multi-block erase / multi-page write range.
ra8_err_t ra8_flash_erase (uintptr_t address, uint32_t num_blocks)
 Erase num_blocks consecutive 32-byte MRAM blocks.
ra8_err_t ra8_flash_write (uintptr_t address, const uint8_t *src, uint32_t len)
 Program len bytes into code-MRAM starting at address.
ra8_err_t ra8_flash_blank_check (uintptr_t address, uint32_t len, bool *out_blank)
 Check whether a region holds the erase pattern (all 0xFF).
ra8_err_t ra8_flash_status (ra8_flash_status_t *out)
 Decode the controller status into a flat ra8_flash_status_t.

Detailed Description

MRAM IRQ enables + dispatcher and FSP r_mram parity surface – DANGEROUS.

Tag
[Ring 3 / HAL] {World: S}

Interrupt-handling and FSP-parity aspect of the ra8_flash driver, split out of ra8_flash.c so every translation unit stays under the file-size cap. Implements the slice of the HUM Ch 59 surface declared in ra8_flash.h:

  • Per-source IRQ enables (ECC TED/DEC, program error, extra access error / command-lock, ready) and a single-callback dispatcher (HUM Ch 59 p 3554..3601 + p 3624).
  • The FSP r_mram parity surface: open / close, soft access window, multi-block erase, multi-page write, blank-check, and the high-level status snapshot (HUM Ch 59.4.2 p 3548 + p 3577..3605).

Cross-TU shared runtime state and the promoted window_allows helper live in ra8_flash_internal.h. Every register access carries a HUM Ch 59 citation.

Since
0.1.0

Definition in file ra8_flash_irq.c.

Enumeration Type Documentation

◆ ra8_flash_blank_const_t

enum ra8_flash_blank_const_t : uint8_t

Erase-pattern constants used by ra8_flash_blank_check.

Enumerator
k_ra8_flash_blank_byte 

Erased state byte value (HUM Ch 59 p 3548).

Definition at line 461 of file ra8_flash_irq.c.

Function Documentation

◆ internal_apply_ecc_irq()

void internal_apply_ecc_irq ( uint16_t off,
bool is_ted,
bool enable )
static

Apply enable/disable to an MRCRAEINT-style ECC IRQ.

HUM Ch 59 "MRCRAEINT" p 3554 / "MRERAINT" p 3557. The two registers share TED/DEC bit positions, so the helper just picks which register byte and which bit to flip.

Parameters
[in]offMRCRAEINT or MRERAINT offset.
[in]is_tedtrue for the TED bit, false for DEC.
[in]enabletrue to set the bit.
Precondition
Module clock ungated.
Postcondition
Selected bit reflects enable.
Note
Internal helper, not thread-safe.
Since
0.1.0
Precondition
Module/state preconditions hold (see function body).
Postcondition
Documented side effects are visible on success.

Definition at line 97 of file ra8_flash_irq.c.

References internal_irq_rmw8(), k_ra8_mrcraeint_mask_intenbdc, k_ra8_mrcraeint_mask_intenbtc, and RA8_INTERNAL.

Referenced by ra8_flash_set_irq_enable().

◆ internal_apply_extra_err_irq()

void internal_apply_extra_err_irq ( bool err_kind,
bool enable )
static

Apply enable/disable to an MPAEINT bit.

HUM Ch 59 "MPAEINT" p 3577. Selects between the access-error and command-lock bits.

Parameters
[in]err_kindtrue for MREAEIE, false for CMDLKIE.
[in]enabletrue to set the bit.
Precondition
Module clock ungated.
Postcondition
Selected bit reflects enable.
Note
Internal helper, not thread-safe.
Since
0.1.0
Precondition
Module/state preconditions hold (see function body).
Postcondition
Documented side effects are visible on success.

Definition at line 125 of file ra8_flash_irq.c.

References internal_irq_rmw8(), k_ra8_mpaeint_mask_cmdlkie, k_ra8_mpaeint_mask_mreaeie, k_ra8_mram_off_mpaeint, and RA8_INTERNAL.

Referenced by ra8_flash_set_irq_enable().

◆ internal_deliver()

void internal_deliver ( ra8_flash_irq_src_t src,
uint32_t fault_addr,
uint32_t status_word )
static

Deliver one IRQ event to the registered callback.

Parameters
[in]srcSource identifier.
[in]fault_addrCaptured address (0 if N/A).
[in]status_wordSource register snapshot.
Precondition
None (no-op if no callback registered).
Postcondition
If a callback is registered, it ran exactly once.

See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.

Note
Thread safety: see the header declaration.
Since
0.1.0
Precondition
Module/state preconditions hold (see function body).
Postcondition
Documented side effects are visible on success.

Definition at line 207 of file ra8_flash_irq.c.

References g_flash_rt.

Referenced by internal_dispatch_ecc(), and ra8_flash_dispatch_isr().

◆ internal_dispatch_ecc()

uint32_t internal_dispatch_ecc ( uint16_t status_off,
uint16_t ted_addr_off,
uint16_t dec_addr_off,
ra8_flash_irq_src_t ted_src,
ra8_flash_irq_src_t dec_src )
static

Dispatch ECC TED/DEC events for one of the two MRAM regions.

HUM Ch 59 "MRCRAES" p 3554 (code MRAM) and "MRERAES" p 3557 (extra MRAM). The two registers share the same bit layout; status_off picks which one we observe and W1C-clear, and ted_addr_off / dec_addr_off give the matching error-address registers.

Parameters
[in]status_offMRCRAES / MRERAES offset.
[in]ted_addr_offMRCRTEA / MRERTEA offset.
[in]dec_addr_offMRCRDEA / MRERDEA offset.
[in]ted_srcIRQ source enum for the TED event.
[in]dec_srcIRQ source enum for the DEC event.
Returns
Number of callbacks delivered (0..2).
Precondition
Module clock ungated.
Postcondition
W1C status register cleared on observation.
Note
Internal helper, not thread-safe.
Return values
k_ra8_okSuccess path.
k_ra8_err_invalid_argCaller violated a precondition.
Since
0.1.0
Precondition
Module/state preconditions hold (see function body).
Postcondition
Documented side effects are visible on success.

Definition at line 249 of file ra8_flash_irq.c.

References internal_deliver(), k_ra8_mrcraes_mask_decerrc, k_ra8_mrcraes_mask_tederrc, RA8_INTERNAL, ra8_mram_reg32(), and ra8_mram_reg8().

Referenced by ra8_flash_dispatch_isr().

◆ internal_irq_rmw8()

void internal_irq_rmw8 ( uint16_t off,
uint8_t bit,
bool enable )
static

Read-modify-write a single bit in an 8-bit register.

Helper used by ra8_flash_set_irq_enable to set or clear a single IRQ-enable bit without disturbing the rest of the byte.

Parameters
[in]offMRAM register offset.
[in]bitMask of the bit to drive.
[in]enabletrue to set, false to clear.
Precondition
Module clock ungated.
Postcondition
Register byte reflects the requested change.
Note
Internal helper, not thread-safe.
Since
0.1.0
Precondition
Module/state preconditions hold (see function body).
Postcondition
Documented side effects are visible on success.

Definition at line 65 of file ra8_flash_irq.c.

References RA8_INTERNAL, and ra8_mram_reg8().

Referenced by internal_apply_ecc_irq(), and internal_apply_extra_err_irq().

◆ internal_validate_range()

ra8_err_t internal_validate_range ( uintptr_t address,
uint64_t total_len )
static

Validate a multi-block erase / multi-page write range.

Folds the alignment + bounds + soft-window checks shared by ra8_flash_erase and ra8_flash_write. Both APIs operate on the 32-byte programming unit (HUM Ch 59.4.2 p 3548).

Parameters
[in]addressRange start address.
[in]total_lenTotal number of bytes covered by the operation.
Returns
k_ra8_ok if the range is acceptable.
Precondition
None.
Postcondition
No side effects.
Note
Internal helper, not thread-safe.
Return values
k_ra8_okSuccess path.
k_ra8_err_invalid_argCaller violated a precondition.
Since
0.1.0
Precondition
Module/state preconditions hold (see function body).
Postcondition
Documented side effects are visible on success.

Definition at line 382 of file ra8_flash_irq.c.

References k_ra8_err_invalid_arg, k_ra8_err_out_of_range, k_ra8_flash_code_size, k_ra8_flash_code_start, k_ra8_mram_block_size_bytes, k_ra8_ok, priv_ra8_flash_internal_window_allows(), and RA8_INTERNAL.

Referenced by ra8_flash_erase(), and ra8_flash_write().

◆ ra8_flash_blank_check()

ra8_err_t ra8_flash_blank_check ( uintptr_t address,
uint32_t len,
bool * out_blank )
nodiscard

Check whether a region holds the erase pattern (all 0xFF).

FSP's R_MRAM_BlankCheck is a stub (returns FSP_ERR_UNSUPPORTED on RA8D2 – see r_mram.c line 395). The HUM Ch 59 layout uses 0xFF as the natural erased state, so this driver implements the check as a direct read of the region in 16-byte chunks. *out_blank is true iff every byte in [address, address + len) equals 0xFF.

Parameters
[in]addressStart address inside code-MRAM, extra-MRAM, or OFS.
[in]lenLength in bytes; must be > 0 and inside one window.
[out]out_blankNon-NULL destination for the result.
Returns
ra8_err_t error code.
Return values
k_ra8_okCheck completed; *out_blank set.
k_ra8_err_null_ptrout_blank was NULL.
k_ra8_err_invalid_arglen is 0 or range outside MRAM windows.
Precondition
out_blank non-null and len > 0.
ra8_flash_open (or ra8_flash_init) has been called.
Postcondition
*out_blank reflects whether every byte equals 0xFF.
No state change in the controller.
Note
Thread-safe: pure reads; not atomic if concurrent writers exist.
Since
0.1.0

Definition at line 465 of file ra8_flash_irq.c.

References g_flash_tag, k_ra8_err_invalid_arg, k_ra8_flash_blank_byte, k_ra8_flash_code_size, k_ra8_flash_code_start, k_ra8_flash_extra_size, k_ra8_flash_extra_start, k_ra8_flash_ofs_size, k_ra8_flash_ofs_start, k_ra8_ok, and RA8_CHECK_NULL_PTR.

◆ ra8_flash_callback_set()

ra8_err_t ra8_flash_callback_set ( ra8_flash_callback_t cb,
void * user_ctx )
nodiscard

Register the unified IRQ callback.

The dispatcher (ra8_flash_dispatch_isr) walks every documented status register and calls this callback once per pending source. Pass NULL to deregister.

Parameters
[in]cbCallback function or NULL.
[in]user_ctxOpaque pointer passed back via ev->user_ctx.
Returns
ra8_err_t error code.
Return values
k_ra8_okAlways.
Precondition
None.
Postcondition
Subsequent ra8_flash_dispatch_isr calls invoke cb.
Pre-existing pending events are NOT replayed.
Note
Thread-safe: no – caller must serialise vs dispatch_isr.
See also
ra8_flash_dispatch_isr
Since
0.1.0

Definition at line 181 of file ra8_flash_irq.c.

References g_flash_rt, and k_ra8_ok.

◆ ra8_flash_close()

ra8_err_t ra8_flash_close ( void )
nodiscard

FSP-parity tear-down: equivalent to ra8_flash_deinit.

Mirrors R_MRAM_Close (FSP r_mram.c line 646). Locks all program gates, exits P/E mode, clears sticky errors, re-enables prefetch.

Returns
ra8_err_t error code.
Return values
k_ra8_okAlways.
Precondition
No write/erase operation in progress.
Postcondition
Controller is in pure read mode.
Note
Thread-safe: no.
See also
ra8_flash_open
Since
0.1.0

Definition at line 336 of file ra8_flash_irq.c.

References ra8_flash_deinit().

◆ ra8_flash_dispatch_isr()

uint32_t ra8_flash_dispatch_isr ( void )

Run the MRAM IRQ dispatcher (call from the BSP vector).

Walks MRCRAES (code-ECC), MRERAES (extra-ECC), MRCPS (program-err), MASTAT (extra-err / cmdlk), MSTATR (extra-ready); for each pending bit, builds a ra8_flash_isr_event_t and calls the registered callback. After the callback returns, the dispatcher clears the matching status flag (W1C bits) so the next call sees only fresh events.

Returns
Number of events delivered.
Precondition
ra8_flash_callback_set registered a callback (otherwise a no-op walk runs and 0 is returned).
Postcondition
Every W1C status bit observed at entry is cleared.
The registered callback was invoked once per pending source.
Note
Thread-safe: no, IRQ-context only.
See also
ra8_flash_callback_set
Since
0.1.0
Return values
k_ra8_okSuccess path.
k_ra8_err_invalid_argCaller violated a precondition.
Precondition
Module has been initialized.

Definition at line 273 of file ra8_flash_irq.c.

References internal_deliver(), internal_dispatch_ecc(), k_ra8_flash_irq_code_ecc_dec, k_ra8_flash_irq_code_ecc_ted, k_ra8_flash_irq_extra_cmdlk, k_ra8_flash_irq_extra_ecc_dec, k_ra8_flash_irq_extra_ecc_ted, k_ra8_flash_irq_extra_err, k_ra8_flash_irq_extra_ready, k_ra8_flash_irq_program_err, k_ra8_mastat_mask_cmdlk, k_ra8_mastat_mask_mreae, k_ra8_mram_off_mastat, k_ra8_mram_off_mrcpea, k_ra8_mram_off_mrcps, k_ra8_mram_off_mrcraes, k_ra8_mram_off_mrcrdea, k_ra8_mram_off_mrcrtea, k_ra8_mram_off_mreraes, k_ra8_mram_off_mrerdea, k_ra8_mram_off_mrertea, k_ra8_mram_off_mstatr, k_ra8_mrcps_mask_errors, k_ra8_mstatr_mask_mrdy, ra8_mram_reg32(), and ra8_mram_reg8().

◆ ra8_flash_erase()

ra8_err_t ra8_flash_erase ( uintptr_t address,
uint32_t num_blocks )
nodiscard

Erase num_blocks consecutive 32-byte MRAM blocks.

Mirrors R_MRAM_Erase (FSP r_mram.c line 365). Loops over ra8_flash_erase_block once per block. The world (NS / S) is inferred from the destination address: addresses inside the secure code-MRAM alias use MRCPC1, all others use MRCPC0.

Parameters
[in]address32-byte aligned destination inside code-MRAM.
[in]num_blocksNumber of consecutive 32-byte blocks to erase. Must be > 0 and inside the code-MRAM window.
Returns
ra8_err_t error code.
Return values
k_ra8_okAll blocks erased.
k_ra8_err_invalid_argAddress misaligned, num_blocks is 0, or the range exceeds the code-MRAM window.
k_ra8_err_out_of_rangeAddress blocked by the soft access window set via ra8_flash_set_window.
k_ra8_err_hw_errorController reported a program error.
k_ra8_err_hw_timeoutController never observed OPDONE.
Precondition
address is 32-byte aligned and inside code-MRAM.
ra8_flash_open (or ra8_flash_init) has been called.
Postcondition
On success, every byte in [address, address + 32*num_blocks) reads 0xFF.
Program-control gate is locked on every exit path.
Note
Thread-safe: no.
Warning
Same brick warnings as ra8_flash_write_block.
See also
ra8_flash_erase_block
Since
0.1.0

Definition at line 400 of file ra8_flash_irq.c.

References g_flash_rt, g_flash_tag, internal_validate_range(), k_ra8_err_invalid_arg, k_ra8_flash_world_ns, k_ra8_mram_block_size_bytes, k_ra8_ok, ra8_flash_erase_block(), RA8_RETURN_ON_ERROR, and RA8_VALIDATE_INIT.

◆ ra8_flash_open()

ra8_err_t ra8_flash_open ( const ra8_flash_cfg_t * cfg)
nodiscard

FSP-parity bring-up: equivalent to ra8_flash_init.

Mirrors R_MRAM_Open (FSP r_mram.c line 253). Registers the controller for use, programs MRCFREQ / MREFREQ, and locks both program-control gates. After ra8_flash_open callers may invoke ra8_flash_write / ra8_flash_erase / ra8_flash_blank_check / ra8_flash_status / ra8_flash_set_window.

Parameters
[in]cfgNon-NULL configuration descriptor.
Returns
ra8_err_t error code.
Return values
k_ra8_okController opened.
k_ra8_err_null_ptrcfg was NULL.
k_ra8_err_invalid_argcfg field out of range.
Precondition
IRQs masked or single-threaded init context.
Caller is not currently executing out of MRAM that will be programmed.
Postcondition
Soft access window (ra8_flash_set_window) state is preserved across re-open; defaults to "all-allowed" on first boot.
MRCPC0 / MRCPC1 are locked.
Note
Thread-safe: no, single-threaded init only.
See also
ra8_flash_close
ra8_flash_init
Since
0.1.0

Definition at line 329 of file ra8_flash_irq.c.

References ra8_flash_init().

Referenced by ra8_dfu_program_prepare().

◆ ra8_flash_set_irq_enable()

ra8_err_t ra8_flash_set_irq_enable ( ra8_flash_irq_src_t src,
bool enable )
nodiscard

Enable or disable MRAM-controller IRQs by source.

Routes per-source enable bits to the matching register:

  • code_ecc_* -> MRCRAEINT (HUM Ch 59 p 3554).
  • extra_ecc_* -> MRERAINT (HUM Ch 59 p 3557).
  • program_err -> MRCPAEINT (HUM Ch 59 p 3601).
  • extra_err / extra_cmdlk -> MPAEINT (HUM Ch 59 p 3577).
  • extra_ready -> MRDYIE (HUM Ch 59 p 3577).
Parameters
[in]srcSource to gate.
[in]enabletrue => enable, false => disable.
Returns
ra8_err_t error code.
Return values
k_ra8_okEnable bit applied.
k_ra8_err_invalid_argsrc out of range.
Precondition
src < k_ra8_flash_irq_count.
ra8_flash_init has been called.
Postcondition
Matching enable bit set / cleared.
Note
Thread-safe: no.
Since
0.1.0

Definition at line 134 of file ra8_flash_irq.c.

References internal_apply_ecc_irq(), internal_apply_extra_err_irq(), k_ra8_err_invalid_arg, k_ra8_flash_irq_code_ecc_dec, k_ra8_flash_irq_code_ecc_ted, k_ra8_flash_irq_count, k_ra8_flash_irq_extra_cmdlk, k_ra8_flash_irq_extra_ecc_dec, k_ra8_flash_irq_extra_ecc_ted, k_ra8_flash_irq_extra_err, k_ra8_flash_irq_extra_ready, k_ra8_flash_irq_program_err, k_ra8_mram_off_mrcpaeint, k_ra8_mram_off_mrcraeint, k_ra8_mram_off_mrdyie, k_ra8_mram_off_mreraint, k_ra8_mrcpaeint_mask_mrcaeie, k_ra8_mrdyie_mask_mrdyie, k_ra8_ok, and ra8_mram_reg8().

◆ ra8_flash_set_window()

ra8_err_t ra8_flash_set_window ( uintptr_t low,
uintptr_t high )
nodiscard

Configure the soft access window enforced by write/erase.

FSP's R_MRAM_AccessWindowSet is a stub on RA8D2 (returns FSP_ERR_UNSUPPORTED – see r_mram.c line 469); the silicon has no FAWMON / FAWMR registers because MRAM uses block-protect bits in the MRCBPROT0 / MRCBPROT1 registers instead. To preserve a useful FSP-style surface, this driver maintains a software window: ra8_flash_write, ra8_flash_erase and ra8_flash_write_block reject any request that touches an address outside [low, high). Pass low == high == 0 to disable the window (allow all addresses, the default after open).

Parameters
[in]lowInclusive lower bound (or 0 to disable).
[in]highExclusive upper bound (or 0 to disable).
Returns
ra8_err_t error code.
Return values
k_ra8_okWindow applied.
k_ra8_err_invalid_arglow >= high and not both zero.
Precondition
low < high or both are zero.
Postcondition
Subsequent writes/erases enforce the window.
Note
Thread-safe: no – caller must serialise vs writes/erases.
See also
ra8_flash_block_protect_set
Since
0.1.0

Definition at line 343 of file ra8_flash_irq.c.

References g_flash_rt, k_ra8_err_invalid_arg, and k_ra8_ok.

Referenced by ra8_dfu_program_prepare().

◆ ra8_flash_status()

ra8_err_t ra8_flash_status ( ra8_flash_status_t * out)
nodiscard

Decode the controller status into a flat ra8_flash_status_t.

Reads MRCPS / MASTAT / MENTRYR / MSTATR / MRCBPROT0 / MRCBPROT1 and collapses the bits down to the FSP-parity ra8_flash_status_t boolean fields. HUM Ch 59 p 3577..3605.

Parameters
[out]outNon-NULL destination structure.
Returns
ra8_err_t error code.
Return values
k_ra8_okStatus decoded.
k_ra8_err_null_ptrout was NULL.
Precondition
out non-null.
Controller is powered (always true after reset).
Postcondition
Every out-> field reflects the registers at call time.
Note
Thread-safe: pure reads; not atomic across registers.
See also
ra8_flash_get_extended_status
Since
0.1.0

Definition at line 504 of file ra8_flash_irq.c.

References ra8_flash_status_t::ecc_error, ra8_flash_status_t::erase_busy, g_flash_tag, ra8_flash_status_t::illegal_command, k_ra8_mastat_mask_cmdlk, k_ra8_mentryr_mask_pe_mode, k_ra8_mram_off_mastat, k_ra8_mram_off_mentryr, k_ra8_mram_off_mrcbprot0, k_ra8_mram_off_mrcbprot1, k_ra8_mram_off_mrcps, k_ra8_mram_off_mstatr, k_ra8_mrcps_mask_eccerrc, k_ra8_mrcps_mask_prgbsyc, k_ra8_mrcps_mask_prgerrc, k_ra8_mstatr_mask_ilgcomerr, k_ra8_mstatr_mask_oterr, k_ra8_ok, ra8_flash_status_t::program_error, ra8_flash_status_t::programming_busy, RA8_CHECK_NULL_PTR, ra8_mram_reg16(), ra8_mram_reg32(), ra8_mram_reg8(), ra8_flash_status_t::sector_protected, and ra8_flash_status_t::voltage_error.

◆ ra8_flash_write()

ra8_err_t ra8_flash_write ( uintptr_t address,
const uint8_t * src,
uint32_t len )
nodiscard

Program len bytes into code-MRAM starting at address.

Mirrors R_MRAM_Write (FSP r_mram.c line 323 + mram_write_data line 861). The driver chunks the request into per-page writes of up to 32 bytes (k_ra8_mram_write_size_bytes), each one going through ra8_flash_write_block. len must be a non-zero multiple of the 32-byte page size; arbitrary lengths are rejected to match FSP's BSP_FEATURE_MRAM_PROGRAMMING_SIZE_BYTES boundary requirement.

Parameters
[in]addressDestination start address (32-byte aligned, inside code-MRAM).
[in]srcNon-NULL source buffer of at least len bytes.
[in]lenLength in bytes; must be non-zero and a multiple of 32.
Returns
ra8_err_t error code.
Return values
k_ra8_okAll bytes written.
k_ra8_err_null_ptrsrc was NULL.
k_ra8_err_invalid_argaddress misaligned, len not a multiple of 32, or range outside the code-MRAM window.
k_ra8_err_out_of_rangeRange blocked by the soft access window.
k_ra8_err_hw_errorController reported a program error.
k_ra8_err_hw_timeoutController never observed OPDONE.
Precondition
src non-null; address 32-byte aligned; len multiple of 32.
ra8_flash_open (or ra8_flash_init) has been called.
Postcondition
On success, the destination range holds the source bytes.
Program-control gate is locked on every exit path.
Note
Thread-safe: no.
Warning
Same brick warnings as ra8_flash_write_block.
See also
ra8_flash_write_block
Since
0.1.0

Definition at line 430 of file ra8_flash_irq.c.

References g_flash_rt, g_flash_tag, internal_validate_range(), k_ra8_err_invalid_arg, k_ra8_flash_world_ns, k_ra8_mram_write_size_bytes, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_flash_write_block(), RA8_RETURN_ON_ERROR, and RA8_VALIDATE_INIT.