ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_acmphs.h
Go to the documentation of this file.
1
18
19#pragma once
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25#include <stdint.h>
26
27#include "ra8_acmphs_regs.h"
28#include "ra8_err.h"
29#include "ra8_port_constants.h"
30
41
51typedef struct {
52 uint8_t ivpsel;
53 uint8_t ivrefsel;
55 bool filter_en;
58
65typedef void (*ra8_acmphs_event_fn_t)(void* ctx, uint8_t channel);
66
67/* =============================================================================
68 * Lifecycle
69 * =============================================================================
70 */
71
77[[nodiscard]] ra8_err_t ra8_acmphs_init(void);
78
93[[nodiscard]] ra8_err_t ra8_acmphs_channel_init(uint8_t channel, const ra8_acmphs_cfg_t* cfg);
94
99[[nodiscard]] ra8_err_t ra8_acmphs_channel_deinit(uint8_t channel);
100
101/* =============================================================================
102 * Legacy polling API
103 * =============================================================================
104 */
105
112[[nodiscard]] ra8_err_t ra8_acmphs_channel_enable(uint8_t channel);
113
121[[nodiscard]] ra8_err_t ra8_acmphs_read_output(uint8_t channel, ra8_level_t* out);
122
123/* =============================================================================
124 * Runtime reconfigure
125 * =============================================================================
126 */
127
136[[nodiscard]] ra8_err_t ra8_acmphs_set_inputs(uint8_t channel, uint8_t ivpsel, uint8_t ivrefsel);
137
138/* =============================================================================
139 * Status
140 * =============================================================================
141 */
142
150[[nodiscard]] ra8_err_t ra8_acmphs_get_status(uint8_t channel, uint8_t* out_mask);
151
156[[nodiscard]] ra8_err_t ra8_acmphs_clear_status(uint8_t channel);
157
158/* =============================================================================
159 * Interrupt path
160 * =============================================================================
161 */
162
171
172/* =============================================================================
173 * Power transition
174 * =============================================================================
175 */
176
181[[nodiscard]] ra8_err_t ra8_acmphs_enter_stop(uint8_t channel);
182
187[[nodiscard]] ra8_err_t ra8_acmphs_exit_stop(uint8_t channel);
188
189/* =============================================================================
190 * ISR dispatch
191 * =============================================================================
192 */
193
208void ra8_acmphs_dispatch(uint8_t channel);
209
210#ifdef __cplusplus
211}
212#endif
ra8_err_t ra8_acmphs_channel_enable(uint8_t channel)
Enable a single ACMPHS channel.
Definition ra8_acmphs.c:113
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.
Definition ra8_acmphs.c:217
void ra8_acmphs_dispatch(uint8_t channel)
Dispatch an ACMPHS edge event – fire the registered callback.
Definition ra8_acmphs.c:285
ra8_err_t ra8_acmphs_channel_init(uint8_t channel, const ra8_acmphs_cfg_t *cfg)
Initialise one channel with a full config descriptor.
Definition ra8_acmphs.c:166
ra8_err_t ra8_acmphs_channel_deinit(uint8_t channel)
Tear down one channel (disable + clear CMPCTL).
Definition ra8_acmphs.c:200
ra8_err_t ra8_acmphs_read_output(uint8_t channel, ra8_level_t *out)
Read the live output of a channel.
Definition ra8_acmphs.c:127
ra8_err_t ra8_acmphs_exit_stop(uint8_t channel)
Exit MSTP-gated stop for one channel.
Definition ra8_acmphs.c:273
ra8_err_t ra8_acmphs_enter_stop(uint8_t channel)
Put one channel into MSTP-gated stop.
Definition ra8_acmphs.c:262
ra8_err_t ra8_acmphs_get_status(uint8_t channel, uint8_t *out_mask)
Read CMPCTL enable / edge bits.
Definition ra8_acmphs.c:230
ra8_err_t ra8_acmphs_clear_status(uint8_t channel)
Clear CMPCTL (disable + edge mode off) for one channel.
Definition ra8_acmphs.c:243
ra8_err_t ra8_acmphs_init(void)
Legacy init – reset every channel to its power-on state.
Definition ra8_acmphs.c:101
ra8_err_t ra8_acmphs_attach_handler(ra8_acmphs_event_fn_t fn, void *ctx)
Attach an ACMPHS event callback (shared across all channels).
Definition ra8_acmphs.c:255
void(* ra8_acmphs_event_fn_t)(void *ctx, uint8_t channel)
ACMPHS edge event callback.
Definition ra8_acmphs.h:65
ra8_acmphs_edge_t
Edge detection mode (CMPCTL.CEG).
Definition ra8_acmphs.h:35
@ k_ra8_acmphs_edge_rise
Rising edge.
Definition ra8_acmphs.h:37
@ k_ra8_acmphs_edge_fall
Falling edge.
Definition ra8_acmphs.h:38
@ k_ra8_acmphs_edge_none
Polling only, no edge trigger.
Definition ra8_acmphs.h:36
@ k_ra8_acmphs_edge_both
Either edge.
Definition ra8_acmphs.h:39
High-Speed Analog Comparator (ACMPHS) register layout for the RA8D2.
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Typed Port / Pin Constants for the RA8D2 IOPORT Module.
ra8_level_t
Digital output / input level.
Configuration descriptor for ra8_acmphs_channel_init.
Definition ra8_acmphs.h:51
uint8_t ivpsel
Plus-input select (CMPSEL0).
Definition ra8_acmphs.h:52
bool invert_out
True -> invert output.
Definition ra8_acmphs.h:56
ra8_acmphs_edge_t edge
Edge detect mode.
Definition ra8_acmphs.h:54
bool filter_en
True -> enable filter.
Definition ra8_acmphs.h:55
uint8_t ivrefsel
Minus-input select (CMPSEL1).
Definition ra8_acmphs.h:53