|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
DAC_B (12-bit D/A) peripheral-block model for the board emulator. More...
#include <stdint.h>#include <stdio.h>#include "board_console.h"#include "board_periph_block.h"#include "emu_host_io_internal.h"Go to the source code of this file.
Data Structures | |
| struct | dac_inst_t |
| One DAC_B instance: register backing store + write observability. More... | |
Enumerations | |
| enum | dac_console_t : uint32_t { k_dac_console_line_cap = 48U , k_dac_console_every = 256U } |
| Console-tap sizing for DAC output summaries. More... | |
| enum | dac_map_t : uint64_t { k_dac_base = 0x40233000UL , k_dac_stride = 0x100UL , k_dac_count = 2UL , k_dac_span = 0x200UL , k_dac_inst_words = 0x100UL / 4UL , k_dac_off_dadr = 0x00UL , k_dac_off_dacr0 = 0x04UL , k_dac_off_dacr1 = 0x08UL , k_dac_off_dacr2 = 0x0CUL } |
| DAC_B block geometry (ra8_dac_b_regs.h, FSP R_DAC_B0_Type). More... | |
| enum | dac_field_t : uint32_t { k_dac_dadr_mask = 0x00000FFFUL , k_dac_dacen_mask = 0x00000001UL } |
| DAC_B field masks. More... | |
Functions | |
| static RA8_INTERNAL uint32_t | internal_dac_word (uint64_t inst_off) |
| Word index into an instance's backing store for an in-instance offset. | |
| static RA8_INTERNAL uint64_t | internal_dac_read (uc_engine *uc, uint64_t addr, unsigned size) |
| MMIO read inside the DAC window: read back the latched register. | |
| static RA8_INTERNAL void | internal_dac_write (uc_engine *uc, uint64_t addr, unsigned size, uint64_t value) |
| MMIO write inside the DAC window: latch the value; track DADR. | |
| static RA8_INTERNAL void | internal_dac_reset (void) |
| Clear both DAC_B instances' registers and observability state. | |
| static RA8_INTERNAL void | internal_dac_report (void) |
| Print one line per DAC_B instance that the firmware drove. | |
| static RA8_INTERNAL void | internal_board_periph_dac_register (void) |
| Self-register the DAC_B block before main runs (decentralized). | |
Variables | |
| static dac_inst_t | s_dac [k_dac_count] |
| static const board_periph_block_t | s_k_dac_block |
| This block's descriptor (static lifetime; the core keeps the pointer). | |
DAC_B (12-bit D/A) peripheral-block model for the board emulator.
Models the two RA8D2 DAC_B instances (ra8_dac_b_regs.h / ra8_dac_b.c): DAC_B0 at 0x40233000 and DAC_B1 at 0x40233100 (stride 0x100). Each instance drives one 12-bit channel through a {DADR, DACR0, DACR1, DACR2} register set.
The DAC has no conversion-result readback on silicon – ra8_dac_b_write is a single 16-bit store to DADR – so this block simply accepts every register write and reads each back as written. That read-back is what matters for the driver: ra8_dac_b_init_configured / _set_output_enable do a read-modify-write of DACR0 (DACEN / DAOUTDIS), and ra8_dac_b_get_status reads DACR0.DACEN, so the control state must survive. The model additionally tracks each channel's last and peak DADR code (and a write count) purely for the end-of-run report, so a ramp/triangle demo's output sweep is observable headlessly even though there is no hardware read path.
Self-registers its descriptor with the board_periph core from a file-scope constructor; the core keeps no central block list – see board_periph_block.h.
Definition in file board_periph_dac.c.
| enum dac_console_t : uint32_t |
Console-tap sizing for DAC output summaries.
| Enumerator | |
|---|---|
| k_dac_console_line_cap | Max chars in a "DAC.. code=.." line. |
| k_dac_console_every | Push 1 line per N updates (anti-flood). |
Definition at line 36 of file board_periph_dac.c.
| enum dac_field_t : uint32_t |
DAC_B field masks.
| Enumerator | |
|---|---|
| k_dac_dadr_mask | 12-bit DADR data field. |
| k_dac_dacen_mask | DACR0.DACEN channel-enable bit. |
Definition at line 55 of file board_periph_dac.c.
| enum dac_map_t : uint64_t |
DAC_B block geometry (ra8_dac_b_regs.h, FSP R_DAC_B0_Type).
Definition at line 42 of file board_periph_dac.c.
|
static |
Self-register the DAC_B block before main runs (decentralized).
Definition at line 227 of file board_periph_dac.c.
References board_periph_register_block(), RA8_INTERNAL, and s_k_dac_block.
|
static |
MMIO read inside the DAC window: read back the latched register.
MMIO read inside the dac window: read back the latched register; this step is contained within the board periph dac model and uses bounded caller or module-owned storage.
| [in,out] | uc | Unicorn engine whose emulated state is read or updated. |
| [in] | addr | Guest address involved in the operation. |
| [in] | size | Size of the requested region or access in bytes. |
| value | The operation-specific dac read value. |
Definition at line 99 of file board_periph_dac.c.
References internal_dac_word(), k_dac_base, k_dac_count, k_dac_stride, RA8_INTERNAL, and s_dac.
|
static |
Print one line per DAC_B instance that the firmware drove.
Print one line per dac_b instance that the firmware drove; this step is contained within the board periph dac model and uses bounded caller or module-owned storage.
Definition at line 195 of file board_periph_dac.c.
References internal_dac_word(), k_dac_count, k_dac_dacen_mask, k_dac_off_dacr0, priv_emu_io_errf(), RA8_INTERNAL, and s_dac.
|
static |
Clear both DAC_B instances' registers and observability state.
Clear both dac_b instances' registers and observability state; this step is contained within the board periph dac model and uses bounded caller or module-owned storage.
Definition at line 180 of file board_periph_dac.c.
References k_dac_count, RA8_INTERNAL, and s_dac.
|
static |
Word index into an instance's backing store for an in-instance offset.
Word index into an instance's backing store for an in-instance offset; this step is contained within the board periph dac model and uses bounded caller or module-owned storage.
| [in] | inst_off | Inst off input used by the operation. |
| value | The operation-specific dac word value. |
Definition at line 81 of file board_periph_dac.c.
References RA8_INTERNAL.
Referenced by internal_dac_read(), internal_dac_report(), and internal_dac_write().
|
static |
MMIO write inside the DAC window: latch the value; track DADR.
MMIO write inside the dac window: latch the value; track dadr; this step is contained within the board periph dac model and uses bounded caller or module-owned storage.
| [in,out] | uc | Unicorn engine whose emulated state is read or updated. |
| [in] | addr | Guest address involved in the operation. |
| [in] | size | Size of the requested region or access in bytes. |
| [in] | value | Register or payload value involved in the operation. |
Definition at line 128 of file board_periph_dac.c.
References board_console_push(), board_periph_trace(), internal_dac_word(), k_board_console_ch_dac, k_dac_base, k_dac_console_every, k_dac_console_line_cap, k_dac_count, k_dac_dadr_mask, k_dac_off_dadr, k_dac_stride, priv_emu_io_errf(), and s_dac.
|
static |
Definition at line 68 of file board_periph_dac.c.
Referenced by internal_dac_read(), internal_dac_report(), internal_dac_reset(), and internal_dac_write().
|
static |
This block's descriptor (static lifetime; the core keeps the pointer).
Definition at line 214 of file board_periph_dac.c.
Referenced by internal_board_periph_dac_register().