Nexus Embedded Platform 0.1.0
Statically assembled reusable embedded mechanisms
Loading...
Searching...
No Matches
adc.h
Go to the documentation of this file.
1
8#ifndef NEXUS_ADC_H
9#define NEXUS_ADC_H
10
11#include "nexus/core/time.h"
13#include "nexus/io/stream.h"
14#include "nexus/io/wake.h"
15#ifdef __cplusplus
16extern "C" {
17#endif
23typedef struct {
25 uint32_t reference_mv;
28
37typedef struct {
38 const uint8_t* channels;
39 const uint8_t* sample_times;
40 const uint16_t* sample_cycles;
43 uint32_t adc_clock_hz;
45 uint32_t scan_cycles;
48
55typedef struct {
56 nx_result_t (*info)(const void* context, nx_adc_info_t* info);
57 nx_result_t (*sample)(void* context, uint16_t* samples, size_t capacity,
58 nx_time_us_t deadline, size_t* count);
59 nx_result_t (*stream_start)(void* context, nx_stream_t* stream,
60 uint32_t trigger_hz);
61 nx_result_t (*stream_stop)(void* context);
62 nx_result_t (*stream_service)(void* context);
63 nx_result_t (*attach_wake)(void* context, const nx_irq_wake_t* wake,
64 uint8_t syscall_ceiling);
65 nx_result_t (*sequence_info)(const void* context,
67 nx_result_t (*attach_observer)(void* context, nx_adc_observer_t* observer);
68 nx_result_t (*block_observation)(const void* context,
69 const nx_stream_block_t* block,
70 nx_adc_observation_t* observation);
72
80 void* context;
81};
82
111 nx_adc_observer_t* observer);
122 const nx_stream_block_t* block,
123 nx_adc_observation_t* observation);
124
147nx_result_t nx_adc_port_sample(const nx_adc_port_t* port, uint16_t* samples,
148 size_t capacity, nx_time_us_t deadline,
149 size_t* count);
169 nx_stream_t* stream, uint32_t trigger_hz);
216 const nx_irq_wake_t* wake,
217 uint8_t syscall_ceiling);
218#ifdef __cplusplus
219}
220#endif
221
222#endif
nx_result_t nx_adc_port_stream_service(const nx_adc_port_t *port)
Explicitly resume discrete block acquisition after consumer drain.
nx_result_t nx_adc_port_attach_observer(const nx_adc_port_t *port, nx_adc_observer_t *observer)
Attach optional observer storage before acquisition starts.
nx_result_t nx_adc_port_sample(const nx_adc_port_t *port, uint16_t *samples, size_t capacity, nx_time_us_t deadline, size_t *count)
Sample the fixed single/scan sequence by bounded polling.
nx_result_t nx_adc_port_sequence_info(const nx_adc_port_t *port, nx_adc_sequence_info_t *info)
Read fixed channel order and complete-scan timing facts.
nx_result_t nx_adc_port_attach_wake(const nx_adc_port_t *port, const nx_irq_wake_t *wake, uint8_t syscall_ceiling)
Attach an optional hint sink after checking publisher IRQ priority.
struct nx_adc_port nx_adc_port_t
Definition adc.h:18
nx_result_t nx_adc_port_info(const nx_adc_port_t *port, nx_adc_info_t *info)
Query the fixed reviewed ADC sequence and raw-count format.
nx_result_t nx_adc_port_stream_stop(const nx_adc_port_t *port)
Stop trigger and memory sources without revoking consumer loans.
nx_result_t nx_adc_port_block_observation(const nx_adc_port_t *port, const nx_stream_block_t *block, nx_adc_observation_t *observation)
Query one live consumer loan's software completion record.
nx_result_t nx_adc_port_stream_start(const nx_adc_port_t *port, nx_stream_t *stream, uint32_t trigger_hz)
Start selected trigger/block acquisition with caller storage.
Optional caller-owned ADC publication observations.
nx_result_t
Operation result; success at submission means admission only.
Definition status.h:21
Bounded caller-owned blocks with explicit producer/consumer loans.
Raw count facts; nominal Vref is not a calibrated physical measurement.
Definition adc.h:23
uint8_t resolution_bits
Definition adc.h:24
uint32_t reference_mv
Definition adc.h:25
size_t channel_count
Definition adc.h:26
One loan's software observation, never a sample aperture.
Optional caller-owned observer control and exact records.
Shared read-only methods using one provider state.
Definition adc.h:55
nx_result_t(* block_observation)(const void *context, const nx_stream_block_t *block, nx_adc_observation_t *observation)
Definition adc.h:68
nx_result_t(* sample)(void *context, uint16_t *samples, size_t capacity, nx_time_us_t deadline, size_t *count)
Definition adc.h:57
nx_result_t(* stream_stop)(void *context)
Definition adc.h:61
nx_result_t(* stream_service)(void *context)
Definition adc.h:62
nx_result_t(* sequence_info)(const void *context, nx_adc_sequence_info_t *info)
Definition adc.h:65
nx_result_t(* stream_start)(void *context, nx_stream_t *stream, uint32_t trigger_hz)
Definition adc.h:59
nx_result_t(* attach_observer)(void *context, nx_adc_observer_t *observer)
Definition adc.h:67
nx_result_t(* info)(const void *context, nx_adc_info_t *info)
Definition adc.h:56
nx_result_t(* attach_wake)(void *context, const nx_irq_wake_t *wake, uint8_t syscall_ceiling)
Definition adc.h:63
Immutable interface pointing to caller-owned state.
Definition adc.h:78
const nx_adc_ops_t * ops
Definition adc.h:79
void * context
Definition adc.h:80
Immutable complete-scan timing facts for the selected mode.
Definition adc.h:37
size_t channel_count
Definition adc.h:41
const uint8_t * sample_times
Definition adc.h:39
uint16_t conversion_cycles
Definition adc.h:46
uint32_t scan_cycles
Definition adc.h:45
const uint8_t * channels
Definition adc.h:38
uint32_t timer_clock_hz
Definition adc.h:44
uint32_t adc_clock_hz
Definition adc.h:43
const uint16_t * sample_cycles
Definition adc.h:40
size_t sample_code_count
Definition adc.h:42
Optional immutable wake target borrowed by an IRQ provider.
Definition wake.h:26
Immutable consumer loan, valid until matching release succeeds.
Definition stream.h:86
Caller-owned stream control, initialized before publication.
Definition stream.h:53
Absolute monotonic microsecond deadlines and wrap extension.
uint64_t nx_time_us_t
Microseconds in one boot/clock domain; no wall-clock semantics.
Definition time.h:20
Explicit borrowed IRQ wake target and syscall-ceiling check.