65 uint32_t mode_repeat_block_val,
68 return (mode == mode_normal_val) || (mode == mode_repeat_block_val);
88 uint32_t mode_repeat_block_val,
91 return irq_each && (mode != mode_repeat_block_val);
94static const char*
s_tag =
"DMAC";
299 (uint32_t)cfg->
mode)) {
325 uint32_t v = (uint32_t)cfg->
count;
407 if (reg ==
nullptr) {
435 if (reg ==
nullptr) {
474 local.
mode = forced_mode;
500 if (reg ==
nullptr) {
505 uint16_t v = reg->
DMAMD;
568 if (reg ==
nullptr) {
580 if (reg ==
nullptr) {
591 if (reg ==
nullptr) {
594 for (uint32_t i = 0U; i < poll_limit; ++i) {
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_ISR_SAFE
The function is callable from interrupt context.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_RETURN_ON_ERROR(err, tag, message)
Early return on error, propagating the code upward.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
void ra8_dmac_dispatch_half(uint8_t channel)
Fire the per-channel half-complete callback (DMINT.RPTIE path).
static void internal_program_channel(volatile r_dmac_channel_regs_t *reg, const ra8_dmac_config_t *cfg)
Programme every per-channel register from cfg.
bool priv_ra8_dmac_internal_mode_disables_dts(uint32_t mode_normal_val, uint32_t mode_repeat_block_val, uint32_t mode)
Pure DTS-disabled predicate – see header for full contract.
static uint16_t internal_md_code(ra8_dmac_mode_t mode)
Translate cfg->mode -> DMTMD.MD 2-bit code.
static uint32_t internal_dmcra_value(const ra8_dmac_config_t *cfg)
Compose the DMCRA register value.
void ra8_dmac_dispatch(uint8_t channel)
Fire the per-channel completion callback (DMINT.DTIE path).
static uint16_t internal_dts_code(ra8_dmac_mode_t mode, ra8_dmac_repeat_area_t area)
Translate cfg->repeat_area -> DMTMD.DTS 2-bit code.
ra8_err_t ra8_dmac_start_repeat(uint8_t channel, const ra8_dmac_config_t *cfg)
Programme a DMAC channel in repeat-area transfer mode.
ra8_err_t ra8_dmac_attach_half_complete_handler(uint8_t channel, ra8_dmac_callback_fn_t fn, void *ctx)
Attach a half-block IRQ callback to a DMAC channel.
ra8_err_t ra8_dmac_stop(uint8_t channel)
Disable a DMAC0 channel and drop its MSTP reference.
static ra8_err_t internal_validate_cfg(const ra8_dmac_config_t *cfg)
ra8_err_t ra8_dmac_is_active(uint8_t channel, bool *out_active)
Query whether a DMAC0 channel is mid-transfer.
ra8_err_t ra8_dmac_start(uint8_t channel, const ra8_dmac_config_t *cfg)
Programme and enable a DMAC0 channel.
static uint16_t internal_dmtmd_value(const ra8_dmac_config_t *cfg)
Compose the DMTMD register value.
ra8_err_t ra8_dmac_set_address_mode(uint8_t channel, ra8_dmac_addr_mode_t src_mode, ra8_dmac_addr_mode_t dest_mode)
Override the DMAMD.SM / DMAMD.DM address-update modes.
ra8_err_t ra8_dmac_start_block(uint8_t channel, const ra8_dmac_config_t *cfg)
Programme a DMAC channel in block-transfer mode.
static ra8_dmac_cb_slot_t s_dmac_cb_slots[k_ra8_dmac_channel_count]
One slot per DMAC0 channel.
static uint16_t internal_sz_code(ra8_dmac_width_t width)
Translate cfg->width -> DMTMD.SZ 2-bit code.
static ra8_err_t internal_start_with_mode(uint8_t channel, const ra8_dmac_config_t *cfg, ra8_dmac_mode_t forced_mode)
ra8_err_t ra8_dmac_wait_idle(uint8_t channel, uint32_t poll_limit)
Spin until a DMAC0 channel goes idle or a poll bound expires.
static uint16_t internal_dmamd_value(bool src_inc, bool dst_inc)
Compose the DMAMD register value from the increment flags.
bool priv_ra8_dmac_internal_dmint_extra_irq(bool irq_each, uint32_t mode_repeat_block_val, uint32_t mode)
Pure extra-IRQ predicate – see header for full contract.
static uint8_t internal_dmint_value(const ra8_dmac_config_t *cfg)
Compose the DMINT register value.
ra8_err_t ra8_dmac_attach_callback(uint8_t channel, ra8_dmac_callback_fn_t fn, void *ctx)
Attach a transfer-end IRQ callback to a DMAC channel.
ra8_err_t ra8_dmac_software_trigger(uint8_t channel)
Software-trigger one transfer request on a DMAC0 channel.
8-channel DMA controller (DMAC0) driver
void(* ra8_dmac_callback_fn_t)(void *ctx)
Per-channel DMAC completion / half-complete callback signature.
ra8_dmac_mode_t
Transfer mode select.
@ k_ra8_dmac_mode_repeat
DMTMD.MD = 01b.
@ k_ra8_dmac_mode_repeat_block
DMTMD.MD = 11b.
@ k_ra8_dmac_mode_normal
DMTMD.MD = 00b.
@ k_ra8_dmac_mode_block
DMTMD.MD = 10b.
ra8_dmac_repeat_area_t
Selects which side is the repeat / block area (DMTMD.DTS).
@ k_ra8_dmac_repeat_area_dest
DTS = 00b.
@ k_ra8_dmac_repeat_area_none
DTS = 10b.
@ k_ra8_dmac_repeat_area_src
DTS = 01b.
ra8_dmac_width_t
Transfer element width.
@ k_ra8_dmac_width_word
32-bit transfers (DMTMD.SZ = 10b).
@ k_ra8_dmac_width_byte
8-bit transfers (DMTMD.SZ = 00b).
@ k_ra8_dmac_width_half
16-bit transfers (DMTMD.SZ = 01b).
ra8_dmac_addr_mode_t
Per-side address-update mode (DMAMD.SM / DMAMD.DM).
@ k_ra8_dmac_addr_decrement
11b: decrement.
Test-access surface for ra8_dmac internal helpers (MC/DC).
DMAC (Direct Memory Access Controller) register layout for the RA8D2.
static volatile r_dmac_channel_regs_t * ra8_dmac(uint8_t channel)
Pointer to DMAC channel channel (0..7), or NULL on error.
@ k_ra8_dmac_channel_count
RA8 DMAC channel count.
@ k_ra8_dmamd_dm_mask
RA8 dmamd dm mask.
@ k_ra8_dmamd_sm_mask
RA8 dmamd sm mask.
@ k_ra8_dmtmd_md_normal
00b: normal transfer.
@ k_ra8_dmtmd_md_repeat
01b: repeat transfer.
@ k_ra8_dmtmd_md_repeat_block
11b: repeat-block transfer.
@ k_ra8_dmtmd_md_block
10b: block transfer.
@ k_ra8_dmcra_low_mask
RA8 dmcra low mask.
@ k_ra8_dmcra_high_mask
RA8 dmcra high mask.
@ k_ra8_dmcra_high_pos
RA8 dmcra high pos.
@ k_ra8_dmcnt_dte_mask
RA8 dmcnt dte mask.
@ k_ra8_dmreq_swreq_mask
RA8 dmreq swreq mask.
@ k_ra8_dmast_dmst_mask
RA8 dmast dmst mask.
@ k_ra8_dmamd_dm_pos
DM[1:0] dst addr update mode.
@ k_ra8_dmamd_sm_pos
SM[1:0] src addr update mode.
static volatile r_dma_shared_regs_t * ra8_dma_shared(void)
Pointer to the shared DMA module-control bank.
@ k_ra8_dmint_esie_mask
RA8 dmint esie mask.
@ k_ra8_dmint_rptie_mask
RA8 dmint rptie mask.
@ k_ra8_dmint_dtie_mask
RA8 dmint dtie mask.
@ k_ra8_dmtmd_sz_pos
SZ[1:0] bit 8..9 – transfer size.
@ k_ra8_dmtmd_md_pos
MD[1:0] bit 14..15 – mode.
@ k_ra8_dmtmd_dts_pos
DTS[1:0] bit 12..13 – repeat area.
@ k_ra8_dmtmd_sz_byte
00b: 8-bit.
@ k_ra8_dmtmd_sz_word
10b: 32-bit.
@ k_ra8_dmtmd_sz_half
01b: 16-bit.
@ k_ra8_dmamd_addr_increment
10b: increment.
@ k_ra8_dmsts_act_mask
RA8 dmsts act mask.
@ k_ra8_dmtmd_dts_dest_repeat
00b: dest is repeat/block area.
@ k_ra8_dmtmd_dts_none
10b: no repeat/block area.
@ k_ra8_dmtmd_dts_src_repeat
01b: src is repeat/block area.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_out_of_range
Sensor or peripheral output out of valid range.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_hw_timeout
Hardware timed out waiting for a flag or handshake.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_info_val(tag, message, value)
RA8 log info val.
Ref-counted Module Stop Control wrapper for the RA8D2.
ra8_err_t ra8_mstp_enable(ra8_mstp_t id)
Reference-counted "ungate this peripheral" request.
ra8_err_t ra8_mstp_disable(ra8_mstp_t id)
Reference-counted "gate this peripheral" request.
@ k_ra8_mstp_dmac0_dtc0
MSTPA22 DMAC0+DTC0 (shared).
volatile uint8_t DMAST
+0x00 DMA Module Activation (bit DMST).
Per-channel DMAC register window.
volatile uint8_t DMSTS
+0x1E Status (ESIF/DTIF/ACT).
volatile uint16_t DMAMD
+0x14 Address Mode.
volatile uint8_t DMREQ
+0x1D Software Start (SWREQ/CLRS).
volatile uint16_t DMTMD
+0x10 Transfer Mode.
volatile uint8_t DMINT
+0x13 Interrupt Setting.
volatile uint32_t DMOFR
+0x18 Offset Register.
volatile uint32_t DMSAR
+0x00 Source address.
volatile uint32_t DMCRA
+0x08 Transfer count (DMCRAL/DMCRAH).
volatile uint8_t DMCNT
+0x1C Transfer Enable (bit DTE).
volatile uint32_t DMCRB
+0x0C Block transfer count.
volatile uint32_t DMDAR
+0x04 Destination address.
Per-channel callback slot pair (full-complete + half-complete).
void * half_ctx
Context for half_fn.
void * full_ctx
Context for full_fn.
ra8_dmac_callback_fn_t half_fn
DMINT.RPTIE user handler.
ra8_dmac_callback_fn_t full_fn
DMINT.DTIE user handler.
DMAC channel configuration.
ra8_dmac_mode_t mode
Transfer mode (DMTMD.MD).
ra8_dmac_repeat_area_t repeat_area
DMTMD.DTS area select.
uint16_t count
Transfer count (DMCRA low).
bool irq_each
Enable RPTIE/ESIE per repeat.
uint32_t src
Source address (DMSAR).
bool enable_dtie
Enable DMINT.DTIE on full end.
bool dst_inc
true: DM = increment, else fixed.
bool src_inc
true: SM = increment, else fixed.
uint16_t block_count
DMCRB block/repeat count.
uint32_t dst
Destination address (DMDAR).
ra8_dmac_width_t width
Transfer element width.