|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Full-featured 12-bit DAC_B driver. More...
Go to the source code of this file.
Data Structures | |
| struct | ra8_dac_b_cfg_t |
| Configuration descriptor for ra8_dac_b_init_configured. More... | |
Typedefs | |
| typedef void(* | ra8_dac_b_update_fn_t) (void *ctx, uint8_t channel) |
| DAC update (conversion done) event callback. | |
Enumerations | |
| enum | ra8_dac_b_vref_t : uint8_t { k_ra8_dac_b_vref_normal = 0U , k_ra8_dac_b_vref_low = 1U } |
| VREFH operating-mode selection (DACR2.OFSSEL bit 8). More... | |
| enum | ra8_dac_b_data_format_t : uint8_t { k_ra8_dac_b_format_right = 0U , k_ra8_dac_b_format_left = 1U } |
| Data placement selection (DACR1.DPSEL bit 16). More... | |
Functions | |
| ra8_err_t | ra8_dac_b_init (void) |
| Legacy init – zero every DAC_B register + enable MSTP. | |
| ra8_err_t | ra8_dac_b_init_configured (const ra8_dac_b_cfg_t *cfg) |
| Initialise DAC_B with a full config descriptor. | |
| ra8_err_t | ra8_dac_b_deinit (void) |
| Tear down the DAC_B peripheral. | |
| ra8_err_t | ra8_dac_b_write (uint8_t channel, uint16_t value) |
| Programme a DAC channel with a 12-bit code. | |
| ra8_err_t | ra8_dac_b_set_vref (ra8_dac_b_vref_t vref) |
| Change the DAC voltage reference at runtime. | |
| ra8_err_t | ra8_dac_b_set_output_enable (uint8_t channel, bool enable) |
| Toggle output-enable for one channel at runtime. | |
| ra8_err_t | ra8_dac_b_get_status (uint8_t *out_mask) |
| Read the DACR output-enable / DAE mask. | |
| ra8_err_t | ra8_dac_b_clear_status (void) |
| Clear DAE + DAOE bits (disable DAC outputs). | |
| ra8_err_t | ra8_dac_b_attach_handler (ra8_dac_b_update_fn_t fn, void *ctx) |
| Attach a DAC-update callback. | |
| ra8_err_t | ra8_dac_b_enter_stop (void) |
| Put DAC_B into MSTP-gated stop. | |
| ra8_err_t | ra8_dac_b_exit_stop (void) |
| Exit MSTP-gated stop. | |
| void | ra8_dac_b_dispatch_update (uint8_t channel) |
| Dispatch a DAC-update event – fire the registered callback. | |
Full-featured 12-bit DAC_B driver.
full build-out of the RA8D2 DAC_B peripheral. Extends the write stub with: descriptor-based init, deinit, runtime reference reconfigure, output-enable controls, interrupt-mode attach / dispatch, power transition.
Definition in file ra8_dac_b.h.
| typedef void(* ra8_dac_b_update_fn_t) (void *ctx, uint8_t channel) |
DAC update (conversion done) event callback.
| [in] | ctx | Caller context. |
| [in] | channel | Channel that finished updating. |
Definition at line 82 of file ra8_dac_b.h.
| enum ra8_dac_b_data_format_t : uint8_t |
Data placement selection (DACR1.DPSEL bit 16).
Mirrors the FSP dac_data_format_t semantics for DAC_B: 0 selects right-justified 12-bit data in the 16-bit DADR; 1 selects left-justified 12-bit data.
| Enumerator | |
|---|---|
| k_ra8_dac_b_format_right | DPSEL=0: right-justified (default). |
| k_ra8_dac_b_format_left | DPSEL=1: left-justified. |
Definition at line 53 of file ra8_dac_b.h.
| enum ra8_dac_b_vref_t : uint8_t |
VREFH operating-mode selection (DACR2.OFSSEL bit 8).
Mirrors FSP dac_b_vrefh_t: only two values are supported by the RA8D2 DAC_B IP. NORMAL is used when VREFH >= 2.7 V; LOW is used when VREFH < 2.7 V. The driver writes this value left-shifted to DACR2 bit 8 (OFSSEL).
| Enumerator | |
|---|---|
| k_ra8_dac_b_vref_normal | OFSSEL=0: VREFH >= 2.7V (default). |
| k_ra8_dac_b_vref_low | OFSSEL=1: VREFH < 2.7V. |
Definition at line 39 of file ra8_dac_b.h.
|
nodiscard |
Attach a DAC-update callback.
| [in] | fn | Callback fired on ISR dispatch. |
| [in] | ctx | Context forwarded to the callback. |
Definition at line 337 of file ra8_dac_b.c.
References k_ra8_ok, and s_dac_b_state.
|
nodiscard |
Clear DAE + DAOE bits (disable DAC outputs).
Definition at line 330 of file ra8_dac_b.c.
References internal_stop_channel(), k_ra8_dac_b_channel_0, k_ra8_dac_b_channel_1, and k_ra8_ok.
|
nodiscard |
Tear down the DAC_B peripheral.
Definition at line 260 of file ra8_dac_b.c.
References r_dac_b_regs_t::DACR0, r_dac_b_regs_t::DADR, k_ra8_dac_b_channel_0, k_ra8_dac_b_channel_1, k_ra8_dacr0_mask_daoutdis, k_ra8_mstp_dac12_0, k_ra8_mstp_dac12_1, ra8_dac_b(), ra8_mstp_disable(), and s_dac_b_state.
| void ra8_dac_b_dispatch_update | ( | uint8_t | channel | ) |
Dispatch a DAC-update event – fire the registered callback.
| [in] | channel | Channel that completed an update. |
See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.
Definition at line 362 of file ra8_dac_b.c.
References k_ra8_dac_b_channel_count, and s_dac_b_state.
|
nodiscard |
Put DAC_B into MSTP-gated stop.
Definition at line 344 of file ra8_dac_b.c.
References internal_disable_channel(), k_ra8_dac_b_channel_0, k_ra8_dac_b_channel_1, k_ra8_mstp_dac12_0, k_ra8_mstp_dac12_1, and ra8_mstp_disable().
|
nodiscard |
Exit MSTP-gated stop.
Definition at line 352 of file ra8_dac_b.c.
References k_ra8_mstp_dac12_0, k_ra8_mstp_dac12_1, ra8_mstp_enable(), RA8_RETURN_ON_ERROR, and s_tag.
|
nodiscard |
Read the DACR output-enable / DAE mask.
| [out] | out_mask | DACR value masked to the control bits. |
Definition at line 310 of file ra8_dac_b.c.
References r_dac_b_regs_t::DACR0, k_ra8_dac_b_channel_0, k_ra8_dac_b_channel_1, k_ra8_dacr0_mask_dacen, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_dac_b(), and s_tag.
|
nodiscard |
Legacy init – zero every DAC_B register + enable MSTP.
Definition at line 153 of file ra8_dac_b.c.
References internal_disable_channel(), k_ra8_dac_b_channel_0, k_ra8_dac_b_channel_1, k_ra8_mstp_dac12_0, k_ra8_mstp_dac12_1, k_ra8_ok, ra8_log_info, ra8_mstp_enable(), RA8_RETURN_ON_ERROR, and s_tag.
Referenced by ra8_nsc_dac_b_init().
|
nodiscard |
Initialise DAC_B with a full config descriptor.
| [in] | cfg | Non-NULL configuration descriptor. |
Definition at line 234 of file ra8_dac_b.c.
References ra8_dac_b_cfg_t::enable_channel0, ra8_dac_b_cfg_t::enable_channel1, internal_apply_cfg(), internal_start_channel(), k_ra8_dac_b_channel_0, k_ra8_dac_b_channel_1, k_ra8_mstp_dac12_0, k_ra8_mstp_dac12_1, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_log_info, ra8_mstp_enable(), RA8_RETURN_ON_ERROR, and s_tag.
Referenced by internal_dac_b_demo_arm(), and internal_dac_demo_setup_or_halt().
|
nodiscard |
Toggle output-enable for one channel at runtime.
| [in] | channel | 0 or 1. |
| [in] | enable | True -> drive the pin; false -> Hi-Z. |
Definition at line 293 of file ra8_dac_b.c.
References r_dac_b_regs_t::DACR0, k_ra8_dacr0_mask_dacen, k_ra8_err_invalid_arg, k_ra8_ok, and ra8_dac_b().
Referenced by main().
|
nodiscard |
Change the DAC voltage reference at runtime.
| [in] | vref | New reference source. |
Definition at line 281 of file ra8_dac_b.c.
References r_dac_b_regs_t::DACR2, k_ra8_dac_b_channel_0, k_ra8_dac_b_channel_1, k_ra8_dacr2_bit_ofssel, k_ra8_dacr2_mask_ofssel, k_ra8_ok, and ra8_dac_b().
|
nodiscard |
Programme a DAC channel with a 12-bit code.
| [in] | channel | 0 or 1. |
| [in] | value | Raw 12-bit code (clamped to 0..4095). |
Definition at line 172 of file ra8_dac_b.c.
References r_dac_b_regs_t::DADR, internal_ra8_dac_b_clamp(), k_ra8_err_invalid_arg, k_ra8_ok, ra8_dac_b(), ra8_log_info_val, and s_tag.
Referenced by internal_dac_demo_one_triangle_period(), main(), and ra8_nsc_dac_b_write().