|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Full-featured High-Speed Analog Comparator (ACMPHS) driver. More...
#include <stdint.h>#include "ra8_acmphs_regs.h"#include "ra8_err.h"#include "ra8_port_constants.h"Go to the source code of this file.
Data Structures | |
| struct | ra8_acmphs_cfg_t |
| Configuration descriptor for ra8_acmphs_channel_init. More... | |
Typedefs | |
| typedef void(* | ra8_acmphs_event_fn_t) (void *ctx, uint8_t channel) |
| ACMPHS edge event callback. | |
Enumerations | |
| enum | ra8_acmphs_edge_t : uint8_t { k_ra8_acmphs_edge_none = 0U , k_ra8_acmphs_edge_rise = 1U , k_ra8_acmphs_edge_fall = 2U , k_ra8_acmphs_edge_both = 3U } |
| Edge detection mode (CMPCTL.CEG). More... | |
Functions | |
| ra8_err_t | ra8_acmphs_init (void) |
| Legacy init – reset every channel to its power-on state. | |
| 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_channel_enable (uint8_t channel) |
| Enable a single ACMPHS channel. | |
| 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_set_inputs (uint8_t channel, uint8_t ivpsel, uint8_t ivrefsel) |
| Change the input selection of one channel at runtime. | |
| ra8_err_t | ra8_acmphs_get_status (uint8_t channel, uint8_t *out_mask) |
| Read CMPCTL enable / edge bits. | |
| ra8_err_t | ra8_acmphs_clear_status (uint8_t channel) |
| Clear CMPCTL (disable + edge mode off) for one channel. | |
| ra8_err_t | ra8_acmphs_attach_handler (ra8_acmphs_event_fn_t fn, void *ctx) |
| Attach an ACMPHS event callback (shared across all channels). | |
| ra8_err_t | ra8_acmphs_enter_stop (uint8_t channel) |
| Put one channel into MSTP-gated stop. | |
| ra8_err_t | ra8_acmphs_exit_stop (uint8_t channel) |
| Exit MSTP-gated stop for one channel. | |
| void | ra8_acmphs_dispatch (uint8_t channel) |
| Dispatch an ACMPHS edge event – fire the registered callback. | |
Full-featured High-Speed Analog Comparator (ACMPHS) driver.
full build-out of the RA8D2 ACMPHS block. Extends the enable/read stub with: per-channel descriptor init, deinit, runtime input selection, edge-sensitive IRQ attach / dispatch, filter config, power transition.
Definition in file ra8_acmphs.h.
| typedef void(* ra8_acmphs_event_fn_t) (void *ctx, uint8_t channel) |
ACMPHS edge event callback.
| [in] | ctx | Caller context. |
| [in] | channel | Channel that fired the edge. |
Definition at line 65 of file ra8_acmphs.h.
| enum ra8_acmphs_edge_t : uint8_t |
Edge detection mode (CMPCTL.CEG).
| Enumerator | |
|---|---|
| k_ra8_acmphs_edge_none | Polling only, no edge trigger. |
| k_ra8_acmphs_edge_rise | Rising edge. |
| k_ra8_acmphs_edge_fall | Falling edge. |
| k_ra8_acmphs_edge_both | Either edge. |
Definition at line 35 of file ra8_acmphs.h.
|
nodiscard |
Attach an ACMPHS event callback (shared across all channels).
| [in] | fn | Callback fired on ISR dispatch. |
| [in] | ctx | Context forwarded to the callback. |
Definition at line 255 of file ra8_acmphs.c.
References k_ra8_ok, s_acmphs_ctx, and s_acmphs_fn.
|
nodiscard |
Tear down one channel (disable + clear CMPCTL).
Definition at line 200 of file ra8_acmphs.c.
References r_acmphs_regs_t::CMPCTL, r_acmphs_regs_t::CMPSEL0, r_acmphs_regs_t::CMPSEL1, k_ra8_acmphs_channel_count, k_ra8_acmphs_mstp_id_count, k_ra8_err_invalid_arg, k_ra8_ok, ra8_acmphs(), RA8_CHECK_NULL_PTR, ra8_mstp_disable(), s_acmphs_mstp_table, and s_tag.
|
nodiscard |
Enable a single ACMPHS channel.
| [in] | channel | Channel index (0..5). |
Definition at line 113 of file ra8_acmphs.c.
References r_acmphs_regs_t::CMPCTL, k_ra8_acmphs_channel_count, k_ra8_acmphs_mask_hcen, k_ra8_err_invalid_arg, k_ra8_ok, ra8_acmphs(), RA8_CHECK_NULL_PTR, ra8_log_info_val, and s_tag.
|
nodiscard |
Initialise one channel with a full config descriptor.
| [in] | channel | Channel 0..5. |
| [in] | cfg | Non-NULL configuration descriptor. |
Definition at line 166 of file ra8_acmphs.c.
References r_acmphs_regs_t::CMPCTL, r_acmphs_regs_t::CMPSEL0, r_acmphs_regs_t::CMPSEL1, ra8_acmphs_cfg_t::edge, ra8_acmphs_cfg_t::filter_en, ra8_acmphs_cfg_t::invert_out, ra8_acmphs_cfg_t::ivpsel, ra8_acmphs_cfg_t::ivrefsel, k_ra8_acmphs_cdfs_enabled_value, k_ra8_acmphs_cdfs_shift, k_ra8_acmphs_ceg_shift, k_ra8_acmphs_channel_count, k_ra8_acmphs_mask_cinv, k_ra8_acmphs_mask_hcen, k_ra8_acmphs_mstp_id_count, k_ra8_err_invalid_arg, k_ra8_ok, ra8_acmphs(), RA8_CHECK_NULL_PTR, ra8_mstp_enable(), RA8_RETURN_ON_ERROR, s_acmphs_mstp_table, and s_tag.
Referenced by internal_acmphs_demo_setup().
|
nodiscard |
Clear CMPCTL (disable + edge mode off) for one channel.
Definition at line 243 of file ra8_acmphs.c.
References r_acmphs_regs_t::CMPCTL, k_ra8_acmphs_channel_count, k_ra8_err_invalid_arg, k_ra8_ok, ra8_acmphs(), RA8_CHECK_NULL_PTR, and s_tag.
| void ra8_acmphs_dispatch | ( | uint8_t | channel | ) |
Dispatch an ACMPHS edge event – fire the registered callback.
| [in] | channel | Channel 0..5 that fired the edge. |
See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.
Definition at line 285 of file ra8_acmphs.c.
References k_ra8_acmphs_channel_count, s_acmphs_ctx, and s_acmphs_fn.
|
nodiscard |
Put one channel into MSTP-gated stop.
Definition at line 262 of file ra8_acmphs.c.
References k_ra8_acmphs_channel_count, k_ra8_acmphs_mstp_id_count, k_ra8_err_invalid_arg, k_ra8_ok, ra8_mstp_disable(), and s_acmphs_mstp_table.
|
nodiscard |
Exit MSTP-gated stop for one channel.
Definition at line 273 of file ra8_acmphs.c.
References k_ra8_acmphs_channel_count, k_ra8_acmphs_mstp_id_count, k_ra8_err_invalid_arg, k_ra8_ok, ra8_mstp_enable(), and s_acmphs_mstp_table.
|
nodiscard |
Read CMPCTL enable / edge bits.
| [in] | channel | Channel 0..5. |
| [out] | out_mask | CMPCTL value. |
Definition at line 230 of file ra8_acmphs.c.
References r_acmphs_regs_t::CMPCTL, k_ra8_acmphs_channel_count, k_ra8_acmphs_ctl_mask, k_ra8_err_invalid_arg, k_ra8_ok, ra8_acmphs(), RA8_CHECK_NULL_PTR, and s_tag.
|
nodiscard |
Legacy init – reset every channel to its power-on state.
Definition at line 101 of file ra8_acmphs.c.
References internal_reset_channel(), k_ra8_acmphs_channel_count, k_ra8_ok, ra8_log_info, RA8_RETURN_ON_ERROR, and s_tag.
Referenced by internal_acmphs_demo_setup(), and ra8_nsc_acmphs_init().
|
nodiscard |
Read the live output of a channel.
| [in] | channel | Channel index (0..5). |
| [out] | out | Receives k_ra8_level_high or k_ra8_level_low. |
Definition at line 127 of file ra8_acmphs.c.
References r_acmphs_regs_t::CMPMON, k_ra8_acmphs_channel_count, k_ra8_acmphs_mask_hcmon, k_ra8_err_invalid_arg, k_ra8_level_high, k_ra8_level_low, k_ra8_ok, ra8_acmphs(), RA8_CHECK_NULL_PTR, and s_tag.
Referenced by internal_acmphs_demo_one_iter(), and ra8_nsc_acmphs_read_output().
|
nodiscard |
Change the input selection of one channel at runtime.
| [in] | channel | Channel 0..5. |
| [in] | ivpsel | Plus-input selector. |
| [in] | ivrefsel | Minus-input selector. |
Definition at line 217 of file ra8_acmphs.c.
References r_acmphs_regs_t::CMPSEL0, r_acmphs_regs_t::CMPSEL1, k_ra8_acmphs_channel_count, k_ra8_err_invalid_arg, k_ra8_ok, ra8_acmphs(), RA8_CHECK_NULL_PTR, and s_tag.