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

Programmable Voltage Detection (PVD / LVD) HAL types. More...

#include <stdint.h>
#include "ra8_err.h"
#include "ra8_lvd_regs.h"
Include dependency graph for ra8_lvd_types.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ra8_lvd_cfg_t
 Configuration descriptor for ra8_lvd_channel_init. More...
struct  ra8_lvd_status_t
 Decoded PVDmSR snapshot. More...

Typedefs

typedef void(* ra8_lvd_event_fn_t) (void *ctx, ra8_lvd_channel_t channel)
 PVD threshold-crossing callback.

Enumerations

enum  ra8_lvd_edge_t : uint8_t {
  k_ra8_lvd_edge_rise = 0U ,
  k_ra8_lvd_edge_fall = 1U ,
  k_ra8_lvd_edge_both = 2U
}
 PVDmCR1.IDTSEL[1:0] edge selector for monitor m channels. More...
enum  ra8_lvd_irq_type_t : uint8_t {
  k_ra8_lvd_irq_nmi = 0U ,
  k_ra8_lvd_irq_maskable = 1U
}
 PVDmCR1.IRQSEL value – NMI vs maskable interrupt. More...
enum  ra8_lvd_response_t : uint8_t {
  k_ra8_lvd_response_none = 0U ,
  k_ra8_lvd_response_interrupt = 1U ,
  k_ra8_lvd_response_nmi = 2U ,
  k_ra8_lvd_response_reset = 3U ,
  k_ra8_lvd_response_reset_on_rise = 4U
}
 Detection response selector for ra8_lvd_cfg_t::response. More...
enum  ra8_lvd_negate_t : uint8_t {
  k_ra8_lvd_negate_after_voltage = 0U ,
  k_ra8_lvd_negate_after_assert = 1U
}
 PVDmCR0.RN value – reset deassertion timing. More...
enum  ra8_lvd_hysteresis_t : uint8_t {
  k_ra8_lvd_hysteresis_lvd = 0U ,
  k_ra8_lvd_hysteresis_hvd = 1U
}
 PVDmFCR.RHSEL / PVDnFCR.RHSEL value. More...
enum  ra8_lvd_pvdlvl_t : uint8_t {
  k_ra8_lvd_pvdlvl_min = 0x03U ,
  k_ra8_lvd_pvdlvl_3_86v = 0x03U ,
  k_ra8_lvd_pvdlvl_3_14v = 0x04U ,
  k_ra8_lvd_pvdlvl_3_10v = 0x05U ,
  k_ra8_lvd_pvdlvl_3_08v = 0x06U ,
  k_ra8_lvd_pvdlvl_2_85v = 0x07U ,
  k_ra8_lvd_pvdlvl_2_83v = 0x08U ,
  k_ra8_lvd_pvdlvl_2_80v = 0x09U ,
  k_ra8_lvd_pvdlvl_2_62v = 0x0AU ,
  k_ra8_lvd_pvdlvl_2_33v = 0x0BU ,
  k_ra8_lvd_pvdlvl_1_90v = 0x0CU ,
  k_ra8_lvd_pvdlvl_1_86v = 0x0DU ,
  k_ra8_lvd_pvdlvl_1_74v = 0x0EU ,
  k_ra8_lvd_pvdlvl_1_71v = 0x0FU ,
  k_ra8_lvd_pvdlvl_max = 0x0FU
}
 PVDLVL[4:0] threshold encoding for PVDmCMPCR / PVDnCMPCR. More...
enum  ra8_lvd_loco_div_t : uint8_t {
  k_ra8_lvd_loco_div_2 = 0U ,
  k_ra8_lvd_loco_div_4 = 1U ,
  k_ra8_lvd_loco_div_8 = 2U ,
  k_ra8_lvd_loco_div_16 = 3U ,
  k_ra8_lvd_loco_div_max = 3U
}
 PVDmCR0.FSAMP[1:0] / PVDnCR0.FSAMP[1:0] sampling-clock divider. More...
enum  ra8_lvd_channel_t : uint8_t {
  k_ra8_lvd_ch1 = 1U ,
  k_ra8_lvd_ch2 = 2U ,
  k_ra8_lvd_ch4 = 4U ,
  k_ra8_lvd_ch5 = 5U
}
 Voltage-monitor channel selector. More...

Detailed Description

Programmable Voltage Detection (PVD / LVD) HAL types.

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

Typed enums, configuration / status structs, and the callback typedef for the RA8D2 PVD HAL driver. Split out of ra8_lvd.h so the public umbrella header stays under the per-file line budget; the umbrella ra8_lvd.h re-includes this header, so consumers are unaffected.

