32static const char*
s_tag =
"ACMPHS";
46typedef enum : uint8_t {
121 const uint8_t current = reg->
CMPCTL;
136 const uint8_t monitor = reg->
CMPMON;
154typedef enum : uint8_t {
ra8_err_t ra8_acmphs_channel_enable(uint8_t channel)
Enable a single ACMPHS channel.
ra8_err_t ra8_acmphs_set_inputs(uint8_t channel, uint8_t ivpsel, uint8_t ivrefsel)
Change the input selection of one channel at runtime.
void ra8_acmphs_dispatch(uint8_t channel)
Dispatch an ACMPHS edge event – fire the registered callback.
static void * s_acmphs_ctx
ra8_err_t ra8_acmphs_channel_init(uint8_t channel, const ra8_acmphs_cfg_t *cfg)
Initialise one channel with a full config descriptor.
ra8_err_t ra8_acmphs_channel_deinit(uint8_t channel)
Tear down one channel (disable + clear CMPCTL).
ra8_err_t ra8_acmphs_read_output(uint8_t channel, ra8_level_t *out)
Read the live output of a channel.
ra8_err_t ra8_acmphs_exit_stop(uint8_t channel)
Exit MSTP-gated stop for one channel.
ra8_err_t ra8_acmphs_enter_stop(uint8_t channel)
Put one channel into MSTP-gated stop.
ra8_err_t ra8_acmphs_get_status(uint8_t channel, uint8_t *out_mask)
Read CMPCTL enable / edge bits.
ra8_acmphs_mstp_limit_t
Number of ACMPHS channels that have dedicated MSTPD bits.
@ k_ra8_acmphs_mstp_id_count
RA8 acmphs mstp ID count.
static ra8_err_t internal_reset_channel(uint8_t ch)
Reset one ACMPHS channel's control + selector registers.
static ra8_acmphs_event_fn_t s_acmphs_fn
ra8_err_t ra8_acmphs_clear_status(uint8_t channel)
Clear CMPCTL (disable + edge mode off) for one channel.
ra8_acmphs_bits_t
CMPCTL field shifts (match FSP R_ACMPHS0_CMPCTL_b).
@ k_ra8_acmphs_ceg_shift
CMPCTL.CEG[1:0] at [4:3].
@ k_ra8_acmphs_cdfs_shift
CMPCTL.CDFS[1:0] at [6:5].
@ k_ra8_acmphs_cdfs_enabled_value
"Any sampling clock" when filter on.
@ k_ra8_acmphs_ctl_mask
RA8 acmphs ctl mask.
ra8_err_t ra8_acmphs_init(void)
Legacy init – reset every channel to its power-on state.
ra8_err_t ra8_acmphs_attach_handler(ra8_acmphs_event_fn_t fn, void *ctx)
Attach an ACMPHS event callback (shared across all channels).
static const ra8_mstp_t s_acmphs_mstp_table[k_ra8_acmphs_mstp_id_count]
Channel-index -> MSTP id lookup for the first 4 channels.
Full-featured High-Speed Analog Comparator (ACMPHS) driver.
void(* ra8_acmphs_event_fn_t)(void *ctx, uint8_t channel)
ACMPHS edge event callback.
High-Speed Analog Comparator (ACMPHS) register layout for the RA8D2.
static volatile r_acmphs_regs_t * ra8_acmphs(uint8_t channel)
Get pointer to ACMPHS channel channel.
@ k_ra8_acmphs_mask_cinv
CINV bit.
@ k_ra8_acmphs_mask_coe
COE bit.
@ k_ra8_acmphs_mask_hcmon
CMPMON.CMPMON: output level read.
@ k_ra8_acmphs_mask_hcen
HCMPON operation enable.
@ k_ra8_acmphs_mask_ceg
CEG[1:0] @ [4:3] edge selector.
@ k_ra8_acmphs_mask_cdfs
CDFS[1:0] @ [6:5] noise filter.
@ k_ra8_acmphs_channel_count
Channels 0..5 on this package.
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.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_hw_init_failed
Hardware peripheral failed to initialise.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ 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.
#define ra8_log_info(tag, message)
RA8 log info.
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.
ra8_mstp_t
Packed (reg << 8) | bit module-stop identifier.
@ k_ra8_mstp_acmphs0
MSTPD28 ACMPHS0.
@ k_ra8_mstp_acmphs3
MSTPD25 ACMPHS3.
@ k_ra8_mstp_acmphs2
MSTPD26 ACMPHS2.
@ k_ra8_mstp_acmphs1
MSTPD27 ACMPHS1.
Typed Port / Pin Constants for the RA8D2 IOPORT Module.
ra8_level_t
Digital output / input level.
@ k_ra8_level_high
Drive or read 1.
@ k_ra8_level_low
Drive or read 0.
Per-channel ACMPHS register window.
volatile uint8_t CMPCTL
+0x00 Control (enable, edges, filter).
volatile uint8_t CMPSEL0
+0x04 Plus-input selection.
volatile uint8_t CPIOC
+0x10 Output polarity / pin control.
volatile uint8_t CMPSEL1
+0x08 Minus-input selection.
volatile uint8_t CMPMON
+0x0C Output monitor (read-only).
Configuration descriptor for ra8_acmphs_channel_init.
uint8_t ivpsel
Plus-input select (CMPSEL0).
bool invert_out
True -> invert output.
ra8_acmphs_edge_t edge
Edge detect mode.
bool filter_en
True -> enable filter.
uint8_t ivrefsel
Minus-input select (CMPSEL1).