ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_lvd.c
Go to the documentation of this file.
1
23
24#include "ra8_lvd.h"
25
26#include <stdint.h>
27
28#include "ra8_attributes.h"
29#include "ra8_check.h"
30#include "ra8_err.h"
31#include "ra8_lvd_internal.h"
32#include "ra8_lvd_regs.h"
33
52 uint32_t after_assert_val,
53 uint32_t hysteresis,
54 uint32_t negate)
55{
56 return (hysteresis == hvd_val) && (negate == after_assert_val);
57}
58
75bool priv_ra8_lvd_internal_set_ri_bit(uint32_t reset_val,
76 uint32_t reset_on_rise_val,
77 uint32_t response)
78{
79 return (response == reset_val) || (response == reset_on_rise_val);
80}
81#include "ra8_log.h"
82
87static const char* s_tag = "LVD";
88
89/* =============================================================================
90 * Channel-map helpers
91 * =============================================================================
92 */
93
109 {.cmpcr = k_ra8_lvd_pvd1_cmpcr_off,
114 .has_irq = true},
115 {.cmpcr = k_ra8_lvd_pvd2_cmpcr_off,
120 .has_irq = true},
121 {.cmpcr = k_ra8_lvd_pvd4_cmpcr_off,
123 .cr1 = k_ra8_lvd_pvd4_cr0_off, /* unused -- n channels have no CR1. */
124 .sr = k_ra8_lvd_pvd4_cr0_off, /* unused -- n channels have no SR. */
126 .has_irq = false},
127 {.cmpcr = k_ra8_lvd_pvd5_cmpcr_off,
132 .has_irq = false},
133};
134
135/* =============================================================================
136 * Internal helpers
137 * =============================================================================
138 */
139
142{
143 switch (channel) {
144 case k_ra8_lvd_ch1:
145 *out_idx = k_ra8_lvd_map_idx_ch1;
146 return k_ra8_ok;
147 case k_ra8_lvd_ch2:
148 *out_idx = k_ra8_lvd_map_idx_ch2;
149 return k_ra8_ok;
150 case k_ra8_lvd_ch4:
151 *out_idx = k_ra8_lvd_map_idx_ch4;
152 return k_ra8_ok;
153 case k_ra8_lvd_ch5:
154 *out_idx = k_ra8_lvd_map_idx_ch5;
155 return k_ra8_ok;
156 default:
158 }
159}
160
183{
184 if ((uint8_t)threshold < k_ra8_lvd_pvdlvl_min) {
186 }
187 if ((uint8_t)threshold > k_ra8_lvd_pvdlvl_max) {
189 }
190 return k_ra8_ok;
191}
192
201
224{
225 /* HUM Ch 8.2.6 "PVDmCR1 : Voltage Monitor m Circuit Control Register" p 307 */
226 if ((uint8_t)edge > k_ra8_lvd_edge_both) {
228 }
229 return k_ra8_ok;
230}
231
234{
235 /* HUM Ch 8.2.4 "PVDmCR0 : Voltage Monitor m Circuit Control Register 0" p 305 */
236 return (uint8_t)(*ra8_lvd_reg8(map->cr0) & k_ra8_lvd_cr0_mask_ri);
237}
238
261RA8_INTERNAL static uint8_t internal_n_cr0_with_reserved(uint8_t base)
262{
263 /* HUM Ch 8.2.5 "PVDnCR0 : Voltage Monitor n Circuit Control Register 0" p 306 */
264 return (uint8_t)(base | k_ra8_lvd_cr0_mask_n_bit6);
265}
266
287RA8_INTERNAL static uint8_t internal_m_cr0_with_reserved(uint8_t base)
288{
289 /* HUM Ch 8.2.4 "PVDmCR0 : Voltage Monitor m Circuit Control Register 0" p 305 */
290 return (uint8_t)(base | k_ra8_lvd_cr0_mask_bit3);
291}
292
316 uint8_t base)
317{
318 if (map->has_irq) {
319 return internal_m_cr0_with_reserved(base);
320 }
321 return internal_n_cr0_with_reserved(base);
322}
323
326 uint8_t clear_mask,
327 uint8_t set_bits)
328{
329 /* HUM Ch 8.2.4 "PVDmCR0 : Voltage Monitor m Circuit Control Register 0" p 305 */
330 /* HUM Ch 8.2.5 "PVDnCR0 : Voltage Monitor n Circuit Control Register 0" p 306 */
331 const uint8_t prev = *ra8_lvd_reg8(map->cr0);
332 const uint8_t base = (uint8_t)((prev & (uint8_t)~clear_mask) | set_bits);
333 *ra8_lvd_reg8(map->cr0) = internal_cr0_apply_reserved(map, base);
334}
335
336/* =============================================================================
337 * Channel init / deinit -- follows HUM Table 8.4 / Table 8.6
338 * =============================================================================
339 */
340
365 const ra8_lvd_cfg_t* cfg)
366{
368 if (err != k_ra8_ok) {
369 return err;
370 }
372 if (err != k_ra8_ok) {
373 return err;
374 }
375 if (map->has_irq) {
376 err = internal_validate_edge(cfg->edge);
377 if (err != k_ra8_ok) {
378 return err;
379 }
380 } else {
381 /* HUM Ch 8.2.5 "PVDnCR0 : Voltage Monitor n Circuit Control Register 0" p 306 */
382 /* n channels only have RE -- reject IRQ / NMI responses. */
386 }
387 }
388 /* HUM Ch 8.2.4 "PVDmCR0 : Voltage Monitor m Circuit Control Register 0" p 306 */
389 /* RN=1 prohibited when RHSEL=1. */
392 (uint32_t)cfg->hysteresis,
393 (uint32_t)cfg->negate)) {
395 }
396 return k_ra8_ok;
397}
398
423 const ra8_lvd_cfg_t* cfg)
424{
425 uint8_t cr0 = (uint8_t)((uint8_t)cfg->filter_div << k_ra8_lvd_cr0_shift_fsamp);
427 cr0 |= k_ra8_lvd_cr0_mask_dfdis; /* DFDIS = 1 while writing FSAMP. */
428 if (map->has_irq) {
431 }
434 (uint32_t)cfg->response)) {
436 }
437 }
438 return cr0;
439}
440
460 const ra8_lvd_cfg_t* cfg)
461{
462 /* HUM Ch 8.2.6 "PVDmCR1 : Voltage Monitor m Circuit Control Register" p 307 */
463 uint8_t cr1 = (uint8_t)((uint8_t)cfg->edge & k_ra8_lvd_cr1_mask_idtsel);
464 if (cfg->irq_type == k_ra8_lvd_irq_maskable) {
466 }
467 *ra8_lvd_reg8(map->cr1) = cr1;
468
469 if (cfg->clear_status) {
470 /* HUM Ch 8.2.7 "PVDmSR : Voltage Monitor m Circuit Status Register" p 307 */
471 *ra8_lvd_reg8(map->sr) = 0U;
472 }
473}
474
494 const ra8_lvd_cfg_t* cfg)
495{
496 /* Step 1: disable everything; HUM Ch 8.2.4 / 8.2.2 */
498 *ra8_lvd_reg8(map->cmpcr) = 0U;
499
500 /* Step 2: PVDLVL with PVDE = 0 */
501 uint8_t cmpcr = (uint8_t)((uint8_t)cfg->threshold & k_ra8_lvd_cmpcr_mask_pvdlvl);
502 *ra8_lvd_reg8(map->cmpcr) = cmpcr;
503
504 /* Step 3: HUM Ch 8.2.8 / 8.2.9 -- RHSEL on FCR */
505 *ra8_lvd_reg8(map->fcr) = (uint8_t)((uint8_t)cfg->hysteresis & k_ra8_lvd_fcr_mask_rhsel);
506
507 /* Step 4: re-assert PVDE */
509 *ra8_lvd_reg8(map->cmpcr) = cmpcr;
510}
511
532 const ra8_lvd_cfg_t* cfg)
533{
534 uint8_t cr0 = internal_compose_cr0(map, cfg);
536
537 if (cfg->filter_en) {
538 cr0 &= (uint8_t)~k_ra8_lvd_cr0_mask_dfdis;
540 }
541
542 if (map->has_irq) {
543 internal_program_cr1(map, cfg);
544 }
545
546 if (cfg->irq_enable && (cfg->response != k_ra8_lvd_response_none)) {
547 /* RIE (m-channel: IRQ/reset enable) and RE (n-channel: reset-only)
548 * sit at the same CR0 bit position (0x01) on RA8D2; the semantic
549 * distinction lives in `map->has_irq`. Either mask gates bit 0. */
552 }
553
556}
557
584{
585 RA8_CHECK_NULL_PTR(cfg, s_tag, "cfg must not be nullptr");
586
587 uint8_t idx = 0U;
588 const ra8_err_t map_err = priv_ra8_lvd_internal_channel_to_idx(channel, &idx);
589 RA8_RETURN_ON_ERROR(map_err, s_tag, "lvd_init: bad channel");
590
591 const ra8_lvd_channel_map_t map = g_lvd_map[idx];
592 const ra8_err_t cfg_err = internal_validate_cfg(&map, cfg);
593 RA8_RETURN_ON_ERROR(cfg_err, s_tag, "lvd_init: bad cfg");
594
597
598 ra8_log_info_val(s_tag, "lvd_init ch", (uint32_t)channel);
599 return k_ra8_ok;
600}
601
625{
626 uint8_t idx = 0U;
627 const ra8_err_t map_err = priv_ra8_lvd_internal_channel_to_idx(channel, &idx);
628 RA8_RETURN_ON_ERROR(map_err, s_tag, "lvd_deinit: bad channel");
629
630 const ra8_lvd_channel_map_t map = g_lvd_map[idx];
631
632 /* === HUM Table 8.5 step 1 / Table 8.7 step 1 -- drop CMPE. */
634
635 /* === HUM Table 8.5 step 3 / Table 8.7 step 3 -- drop RIE / RE. */
636 uint8_t enable_bit = k_ra8_lvd_cr0_mask_re;
637 if (map.has_irq) {
638 enable_bit = k_ra8_lvd_cr0_mask_rie;
639 }
640 priv_ra8_lvd_internal_cr0_rmw(&map, enable_bit, 0U);
641
642 /* === HUM Table 8.5 step 4 / Table 8.7 step 4 -- DFDIS = 1 (filter off). */
644
645 /* === HUM Table 8.5 step 5 / Table 8.7 step 5 -- drop PVDE. */
646 /* HUM Ch 8.2.2 "PVDmCMPCR" p 303 */
647 *ra8_lvd_reg8(map.cmpcr) = 0U;
648
649 /* Cleanly drop the rest of the per-channel state. */
651 *ra8_lvd_reg8(map.fcr) = 0U;
652 if (map.has_irq) {
653 /* HUM Ch 8.2.6 "PVDmCR1 : Voltage Monitor m Circuit Control Register" p 307 */
654 *ra8_lvd_reg8(map.cr1) = 0U;
655 /* HUM Ch 8.2.7 "PVDmSR : Voltage Monitor m Circuit Status Register" p 307 */
656 *ra8_lvd_reg8(map.sr) = 0U;
657 }
658 return k_ra8_ok;
659}
660
661/* =============================================================================
662 * Threshold + edge + kind setters
663 * =============================================================================
664 */
665
689{
690 uint8_t idx = 0U;
691 const ra8_err_t map_err = priv_ra8_lvd_internal_channel_to_idx(channel, &idx);
692 RA8_RETURN_ON_ERROR(map_err, s_tag, "lvd_set_threshold: bad channel");
693
694 const ra8_err_t lvl_err = internal_validate_threshold(threshold);
695 RA8_RETURN_ON_ERROR(lvl_err, s_tag, "lvd_set_threshold: bad threshold");
696
697 const ra8_lvd_channel_map_t map = g_lvd_map[idx];
698
699 /* HUM Ch 8.2.2 "PVDmCMPCR : Voltage Monitor m Comparator Control Register" p 303 */
700 /* Preserve the PVDE bit, drop it around the PVDLVL write, restore it afterwards. */
701 const uint8_t prev = *ra8_lvd_reg8(map.cmpcr);
702 const uint8_t pvde_was = (uint8_t)(prev & k_ra8_lvd_cmpcr_mask_pvde);
703
704 *ra8_lvd_reg8(map.cmpcr) = 0U;
705
706 uint8_t cmpcr = (uint8_t)((uint8_t)threshold & k_ra8_lvd_cmpcr_mask_pvdlvl);
707 cmpcr |= pvde_was;
708 *ra8_lvd_reg8(map.cmpcr) = cmpcr;
709 return k_ra8_ok;
710}
711
737{
738 uint8_t idx = 0U;
739 const ra8_err_t map_err = priv_ra8_lvd_internal_channel_to_idx(channel, &idx);
740 /* GCOVR_EXCL_BR_START -- channel_to_idx() error edge; set_irq_edge pre-validates the channel */
741 RA8_RETURN_ON_ERROR(map_err, s_tag, "lvd_set_irq_edge: bad channel");
742 /* GCOVR_EXCL_BR_STOP */
743
744 const ra8_err_t edge_err = internal_validate_edge(edge);
745 RA8_RETURN_ON_ERROR(edge_err, s_tag, "lvd_set_irq_edge: bad edge");
746
747 const ra8_lvd_channel_map_t map = g_lvd_map[idx];
748 if (!map.has_irq) {
750 }
751
752 /* HUM Ch 8.2.6 "PVDmCR1 : Voltage Monitor m Circuit Control Register" p 307 */
753 const uint8_t prev = *ra8_lvd_reg8(map.cr1);
754 const uint8_t next = (uint8_t)((prev & (uint8_t)~k_ra8_lvd_cr1_mask_idtsel) |
755 ((uint8_t)edge & k_ra8_lvd_cr1_mask_idtsel));
756 *ra8_lvd_reg8(map.cr1) = next;
757 return k_ra8_ok;
758}
759
784{
785 uint8_t idx = 0U;
786 const ra8_err_t map_err = priv_ra8_lvd_internal_channel_to_idx(channel, &idx);
787 /* GCOVR_EXCL_BR_START -- channel_to_idx() error edge; set_irq_kind pre-validates the channel */
788 RA8_RETURN_ON_ERROR(map_err, s_tag, "lvd_set_irq_kind: bad channel");
789 /* GCOVR_EXCL_BR_STOP */
790
791 const ra8_lvd_channel_map_t map = g_lvd_map[idx];
792 if (!map.has_irq) {
794 }
795
796 /* HUM Ch 8.2.6 "PVDmCR1 : Voltage Monitor m Circuit Control Register" p 307 */
797 const uint8_t prev = *ra8_lvd_reg8(map.cr1);
798 uint8_t next = (uint8_t)(prev & (uint8_t)~k_ra8_lvd_cr1_mask_irqsel);
799 if (kind == k_ra8_lvd_irq_maskable) {
801 }
802 *ra8_lvd_reg8(map.cr1) = next;
803 return k_ra8_ok;
804}
static const char * s_tag
Logging / check tag.
Definition ra8_app.c:17
Annotation-attribute framework macros for ra8-firmware.
#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.
Definition ra8_check.h:184
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Definition ra8_check.h:243
Error Code Definitions for ra8-firmware.
@ k_ra8_err_not_supported
Requested feature not compiled in, not wired, or not supported by this MCU variant.
Definition ra8_err.h:180
@ k_ra8_err_invalid_arg
Invalid function argument.
Definition ra8_err.h:152
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_info_val(tag, message, value)
RA8 log info val.
Definition ra8_log.h:366
bool priv_ra8_lvd_internal_reject_hvd_after(uint32_t hvd_val, uint32_t after_assert_val, uint32_t hysteresis, uint32_t negate)
Pure RN+RHSEL reject predicate – see header for full contract.
Definition ra8_lvd.c:51
static ra8_err_t internal_validate_cfg(const ra8_lvd_channel_map_t *map, const ra8_lvd_cfg_t *cfg)
Validate the cfg fields that the per-channel init reads.
Definition ra8_lvd.c:364
const ra8_lvd_channel_map_t g_lvd_map[k_ra8_lvd_map_idx_count]
Lookup table from ra8_lvd_map_idx_t to register offsets.
Definition ra8_lvd.c:108
ra8_err_t ra8_lvd_channel_deinit(ra8_lvd_channel_t channel)
Tear down one PVD channel per HUM Ch 12 Table 12.5 / 12.7.
Definition ra8_lvd.c:624
ra8_err_t priv_ra8_lvd_internal_channel_to_idx(ra8_lvd_channel_t channel, uint8_t *out_idx)
Implementation of priv_ra8_lvd_internal_channel_to_idx() – switch on PVD id.
Definition ra8_lvd.c:141
ra8_err_t ra8_lvd_set_irq_edge(ra8_lvd_channel_t channel, ra8_lvd_edge_t edge)
Update CR1.IDTSEL for an IRQ-capable PVDm channel.
Definition ra8_lvd.c:736
ra8_err_t priv_ra8_lvd_internal_validate_div(ra8_lvd_loco_div_t div)
Implementation of priv_ra8_lvd_internal_validate_div() – upper-bound check.
Definition ra8_lvd.c:194
uint8_t priv_ra8_lvd_internal_read_ri(const ra8_lvd_channel_map_t *map)
Implementation of priv_ra8_lvd_internal_read_ri() – masked CR0 read.
Definition ra8_lvd.c:233
static ra8_err_t internal_validate_edge(ra8_lvd_edge_t edge)
Validate IDTSEL[1:0] candidate (0..2).
Definition ra8_lvd.c:223
static uint8_t internal_m_cr0_with_reserved(uint8_t base)
Build a PVDmCR0 byte with bit3 forced to 1 (HUM-mandated).
Definition ra8_lvd.c:287
ra8_err_t ra8_lvd_set_threshold(ra8_lvd_channel_t channel, ra8_lvd_pvdlvl_t threshold)
Update PVDLVL for an already-armed channel.
Definition ra8_lvd.c:688
static uint8_t internal_n_cr0_with_reserved(uint8_t base)
Build a PVDnCR0 byte with the chip-mandated bit-6 = 1 / bit-7 = 0 reserved values.
Definition ra8_lvd.c:261
bool priv_ra8_lvd_internal_set_ri_bit(uint32_t reset_val, uint32_t reset_on_rise_val, uint32_t response)
Pure RI-bit predicate – see header for full contract.
Definition ra8_lvd.c:75
ra8_err_t ra8_lvd_set_irq_kind(ra8_lvd_channel_t channel, ra8_lvd_irq_type_t kind)
Update CR1.IRQSEL (maskable IRQ vs NMI) for a PVDm channel.
Definition ra8_lvd.c:783
static uint8_t internal_cr0_apply_reserved(const ra8_lvd_channel_map_t *map, uint8_t base)
Apply the chip-specific reserved-bit pattern to a CR0 value.
Definition ra8_lvd.c:315
static uint8_t internal_compose_cr0(const ra8_lvd_channel_map_t *map, const ra8_lvd_cfg_t *cfg)
Compute the initial CR0 value for ra8_lvd_channel_init.
Definition ra8_lvd.c:422
static void internal_program_cr1(const ra8_lvd_channel_map_t *map, const ra8_lvd_cfg_t *cfg)
Program CR1 + status-clear for the m-only steps 9-11.
Definition ra8_lvd.c:459
ra8_err_t ra8_lvd_channel_init(ra8_lvd_channel_t channel, const ra8_lvd_cfg_t *cfg)
Bring up one PVD channel per HUM Ch 12 Table 12.4 / 12.6.
Definition ra8_lvd.c:583
static void internal_lvd_program_cmpcr(const ra8_lvd_channel_map_t *map, const ra8_lvd_cfg_t *cfg)
Run HUM Table 8.4 / 8.6 steps 1-4 (CMPCR programming).
Definition ra8_lvd.c:493
static ra8_err_t internal_validate_threshold(ra8_lvd_pvdlvl_t threshold)
Reject PVDLVL encodings outside the HUM-allowed range.
Definition ra8_lvd.c:182
static void internal_lvd_program_cr0_chain(const ra8_lvd_channel_map_t *map, const ra8_lvd_cfg_t *cfg)
Run HUM Table 8.4 / 8.6 steps 6-13 (CR0 / CR1 / status).
Definition ra8_lvd.c:531
void priv_ra8_lvd_internal_cr0_rmw(const ra8_lvd_channel_map_t *map, uint8_t clear_mask, uint8_t set_bits)
Implementation of priv_ra8_lvd_internal_cr0_rmw() – RMW with reserved-bit refold.
Definition ra8_lvd.c:325
Programmable Voltage Detection (PVD / LVD) HAL driver.
Test-access surface for ra8_lvd internal helpers (MC/DC).
@ k_ra8_lvd_map_idx_ch5
PVD5.
@ k_ra8_lvd_map_idx_ch4
PVD4.
@ k_ra8_lvd_map_idx_count
Sentinel.
@ k_ra8_lvd_map_idx_ch2
PVD2.
@ k_ra8_lvd_map_idx_ch1
PVD1.
Programmable Voltage Detection (PVD / LVD) register layout for the RA8D2.
@ k_ra8_lvd_cr0_mask_re
RE (n) – reset-only enable.
@ k_ra8_lvd_cr0_mask_rn
RN reset-negate timing (m).
@ k_ra8_lvd_cr0_mask_n_bit6
Reserved bit6 – write-1 (n).
@ k_ra8_lvd_cr0_mask_cmpe
CMPE comparator-output enable.
@ k_ra8_lvd_cr0_mask_ri
RI reset-on-cross select (m).
@ k_ra8_lvd_cr0_mask_rie
RIE (m) – IRQ/reset enable.
@ k_ra8_lvd_cr0_mask_bit3
Reserved bit3 – write-1 (m).
@ k_ra8_lvd_cr0_mask_dfdis
DFDIS digital-filter disable.
@ k_ra8_lvd_cr0_mask_fsamp
FSAMP[1:0] divider field.
@ k_ra8_lvd_cr1_mask_irqsel
IRQSEL maskable / NMI selector.
@ k_ra8_lvd_cr1_mask_idtsel
IDTSEL[1:0] edge-select field.
static volatile uint8_t * ra8_lvd_reg8(ra8_lvd_off_t off)
Get a volatile uint8_t* to a PVD 8-bit register.
@ k_ra8_lvd_pvd5_cmpcr_off
PVD5CMPCR.
@ k_ra8_lvd_pvd1_cr1_off
PVD1CR1.
@ k_ra8_lvd_pvd1_fcr_off
PVD1FCR.
@ k_ra8_lvd_pvd1_sr_off
PVD1SR.
@ k_ra8_lvd_pvd5_fcr_off
PVD5FCR.
@ k_ra8_lvd_pvd2_cr1_off
PVD2CR1.
@ k_ra8_lvd_pvd1_cr0_off
PVD1CR0.
@ k_ra8_lvd_pvd4_fcr_off
PVD4FCR.
@ k_ra8_lvd_pvd5_cr0_off
PVD5CR0.
@ k_ra8_lvd_pvd2_cmpcr_off
PVD2CMPCR.
@ k_ra8_lvd_pvd1_cmpcr_off
PVD1CMPCR.
@ k_ra8_lvd_pvd2_sr_off
PVD2SR.
@ k_ra8_lvd_pvd2_cr0_off
PVD2CR0.
@ k_ra8_lvd_pvd2_fcr_off
PVD2FCR.
@ k_ra8_lvd_pvd4_cmpcr_off
PVD4CMPCR.
@ k_ra8_lvd_pvd4_cr0_off
PVD4CR0.
@ k_ra8_lvd_cmpcr_mask_pvdlvl
PVDLVL[4:0] threshold field.
@ k_ra8_lvd_cmpcr_mask_pvde
PVDE detector enable.
@ k_ra8_lvd_fcr_mask_rhsel
RHSEL hysteresis-band selector.
@ k_ra8_lvd_cr0_shift_fsamp
FSAMP[1:0] starts at bit 4.
ra8_lvd_loco_div_t
PVDmCR0.FSAMP[1:0] / PVDnCR0.FSAMP[1:0] sampling-clock divider.
@ k_ra8_lvd_loco_div_max
Highest legal value (sentinel).
@ k_ra8_lvd_negate_after_assert
Negate after reset asserts.
@ k_ra8_lvd_hysteresis_hvd
RHSEL = 1 (rise detect).
ra8_lvd_irq_type_t
PVDmCR1.IRQSEL value – NMI vs maskable interrupt.
@ k_ra8_lvd_irq_maskable
Maskable interrupt via ICU.
ra8_lvd_pvdlvl_t
PVDLVL[4:0] threshold encoding for PVDmCMPCR / PVDnCMPCR.
@ k_ra8_lvd_pvdlvl_max
Highest legal threshold encoding.
@ k_ra8_lvd_pvdlvl_min
Lowest legal threshold encoding.
ra8_lvd_edge_t
PVDmCR1.IDTSEL[1:0] edge selector for monitor m channels.
@ k_ra8_lvd_edge_both
Detect either crossing.
ra8_lvd_channel_t
Voltage-monitor channel selector.
@ k_ra8_lvd_ch5
PVD5 (n series, reset-only).
@ k_ra8_lvd_ch2
PVD2 (m series, NMI-capable).
@ k_ra8_lvd_ch1
PVD1 (m series, NMI-capable).
@ k_ra8_lvd_ch4
PVD4 (n series, reset-only).
@ k_ra8_lvd_response_reset_on_rise
HVD reset (any).
@ k_ra8_lvd_response_interrupt
Maskable IRQ (m only).
@ k_ra8_lvd_response_reset
LVD reset (any).
@ k_ra8_lvd_response_nmi
NMI (m only).
@ k_ra8_lvd_response_none
Flags / ELC only.
Configuration descriptor for ra8_lvd_channel_init.
ra8_lvd_edge_t edge
IDTSEL setting (m channels only).
bool clear_status
true -> write 0 to PVDmSR.DET on init.
ra8_lvd_pvdlvl_t threshold
PVDLVL[4:0] encoding (see enum).
ra8_lvd_irq_type_t irq_type
IRQSEL setting (m channels only).
ra8_lvd_loco_div_t filter_div
FSAMP[1:0] sampling-clock divider.
ra8_lvd_negate_t negate
PVDmCR0.RN (m chan, ignored on n).
ra8_lvd_hysteresis_t hysteresis
PVDmFCR.RHSEL / PVDnFCR.RHSEL.
bool filter_en
true -> clear DFDIS (digital filter on).
ra8_lvd_response_t response
Interrupt / reset / NMI / none.
bool irq_enable
true -> set RIE on init (IRQ + reset).
Per-channel register-offset bundle.
ra8_lvd_off_t fcr
PVDxFCR (RHSEL).
ra8_lvd_off_t cmpcr
PVDxCMPCR offset.
ra8_lvd_off_t cr0
PVDxCR0 offset.
ra8_lvd_off_t cr1
PVDxCR1 (m only; n: same as cr0 stub).
ra8_lvd_off_t sr
PVDxSR (m only; n: same as cr0 stub).
bool has_irq
true for monitor m channels (1, 2).