See ra8_lvd.h for the driver overview and HUM Ch 8 "Programmable Voltage Detection (PVD)", p 300-316 (R01UH1065EJ rev 1.30).

Since
0.1.0

Definition in file ra8_lvd_types.h.

Typedef Documentation

◆ ra8_lvd_event_fn_t

typedef void(* ra8_lvd_event_fn_t) (void *ctx, ra8_lvd_channel_t channel)

PVD threshold-crossing callback.

Parameters
[in]ctxCaller context registered via ra8_lvd_attach_handler.
[in]channelChannel that fired (one of k_ra8_lvd_chN).

Definition at line 241 of file ra8_lvd_types.h.

Enumeration Type Documentation

◆ ra8_lvd_channel_t

enum ra8_lvd_channel_t : uint8_t

Voltage-monitor channel selector.

The RA8D2 PVD block defines four monitor channels: PVD1 / PVD2 are the "m" series (NMI-capable, full feature set), PVD4 / PVD5 are the "n" series (reset-only, no IRQ). Channels 0 and 3 are not exposed on this part. See HUM Ch 8.1 Table 8.1 p 300.

Since
0.1.0
Enumerator
k_ra8_lvd_ch1 

PVD1 (m series, NMI-capable).

k_ra8_lvd_ch2 

PVD2 (m series, NMI-capable).

k_ra8_lvd_ch4 

PVD4 (n series, reset-only).

k_ra8_lvd_ch5 

PVD5 (n series, reset-only).

Definition at line 192 of file ra8_lvd_types.h.

◆ ra8_lvd_edge_t

enum ra8_lvd_edge_t : uint8_t

PVDmCR1.IDTSEL[1:0] edge selector for monitor m channels.

From HUM 8.2.6 p 307:

  • 00b = rise (when VCC >= Vdetm is detected).
  • 01b = fall (when VCC < Vdetm is detected).
  • 10b = both (any crossing fires DET).
  • 11b = "Settings prohibited" – the driver rejects this.
Enumerator
k_ra8_lvd_edge_rise 

Detect VCC >= Vdetm rising crossings.

k_ra8_lvd_edge_fall 

Detect VCC < Vdetm falling crossings.

k_ra8_lvd_edge_both 

Detect either crossing.

Definition at line 41 of file ra8_lvd_types.h.

◆ ra8_lvd_hysteresis_t

enum ra8_lvd_hysteresis_t : uint8_t

PVDmFCR.RHSEL / PVDnFCR.RHSEL value.

From HUM 8.2.8 p 308 and HUM 8.2.9 p 309 (identical semantics):

  • 0 -> hysteresis sits above Vdetm (the comparator behaves as a fall-detector with rising hysteresis – LVD mode).
  • 1 -> hysteresis sits below Vdetm (rise-detector with falling hysteresis – HVD mode). Required for reset_on_rise.
Enumerator
k_ra8_lvd_hysteresis_lvd 

RHSEL = 0 (fall detect).

k_ra8_lvd_hysteresis_hvd 

RHSEL = 1 (rise detect).

Definition at line 115 of file ra8_lvd_types.h.

◆ ra8_lvd_irq_type_t

enum ra8_lvd_irq_type_t : uint8_t

PVDmCR1.IRQSEL value – NMI vs maskable interrupt.

Enumerator
k_ra8_lvd_irq_nmi 

Non-maskable interrupt (default).

k_ra8_lvd_irq_maskable 

Maskable interrupt via ICU.

Definition at line 51 of file ra8_lvd_types.h.

◆ ra8_lvd_loco_div_t

enum ra8_lvd_loco_div_t : uint8_t

PVDmCR0.FSAMP[1:0] / PVDnCR0.FSAMP[1:0] sampling-clock divider.

Selects the LOCO divider feeding the digital filter. HUM Ch 8.2.4 p 305 "FSAMP[1:0] bits" documents 0..3 as the only legal range. The encoding matches FSP lvd_sample_clock_t:

  • 0 = LOCO / 2 (fastest, highest power).
  • 1 = LOCO / 4.
  • 2 = LOCO / 8.
  • 3 = LOCO / 16 (slowest, lowest power).

The "2s + 3 LOCO cycles" stabilisation delay computed by ra8_lvd_filter_delay_us uses s = 2^(div+1) – so div=0 implies s=2 (LOCO/2), div=3 implies s=16 (LOCO/16).

Since
0.1.0
Enumerator
k_ra8_lvd_loco_div_2 

LOCO / 2 (fastest, highest power).

k_ra8_lvd_loco_div_4 

LOCO / 4.

