ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_agt.h
Go to the documentation of this file.
1
11
12#pragma once
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18#include <stdint.h>
19
20#include "ra8_err.h"
21
31[[nodiscard]] ra8_err_t ra8_agt_start_free_run(uint8_t channel, uint16_t reload);
32
40[[nodiscard]] ra8_err_t ra8_agt_stop(uint8_t channel);
41
46typedef void (*ra8_agt_event_fn_t)(void* ctx, uint8_t channel);
47
52[[nodiscard]] ra8_err_t ra8_agt_deinit(uint8_t channel);
53
58[[nodiscard]] ra8_err_t ra8_agt_set_reload(uint8_t channel, uint16_t reload);
59
64[[nodiscard]] ra8_err_t ra8_agt_get_status(uint8_t channel, uint8_t* out_mask);
65
70[[nodiscard]] ra8_err_t ra8_agt_attach_handler(ra8_agt_event_fn_t fn, void* ctx);
71
92void ra8_agt_dispatch(uint8_t channel);
93
98[[nodiscard]] ra8_err_t ra8_agt_enter_stop(uint8_t channel);
99
104[[nodiscard]] ra8_err_t ra8_agt_exit_stop(uint8_t channel);
105
121
138
156
180
212[[nodiscard]] ra8_err_t ra8_agt_start_pulse_output(uint8_t channel, const ra8_agt_pulse_cfg_t* cfg);
213
219
243
282
283#ifdef __cplusplus
284}
285#endif
ra8_agt_pulse_mode_t
AGT pulse-output run mode.
Definition ra8_agt.h:117
@ k_ra8_agt_pulse_mode_one_shot
Underflow -> stop, single pulse.
Definition ra8_agt.h:119
@ k_ra8_agt_pulse_mode_continuous
Free-run, toggle every underflow.
Definition ra8_agt.h:118
ra8_err_t ra8_agt_set_reload(uint8_t channel, uint16_t reload)
Change the AGT reload value at runtime.
Definition ra8_agt.c:255
ra8_err_t ra8_agt_exit_stop(uint8_t channel)
Exit MSTP-gated stop.
Definition ra8_agt.c:423
ra8_err_t ra8_agt_attach_handler(ra8_agt_event_fn_t fn, void *ctx)
Attach an AGT event callback (shared across channels).
Definition ra8_agt.c:324
ra8_err_t ra8_agt_start_free_run(uint8_t channel, uint16_t reload)
Start an AGT channel in free-running mode.
Definition ra8_agt.c:151
ra8_agt_pulse_compare_t
Compare-match output channel selection for pulse mode.
Definition ra8_agt.h:151
@ k_ra8_agt_pulse_compare_b
AGTCMB + AGTOBn toggle armed.
Definition ra8_agt.h:154
@ k_ra8_agt_pulse_compare_a
AGTCMA + AGTOAn toggle armed.
Definition ra8_agt.h:153
@ k_ra8_agt_pulse_compare_none
No compare-match output.
Definition ra8_agt.h:152
void(* ra8_agt_event_fn_t)(void *ctx, uint8_t channel)
AGT event callback.
Definition ra8_agt.h:46
ra8_agt_cascade_clk_t
Definition ra8_agt.h:214
@ k_ra8_agt_cascade_clk_pclkb
TCK = 000b.
Definition ra8_agt.h:215
@ k_ra8_agt_cascade_clk_pclkb_div2
TCK = 011b.
Definition ra8_agt.h:217
@ k_ra8_agt_cascade_clk_pclkb_div8
TCK = 001b.
Definition ra8_agt.h:216
ra8_err_t ra8_agt_deinit(uint8_t channel)
Tear down one AGT channel.
Definition ra8_agt.c:221
ra8_err_t ra8_agt_start_cascade(const ra8_agt_cascade_cfg_t *cfg)
Cascade AGT0 and AGT1 into a 32-bit virtual down-counter.
Definition ra8_agt.c:949
ra8_err_t ra8_agt_get_status(uint8_t channel, uint8_t *out_mask)
Read the AGTCR status register.
Definition ra8_agt.c:289
ra8_agt_output_polarity_t
Initial level of the AGTOn pulse output.
Definition ra8_agt.h:134
@ k_ra8_agt_output_polarity_active_low
TEDGSEL = 0, start-high pin.
Definition ra8_agt.h:136
@ k_ra8_agt_output_polarity_active_high
TEDGSEL = 1, start-low pin.
Definition ra8_agt.h:135
ra8_err_t ra8_agt_start_pulse_output(uint8_t channel, const ra8_agt_pulse_cfg_t *cfg)
Start an AGT channel in pulse-output / output-compare mode.
Definition ra8_agt.c:649
ra8_err_t ra8_agt_enter_stop(uint8_t channel)
Put one channel into MSTP-gated stop.
Definition ra8_agt.c:389
ra8_err_t ra8_agt_stop(uint8_t channel)
Stop an AGT channel.
Definition ra8_agt.c:177
void ra8_agt_dispatch(uint8_t channel)
Dispatch an AGT event – fire callback.
Definition ra8_agt.c:351
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
Configuration for ra8_agt_start_cascade.
Definition ra8_agt.h:237
void * ctx
Opaque ctx forwarded to callback.
Definition ra8_agt.h:241
ra8_agt_event_fn_t on_underflow
Optional: fires on AGT1 underflow.
Definition ra8_agt.h:240
uint32_t reload32
32-bit virtual reload value.
Definition ra8_agt.h:238
ra8_agt_cascade_clk_t clock
Count source for the AGT0 half.
Definition ra8_agt.h:239
Configuration for ra8_agt_start_pulse_output.
Definition ra8_agt.h:173
ra8_agt_pulse_compare_t compare
Which compare-match pin is armed.
Definition ra8_agt.h:178
uint16_t period
16-bit reload (AGT register).
Definition ra8_agt.h:174
uint16_t duty
Compare-match A/B value.
Definition ra8_agt.h:175
ra8_agt_pulse_mode_t mode
continuous or one-shot.
Definition ra8_agt.h:176
ra8_agt_output_polarity_t polarity
Start-level of AGTOn.
Definition ra8_agt.h:177