k_ra8_lvd_loco_div_8 

LOCO / 8.

k_ra8_lvd_loco_div_16 

LOCO / 16 (slowest, lowest power).

k_ra8_lvd_loco_div_max 

Highest legal value (sentinel).

Definition at line 172 of file ra8_lvd_types.h.

◆ ra8_lvd_negate_t

enum ra8_lvd_negate_t : uint8_t

PVDmCR0.RN value – reset deassertion timing.

From HUM 8.2.4 p 305 "RN bit":

  • case PVDmFCR.RHSEL = 0: 0 = negation follows tPVDm after VCC > Vdetm. 1 = negation follows tPVDm after the PVDm reset asserts.
  • case PVDmFCR.RHSEL = 1: RN = 1 is prohibited.

The driver uses k_ra8_lvd_negate_after_voltage as the safe default because that is the only value compatible with Software Standby and Deep Software Standby (HUM 8.2.4 p 306 "RN bit").

Enumerator
k_ra8_lvd_negate_after_voltage 

Negate after VCC clears Vdetm.

k_ra8_lvd_negate_after_assert 

Negate after reset asserts.

Definition at line 99 of file ra8_lvd_types.h.

◆ ra8_lvd_pvdlvl_t

enum ra8_lvd_pvdlvl_t : uint8_t

PVDLVL[4:0] threshold encoding for PVDmCMPCR / PVDnCMPCR.

The legal range is 0x03..0x0F per HUM Ch 8.2.2 p 303 (Table 8.2). Encodings 0x00..0x02 and 0x10..0x1F are reserved / prohibited; the driver rejects any value outside k_ra8_lvd_pvdlvl_min..k_ra8_lvd_pvdlvl_max. Each named entry maps to a nominal Vdetm voltage; values verified against FSP lvd_threshold_t for RA8D2 in bsp/mcu/ra8d2/bsp_override.h.

Since
0.1.0
Enumerator
k_ra8_lvd_pvdlvl_min 

Lowest legal threshold encoding.

k_ra8_lvd_pvdlvl_3_86v 

3.86 V.

k_ra8_lvd_pvdlvl_3_14v 

3.14 V.

k_ra8_lvd_pvdlvl_3_10v 

3.10 V.

k_ra8_lvd_pvdlvl_3_08v 

3.08 V.

k_ra8_lvd_pvdlvl_2_85v 

2.85 V.

k_ra8_lvd_pvdlvl_2_83v 

2.83 V.

k_ra8_lvd_pvdlvl_2_80v 

2.80 V.

k_ra8_lvd_pvdlvl_2_62v 

2.62 V.

k_ra8_lvd_pvdlvl_2_33v 

2.33 V.

k_ra8_lvd_pvdlvl_1_90v 

1.90 V.

k_ra8_lvd_pvdlvl_1_86v 

1.86 V.

k_ra8_lvd_pvdlvl_1_74v 

1.74 V.

k_ra8_lvd_pvdlvl_1_71v 

1.71 V.

k_ra8_lvd_pvdlvl_max 

Highest legal threshold encoding.

Definition at line 134 of file ra8_lvd_types.h.

◆ ra8_lvd_response_t

enum ra8_lvd_response_t : uint8_t

Detection response selector for ra8_lvd_cfg_t::response.

Determines which downstream signal the comparator drives:

  • none – comparator output enabled but neither IRQ nor reset is asserted (only the MON / DET flags + ELC event are useful in this mode – HUM Section 8.7 p 315).
  • interrupt – maskable IRQ via the ICU (m channels only). Sets PVDmCR1.IRQSEL = 1 and PVDmCR0.RIE = 1.
  • nmi – non-maskable IRQ via the NMIER block (m channels only). Sets PVDmCR1.IRQSEL = 0 and PVDmCR0.RIE = 1.
  • reset – LVD-style "fall to below Vdetm -> reset" path (m: PVDmCR0.RI=1 + RIE=1; n: PVDnCR0.RE=1).
  • reset_on_rise – HVD-style "rise above Vdetm -> reset" path, forces PVDmFCR.RHSEL = 1 (HUM 8.2.8 p 308 "When PVD reset generated by the VCC-rise detection is required, you should clear RHSEL to 1").
Enumerator
k_ra8_lvd_response_none 

Flags / ELC only.

k_ra8_lvd_response_interrupt 

Maskable IRQ (m only).

k_ra8_lvd_response_nmi 

NMI (m only).

k_ra8_lvd_response_reset 

LVD reset (any).

k_ra8_lvd_response_reset_on_rise 

HVD reset (any).

Definition at line 76 of file ra8_lvd_types.h.