Typed I/O: devices and execution contracts¶
These declarations come from public header files. Selection, lifecycle, supported execution modes and physical authorization remain bounded by the corresponding design and support records.
adc.h¶
Reviewed ADC single-shot and low-rate polling scans.
- Author
Nexus Team
Typedefs
-
typedef struct nx_adc_port nx_adc_port_t¶
Functions
-
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.
- 参数:
port – [in] Single-shot/low-rate scan provider.
info – [out] Resolution, declared reference and sequence length.
- 返回:
Success or INVALID.
-
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.
- 参数:
port – [in] Initialized timing-capable provider.
info – [out] Cold read-only facts; no acquisition starts.
- 返回:
Success or INVALID/STATE/UNSUPPORTED.
-
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.
备注
Stop and join before detach/reclaim. No hidden allocation; polling and finite modes need no observation storage.
- 参数:
port – [in] Initialized continuous provider, one task owner.
observer – [inout] Initialized stable caller storage, or NULL to detach. Provider validates exact stream count at start.
- 返回:
Success or BUSY/CONTEXT/UNSUPPORTED.
-
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.
- 参数:
port – [in] Same stable observer-capable provider.
block – [in] Same stream’s currently acquired immutable block.
observation – [out] Copied epoch, ordinal, observed time and gap flag. This is never a hardware sample aperture timestamp.
- 返回:
Success or INVALID/STATE/UNSUPPORTED, output unchanged on rejection.
-
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.
备注
CPU-active task-only acquisition. Reference voltage, sampling error and maximum rate need physical qualification.
- 参数:
port – [inout] Single execution owner; fixed channel/sample-time setup.
samples – [out] Raw counts in configured channel order.
capacity – [in] Sample capacity at least channel_count.
deadline – [in] Absolute clock-domain deadline.
count – [out] Complete valid samples; remaining output is untouched.
- 返回:
Success or INVALID/BUSY/TIMEOUT/IO; abort/drain completes before return. No retained buffer, DMA/trigger/stream promise.
-
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.
备注
Blocks contain native uint16_t raw counts in channel order. Capacities and lengths are multiples of a complete scan; DMA domains/alignment and physical rate require separate evidence.
- 参数:
port – [in] Trigger/block-capable provider, one task executor.
stream – [inout] Initialized immutable-consumer block mechanism.
trigger_hz – [in] Positive requested complete-scan rate; provider rejects rates outside its declared timer/ADC capability.
- 返回:
Success or INVALID/BUSY/UNSUPPORTED before buffer admission.
-
nx_result_t nx_adc_port_stream_stop(const nx_adc_port_t *port)¶
Stop trigger and memory sources without revoking consumer loans.
备注
Consumer READY/BORROWED blocks must still be drained/released.
- 参数:
port – [in] Same acquisition executor; retain storage on BUSY.
- 返回:
Success proves source detach, BUSY retains producer storage, UNSUPPORTED for a polling-only provider.
-
nx_result_t nx_adc_port_stream_service(const nx_adc_port_t *port)¶
Explicitly resume discrete block acquisition after consumer drain.
备注
No task, retry or hidden rearm is created. Block modes state their trigger gaps; continuous zero-gap capture requires a separately declared hardware capability and qualification.
- 参数:
port – [in] Same single task executor as start and stop.
- 返回:
Success when an engine is armed, BUSY during source drain or free-block backpressure, STATE after acquisition stops.
-
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.
备注
Block/error predicates latch before notifications. Stop and join publishers and waiters before reclaiming old sink storage.
- 参数:
port – [in] Initialized block-capable provider, one task executor.
wake – [in] Immutable borrowed target or NULL to detach.
syscall_ceiling – [in] Optional additional unshifted kernel-safe priority floor; cannot weaken generated policy. PRIMASK kernel targets require zero. Ignored without kernel calls.
- 返回:
Success or CONTEXT/STATE/PERMISSION/UNSUPPORTED.
-
struct nx_adc_info_t¶
- #include <adc.h>
Raw count facts; nominal Vref is not a calibrated physical measurement.
-
struct nx_adc_sequence_info_t¶
- #include <adc.h>
Immutable complete-scan timing facts for the selected mode.
备注
sample_times are codes into sample_cycles, in channel order. scan_cycles includes each channel’s sample and conversion. Clock declarations and cycle counts describe scheduling; they do not establish electrical accuracy or sample aperture timestamps. Arrays remain valid through provider lifetime.
-
struct nx_adc_ops_t¶
- #include <adc.h>
Shared read-only methods using one provider state.
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
Public Members
-
nx_result_t (*info)(const void *context, nx_adc_info_t *info)¶
-
nx_result_t (*sample)(void *context, uint16_t *samples, size_t capacity, nx_time_us_t deadline, size_t *count)¶
-
nx_result_t (*stream_start)(void *context, nx_stream_t *stream, uint32_t trigger_hz)¶
-
nx_result_t (*stream_stop)(void *context)¶
-
nx_result_t (*stream_service)(void *context)¶
-
nx_result_t (*attach_wake)(void *context, const nx_irq_wake_t *wake, uint8_t syscall_ceiling)¶
-
nx_result_t (*sequence_info)(const void *context, nx_adc_sequence_info_t *info)¶
-
nx_result_t (*attach_observer)(void *context, nx_adc_observer_t *observer)¶
-
nx_result_t (*block_observation)(const void *context, const nx_stream_block_t *block, nx_adc_observation_t *observation)¶
-
nx_result_t (*info)(const void *context, nx_adc_info_t *info)¶
adc_observer.h¶
Optional caller-owned ADC publication observations.
- Author
Nexus Team
Defines
-
NX_ADC_OBSERVATION_DISCONTINUITY¶
Functions
-
nx_result_t nx_adc_observer_initialize(nx_adc_observer_t *observer, nx_adc_observation_t *records, size_t count)¶
Initialize fresh unborrowed optional observation storage.
- 参数:
observer – [out] Aligned fresh control, not published to readers.
records – [out] Distinct aligned exact record array.
count – [in] Positive count; must equal the selected stream count.
- 返回:
Success or INVALID/CONTEXT; rejected outputs stay untouched.
-
nx_result_t nx_adc_observer_bind(nx_adc_observer_t *observer, nx_stream_t *stream, const void *owner, size_t owner_size)¶
Provider-only cold bind validates every metadata/payload span before the first DMA loan.
- 参数:
observer – [inout] Initialized exclusive observation control.
stream – [in] Exact initialized stream, no outstanding loans.
owner – [in] Provider’s stable complete private state span.
owner_size – [in] Positive exact state byte count.
- 返回:
Success or INVALID/BUSY, without a partial retained bind.
-
nx_result_t nx_adc_observer_record(nx_adc_observer_t *observer, const nx_stream_fill_t *fill, nx_time_us_t observed_at)¶
Provider-only record before matching release-publication.
- 参数:
observer – [inout] Bound exact producer-owned control.
fill – [in] Still FILLING, with a proved detached memory target.
observed_at – [in] Software observation in the same clock domain.
- 返回:
Success or STATE/EXHAUSTED without wrapping identities.
-
nx_result_t nx_adc_observer_read(const nx_adc_observer_t *observer, const nx_stream_block_t *block, nx_adc_observation_t *observation)¶
Read only a currently acquired block’s exact epoch record.
- 参数:
observer – [in] Stable bound observation control.
block – [in] Same stream’s live immutable consumer loan.
observation – [out] Complete copy; untouched on rejection.
- 返回:
Success or INVALID/STATE for a missing/stale/released loan.
-
nx_result_t nx_adc_observer_unbind(nx_adc_observer_t *observer)¶
Provider-only unbind after all producer/consumer loans join.
- 参数:
observer – [inout] Stable initialized control; NULL is allowed.
- 返回:
Success or BUSY retaining the bound stream.
-
struct nx_adc_observation_t¶
- #include <adc_observer.h>
One loan’s software observation, never a sample aperture.
备注
observed_at uses the platform monotonic clock after target detach readback. IRQ delivery and publication latency are included. sequence counts observed valid block records, not timer triggers, samples or guessed missed scans.
-
struct nx_adc_observer_t¶
- #include <adc_observer.h>
Optional caller-owned observer control and exact records.
备注
Initialize before attaching; internal fields belong to one producer. Records and control remain live through successful provider stop and all consumer releases. No default stream, slot or finite provider storage is enlarged.
Public Members
-
nx_stream_t *stream¶
-
nx_adc_observation_t *records¶
-
size_t count¶
-
uint64_t sequence¶
-
bool discontinuity¶
-
nx_stream_t *stream¶
advanced_pwm.h¶
Optional fixed complementary PWM with latched break.
- Author
Nexus Team
Functions
-
nx_result_t nx_advanced_pwm_set_duty(const nx_advanced_pwm_t *port, uint32_t duty_ticks)¶
Stage duty against the fixed declared PSC/ARR and complementary pair.
备注
Shadow duty becomes effective at the next update. Hardware deadtime encoding must exactly represent the cold-configured tDTS count; PSC does not scale deadtime. This API does not certify pin timing.
- 参数:
port – [in] One serialized privileged task owner.
duty_ticks – [in] Zero through the maintained period, inclusive.
- 返回:
SUCCESS or INVALID/STATE/CONTEXT; no base-clock reconfiguration.
-
nx_result_t nx_advanced_pwm_start(const nx_advanced_pwm_t *port)¶
Enable outputs only with inactive break and no latched fault.
备注
Automatic output reenabling and irreversible hardware LOCK are prohibited. A break never silently starts outputs again.
- 参数:
port – [in] Privileged task owner of reviewed pin/clock/vector leases.
- 返回:
SUCCESS or BUSY/STATE/IO/CONTEXT; failure retains ownership.
-
nx_result_t nx_advanced_pwm_stop(const nx_advanced_pwm_t *port)¶
Disable/read back master output and both channel sources.
备注
Cold assembly keeps the reviewed inactive-pin and shared-vector leases until success and IRQ quiescence. A latched break survives stop.
- 参数:
port – [in] Privileged task owner, no concurrent duty/lifecycle calls.
- 返回:
SUCCESS proves output source detachment; BUSY retains responsibility.
-
nx_result_t nx_advanced_pwm_state(const nx_advanced_pwm_t *port, nx_advanced_pwm_state_t *state)¶
Query staged duty, actual enable state and latched break facts.
- 参数:
port – [in] Privileged task owner.
state – [out] Separate writable snapshot, never provider storage.
- 返回:
SUCCESS or INVALID/STATE/CONTEXT.
-
nx_result_t nx_advanced_pwm_clear_fault(const nx_advanced_pwm_t *port)¶
Clear a software fault only while disabled and BKIN is inactive.
备注
Physical input and pending hardware break are rechecked. Application recovery policy and external power safety remain outside Nexus.
- 参数:
port – [in] Privileged task recovery owner.
- 返回:
SUCCESS or BUSY/STATE/IO/CONTEXT; does not enable outputs.
-
struct nx_advanced_pwm_state_t¶
- #include <advanced_pwm.h>
Counts use the fixed post-prescaler clock; deadtime uses tDTS.
-
struct nx_advanced_pwm_ops_t¶
- #include <advanced_pwm.h>
Shared immutable controls; configuration is a cold assembly fact.
Public Members
-
nx_result_t (*set_duty)(void *context, uint32_t duty_ticks)¶
-
nx_result_t (*start)(void *context)¶
-
nx_result_t (*stop)(void *context)¶
-
nx_result_t (*state)(const void *context, nx_advanced_pwm_state_t *state)¶
-
nx_result_t (*clear_fault)(void *context)¶
-
nx_result_t (*set_duty)(void *context, uint32_t duty_ticks)¶
-
struct nx_advanced_pwm_t¶
- #include <advanced_pwm.h>
Immutable identity; controller state and configuration outlive IRQs.
can.h¶
Classic CAN value frames and caller-owned mailbox requests.
- Author
Nexus Team
Defines
-
NX_CAN_LOSS_SOFTWARE¶
-
NX_CAN_LOSS_HARDWARE_LOWER_BOUND¶
-
NX_CAN_LOSS_SATURATED¶
-
NX_CAN_DLC_NORMALIZED¶
Enums
Functions
-
nx_result_t nx_can_tx_prepare(nx_can_tx_request_t *request, const nx_can_frame_t *frame, nx_time_us_t deadline)¶
Validate and copy a classic frame into unborrowed request storage.
备注
Task owner only; failure retains no reference and changes no frame.
- 参数:
request – [inout] Initialized READY or consumed SETTLED storage.
frame – [in] Value copied here; remote data bytes are ignored.
deadline – [in] Absolute provider-clock deadline, including admission.
- 返回:
Success, INVALID for nonclassic frame, STATE while borrowed.
-
nx_result_t nx_can_port_submit(const nx_can_port_t *port, nx_can_tx_request_t *request)¶
Admit one frame into one of three hardware mailboxes.
备注
Serialized privileged task owner, incoming IRQ masks clear. REJECTED retains nothing. TXOK plus completed/empty hardware proves success.
- 参数:
port – [in] Stable immutable face and private storage.
request – [inout] READY value request, kept alive until SETTLED.
- 返回:
Success means ACCEPTED, not on-wire completion; other results reject.
-
nx_result_t nx_can_port_cancel(const nx_can_port_t *port, nx_can_tx_request_t *request)¶
Request abort without revoking a borrowed request.
备注
Abort may race real transmission; observed TXOK remains SUCCESS. Failed abort remains QUARANTINED and must keep storage alive.
- 参数:
port – [in] Stable face owned by the serialized task executor.
request – [inout] Live request previously accepted by this instance.
- 返回:
Success requests drain; STATE for an unrelated request.
-
nx_result_t nx_can_port_service(const nx_can_port_t *port)¶
Process latched completions and absolute timeout/drain deadlines.
备注
Bounded three-mailbox/six-frame work, no worker, blocking or replay.
- 参数:
port – [in] Serialized task-owner face with incoming masks clear.
- 返回:
Success, STATE before start, CONTEXT for an illegal caller.
-
nx_result_t nx_can_port_read_events(const nx_can_port_t *port, nx_can_event_t *events, size_t capacity, size_t *count)¶
Consume value events without overwriting earlier unconsumed facts.
备注
Each bounded record copy has a short metadata exclusion; pending loss is ordered after older records and before future frames.
- 参数:
port – [in] Stable instance; one task consumer owns this operation.
events – [out] Caller capacity; no retained output reference.
capacity – [in] Nonzero number of event records.
count – [out] Number copied; EMPTY means zero available.
- 返回:
Success, EMPTY, INVALID or CONTEXT.
-
nx_result_t nx_can_port_state(const nx_can_port_t *port, nx_can_state_t *state)¶
Copy authoritative error/admission state, even when RX is full.
备注
Task-only, bounded; bus-off is latched until explicit recovery.
- 参数:
port – [in] Live instance and storage.
state – [out] Unretained value output.
- 返回:
Success, INVALID or CONTEXT.
-
nx_result_t nx_can_port_stop(const nx_can_port_t *port)¶
Close admission, abort TX and detach IRQ/RX publishers.
备注
Never resets the shared primary controller to release a peer’s loan. Retry after progress. Success ends provider access to RX/wake storage.
- 参数:
port – [in] Serialized owner; external observers must also join.
- 返回:
Success after hardware drain; BUSY retains requests/ring/wake loans.
-
nx_result_t nx_can_port_recover(const nx_can_port_t *port)¶
Explicitly reenter initialization after bus-off and complete drain.
备注
No automatic recovery or retransmission; domain/filter identity stays.
- 参数:
port – [in] Started owner with no active/quarantined TX slots.
- 返回:
Success after bounded hardware acknowledgement, BUSY while borrowed.
-
nx_result_t nx_can_port_attach_wake(const nx_can_port_t *port, const nx_irq_wake_t *wake, uint8_t syscall_ceiling)¶
Borrow an optional wake target after checking all four actual IRQs.
备注
No implicit OS policy; NULL detaches. Wake is only a hint. The sink must support both task service/cancel and configurable IRQ contexts.
- 参数:
port – [in] Serialized task owner, started and masks clear.
wake – [in] Immutable target kept alive until successful stop/detach.
syscall_ceiling – [in] Additional numerical BASEPRI ceiling.
- 返回:
Success, BUSY while an earlier publisher is live, PERMISSION, INVALID or CONTEXT, with no new borrow on failure.
-
struct nx_can_frame_t¶
- #include <can.h>
Classic 2.0A/B value frame; DLC is always 0..8, never CAN FD.
Public Members
-
uint32_t id¶
-
nx_can_format_t format¶
-
nx_can_frame_kind_t kind¶
-
uint8_t dlc¶
-
uint8_t data[8]¶
-
uint32_t id¶
-
struct nx_can_tx_request_t¶
- #include <can.h>
Caller-owned frame copied at prepare; base must first be initialized.
-
struct nx_can_event_t¶
- #include <can.h>
Value receive fact or ordered loss boundary.
备注
Timestamp is IRQ acquisition/report time, not hardware SOF. Hardware overrun proves only a lower bound. Raw DLC 9..15 is normalized to 8.
Public Members
-
nx_can_frame_t frame¶
-
nx_time_us_t timestamp_us¶
-
uint64_t lost¶
-
uint32_t flags¶
-
nx_can_event_kind_t kind¶
-
uint8_t fifo¶
-
uint8_t filter¶
-
uint8_t raw_dlc¶
-
nx_can_frame_t frame¶
-
struct nx_can_state_t¶
- #include <can.h>
Latched controller state, independent of receive-ring fullness.
-
struct nx_can_ops_t¶
- #include <can.h>
Shared immutable operations; execution owner serializes task methods.
Public Members
-
nx_result_t (*submit)(void*, nx_can_tx_request_t*)¶
-
nx_result_t (*cancel)(void*, nx_can_tx_request_t*)¶
-
nx_result_t (*service)(void*)¶
-
nx_result_t (*read_events)(void*, nx_can_event_t*, size_t, size_t*)¶
-
nx_result_t (*state)(void*, nx_can_state_t*)¶
-
nx_result_t (*stop)(void*)¶
-
nx_result_t (*recover)(void*)¶
-
nx_result_t (*attach_wake)(void*, const nx_irq_wake_t*, uint8_t)¶
-
nx_result_t (*submit)(void*, nx_can_tx_request_t*)¶
dma.h¶
Explicit DMA memory domains, physical streams and drain facts.
- Author
Nexus Team
Enums
Functions
-
nx_result_t nx_dma_buffer_validate(const nx_dma_memory_region_t *regions, size_t count, const void *data, size_t length, size_t alignment, nx_dma_direction_t direction)¶
Validate an entire buffer within one explicit memory domain.
备注
Bounded task/IRQ check, no MMIO, allocation or side effects.
- 参数:
regions – [in] Immutable SoC domains kept alive for this call.
count – [in] Positive number of domains.
data – [in] Nonempty caller buffer; never borrowed by this helper.
length – [in] Positive byte length, including all DMA accesses.
alignment – [in] Nonzero power-of-two transfer alignment.
direction – [in] Device reads or writes the supplied memory.
- 返回:
Success, INVALID for malformed ranges/alignment or PERMISSION for a range outside the required DMA domain.
-
nx_result_t nx_dma_resources_validate(const nx_dma_resource_t *resources, size_t count)¶
Reject duplicate physical streams in an assembled resource set.
备注
Cold conflict check; the selected SoC must validate all identities against its actual topology before using them. This helper does not infer silicon support or allocate.
- 参数:
resources – [in] Immutable resource list, not retained.
count – [in] Resource count; zero allows a NULL list.
- 返回:
Success, INVALID for a NULL nonempty list or reserved zero controller, BUSY for a duplicate physical engine.
-
nx_result_t nx_dma_drain_check(const nx_dma_drain_facts_t *facts)¶
Require engine, IRQ and peripheral drain independently.
备注
The provider must observe actual registers and ordering before setting these facts. This helper does not stop hardware.
- 参数:
facts – [in] Provider observations; not retained.
- 返回:
Success only when all sources are detached and idle, BUSY while any source remains, INVALID for impossible counters.
-
struct nx_dma_memory_region_t¶
- #include <dma.h>
Reviewed DMA-visible memory interval, never CPU accessibility.
备注
begin plus size must not wrap. Cache maintenance remains a provider responsibility on cached architectures.
ethernet.h¶
Caller-owned untagged Ethernet II frames and receive loans.
- Author
Nexus Team
Defines
-
NX_ETH_FRAME_MIN¶
-
NX_ETH_FRAME_MAX¶
-
NX_ETH_RX_STORAGE_MIN¶
-
NX_ETH_RX_CRC¶
-
NX_ETH_RX_LENGTH¶
-
NX_ETH_RX_FRAGMENT¶
-
NX_ETH_RX_UNSUPPORTED¶
-
NX_ETH_RX_DMA_ERROR¶
-
NX_ETH_RX_BACKPRESSURE¶
Functions
-
nx_result_t nx_eth_tx_prepare(nx_eth_tx_request_t *request, const void *data, size_t length, nx_time_us_t deadline)¶
Prepare an initialized, unborrowed request and its immutable frame.
备注
Task owner. Ethernet II only, 14..1514 bytes excluding FCS; no VLAN or length-coded 802.3. Failure changes no request or payload.
- 参数:
request – [inout] Initialized READY or consumed SETTLED storage.
data – [in] Immutable contiguous Ethernet II frame.
length – [in] Bytes excluding FCS, from 14 through 1514.
deadline – [in] Absolute provider-clock deadline or NEVER.
- 返回:
Success, INVALID for frame/overlap, STATE while borrowed.
-
nx_result_t nx_eth_port_submit(const nx_eth_port_t *port, nx_eth_tx_request_t *request)¶
Admit one frame into caller-owned hardware descriptors.
备注
Privileged serialized task, masks clear. SUCCESS is ACCEPTED. Borrow includes request and frame until acquire-observed SETTLED. Completion reports MAC wire status, never delivery to another application.
- 参数:
port – [in] Stable face and live private assembly.
request – [inout] Prepared storage borrowed on acceptance.
- 返回:
Success means ACCEPTED; BUSY/STATE/IO/invalid inputs reject.
-
nx_result_t nx_eth_port_cancel(const nx_eth_port_t *port, nx_eth_tx_request_t *request)¶
Close TX admission and drain the shared TX engine without replay.
备注
Task owner. Cancel is controller-wide: other pending TX requests also become CANCELLED. It never revokes a borrow. Stuck sources quarantine. Apply a confirmed link again after successful drain to reopen TX.
- 参数:
port – [in] Serialized task-owner face.
request – [inout] Live request accepted by this instance.
- 返回:
Success requests drain; STATE for a foreign request.
-
nx_result_t nx_eth_port_service(const nx_eth_port_t *port)¶
Task-owner bounded progress; no worker, lock, pool or wait.
- 参数:
port – [in] Serialized task-owner face and live storage.
- 返回:
Success, STATE before startup, or invalid context/input.
-
nx_result_t nx_eth_port_acquire(const nx_eth_port_t *port, nx_eth_rx_frame_t *frame)¶
Task-consumer complete-frame loan; EMPTY creates no borrow.
- 参数:
port – [in] Stable started instance and one consumer.
frame – [out] Exact immutable frame loan, not output storage borrow.
- 返回:
Success, EMPTY without a loan, or invalid state/context.
-
nx_result_t nx_eth_port_release(const nx_eth_port_t *port, const nx_eth_rx_frame_t *frame)¶
Final consumer access; stale, foreign and double releases reject.
备注
A held descriptor is never rearmed, even at ring wrap or stop.
- 参数:
port – [in] The same provider identity as acquisition.
frame – [in] Exact acquired token after final consumer access.
- 返回:
Success, STATE for an altered token, or invalid input/context.
-
nx_result_t nx_eth_port_state(const nx_eth_port_t *port, nx_eth_state_t *state)¶
Copy latched instance/link/error facts; output is not retained.
- 参数:
port – [in] Stable private instance.
state – [out] Unretained output, separate from all provider storage.
- 返回:
Success, INVALID for output alias, or CONTEXT.
-
nx_result_t nx_eth_port_apply_link(const nx_eth_port_t *port, const nx_eth_link_t *link)¶
Apply external PHY observations, not auto-negotiate or invent link.
备注
Task owner; changing speed/duplex first requires explicit link-down and observed idle TX/RX engines and FIFOs. BUSY keeps the old mode. Reapplying an unchanged up fact is idempotent. Link-down closes admission and drains pending TX with IO; later up requires real quiescence. This is not a PHY power/reset/electrical proof.
- 参数:
port – [in] Serialized task-owner face.
link – [in] Observed up/speed/duplex fact, never a guess.
- 返回:
Success, BUSY until real drain, or STATE/IO/context error.
-
nx_result_t nx_eth_port_stop(const nx_eth_port_t *port)¶
Close admission and withdraw MAC/DMA/IRQ sources with readback.
备注
Task owner. Closing rejects new RX loans; existing loans still release. BUSY retains hardware/storage/wake ownership; timeout quarantines pending TX. Held RX loans remain valid and must be released before SUCCESS. Caller joins IRQ/consumers before reclaiming storage.
- 参数:
port – [in] Live face and all storage, including held loans.
- 返回:
Success releases sources; BUSY/IO retain remaining ownership.
-
nx_result_t nx_eth_port_attach_wake(const nx_eth_port_t *port, const nx_irq_wake_t *wake, uint8_t syscall_ceiling)¶
Bind an optional borrowed hint after actual IRQ-policy validation.
备注
Task owner with no pending TX; notify is bounded and legal in IRQ. Service does not invoke the IRQ hint from a task. Detach after stop.
- 参数:
port – [in] Started serialized task-owner face.
wake – [in] Borrowed IRQ hint; NULL requests detach.
syscall_ceiling – [in] Exact configured unshifted syscall ceiling.
- 返回:
Success, BUSY while publishers live, or policy/context error.
-
struct nx_eth_tx_request_t¶
- #include <ethernet.h>
Caller-owned immutable contiguous frame, excluding its hardware FCS.
-
struct nx_eth_link_t¶
- #include <ethernet.h>
Observed PHY fact, supplied explicitly by the external link owner.
-
struct nx_eth_rx_frame_t¶
- #include <ethernet.h>
Complete immutable frame; release requires this exact incarnation.
备注
data excludes FCS; storage stays live until matching release. Copying a token does not create a second loan. Timestamp is acquisition, not SOF.
-
struct nx_eth_state_t¶
- #include <ethernet.h>
Latched facts survive receive backpressure and failed wake hints.
-
struct nx_eth_ops_t¶
- #include <ethernet.h>
Public Members
-
nx_result_t (*submit)(void*, nx_eth_tx_request_t*)¶
-
nx_result_t (*cancel)(void*, nx_eth_tx_request_t*)¶
-
nx_result_t (*service)(void*)¶
-
nx_result_t (*acquire)(void*, nx_eth_rx_frame_t*)¶
-
nx_result_t (*release)(void*, const nx_eth_rx_frame_t*)¶
-
nx_result_t (*state)(void*, nx_eth_state_t*)¶
-
nx_result_t (*apply_link)(void*, const nx_eth_link_t*)¶
-
nx_result_t (*stop)(void*)¶
-
nx_result_t (*attach_wake)(void*, const nx_irq_wake_t*, uint8_t)¶
-
nx_result_t (*submit)(void*, nx_eth_tx_request_t*)¶
-
struct nx_eth_port_t¶
- #include <ethernet.h>
exti.h¶
Static EXTI line bindings, bounded event storage and drain.
- Author
Nexus Team
Typedefs
-
typedef struct nx_exti_port nx_exti_port_t¶
Enums
Functions
-
nx_result_t nx_exti_port_read(const nx_exti_port_t *port, nx_exti_event_t *events, size_t capacity, size_t *count)¶
Read queued EXTI events from an exact static line binding.
- 参数:
port – [inout] One consumer; bounded configured IRQ-producer storage.
events – [out] Caller destination, never retained.
capacity – [in] Destination event count.
count – [out] Copied events; loss is observable via event flags.
- 返回:
Success, EMPTY or INVALID. No debounce policy or callbacks.
-
nx_result_t nx_exti_port_stop(const nx_exti_port_t *port)¶
Disable the line source, clear pending and drain its handler.
备注
Failed withdrawal may already have disabled part of the source. Retry and observe success before reclaiming event or wake storage. Face and state remain live while a shared dispatch domain still refers to them.
- 参数:
port – [inout] Execution owner; consumer/writers must quiesce first.
- 返回:
Success proves no remaining accesses to event storage; BUSY or IO retains storage, wake targets and cleanup responsibility. Shared vectors preserve other lines.
-
nx_result_t nx_exti_port_attach_wake(const nx_exti_port_t *port, const nx_irq_wake_t *wake, uint8_t syscall_ceiling)¶
Attach or detach an explicit event/loss IRQ wake target.
备注
Actual shared-vector priority must satisfy the target. Stop and join publishers before freeing old target storage. Wake callbacks observe already-latched event or loss facts.
- 参数:
port – [in] Initialized line, controlled by one task executor.
wake – [in] Immutable live target, or NULL to detach.
syscall_ceiling – [in] Optional additional unshifted kernel-safe priority floor; cannot weaken generated policy. PRIMASK kernel targets require zero. Ignored without kernel calls.
- 返回:
Success or CONTEXT/STATE/PERMISSION/UNSUPPORTED.
-
struct nx_exti_event_t¶
- #include <exti.h>
Edge facts; timestamp precision and coalescing are provider-specific.
备注
LOSS is an independent boundary after older buffered facts and before later facts. Its edge is invalid; its timestamp is detection/report time, never a reconstructed missing edge. For COALESCED facts, edge may derive from sampled pin level after an IRQ and does not represent complete edge history.
-
struct nx_exti_ops_t¶
- #include <exti.h>
Shared read-only methods using one provider state.
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
Public Members
-
nx_result_t (*read)(void *context, nx_exti_event_t *events, size_t capacity, size_t *count)¶
-
nx_result_t (*stop)(void *context)¶
-
nx_result_t (*attach_wake)(void *context, const nx_irq_wake_t *wake, uint8_t syscall_ceiling)¶
-
nx_result_t (*read)(void *context, nx_exti_event_t *events, size_t capacity, size_t *count)¶
flash.h¶
Full physical Flash geometry and explicit bounded regions.
- Author
Nexus Team
Typedefs
-
typedef struct nx_flash_port nx_flash_port_t¶
Functions
-
const nx_flash_geometry_t *nx_flash_port_geometry(const nx_flash_port_t *port)¶
Query exact physical Flash geometry without side effects.
- 参数:
port – [in] Selected exact-density physical Flash provider.
- 返回:
Immutable geometry, or NULL for invalid port.
-
nx_result_t nx_flash_port_read(const nx_flash_port_t *port, uint32_t offset, void *data, size_t length)¶
Read bounded physical Flash without retaining destination.
- 参数:
port – [in] Fixed provider; no concurrent erase/program.
offset – [in] Physical relative offset.
data – [out] Destination not retained beyond return.
length – [in] Byte count; zero permitted with NULL data.
- 返回:
Success or INVALID; no access on rejected range/overflow.
-
nx_result_t nx_flash_port_program(const nx_flash_port_t *port, uint32_t offset, const void *data, size_t length, nx_time_us_t deadline)¶
Program aligned physical Flash and settle all hardware pulses.
备注
Task-only CPU-active operation. Product owns execution-from- Flash stall, watchdog and power-loss policy. No RAM fake on MCU.
- 参数:
port – [inout] Single execution owner with valid voltage/clock policy.
offset – [in] Program-unit aligned physical offset.
data – [in] Aligned-length input retained only until return.
length – [in] Positive program-unit multiple.
deadline – [in] Absolute deadline checked between hardware pulses.
- 返回:
Success or INVALID/TIMEOUT/IO. Return proves no remaining buffer/hardware access; an active pulse cannot be preempted.
-
nx_result_t nx_flash_port_erase(const nx_flash_port_t *port, uint32_t offset, size_t length, nx_time_us_t deadline)¶
Erase a whole physical sector range with pulse settlement.
- 参数:
port – [inout] Single execution owner.
offset – [in] Exact sector-start physical offset.
length – [in] Positive sum of whole sectors.
deadline – [in] Absolute deadline checked between erase pulses.
- 返回:
Success or INVALID/TIMEOUT/IO; partial erase is possible on timeout/error. Return waits for current pulse to become idle.
-
nx_result_t nx_flash_region_validate(const nx_flash_region_t *region)¶
Validate region bounds against physical geometry.
- 参数:
region – [in] Explicit caller-owned region description.
- 返回:
Success or INVALID; erase geometry is checked per operation.
-
nx_result_t nx_flash_region_read(const nx_flash_region_t *region, uint32_t offset, void *data, size_t length)¶
Read within an explicit physical region.
- 参数:
region – [in] Valid region.
offset – [in] Region-relative byte offset.
data – [out] Destination buffer.
length – [in] Byte count.
- 返回:
Success or INVALID without access outside the region.
-
nx_result_t nx_flash_region_program(const nx_flash_region_t *region, uint32_t offset, const void *data, size_t length, nx_time_us_t deadline)¶
Program within an explicitly writable physical region.
- 参数:
region – [in] Valid writable region.
offset – [in] Region-relative aligned offset.
data – [in] Input buffer; borrowed until return only.
length – [in] Aligned positive length.
deadline – [in] Absolute pulse deadline.
- 返回:
Success, INVALID/PERMISSION or underlying pulse result.
-
nx_result_t nx_flash_region_erase(const nx_flash_region_t *region, uint32_t offset, size_t length, nx_time_us_t deadline)¶
Erase whole physical sectors within a writable region.
- 参数:
region – [in] Explicit valid writable region.
offset – [in] Region-relative sector boundary.
length – [in] Sum of whole sector lengths.
deadline – [in] Absolute pulse deadline.
- 返回:
Success, INVALID/PERMISSION or underlying pulse result.
-
struct nx_flash_sector_t¶
- #include <flash.h>
Erase sector geometry, with offset relative to full physical Flash.
-
struct nx_flash_geometry_t¶
- #include <flash.h>
Read-only physical geometry; platform reserves no product storage.
-
struct nx_flash_region_t¶
- #include <flash.h>
Explicit consumer-selected bounds; no implicit product partition.
-
struct nx_flash_ops_t¶
- #include <flash.h>
Shared read-only methods using one provider state.
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
Public Members
-
const nx_flash_geometry_t *(*geometry)(const void *context)¶
-
nx_result_t (*read)(const void *context, uint32_t offset, void *data, size_t length)¶
-
nx_result_t (*program)(void *context, uint32_t offset, const void *data, size_t length, nx_time_us_t deadline)¶
-
nx_result_t (*erase)(void *context, uint32_t offset, size_t length, nx_time_us_t deadline)¶
-
const nx_flash_geometry_t *(*geometry)(const void *context)¶
gpio.h¶
Fixed GPIO authorization masks and bounded port operations.
- Author
Nexus Team
Typedefs
-
typedef struct nx_gpio_port nx_gpio_port_t¶
Functions
-
nx_result_t nx_gpio_port_write(const nx_gpio_port_t *port, uint32_t set_mask, uint32_t reset_mask)¶
Atomically set/reset one port’s authorized output mask.
备注
Task/IRQ bounded, no wait. One serialized writer owns the binding. Stop/mode changes require writers and IRQ quiescence.
- 参数:
port – [in] Fixed initialized binding, no registry or OS lock.
set_mask – [in] Authorized bits to set.
reset_mask – [in] Authorized bits to reset; disjoint from set_mask.
- 返回:
NX_SUCCESS or INVALID/PERMISSION before any register write.
-
nx_result_t nx_gpio_port_read(const nx_gpio_port_t *port, uint32_t *value)¶
Read one input snapshot restricted to the binding mask.
- 参数:
port – [in] Fixed initialized binding.
value – [out] Masked input snapshot; unchanged on error.
- 返回:
NX_SUCCESS or NX_ERROR_INVALID. No cross-port simultaneity.
-
nx_result_t nx_gpio_port_toggle(const nx_gpio_port_t *port, uint32_t mask)¶
Toggle authorized outputs under the single-writer contract.
备注
Read-modify-write is not atomic against unrelated writes.
- 参数:
port – [in] Fixed output binding with a serialized writer.
mask – [in] Authorized subset to toggle.
- 返回:
NX_SUCCESS or INVALID/PERMISSION before register writes.
-
struct nx_gpio_ops_t¶
- #include <gpio.h>
Shared read-only methods using one provider state.
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
Public Members
-
nx_result_t (*write)(void *context, uint32_t set_mask, uint32_t reset_mask)¶
-
nx_result_t (*read)(const void *context, uint32_t *value)¶
-
nx_result_t (*toggle)(void *context, uint32_t mask)¶
-
nx_result_t (*write)(void *context, uint32_t set_mask, uint32_t reset_mask)¶
i2c.h¶
Address endpoints, repeated START and explicit STOP settlement.
- Author
Nexus Team
Defines
-
NX_I2C_MAX_MESSAGES¶
Maintained finite-message admission bounds, checked before hardware access.
-
NX_I2C_MAX_MESSAGE_BYTES¶
Typedefs
-
typedef struct nx_i2c_port nx_i2c_port_t¶
-
typedef struct nx_i2c_endpoint nx_i2c_endpoint_t¶
Functions
-
nx_result_t nx_i2c_endpoint_transaction(const nx_i2c_endpoint_t *endpoint, nx_i2c_message_t *messages, size_t count, nx_time_us_t deadline, size_t *transferred)¶
Execute a polling 7-bit-address message transaction.
备注
Task-only, one executor. No hidden scan or GPIO recovery. Failed bus recovery is never reported as transfer success.
- 参数:
endpoint – [in] Fixed address/controller binding.
messages – [inout] Message buffers; write data are not modified.
count – [in] One through NX_I2C_MAX_MESSAGES.
deadline – [in] Finite absolute provider-clock deadline.
transferred – [out] Completed byte prefix across messages, including error returns.
- 返回:
Success or INVALID/UNSUPPORTED/CONTEXT/STATE/BUSY/TIMEOUT/ NACK/ARBITRATION/IO. Each message has 1..NX_I2C_MAX_MESSAGE_BYTES bytes; any message may read or write. Return releases buffers after STOP/abort drain. Controller settlement does not establish bus recovery.
-
nx_result_t nx_i2c_port_recover(const nx_i2c_port_t *port)¶
Recover an idle controller after a bus fault.
- 参数:
port – [inout] Single executor, no live transaction/buffer borrow.
- 返回:
Success only when hardware bus idle is observed; otherwise BUSY/IO/UNSUPPORTED. Does not replay a failed transaction.
-
nx_result_t nx_i2c_request_prepare(nx_i2c_request_t *request, nx_i2c_message_t *messages, size_t count, nx_time_us_t deadline)¶
Prepare an unborrowed request without copying payload.
备注
Payloads cannot overlap control storage, nor a read span overlap an immutable write span. Limits match polling.
- 参数:
request – [inout] Initialized READY or consumed SETTLED storage
messages – [inout] One through eight complete descriptors
count – [in] Exact descriptor count
deadline – [in] Absolute provider-clock deadline
- 返回:
SUCCESS, INVALID, UNSUPPORTED or STATE; no new loan
-
nx_result_t nx_i2c_request_validate(const nx_i2c_request_t *request)¶
Validate finite descriptors and payload/control separation.
备注
Bounded cold check. Provider separately validates state, context and DMA domains before acquiring any loan.
- 参数:
request – [in] Complete caller-owned request, not retained
- 返回:
SUCCESS, INVALID or UNSUPPORTED without mutation
-
nx_result_t nx_i2c_endpoint_submit(const nx_i2c_endpoint_t *endpoint, nx_i2c_request_t *request)¶
Admit one finite asynchronous repeated-START transaction.
备注
Selected modes declare DMA domains. DMA completion alone never establishes wire/STOP drain or borrow release. Any admitted abort requires explicit local recover before reuse; recovery never replays or pulses Board GPIO lines.
- 参数:
endpoint – [in] Initialized fixed address and single executor
request – [inout] READY descriptor and all referenced storage
- 返回:
SUCCESS means ACCEPTED; rejection retains no references
-
nx_result_t nx_i2c_endpoint_start_admitted(const nx_i2c_endpoint_t *endpoint, nx_i2c_request_t *request)¶
Start an already borrowed QUEUED request without readmission.
备注
Other errors require adapter settlement; no polling fallback.
- 参数:
endpoint – [in] Fixed address on the adapter’s exact controller
request – [inout] Adapter-admitted QUEUED storage
- 返回:
SUCCESS hands execution to provider; BUSY retains QUEUED
-
bool nx_i2c_endpoint_on_port(const nx_i2c_endpoint_t *endpoint, const nx_i2c_port_t *port)¶
Prove controller identity without hardware effects.
- 参数:
endpoint – [in] Immutable addressed child
port – [in] Exact execution controller
- 返回:
True only for matching provider state and compatible methods
-
nx_result_t nx_i2c_port_cancel(const nx_i2c_port_t *port, nx_i2c_request_t *request)¶
Request cancellation without reclaiming any storage.
- 参数:
port – [in] Same single executor as submit/service
request – [inout] Exact active descriptor, never a stale raw pointer
- 返回:
SUCCESS begins drain; STATE for another request
-
void nx_i2c_port_service(const nx_i2c_port_t *port)¶
Advance deadline and STOP/DMA drain in bounded task context.
备注
Final publication follows source detach and local wire idle. Drain failure quarantines all storage. This invokes no payload completion callback and never automatically replays.
- 参数:
port – [in] Live single executor, serviced throughout stop
-
nx_result_t nx_i2c_port_stop(const nx_i2c_port_t *port)¶
Close admission and stop only after every borrower drains.
- 参数:
port – [in] Controller with external producers quiesced
- 返回:
SUCCESS releases sources; BUSY requires continued service
-
nx_result_t nx_i2c_port_attach_wake(const nx_i2c_port_t *port, const nx_irq_wake_t *wake, uint8_t syscall_ceiling)¶
Attach one optional hint sink after actual IRQ policy checks.
备注
Task-only. Sink remains alive until successful stop/detach.
- 参数:
port – [in] Initialized asynchronous controller
wake – [in] Borrowed sink or NULL to detach after publisher exit
syscall_ceiling – [in] Cannot weaken selected kernel policy
- 返回:
SUCCESS or rejection before replacing any live binding
-
struct nx_i2c_message_t¶
- #include <i2c.h>
One message; a new message starts with repeated START, final with STOP.
-
struct nx_i2c_request_t¶
- #include <i2c.h>
Caller-owned finite message sequence.
备注
Descriptors and payloads remain borrowed until SETTLED. Writes stay immutable; reads receive into caller storage. Cancellation, deadlines and quarantine never revoke loans.
-
struct nx_i2c_ops_t¶
- #include <i2c.h>
Shared read-only methods using one provider state.
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
Public Members
-
nx_result_t (*recover)(void *context)¶
-
nx_result_t (*cancel)(void *context, nx_i2c_request_t *request)¶
-
void (*service)(void *context)¶
-
nx_result_t (*stop)(void *context)¶
-
nx_result_t (*attach_wake)(void *context, const nx_irq_wake_t *wake, uint8_t syscall_ceiling)¶
-
nx_result_t (*recover)(void *context)¶
-
struct nx_i2c_port¶
- #include <i2c.h>
Immutable interface pointing to caller-owned state.
备注
Face and state outlive callers, IRQs and retained borrows. Factory lookup neither initializes nor acquires hardware.
-
struct nx_i2c_endpoint_ops_t¶
- #include <i2c.h>
Shared read-only methods using one provider state.
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
Public Members
-
nx_result_t (*transaction)(void *context, nx_i2c_message_t *messages, size_t count, nx_time_us_t deadline, size_t *transferred)¶
-
nx_result_t (*submit)(void *context, nx_i2c_request_t *request)¶
-
nx_result_t (*start_admitted)(void *context, nx_i2c_request_t *request)¶
-
bool (*on_port)(const void *context, const nx_i2c_port_t *port)¶
-
nx_result_t (*transaction)(void *context, nx_i2c_message_t *messages, size_t count, nx_time_us_t deadline, size_t *transferred)¶
i2c_bus_clear.h¶
Explicit open-drain I2C bus clear with retained leases.
- Author
Nexus Team
Defines
-
NX_I2C_BUS_CLEAR_MAX_PULSES¶
Maximum completed recovery low/high periods per attempt.
Functions
-
nx_result_t nx_i2c_bus_clear_init(nx_i2c_bus_clear_t *clear, nx_i2c_bus_clear_port_t port, nx_clock_t clock, nx_i2c_bus_clear_timing_t timing)¶
Bind explicit electrical operations without touching pins.
- 参数:
clear – [inout] Fresh zeroed session or a session with no lease.
port – [in] All five methods required; caller verifies electrical authorization rather than relying on generic GPIO APIs.
clock – [in] Required bounded monotonic read in one boot domain.
timing – [in] Reviewed nonzero low/high/STOP/poll durations.
- 返回:
SUCCESS, INVALID or BUSY for a retained lease. Rejection leaves the session and external resources unchanged.
-
nx_result_t nx_i2c_bus_clear_run(nx_i2c_bus_clear_t *clear, nx_time_us_t deadline, nx_time_us_t cleanup_deadline, nx_i2c_bus_clear_result_t *result)¶
Clear one idle, authorized bus with at most nine pulses.
备注
Task-only, all other bus users quiescent. Timing evidence and actual open-drain behavior require physical HIL.
- 参数:
clear – [inout] Initialized session with no retained lease.
deadline – [in] Finite absolute primary-operation deadline.
cleanup_deadline – [in] Finite absolute STOP/lease deadline in the same clock domain, at or after deadline.
result – [out] Independent primary/cleanup and retained effects.
- 返回:
Primary failure, otherwise cleanup result. Invalid inputs and an existing lease reject without callbacks or changing result. An expired primary deadline has no pin effects. Each released SCL must be physically HIGH before timing its high period. A frozen/reversed clock reports IO and exits rather than spinning. Every acquired attempt performs explicit STOP cleanup under its independent budget; failed STOP or release method retains the lease. If release succeeds after its deadline, cleanup reports TIMEOUT with lease_held false to preserve actual returned ownership. It never replays the failed I2C transaction or retries recovery pulses.
-
nx_result_t nx_i2c_bus_clear_finish(nx_i2c_bus_clear_t *clear, nx_time_us_t deadline, nx_i2c_bus_clear_result_t *result)¶
Retry only retained STOP cleanup and ownership return.
- 参数:
clear – [inout] Initialized session with a retained lease.
deadline – [in] New finite absolute cleanup deadline.
result – [out] Preserved primary/pulse count and latest cleanup.
- 返回:
Latest cleanup result; INVALID/STATE rejects without effects. A proved STOP is not repeated after release fails. Failure retains the lease and must not trigger a new clear or transaction. Success does not change a failed primary operation into success.
-
struct nx_i2c_bus_clear_ops_t¶
- #include <i2c_bus_clear.h>
Read-only methods for an authorized two-pin GPIO handoff.
备注
Task-only, one executor. acquire is a bounded, nonblocking handoff: success proves the controller, DMA, IRQs, other masters and pin users quiescent, both physical pins exclusively leased in reviewed open-drain GPIO mode, with both lines released. Failure retains no lease or effects. drive only sinks LOW or releases a pin; false never means drive HIGH. When scl_low is true, drive establishes SCL LOW before changing SDA, including a retry from unknown previous pin state. sample reads physical levels, not output latches. Methods are bounded and preserve the lease on errors. release restores the saved peripheral/pin ownership only on success; failure retains all lease/storage responsibility. wait_until uses the injected clock’s finite absolute domain and reaches target or reports an error within a caller- proved finite bound, even if the clock stops. Late waits cannot qualify an expired operation. No callback may recursively operate on this session or run a transaction. The adapter must verify reviewed open-drain, pull-up, voltage and two-pin authorization facts before acquire.
Public Members
-
nx_result_t (*acquire)(void *context)¶
-
nx_result_t (*drive)(void *context, bool scl_low, bool sda_low)¶
-
nx_result_t (*sample)(void *context, bool *scl_high, bool *sda_high)¶
-
nx_result_t (*wait_until)(void *context, nx_time_us_t target)¶
-
nx_result_t (*release)(void *context)¶
-
nx_result_t (*acquire)(void *context)¶
-
struct nx_i2c_bus_clear_port_t¶
- #include <i2c_bus_clear.h>
Explicit immutable GPIO methods and caller-owned adapter state.
-
struct nx_i2c_bus_clear_timing_t¶
- #include <i2c_bus_clear.h>
Caller-selected electrical timings in microseconds.
备注
All fields are nonzero. low/high bound each clear pulse; stop_setup bounds the observed SCL-high to SDA-release interval. stretch_poll bounds the interval between actual SCL samples. Values need board/device electrical review; the mechanism supplies no universal safe defaults.
-
struct nx_i2c_bus_clear_result_t¶
- #include <i2c_bus_clear.h>
Independent recovery and STOP/ownership-return results.
备注
pulses counts completed recovery low/high periods, not the STOP preparation edge. stop_observed proves the requested STOP sequence ended with both sampled lines HIGH. lease_held means the adapter, session and context must remain alive and no controller transaction may start. A cleanup failure never replaces the primary failure.
Public Members
-
nx_result_t primary¶
-
nx_result_t cleanup¶
-
uint8_t pulses¶
-
bool stop_observed¶
-
bool lease_held¶
-
nx_result_t primary¶
-
struct nx_i2c_bus_clear_t¶
- #include <i2c_bus_clear.h>
Caller-owned, zero-initialized single-executor session.
备注
Public fields are mechanism storage, not caller controls. Methods, context and clock outlive every retained lease. No allocation, worker, lock, transaction buffer or hidden retry exists. Abandoning a retained lease requires explicit product quarantine/reset responsibility.
Public Members
-
nx_clock_t clock¶
-
nx_i2c_bus_clear_timing_t timing¶
-
nx_i2c_bus_clear_result_t result¶
-
nx_time_us_t last_time¶
-
bool clock_observed¶
-
bool initialized¶
-
nx_clock_t clock¶
mdio.h¶
Narrow Clause22 station management with absolute deadlines.
- Author
Nexus Team
Functions
-
nx_result_t nx_mdio_read(const nx_mdio_port_t *port, uint8_t address, uint8_t reg, uint16_t *value, nx_time_us_t deadline)¶
Read one Clause22 PHY register without retaining output storage.
备注
Serialized privileged task, incoming masks clear; finite absolute deadline in the provider clock. Address and register are 0..31. BUSY rejects before new MMIO effects; timeout does not pretend busy cleared.
- 参数:
port – [in] Stable face and caller-owned execution context.
address – [in] Clause22 PHY address, from 0 through 31.
reg – [in] Clause22 register address, from 0 through 31.
value – [out] Written only after timely observed completion.
deadline – [in] Finite absolute provider-clock deadline.
- 返回:
Success, BUSY without a new command, or timeout/input/context error.
-
nx_result_t nx_mdio_write(const nx_mdio_port_t *port, uint8_t address, uint8_t reg, uint16_t value, nx_time_us_t deadline)¶
Write one Clause22 PHY register, not a PHY-specific policy sequence.
备注
Same task/deadline rules as read. No IRQ-masked busy wait or fallback.
- 参数:
port – [in] Stable face and caller-owned execution context.
address – [in] Clause22 PHY address, from 0 through 31.
reg – [in] Clause22 register address, from 0 through 31.
value – [in] Exact 16-bit register value.
deadline – [in] Finite absolute provider-clock deadline.
- 返回:
Success, BUSY without a new command, or timeout/input/context error.
-
struct nx_mdio_ops_t¶
- #include <mdio.h>
Public Members
-
nx_result_t (*read)(void*, uint8_t, uint8_t, uint16_t*, nx_time_us_t)¶
-
nx_result_t (*write)(void*, uint8_t, uint8_t, uint16_t, nx_time_us_t)¶
-
nx_result_t (*read)(void*, uint8_t, uint8_t, uint16_t*, nx_time_us_t)¶
model.h¶
Explicit host-model fixtures; no physical MCU qualification.
- Author
Nexus Team
Functions
-
nx_result_t nx_native_clock_configure(bool enabled, nx_time_us_t now)¶
Switch host model to a deterministic clock domain.
- 参数:
enabled – [in] True selects manual clock, false real monotonic.
now – [in] Initial manual microsecond value, below UINT64_MAX.
- 返回:
Success or INVALID. Caller must first settle every request; switching creates a new domain and invalidates old deadlines.
-
nx_result_t nx_native_clock_advance(uint64_t duration_us)¶
Advance deterministic time without an implicit hardware IRQ.
- 参数:
duration_us – [in] Positive or zero microsecond increment.
- 返回:
Success, STATE outside manual mode or EXHAUSTED on overflow.
-
nx_result_t nx_native_gpio_configure(uint32_t mask, uint32_t initial)¶
Configure the fixed GPIO model after writer quiescence.
- 参数:
mask – [in] Authorized input/output bit mask.
initial – [in] Initial output snapshot within mask.
- 返回:
Success or INVALID; no fake Board/electrical qualification.
-
void nx_native_gpio_input(uint32_t value)¶
Inject one GPIO input snapshot in the deterministic model.
- 参数:
value – [in] Physical-port snapshot; read masks unauthorized bits.
-
uint32_t nx_native_gpio_output(void)¶
Observe output state for a host behavioral assertion.
- 返回:
Model output snapshot; no measured waveform semantics.
-
nx_result_t nx_native_uart_configure(const nx_native_uart_config_t *config)¶
Configure exact RX/TX fixture capacities on the fixed UART.
- 参数:
config – [in] Caller-owned selected-profile storage description.
- 返回:
Success, INVALID or BUSY if an active request remains.
-
nx_result_t nx_native_uart_tx_validate(void *context, const nx_uart_tx_request_t *request)¶
Validate exact Native TX context for selected RS485 binding.
备注
Task-only; no model IRQ, admission, GPIO or state mutation.
- 参数:
context – [in] Configured Native UART face’s exact context.
request – [in] Live READY/QUEUED descriptor, never retained.
- 返回:
Same pure rejectable checks as Native submit/start.
-
nx_result_t nx_native_uart_model_irq_configure(const nx_uart_port_t *binding, const nx_irq_policy_t *policy, const nx_irq_source_t *source)¶
Copy explicit IRQ facts into a quiescent host UART model.
备注
Task-only cold configuration; caller has stopped publishers. No active request, stream or attached wake may remain. Default preparation explicitly models BASEPRI/four-bit IRQs; this entry can model Baseline without inventing a SoC/Board.
- 参数:
binding – [in] Configured Native UART face with no IRQ users.
policy – [in] Immutable CPU/kernel facts copied during this call.
source – [in] Actual modeled publisher facts copied during call.
- 返回:
Success, INVALID, CONTEXT, STATE or BUSY before side effects.
-
void nx_native_uart_irq_step(void)¶
Execute one deterministic TX IRQ byte/TC event.
备注
No actual hardware IRQ, latency or wire timing is simulated.
-
nx_result_t nx_native_uart_receive(uint8_t byte, uint32_t flags)¶
Inject one RX IRQ fact into bounded selected-profile storage.
- 参数:
byte – [in] Received byte; ignored for NO_BYTE status facts.
flags – [in] NX_UART_EVENT_* error facts; zero for normal reception.
- 返回:
Success, OVERFLOW or STATE if disabled.
-
void nx_native_uart_fault(bool start_failure, bool hold_drain)¶
Configure start failure or inability to prove hardware drain.
- 参数:
start_failure – [in] Fail after direct admission, not as rejection.
hold_drain – [in] Retain QUARANTINED request until explicitly released.
-
size_t nx_native_uart_transmitted(void)¶
Observe captured TX bytes.
- 返回:
Number captured in caller-owned tx_log.
-
nx_result_t nx_native_spi_configure(uint8_t *registers, size_t length)¶
Configure a fixed SPI echo or register-file model.
- 参数:
registers – [inout] Optional caller-owned register bytes; NULL is echo.
length – [in] Register capacity; zero only for echo mode.
- 返回:
Success or INVALID; fixture has one serialized executor.
-
void nx_native_spi_fault(size_t fail_after, bool busy)¶
Inject bounded SPI partial failure or controller occupancy.
- 参数:
fail_after – [in] Byte index to fail at, SIZE_MAX disables fault.
busy – [in] True rejects transactions without CS/buffer access.
-
bool nx_native_spi_cs_active(void)¶
Check the modeled CS level after a transaction.
- 返回:
True while model transaction owns active CS.
-
nx_result_t nx_native_i2c_configure(uint8_t *memory, size_t length, uint8_t address)¶
Configure one 7-bit-address register-file I2C model.
- 参数:
memory – [inout] Caller-owned register bytes retained by fixture.
length – [in] Positive register capacity, at most 256.
address – [in] Valid nonreserved 7-bit address.
- 返回:
Success or INVALID.
-
void nx_native_i2c_fault(nx_result_t result, bool stuck)¶
Inject NACK, arbitration loss or a stuck bus.
- 参数:
result – [in] Success disables fault; NACK/ARBITRATION/IO supported.
stuck – [in] True makes explicit recovery fail until released.
-
nx_result_t nx_native_flash_configure(uint8_t *memory, const nx_flash_geometry_t *geometry)¶
Configure physical-geometry RAM model, clearly nonpersistent.
- 参数:
memory – [inout] Caller-owned geometry-sized bytes; erased to 0xff.
geometry – [in] Caller-owned immutable contiguous sector geometry.
- 返回:
Success or INVALID; no heap, product reserve or persistence.
-
void nx_native_flash_fault(size_t pulse_count)¶
Inject program/erase failure after complete modeled pulses.
- 参数:
pulse_count – [in] Complete pulses allowed; SIZE_MAX disables fault.
-
void nx_native_watchdog_boot(uint32_t causes)¶
Reset the watchdog fixture as a simulated new boot.
备注
Test-only; production IWDG cannot be disabled by this action.
- 参数:
causes – [in] Latched reset cause mask.
-
bool nx_native_watchdog_expired(void)¶
Observe expiration of the enabled deterministic IWDG.
- 返回:
True once its nominal model deadline expires; latches IWDG.
-
nx_result_t nx_native_exti_configure(uint8_t line, nx_exti_edge_t edge, nx_exti_event_t *events, size_t capacity)¶
Configure exact storage for one static EXTI line.
- 参数:
line – [in] Zero through fifteen.
edge – [in] RISING/FALLING/BOTH selection.
events – [inout] Fixture-owned queue storage.
capacity – [in] Positive event capacity.
- 返回:
Success or INVALID; quiesce producer/consumer before reset.
-
nx_result_t nx_native_exti_emit(uint8_t line, nx_exti_edge_t edge)¶
Inject a timestamped selected edge fact.
- 参数:
line – [in] Configured static line.
edge – [in] RISING or FALLING occurrence.
- 返回:
Success, INVALID/STATE/OVERFLOW; loss remains observable.
-
nx_result_t nx_native_pwm_configure(uint32_t tick_hz, uint32_t period_ticks)¶
Configure fixed PWM model timer facts after writer quiescence.
- 参数:
tick_hz – [in] Positive post-prescaler frequency.
period_ticks – [in] Fixed shared-base positive period.
- 返回:
Success or INVALID.
-
nx_result_t nx_native_adc_configure(const uint16_t *samples, size_t count, uint8_t resolution_bits, uint32_t reference_mv)¶
Configure fixed ADC raw-count sequence and format.
- 参数:
samples – [in] Fixture-owned nominal sample sequence.
count – [in] Positive channel count.
resolution_bits – [in] One through sixteen.
reference_mv – [in] Positive nominal reference voltage.
- 返回:
Success or INVALID.
-
void nx_native_adc_fault(size_t sample_count)¶
Inject ADC failure after a prefix of complete samples.
- 参数:
sample_count – [in] Complete samples allowed; SIZE_MAX disables.
-
void nx_native_gpio_model_input(const nx_gpio_port_t *binding, uint32_t value)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
uint32_t nx_native_gpio_model_output(const nx_gpio_port_t *binding)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
nx_result_t nx_native_uart_model_configure(const nx_uart_port_t *binding, const nx_native_uart_config_t *config)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
void nx_native_uart_model_irq_step(const nx_uart_port_t *binding)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
nx_result_t nx_native_uart_model_receive(const nx_uart_port_t *binding, uint8_t byte, uint32_t flags)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
void nx_native_uart_model_fault(const nx_uart_port_t *binding, bool start_failure, bool hold_drain)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
size_t nx_native_uart_model_transmitted(const nx_uart_port_t *binding)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
nx_result_t nx_native_spi_model_configure(const nx_spi_endpoint_t *binding, uint8_t *registers, size_t length)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
void nx_native_spi_model_fault(const nx_spi_port_t *binding, size_t fail_after, bool busy)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
bool nx_native_spi_model_cs_active(const nx_spi_endpoint_t *binding)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
nx_result_t nx_native_i2c_model_configure(const nx_i2c_endpoint_t *binding, uint8_t *memory, size_t length, uint8_t address)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
void nx_native_i2c_model_fault(const nx_i2c_port_t *binding, nx_result_t result, bool stuck)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
nx_result_t nx_native_flash_model_configure(const nx_flash_port_t *binding, uint8_t *memory, const nx_flash_geometry_t *geometry)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
void nx_native_flash_model_fault(const nx_flash_port_t *binding, size_t pulse_count)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
void nx_native_watchdog_model_boot(const nx_watchdog_port_t *binding, uint32_t causes)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
bool nx_native_watchdog_model_expired(const nx_watchdog_port_t *binding)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
nx_result_t nx_native_exti_model_configure(const nx_exti_port_t *binding, uint8_t line, nx_exti_edge_t edge, nx_exti_event_t *events, size_t capacity)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
nx_result_t nx_native_exti_model_emit(const nx_exti_port_t *binding, uint8_t line, nx_exti_edge_t edge)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
nx_result_t nx_native_pwm_model_configure(const nx_pwm_port_t *binding, uint32_t tick_hz, uint32_t period_ticks)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
nx_result_t nx_native_adc_model_configure(const nx_adc_port_t *binding, const uint16_t *samples, size_t count, uint8_t resolution_bits, uint32_t reference_mv)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
void nx_native_adc_model_fault(const nx_adc_port_t *binding, size_t sample_count)¶
Operate on the selected Native model face only.
备注
Null or foreign-provider faces return INVALID for status operations, zero/false for observations, and have no effect for injections. Referenced fixture storage remains owned by the caller; reconfiguration requires writer and IRQ quiescence and never revokes a live UART borrow.
-
void nx_native_spi_model_async_configure(const nx_spi_port_t *binding, bool automatic_irq)¶
Choose explicit or automatic modeled SPI IRQ stepping.
备注
Quiesce the controller first. Automatic service advances at most one byte or a separate final idle fact per call; this does not model physical DMA or wire timing.
-
void nx_native_spi_model_irq_step(const nx_spi_port_t *binding)¶
Inject one bounded SPI byte/idle event on the exact Native bus.
-
void nx_native_spi_model_drain_hold(const nx_spi_port_t *binding, bool hold)¶
Inject inability to prove SPI hardware drain.
备注
Retained requests become QUARANTINED until hold is released and the executor services the bus again. No loan is revoked.
-
nx_result_t nx_native_uart_model_idle(const nx_uart_port_t *binding)¶
Inject UART IDLE and publish its current valid byte prefix.
- 返回:
Success, EMPTY without a prefix, STATE outside a running block stream, BUSY while its modeled writer is active, or INVALID for a foreign provider. No producer loan is revoked.
-
nx_result_t nx_native_adc_model_trigger(const nx_adc_port_t *binding)¶
Inject one ADC timer-trigger scan into a free selected block.
备注
Each success publishes one interleaved raw-count scan; partial failed scans are detached and never published.
- 返回:
Success, OVERFLOW while a required block remains held, IO for a failed scan, STATE after stop, or INVALID for a foreign provider. No hardware cadence or analog accuracy is claimed.
Variables
-
const nx_gpio_port_t *const nx_native_gpio¶
Fixed model bindings; no allocation, lookup, probe or construction.
-
const nx_uart_port_t *const nx_native_uart¶
-
const nx_spi_endpoint_t *const nx_native_spi¶
-
const nx_spi_port_t *const nx_native_spi_port¶
-
const nx_i2c_port_t *const nx_native_i2c_port¶
-
const nx_i2c_endpoint_t *const nx_native_i2c¶
-
const nx_flash_port_t *const nx_native_flash¶
-
const nx_watchdog_port_t *const nx_native_watchdog¶
-
const nx_exti_port_t *const nx_native_exti¶
-
const nx_pwm_port_t *const nx_native_pwm¶
-
const nx_adc_port_t *const nx_native_adc¶
spi.h¶
Single-executor polling SPI endpoints and complete CS transactions.
- Author
Nexus Team
Defines
-
NX_SPI_MEMORY_TX_FIXED¶
Explicit single-cell DMA addresses, both borrowed until SETTLED.
-
NX_SPI_MEMORY_RX_FIXED¶
Typedefs
-
typedef struct nx_spi_port nx_spi_port_t¶
-
typedef struct nx_spi_endpoint nx_spi_endpoint_t¶
Functions
-
nx_result_t nx_spi_endpoint_transfer(const nx_spi_endpoint_t *endpoint, const uint8_t *tx, uint8_t *rx, size_t length, nx_time_us_t deadline, size_t *transferred)¶
Execute one bounded full-duplex 8-bit polling transaction.
备注
Task-only single executor, no allocation/OS lock. One CS interval covers the entire transfer. Deadline cannot preempt an in-flight hardware byte; peripheral drain may exceed it.
- 参数:
endpoint – [in] Fixed CS/mode/rate binding on one controller.
tx – [in] Transmit bytes, or NULL to send 0xff.
rx – [out] Receive bytes, or NULL to discard.
length – [in] Positive transfer length; at least one buffer exists.
deadline – [in] Absolute deadline; includes adapter queue residence.
transferred – [out] Complete bytes; reset to zero before execution.
- 返回:
Success, BUSY/INVALID/TIMEOUT/IO. Return releases all buffers and CS after drain; polling is CPU-active, not IRQ/DMA async.
-
nx_result_t nx_spi_port_recover(const nx_spi_port_t *port)¶
Recover an idle SPI controller after its retained fault.
- 参数:
port – [in] Single executor with no live transaction or CS borrow.
- 返回:
Success only after reset/idle proof; BUSY/STATE/UNSUPPORTED preserves recovery responsibility and never replays work.
-
nx_result_t nx_spi_request_prepare(nx_spi_request_t *request, const uint8_t *tx, uint8_t *rx, size_t length, nx_time_us_t deadline)¶
Prepare an unborrowed finite request without copying buffers.
- 参数:
request – [inout] Fresh initialized or consumed SETTLED descriptor.
tx – [in] Nonempty TX bytes or NULL when the selected mode supports dummy transmission; immutable through final settlement.
rx – [out] RX buffer or NULL when the selected mode supports discard.
length – [in] Positive byte count with at least one supplied buffer.
deadline – [in] Absolute monotonic deadline including queue time.
- 返回:
Success or INVALID/STATE; failure creates no buffer loan.
-
nx_result_t nx_spi_endpoint_submit(const nx_spi_endpoint_t *endpoint, nx_spi_request_t *request)¶
Submit one finite asynchronous whole-CS transaction.
备注
Task-only bounded admission. Selected modes declare DMA domain/length/buffer requirements. DMA TC alone never proves peripheral idle; the bus executor continues service to SETTLED.
- 参数:
endpoint – [in] Initialized endpoint on a single-executor bus.
request – [inout] READY storage; retained only after NX_SUCCESS.
- 返回:
Success means ACCEPTED; all rejection errors create zero retained references and zero residual hardware effects.
-
nx_result_t nx_spi_endpoint_submit_memory(const nx_spi_endpoint_t *endpoint, nx_spi_request_t *request, uint8_t memory_flags)¶
Submit explicit incrementing or single-cell DMA memory.
备注
Fixed directions require one byte, other directions length bytes, within reviewed DMA domains. The actual spans must not overlap. All addresses remain borrowed through drain until acquire-observed SETTLED. No hidden scratch is used. Both fixed flags permit explicit clock-only transfers. Request preparation does not retain these flags; only this successful admission selects them. Ordinary submit and the existing owner continue their ordinary buffer contract.
- 参数:
endpoint – [in] Initialized single-executor DMA endpoint
request – [inout] READY request with two non-NULL caller addresses
memory_flags – [in] TX_FIXED repeats one immutable dummy byte; RX_FIXED repeatedly writes one caller-owned discard byte; zero uses complete incrementing TX/RX buffers
- 返回:
ACCEPTED on SUCCESS; other results retain no references
-
nx_result_t nx_spi_endpoint_start_admitted(const nx_spi_endpoint_t *endpoint, nx_spi_request_t *request)¶
Start an adapter-admitted QUEUED request without readmission.
- 参数:
endpoint – [in] Initialized exact CS binding and bus executor.
request – [inout] Live QUEUED storage already borrowed by its adapter.
- 返回:
Success hands execution to the bus; BUSY retains QUEUED. Other errors must be settled by the adapter executor.
-
bool nx_spi_endpoint_on_port(const nx_spi_endpoint_t *endpoint, const nx_spi_port_t *port)¶
Verify an endpoint belongs to the serviced bus.
备注
Task/IRQ bounded cold identity check, no lookup or ownership effects. An adapter checks this before hardware execution; asynchronous admission also checks before borrowing.
- 参数:
endpoint – [in] Immutable endpoint identity kept alive by its caller.
port – [in] Exact execution bus bound to an adapter.
- 返回:
True only when the provider proves matching controller state and compatible bus methods; false for invalid/missing methods.
-
nx_result_t nx_spi_port_cancel(const nx_spi_port_t *port, nx_spi_request_t *request)¶
Request cancellation without revoking DMA/CS buffer loans.
备注
Cross-task controls use stable adapter slots and epochs.
- 参数:
port – [in] Same single execution owner as submit and service.
request – [inout] Exact live active request, never a stale raw pointer.
- 返回:
Success starts drain or observes prior settlement; STATE for another request, UNSUPPORTED for a polling-only provider.
-
void nx_spi_port_service(const nx_spi_port_t *port)¶
Advance one asynchronous bus under its single task executor.
备注
Bounded no-wait service. Final publication follows DMA/IRQ detach and peripheral-idle proof; failed drain quarantines.
- 参数:
port – [in] Live provider; call while stopping and throughout drain.
-
nx_result_t nx_spi_port_stop(const nx_spi_port_t *port)¶
Close admission and retain active sources until full drain.
- 参数:
port – [in] Live bus; all external producers already quiesced.
- 返回:
Success proves source release, BUSY requires service, or UNSUPPORTED when the provider has no asynchronous lifecycle.
-
nx_result_t nx_spi_port_attach_wake(const nx_spi_port_t *port, const nx_irq_wake_t *wake, uint8_t syscall_ceiling)¶
Attach an optional hint sink to asynchronous bus IRQ publishers.
备注
Join old publishers and waiters before freeing wake storage.
- 参数:
port – [in] One initialized bus controlled by a task executor.
wake – [in] Immutable borrowed target or NULL to detach.
syscall_ceiling – [in] Optional additional unshifted kernel-safe priority floor; cannot weaken generated policy. PRIMASK kernel targets require zero. Ignored without kernel calls.
- 返回:
Success, PERMISSION for unsafe actual priority, CONTEXT/STATE for illegal control or UNSUPPORTED for a polling-only bus.
-
struct nx_spi_request_t¶
- #include <spi.h>
Caller-owned finite SPI request with one whole-CS interval.
备注
Initialize base before prepare. Accepted requests borrow both non-NULL buffers until acquire-observed SETTLED, including cancellation and timeout drain. QUARANTINED retains the loan.
-
struct nx_spi_ops_t¶
- #include <spi.h>
Shared read-only methods using one provider state.
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
Public Members
-
nx_result_t (*recover)(void *context)¶
-
nx_result_t (*cancel)(void *context, nx_spi_request_t *request)¶
-
void (*service)(void *context)¶
-
nx_result_t (*stop)(void *context)¶
-
nx_result_t (*attach_wake)(void *context, const nx_irq_wake_t *wake, uint8_t syscall_ceiling)¶
-
nx_result_t (*recover)(void *context)¶
-
struct nx_spi_port¶
- #include <spi.h>
Immutable interface pointing to caller-owned state.
备注
Face and state outlive callers, IRQs and retained borrows. Factory lookup neither initializes nor acquires hardware.
-
struct nx_spi_endpoint_ops_t¶
- #include <spi.h>
Shared read-only methods using one provider state.
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
Public Members
-
nx_result_t (*transfer)(void *context, const uint8_t *tx, uint8_t *rx, size_t length, nx_time_us_t deadline, size_t *transferred)¶
-
nx_result_t (*submit)(void *context, nx_spi_request_t *request)¶
-
nx_result_t (*start_admitted)(void *context, nx_spi_request_t *request)¶
-
bool (*on_port)(const void *context, const nx_spi_port_t *port)¶
-
nx_result_t (*submit_memory)(void *context, nx_spi_request_t *request, uint8_t memory_flags)¶
-
nx_result_t (*transfer)(void *context, const uint8_t *tx, uint8_t *rx, size_t length, nx_time_us_t deadline, size_t *transferred)¶
stream.h¶
Bounded caller-owned blocks with explicit producer/consumer loans.
- Author
Nexus Team
Defines
-
NX_STREAM_BOUNDARY_IDLE¶
-
NX_STREAM_BOUNDARY_TRIGGER¶
-
NX_STREAM_BOUNDARY_LOSS¶
-
NX_STREAM_BOUNDARY_ERROR¶
Enums
Functions
-
nx_result_t nx_stream_initialize(nx_stream_t *stream, nx_stream_slot_t *slots, size_t count)¶
Initialize an unborrowed stream and exact supplied block array.
备注
Task-only cold assembly. This helper does not validate DMA domains; the hardware provider must validate every block.
- 参数:
stream – [out] Fresh storage, not visible to any producer/consumer.
slots – [inout] Buffers distinct from all control and slot metadata.
count – [in] Positive exact block count, not a maximum pool size.
- 返回:
Success or INVALID; never allocates or retains bad inputs.
-
nx_result_t nx_stream_reserve(nx_stream_t *stream, nx_stream_fill_t *fill)¶
Reserve the next free block for one serialized producer.
备注
Bounded task/IRQ metadata operation; payload writes occur outside the short interrupt mask, within the returned loan.
- 参数:
stream – [inout] Live initialized stream with one producer.
fill – [out] Producer loan valid until publish or proved abort.
- 返回:
Success, OVERFLOW without overwrite, STATE while stopping or EXHAUSTED when the monotonic loan identity cannot advance.
-
bool nx_stream_can_reserve(const nx_stream_t *stream)¶
Query the next physical slot without creating a loan or loss.
备注
Task/IRQ bounded hint. A producer still calls reserve before accessing payload; another context must not race admission.
- 参数:
stream – [in] Live initialized stream with one serialized producer.
- 返回:
True only when admission is open and the next slot is free.
-
void nx_stream_note_loss(nx_stream_t *stream, uint32_t count)¶
Latch explicitly observed dropped producer boundaries.
备注
Task/IRQ bounded. Saturates at UINT32_MAX; the next published block carries LOSS independently of its useful payload length.
- 参数:
stream – [inout] Live stream controlled by the serialized producer.
count – [in] Positive lost block/boundary count, never guessed bytes.
-
nx_result_t nx_stream_publish(nx_stream_t *stream, const nx_stream_fill_t *fill, size_t length, uint32_t flags)¶
Publish a complete block after all hardware writes detached.
备注
Task/IRQ bounded. A DMA half/full flag is insufficient if the engine can still write the published block. Consumer-visible block bytes stay immutable until the consumer releases them.
- 参数:
stream – [inout] Same serialized producer as reserve.
fill – [in] Current producer loan, not retained after publication.
length – [in] Positive produced bytes within the reserved capacity.
flags – [in] IDLE/TRIGGER boundaries observed by the provider.
- 返回:
Success, INVALID or STATE; failure retains producer ownership.
-
nx_result_t nx_stream_acquire(nx_stream_t *stream, nx_stream_block_t *block)¶
Acquire the next ready block for one serialized consumer.
备注
Task/IRQ bounded metadata; consumer processing happens outside the mask. Release may occur out of order without overwrite.
- 参数:
stream – [inout] Live stream; consumer may drain during stop.
block – [out] Immutable consumer loan with exact incarnation token.
- 返回:
Success, EMPTY or INVALID; empty creates no loan.
-
nx_result_t nx_stream_release(nx_stream_t *stream, const nx_stream_block_t *block)¶
Release only the matching consumer incarnation after final use.
备注
Task/IRQ bounded; release is the consumer’s final block access.
- 参数:
stream – [inout] Same consumer owner; no remaining observers of block.
block – [in] Exact acquired token, never a reconstructed pointer.
- 返回:
Success, STATE for stale/double release or INVALID.
-
nx_result_t nx_stream_abort(nx_stream_t *stream, const nx_stream_fill_t *fill, bool memory_quiesced)¶
Abort a producer loan only after memory write sources detach.
备注
Cancellation/deadline alone never establishes quiescence.
- 参数:
stream – [inout] Same producer owner as reserve.
fill – [in] Current exact loan.
memory_quiesced – [in] True only after provider proves DMA/IRQ stopped.
- 返回:
Success, BUSY without proven drain, STATE for a stale token.
-
nx_result_t nx_stream_stop(nx_stream_t *stream)¶
Close producer admission while retaining every outstanding loan.
备注
Task/IRQ constant metadata work independent of block count. This operation does not stop hardware or revoke loans.
- 参数:
stream – [inout] Live control kept alive until final successful stop.
- 返回:
Success only when all blocks are free, BUSY until producers detach and consumers drain/release, INVALID for bad control.
-
nx_result_t nx_stream_post_initialize(nx_stream_producer_t *producer, nx_stream_t *stream)¶
Bind a posted producer to a quiescent initialized stream.
备注
Task-only cold binding. Caller owns exclusive producer rights and retains control until all pending fills and IRQs drain.
- 参数:
producer – [out] Separate caller control, not aliased with buffers
stream – [inout] Admission open, no outstanding producer/consumer loans
- 返回:
SUCCESS, INVALID, BUSY or STATE; rejected output is untouched
-
bool nx_stream_post_can_reserve(const nx_stream_producer_t *producer)¶
Query the next preposted slot without a loan or guessed loss.
备注
Bounded task/IRQ hint; still reserve before writing payload.
- 参数:
producer – [in] Same exclusive serialized producer
- 返回:
True when the next reservation can succeed
-
nx_result_t nx_stream_post_reserve(nx_stream_producer_t *producer, nx_stream_fill_t *fill)¶
Reserve a future fill without making earlier blocks ready.
备注
O(1) task/IRQ. Failure leaves output and loss counters intact; only explicitly observed boundaries justify note_loss.
- 参数:
producer – [inout] Live posted producer
fill – [out] Exact pending loan until FIFO publish or LIFO abort
- 返回:
SUCCESS, OVERFLOW, STATE, EXHAUSTED or INVALID
-
nx_result_t nx_stream_post_publish(nx_stream_producer_t *producer, const nx_stream_fill_t *fill, size_t length, uint32_t flags)¶
Publish only the oldest pending detached producer loan.
备注
O(1) task/IRQ. Consumer acquire/release use the original stream.
- 参数:
producer – [inout] Same exclusive producer as reserve
fill – [in] Exact oldest token, absent from every hardware target
length – [in] Positive valid bytes at most the block capacity
flags – [in] Observed IDLE/TRIGGER/ERROR boundary facts
- 返回:
SUCCESS, INVALID or STATE; rejection retains the loan
-
nx_result_t nx_stream_post_abort(nx_stream_producer_t *producer, const nx_stream_fill_t *fill, bool memory_quiesced)¶
Cancel the newest pending fill after proof of memory drain.
备注
O(1) task/IRQ. Does not advance consumer or published cursor; no FREE hole appears ahead of future publication. Stopping closes admission but still permits proved tail rollback.
- 参数:
producer – [inout] Same producer; rollback is strictly LIFO
fill – [in] Exact newest pending token
memory_quiesced – [in] Source detached, no remaining writes
- 返回:
SUCCESS, BUSY, STATE or INVALID; failure retains the loan
-
struct nx_stream_slot_t¶
- #include <stream.h>
Caller-owned block metadata; initialize data and capacity only.
备注
Storage remains live through producer and consumer quiescence.
-
struct nx_stream_t¶
- #include <stream.h>
Caller-owned stream control, initialized before publication.
备注
outstanding counts nonfree blocks, including filling, ready and borrowed states. Only stream operations mutate it.
-
struct nx_stream_fill_t¶
- #include <stream.h>
Mutable producer loan; hardware must stop before abort or publish.
-
struct nx_stream_producer_t¶
- #include <stream.h>
Optional caller-owned preposted producer; no default cost.
备注
One serialized producer owns this control and the stream. Do not mix ordinary reserve/publish/abort with a live posted producer. Two hardware targets remain FILLING until detached. Publication is FIFO; rollback is LIFO to avoid consumer holes.
stream_budget.h¶
Optional constant-work snapshot and checked cold sizing.
- Author
Nexus Team
Functions
-
nx_result_t nx_stream_observe(const nx_stream_t *stream, nx_stream_observation_t *out)¶
Snapshot maintained metadata under one short IRQ guard.
备注
Task/IRQ fixed work, no slot scan or payload access. Caller keeps all storage alive; no observer reference is retained. next_free is the ordinary stream cursor, not the private preposted cursor. Output is distinct from every payload.
- 参数:
stream – [in] Live initialized storage, no concurrent destruction.
out – [out] Distinct output, unchanged on rejected metadata/alias.
- 返回:
SUCCESS, INVALID or STATE for inconsistent control facts.
-
nx_result_t nx_stream_budget_calculate(const nx_stream_budget_t *budget, nx_stream_budget_result_t *out)¶
Checked cold calculation, no stream mutation or allocation.
备注
required = targets + spares + ceil(rate*release_delay / (block_units*1000000)); payload is required*block*unit_bytes. Finite math is conservative under the declared FIFO frontier release bound; out-of-order release may still block the next cursor. Latency requires target_delay < floor(block/rate). This creates no backpressure or hardware qualification.
- 参数:
budget – [in] Explicit rate, longest release delay and pipeline.
out – [out] Distinct output, unchanged on error or overflow.
- 返回:
SUCCESS, INVALID or EXHAUSTED for arithmetic overflow.
-
struct nx_stream_observation_t¶
- #include <stream_budget.h>
O(1) aggregate facts; free total does not imply cursor is free.
-
struct nx_stream_budget_t¶
- #include <stream_budget.h>
Explicit engineering assumptions, no inferred hardware rate.
备注
release_delay includes queue/consumer delay until release of each published FIFO frontier. units convert to bytes using unit_bytes. targets/spares are actual selected hardware loans. All quantities are positive except delay/targets/spares.
Public Members
-
uint64_t units_per_second¶
-
size_t units_per_block¶
-
size_t unit_bytes¶
-
nx_time_us_t release_delay_us¶
-
nx_time_us_t target_delay_us¶
-
size_t hardware_targets¶
-
size_t spare_blocks¶
-
size_t configured_blocks¶
-
uint64_t units_per_second¶
-
struct nx_stream_budget_result_t¶
- #include <stream_budget.h>
Conservative declared-assumption budget; never physical evidence.
timer.h¶
Fixed timer/channel PWM with one shared base configuration.
- Author
Nexus Team
Typedefs
-
typedef struct nx_pwm_port nx_pwm_port_t¶
Functions
-
nx_result_t nx_pwm_port_set(const nx_pwm_port_t *port, uint32_t period_ticks, uint32_t duty_ticks)¶
Atomically stage a reviewed fixed-base PWM duty.
备注
Shadow update becomes effective at next update event; do not infer immediate electrical change from successful staging.
- 参数:
port – [inout] Fixed timer/channel with one serialized writer.
period_ticks – [in] Positive maintained shared-base period.
duty_ticks – [in] Zero through period_ticks, inclusive.
- 返回:
Success or INVALID/STATE/BUSY. Zero/100 percent are explicit constant levels. Shared channels must use one PSC/ARR/base; changing another channel’s base is rejected by configuration.
-
nx_result_t nx_pwm_port_start(const nx_pwm_port_t *port)¶
Enable a previously configured fixed PWM output.
- 参数:
port – [inout] Execution owner after Board inactive level setup.
- 返回:
Success or INVALID/STATE.
-
nx_result_t nx_pwm_port_stop(const nx_pwm_port_t *port)¶
Stop PWM at its declared Board inactive electrical level.
- 参数:
port – [inout] Quiesced execution owner; no concurrent set/start.
- 返回:
Success or INVALID; no advanced break/capture promise.
-
nx_result_t nx_pwm_port_state(const nx_pwm_port_t *port, nx_pwm_state_t *state)¶
Query staged PWM counts and selected timer clock.
- 参数:
port – [in] Fixed initialized channel.
state – [out] Staged counts, clock and running state.
- 返回:
Success or INVALID.
-
struct nx_pwm_state_t¶
- #include <timer.h>
PWM counts refer to the fixed declared post-prescaler timer clock.
-
struct nx_pwm_ops_t¶
- #include <timer.h>
Shared read-only methods using one provider state.
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
Public Members
-
nx_result_t (*set)(void *context, uint32_t period_ticks, uint32_t duty_ticks)¶
-
nx_result_t (*start)(void *context)¶
-
nx_result_t (*stop)(void *context)¶
-
nx_result_t (*state)(const void *context, nx_pwm_state_t *state)¶
-
nx_result_t (*set)(void *context, uint32_t period_ticks, uint32_t duty_ticks)¶
timer_capture.h¶
Optional raw timer edge capture with caller-owned events.
- Author
Nexus Team
Enums
Functions
-
nx_result_t nx_timer_capture_start(const nx_timer_capture_t *port, nx_timer_capture_event_t *events, size_t capacity)¶
Borrow an exact event ring and enable the fixed capture channel.
备注
Ring remains borrowed until successful stop. ISR access is confined to this ring. Caller must not modify it or its provider while borrowed. Counter wrap is modulo the reported width; observation time is not an absolute edge timestamp or a clock accuracy qualification.
- 参数:
port – [in] One privileged task owner, serialized with stop/read.
events – [inout] Aligned writable ring, capacity positive.
capacity – [in] Number of events; no hidden buffer or worker.
- 返回:
SUCCESS transfers the ring borrow; rejection retains nothing.
-
nx_result_t nx_timer_capture_stop(const nx_timer_capture_t *port)¶
Disable and read back channel/IRQ sources before returning storage.
备注
Read drains events after capture stops. Failed detach never frees storage. Board pins, timer clock and shared vector leases are released by cold assembly only after successful stop and publisher quiescence.
- 参数:
port – [in] Privileged task owner, with generated IRQ owner retained.
- 返回:
SUCCESS is the final access to the ring; BUSY retains the borrow while queued events or failed hardware detachment remain.
-
nx_result_t nx_timer_capture_read(const nx_timer_capture_t *port, nx_timer_capture_event_t *event)¶
Copy the oldest event in a short saved-mask metadata section.
- 参数:
port – [in] Single privileged task consumer.
event – [out] Separate writable output, unchanged on EMPTY/rejection.
- 返回:
SUCCESS, EMPTY, STATE or INVALID; no block release is required.
-
nx_result_t nx_timer_capture_state(const nx_timer_capture_t *port, nx_timer_capture_state_t *state)¶
Query counter units and observable queue/loss facts.
备注
Hardware overcapture and ring saturation can coalesce edges. A loss incident does not estimate edges, edge frequency or actual IRQ WCET.
- 参数:
port – [in] Privileged task owner; no concurrent lifecycle writer.
state – [out] Separate writable snapshot.
- 返回:
SUCCESS or INVALID/STATE/CONTEXT.
-
struct nx_timer_capture_event_t¶
- #include <timer_capture.h>
Hardware modulo counter and the separate IRQ observation time.
-
struct nx_timer_capture_state_t¶
- #include <timer_capture.h>
Fixed counter units and current software retention state.
-
struct nx_timer_capture_ops_t¶
- #include <timer_capture.h>
Shared immutable methods; no per-call acquisition or allocation.
Public Members
-
nx_result_t (*start)(void *context, nx_timer_capture_event_t *events, size_t capacity)¶
-
nx_result_t (*stop)(void *context)¶
-
nx_result_t (*read)(void *context, nx_timer_capture_event_t *event)¶
-
nx_result_t (*state)(const void *context, nx_timer_capture_state_t *state)¶
-
nx_result_t (*start)(void *context, nx_timer_capture_event_t *events, size_t capacity)¶
-
struct nx_timer_capture_t¶
- #include <timer_capture.h>
Immutable identity; state and methods outlive calls and IRQs.
uart.h¶
IRQ TX requests and independently budgeted byte/event reception.
- Author
Nexus Team
Defines
-
NX_UART_EVENT_PARITY¶
-
NX_UART_EVENT_FRAMING¶
-
NX_UART_EVENT_OVERRUN¶
-
NX_UART_EVENT_NOISE¶
-
NX_UART_EVENT_LOSS¶
-
NX_UART_EVENT_NO_BYTE¶
Typedefs
-
typedef struct nx_uart_port nx_uart_port_t¶
Enums
Functions
-
nx_result_t nx_uart_tx_prepare(nx_uart_tx_request_t *request, const uint8_t *data, size_t length, nx_time_us_t deadline)¶
Prepare an unborrowed IRQ TX descriptor without copying data.
- 参数:
request – [inout] Fresh initialized or consumed SETTLED request.
data – [in] Nonempty payload retained unchanged through SETTLED.
length – [in] Positive byte count.
deadline – [in] Absolute deadline in nx_time_now_us clock domain.
- 返回:
NX_SUCCESS or INVALID/STATE; failure retains no buffer.
-
nx_result_t nx_uart_port_submit(const nx_uart_port_t *port, nx_uart_tx_request_t *request)¶
Submit one direct request to a single-executor UART.
备注
Task-only, bounded admission. TX completion waits for true TC (wire idle). IRQ only moves bytes/publishes hardware facts; the owner calls service to observe deadlines and settle. The first observed terminal fact latches its result. Later service, deadline or cancellation does not overwrite an already observed TC. IRQ/service latency bounds remain provider and product qualification inputs.
- 参数:
port – [inout] Initialized idle port owned by this execution context.
request – [inout] READY descriptor; borrowed only on NX_SUCCESS.
- 返回:
NX_SUCCESS means ACCEPTED, including a later start failure. BUSY/INVALID/CONTEXT/STATE/TIMEOUT means REJECTED with zero borrow; an already expired direct request is not admitted.
-
nx_result_t nx_uart_port_start_admitted(const nx_uart_port_t *port, nx_uart_tx_request_t *request)¶
Start an adapter-admitted QUEUED request without readmission.
- 参数:
port – [inout] Single-executor initialized port.
request – [inout] QUEUED descriptor already borrowed by adapter.
- 返回:
BUSY retains QUEUED; NX_SUCCESS transfers execution to port. Other start errors must be settled by the adapter executor.
-
nx_result_t nx_uart_port_cancel(const nx_uart_port_t *port, nx_uart_tx_request_t *request)¶
Request cancellation; acceptance does not mean settlement.
- 参数:
port – [inout] Same single execution owner as submit/service.
request – [inout] Active live descriptor; cross-task callers use a stable adapter slot and expected epoch instead of this pointer.
- 返回:
NX_SUCCESS for pending/already settled cancellation; STATE for a different request. Borrow continues until SETTLED.
-
void nx_uart_port_service(const nx_uart_port_t *port)¶
Observe time/hardware completion and drain one active request.
备注
Bounded, no wait/callback; call throughout stop/drain and at the declared maximum service interval. Publication is final request access. Hardware unable to drain retains QUARANTINED.
- 参数:
port – [inout] Single task/loop execution owner.
-
nx_result_t nx_uart_port_read_events(const nx_uart_port_t *port, nx_uart_rx_event_t *events, size_t capacity, size_t *count)¶
Read buffered RX events from the selected event profile.
- 参数:
port – [inout] Initialized event-profile port; one consumer.
events – [out] Caller-owned destination; not retained.
capacity – [in] Destination event count.
count – [out] Events copied, including explicit loss/error flags.
- 返回:
NX_SUCCESS, EMPTY or INVALID/UNSUPPORTED. IRQ produces only into configured storage; overflow never silently overwrites.
-
nx_result_t nx_uart_port_read_bytes(const nx_uart_port_t *port, uint8_t *bytes, size_t capacity, size_t *count)¶
Read buffered bytes from the selected byte profile.
- 参数:
port – [inout] Initialized byte-profile port; one consumer.
bytes – [out] Caller-owned destination; not retained.
capacity – [in] Destination capacity in bytes.
count – [out] Bytes copied; valid even when OVERFLOW is returned.
- 返回:
NX_SUCCESS, EMPTY, OVERFLOW or INVALID/UNSUPPORTED. Byte profile reports aggregate loss without invented timestamps.
-
nx_result_t nx_uart_port_stop(const nx_uart_port_t *port)¶
Close admission and drain TX before releasing hardware.
备注
RX/IRQ and external consumers must quiesce before storage reclamation. No automatic task/notification destruction.
- 参数:
port – [inout] Owner; producers must already have quiesced.
- 返回:
NX_SUCCESS when stopped; BUSY while service must continue.
-
nx_result_t nx_uart_port_attach_wake(const nx_uart_port_t *port, const nx_irq_wake_t *wake, uint8_t syscall_ceiling)¶
Attach or detach one explicit IRQ wake target.
备注
Quiesce every previous publisher before reclaiming an old target. IRQ events latch RX/completion facts before notifying. Detachment removes future publications; notification storage still requires joining external waiters and callbacks.
- 参数:
port – [in] Initialized provider, controlled by one task executor.
wake – [in] Immutable live target or NULL to detach.
syscall_ceiling – [in] Optional additional unshifted kernel-safe priority floor; cannot weaken generated policy. PRIMASK kernel targets require zero. Ignored without kernel calls.
- 返回:
Success, CONTEXT outside task control, PERMISSION for unsafe actual IRQ priority, or provider STATE/UNSUPPORTED.
-
nx_result_t nx_uart_port_rx_start(const nx_uart_port_t *port, nx_stream_t *stream)¶
Start the selected RX block mode using exact caller storage.
备注
Provider boundaries and gaps are explicit capability facts. The provider must never overwrite a borrowed consumer block.
- 参数:
port – [in] Block-capable provider, one task execution owner.
stream – [inout] Initialized block stream retained until RX stops and all acquired consumer blocks are released.
- 返回:
Success or INVALID/BUSY/UNSUPPORTED with zero failed admission loan; selected hardware modes validate every DMA block domain.
-
nx_result_t nx_uart_port_rx_stop(const nx_uart_port_t *port)¶
Stop RX block production without revoking consumer loans.
备注
Consumers separately drain READY blocks and release loans; successful RX stop does not destroy stream or wake storage.
- 参数:
port – [in] Same executor as RX start; storage stays live on BUSY.
- 返回:
Success proves memory sources detached; BUSY retains producer loan, UNSUPPORTED for a byte/event-only provider.
-
struct nx_uart_rx_event_t¶
- #include <uart.h>
Timestamp belongs to provider clock; precision is hardware-specific.
备注
NO_BYTE marks status-only IRQ facts: byte is invalid. LOSS is an independent NO_BYTE boundary marker, ordered after older buffered facts and before later reception. Its timestamp is provider detection/report time, never a reconstructed timestamp for missing bytes. Byte-profile reads report aggregate loss and omit status-only facts.
-
struct nx_uart_tx_request_t¶
- #include <uart.h>
Caller-owned TX descriptor; initialize base before first prepare.
-
struct nx_uart_ops_t¶
- #include <uart.h>
Shared read-only methods using one provider state.
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
Public Members
-
nx_result_t (*submit)(void *context, nx_uart_tx_request_t *request)¶
-
nx_result_t (*start_admitted)(void *context, nx_uart_tx_request_t *request)¶
-
nx_result_t (*cancel)(void *context, nx_uart_tx_request_t *request)¶
-
void (*service)(void *context)¶
-
nx_result_t (*read_events)(void *context, nx_uart_rx_event_t *events, size_t capacity, size_t *count)¶
-
nx_result_t (*read_bytes)(void *context, uint8_t *bytes, size_t capacity, size_t *count)¶
-
nx_result_t (*stop)(void *context)¶
-
nx_result_t (*attach_wake)(void *context, const nx_irq_wake_t *wake, uint8_t syscall_ceiling)¶
-
nx_result_t (*rx_start)(void *context, nx_stream_t *stream)¶
-
nx_result_t (*rx_stop)(void *context)¶
-
nx_result_t (*submit)(void *context, nx_uart_tx_request_t *request)¶
uart_rs485.h¶
Optional single-owner RS485 direction and wire-tail adapter.
- Author
Nexus Team
Typedefs
-
typedef nx_result_t (*nx_uart_tx_validate_fn)(void *context, const nx_uart_tx_request_t *request)¶
Exact transport’s side-effect-free TX admission validator.
备注
Reads clock/hardware facts but never writes GPIO/MMIO, admits, starts or retains a reference. One executor owns adapter and transport; no external direct TX is permitted.
- Param context:
[in] The immutable transport face’s exact context.
- Param request:
[in] Live READY or QUEUED descriptor, never retained.
- Return:
Same rejectable checks used by the transport submit/start.
Functions
-
nx_result_t nx_uart_rs485_initialize(nx_uart_rs485_state_t *state, const nx_uart_rs485_config_t *config)¶
Bind exclusive transport and establish inactive DE.
备注
Task-only, no wait. No physical transceiver is inferred. Setup starts after successful DE assertion; hold starts after acquire-observed true transport settlement. Transfer deadline includes setup and wire completion; mandatory drain/hold may extend the borrow beyond that deadline. Rejected TX leaves DE and transport unchanged. Failed drain or DE withdrawal keeps QUARANTINED outer storage and DE ownership until service retry.
- 参数:
state – [inout] Fresh zero-initialized caller control.
config – [in] Immutable lifetime binding; one authorized DE bit, real board polarity, setup/hold in nx_time_now_us domain.
- 返回:
Success or INVALID/CONTEXT/STATE/GPIO failure, no TX loan.
Variables
-
const nx_uart_ops_t nx_uart_rs485_ops¶
-
struct nx_uart_rs485_config_t¶
- #include <uart_rs485.h>
Immutable selected electrical/timing facts, no task or heap.
备注
Configuration, faces, ops and context identities cannot change while bound. They are disjoint from mutable adapter, request and payload storage; exact pin ownership is external.
Public Members
-
const nx_uart_port_t *transport¶
-
const nx_gpio_port_t *direction¶
-
nx_uart_tx_validate_fn validate¶
-
uint32_t mask¶
-
nx_time_us_t setup_us¶
-
nx_time_us_t hold_us¶
-
bool active_high¶
-
const nx_uart_port_t *transport¶
-
struct nx_uart_rs485_state_t¶
- #include <uart_rs485.h>
Caller-owned opt-in adapter, zero-initialize before init.
备注
Control is private after initialization. Immutable config, both faces, pin ownership and all storage outlive successful stop plus external observers. Default UART state is unchanged.
Public Members
-
const nx_uart_rs485_config_t *config¶
-
nx_uart_tx_request_t inner¶
-
nx_uart_tx_request_t *active¶
-
nx_time_us_t boundary¶
-
nx_result_t terminal¶
-
size_t transferred¶
-
uint8_t phase¶
-
bool initialized¶
-
bool closing¶
-
const nx_uart_rs485_config_t *config¶
usb_device.h¶
Full-speed device packets and caller-owned endpoint loans.
- Author
Nexus Team
Enums
Functions
-
nx_result_t nx_usb_in_prepare(nx_usb_request_t *request, const uint8_t *bytes, size_t length, nx_usb_stage_t stage, uint64_t epoch, nx_time_us_t deadline)¶
Prepare one IN packet without reading or borrowing its bytes.
- 参数:
request – [inout] Initialized unborrowed request.
bytes – [in] Immutable packet bytes, NULL only for zero length.
length – [in] Packet length, no automatic terminating ZLP.
stage – [in] DATA or control STATUS; STATUS must be zero length.
epoch – [in] Current SETUP epoch for EP0, zero for bulk endpoints.
deadline – [in] Absolute independent monotonic clock deadline.
- 返回:
Success, INVALID or STATE; rejection retains no references.
-
nx_result_t nx_usb_out_prepare(nx_usb_request_t *request, uint8_t *bytes, size_t capacity, nx_usb_stage_t stage, uint64_t epoch, nx_time_us_t deadline)¶
Prepare an OUT packet capacity without modifying its storage.
- 参数:
request – [inout] Initialized unborrowed request.
bytes – [out] Borrowed until SETTLED only after accepted submission.
capacity – [in] At most endpoint MPS; short packets complete normally.
stage – [in] DATA or zero-capacity control STATUS.
epoch – [in] Current SETUP epoch for EP0, zero for bulk endpoints.
deadline – [in] Absolute independent monotonic clock deadline.
- 返回:
Success, INVALID or STATE; rejection creates no borrow.
-
nx_result_t nx_usb_endpoint_submit(const nx_usb_endpoint_port_t *port, nx_usb_request_t *request)¶
Admit one packet, never a hidden queue or complete USB transaction.
备注
One privileged task executor, IRQ masks clear. IN FIFO writes do not prove host ACK. OUT overrun drains all packet words without overflow.
- 参数:
port – [in] Stable endpoint face and private state.
request – [inout] READY packet, buffers alive until acquire SETTLED.
- 返回:
Success means ACCEPTED; fourth-party buffers are not copied early.
-
nx_result_t nx_usb_endpoint_cancel(const nx_usb_endpoint_port_t *port, nx_usb_request_t *request)¶
Request endpoint disable/drain without revoking a buffer loan.
备注
Control OUT0 has no hardware disable command: cancellation may require full device stop to settle. Missing proof becomes QUARANTINED. Reset/SETUP invalidates epochs but releases only after actual source drain.
- 参数:
port – [in] Same serialized privileged task owner.
request – [inout] Live request accepted by this exact endpoint.
- 返回:
Success requests drain; failures retain all prior accepted loans.
-
nx_result_t nx_usb_endpoint_stall(const nx_usb_endpoint_port_t *port, bool stalled)¶
Set/clear STALL only after the endpoint has no live transfer.
- 参数:
port – [in] Serialized owner, started and IRQ masks clear.
stalled – [in] Desired STALL; clearing bulk also resets DATA0.
- 返回:
Success after readback, BUSY retains a pending request.
-
nx_result_t nx_usb_device_service(const nx_usb_device_port_t *port)¶
Task-only bounded progress; deadline never depends on USB SOF.
- 参数:
port – [in] Serialized privileged owner with incoming IRQ masks clear.
- 返回:
Success requests progress; no clock/endpoint loan is released early.
-
nx_result_t nx_usb_device_read_events(const nx_usb_device_port_t *port, nx_usb_event_t *events, size_t capacity, size_t *count)¶
Consume bounded value events; output is never retained.
备注
Invalid/STATE rejection leaves both outputs unchanged.
- 参数:
port – [in] Single task consumer and stable controller.
events – [out] Caller records disjoint from provider and live loans.
capacity – [in] Positive output count.
count – [out] Disjoint count output; EMPTY means zero.
- 返回:
Success, EMPTY or rejection; authoritative latest SETUP is in state.
-
nx_result_t nx_usb_device_state(const nx_usb_device_port_t *port, nx_usb_device_state_t *state)¶
Task-only authoritative snapshot, independent of event-ring space.
- 参数:
port – [in] Serialized privileged owner with IRQ masks clear.
state – [out] Disjoint caller snapshot, never retained.
- 返回:
Success copies state; alias/context rejection leaves output unchanged.
-
nx_result_t nx_usb_device_address(const nx_usb_device_port_t *port, uint64_t epoch, uint8_t address)¶
Stage SET_ADDRESS for the matching zero-data standard SETUP.
- 参数:
port – [in] Serialized privileged controller owner.
epoch – [in] Current SETUP identity.
address – [in] 0..127, matching SETUP wValue.
- 返回:
Success stages only; address applies after real status-IN XFRC.
-
nx_result_t nx_usb_device_attach_wake(const nx_usb_device_port_t *port, const nx_irq_wake_t *wake, uint8_t syscall_ceiling)¶
Attach/detach a borrowed task/IRQ-compatible wake hint.
- 参数:
port – [in] Started serialized owner with IRQ masks clear.
wake – [in] Immutable target, or NULL to detach.
syscall_ceiling – [in] Additional numerical IRQ priority floor.
- 返回:
Success after actual priority policy checks, BUSY while publisher remains live; rejection retains no new sink.
-
nx_result_t nx_usb_device_stop(const nx_usb_device_port_t *port)¶
Disconnect, disable, drain, detach IRQs, then release clock consumer.
备注
PIO OUT0 may remain enabled: successful global stop proves disconnect, OUT NAK, no DMA, empty RX FIFO, IRQ withdrawal and publisher join before final SETTLED. No forced reset revokes an unproved accepted borrow.
- 参数:
port – [in] Serialized owner; external observers must also join.
- 返回:
Success ends provider access to endpoint/ring/wake storage; BUSY retains all storage and 48MHz ownership until actual progress.
-
struct nx_usb_request_t¶
- #include <usb_device.h>
Public Members
-
nx_request_t base¶
-
const uint8_t *in¶
-
uint8_t *out¶
-
size_t length¶
-
uint64_t control_epoch¶
-
nx_usb_stage_t stage¶
-
nx_request_t base¶
-
struct nx_usb_setup_t¶
- #include <usb_device.h>
-
struct nx_usb_event_t¶
- #include <usb_device.h>
Public Members
-
nx_usb_setup_t setup¶
-
nx_time_us_t timestamp_us¶
-
uint64_t lost¶
-
nx_usb_event_kind_t kind¶
-
nx_usb_setup_t setup¶
-
struct nx_usb_device_state_t¶
- #include <usb_device.h>
-
struct nx_usb_endpoint_ops_t¶
- #include <usb_device.h>
Shared readonly packet methods; context is a selected endpoint.
Public Members
-
nx_result_t (*submit)(void*, nx_usb_request_t*)¶
-
nx_result_t (*cancel)(void*, nx_usb_request_t*)¶
-
nx_result_t (*stall)(void*, bool)¶
-
nx_result_t (*submit)(void*, nx_usb_request_t*)¶
-
struct nx_usb_endpoint_port_t¶
- #include <usb_device.h>
-
struct nx_usb_device_ops_t¶
- #include <usb_device.h>
Controller identity remains separate from endpoint identities.
Public Members
-
nx_result_t (*service)(void*)¶
-
nx_result_t (*read_events)(void*, nx_usb_event_t*, size_t, size_t*)¶
-
nx_result_t (*state)(void*, nx_usb_device_state_t*)¶
-
nx_result_t (*address)(void*, uint64_t, uint8_t)¶
-
nx_result_t (*attach_wake)(void*, const nx_irq_wake_t*, uint8_t)¶
-
nx_result_t (*stop)(void*)¶
-
nx_result_t (*service)(void*)¶
-
struct nx_usb_device_port_t¶
- #include <usb_device.h>
wake.h¶
Explicit borrowed IRQ wake target and syscall-ceiling check.
- Author
Nexus Team
Enums
Functions
-
nx_result_t nx_irq_wake_validate(const nx_irq_wake_t *wake, const nx_irq_policy_t *policy, const nx_irq_source_t *source)¶
Validate actual IRQ facts against an explicit kernel policy.
备注
Cold check without attachment or callback effects. No kernel target is accepted by NONE. PRIMASK permits every valid configurable IRQ with its fixed zero priority group. Kernel-calling BASEPRI targets require the maintained preemption grouping and a numerical priority at least the ceiling. Nonkernel hints do not impose kernel grouping. Binding does not authorize future CPU-context violations.
- 参数:
wake – [in] Optional immutable target; NULL disables notification.
policy – [in] Immutable validated CPU and kernel configuration.
source – [in] External IRQ number, unshifted priority and group.
- 返回:
Success, INVALID for malformed facts/target, PERMISSION for a kernel-calling target in an unsafe interrupt domain.
-
nx_result_t nx_irq_wake_signal(const nx_irq_wake_t *wake)¶
Deliver one bounded hint after authoritative state is latched.
备注
Task/IRQ as allowed by the target, no hidden task or retry. A failed wake does not revoke state or request ownership.
- 参数:
wake – [in] Previously validated live target or NULL.
- 返回:
Callback result, success for NULL, INVALID for a bad target.
-
struct nx_irq_wake_t¶
- #include <wake.h>
Optional immutable wake target borrowed by an IRQ provider.
备注
notify runs in publisher context and must be bounded and legal in that IRQ. Storage and context outlive all publishers. Stop and join publishers before destroying the sink. A wake is only a hint; latched RX/request predicates stay authoritative.
-
struct nx_irq_policy_t¶
- #include <wake.h>
Immutable CPU and kernel facts for cold wake binding.
备注
NONE and PRIMASK require a zero syscall ceiling. BASEPRI requires a nonzero unshifted ceiling. Configuration owns these facts; a wake target cannot weaken them.
Public Members
-
nx_irq_kernel_policy_t kernel¶
-
uint16_t external_irq_count¶
-
uint8_t priority_bits¶
-
uint8_t syscall_ceiling¶
-
nx_irq_kernel_policy_t kernel¶
watchdog.h¶
Irreversible IWDG effects and neutral hardware reset causes.
- Author
Nexus Team
Defines
-
NX_RESET_POWER_ON¶
-
NX_RESET_PIN¶
-
NX_RESET_SOFTWARE¶
-
NX_RESET_IWDG¶
-
NX_RESET_WWDG¶
-
NX_RESET_LOW_POWER¶
-
NX_RESET_BROWNOUT¶
Typedefs
-
typedef struct nx_watchdog_port nx_watchdog_port_t¶
Functions
-
nx_result_t nx_watchdog_port_enable(const nx_watchdog_port_t *port, uint32_t timeout_us, bool debug_freeze, nx_watchdog_state_t *state)¶
Enable IWDG with reviewed bounds; activation is irreversible.
- 参数:
port – [inout] Fixed provider; product owns feed/recovery policy.
timeout_us – [in] Requested nominal timeout in maintained range.
debug_freeze – [in] Whether debug halting freezes counting.
state – [out] Actual timeout bounds and remaining effect, including enabled=true when later setup reports failure after enabling.
- 返回:
Success or INVALID/STATE/IO; never claims enabled hardware was disabled during rollback. Existing enable is identified.
-
nx_result_t nx_watchdog_port_feed(const nx_watchdog_port_t *port)¶
Feed an enabled IWDG without changing product health policy.
- 参数:
port – [inout] Fixed enabled provider with one serialized feed owner.
- 返回:
Success or INVALID/STATE; bounded task/IRQ, no allocation.
-
nx_result_t nx_watchdog_port_state(const nx_watchdog_port_t *port, nx_watchdog_state_t *state)¶
Query current watchdog effect and timeout uncertainty.
- 参数:
port – [in] Fixed provider.
state – [out] Current hardware/remembered initialization state.
- 返回:
Success or INVALID.
-
uint32_t nx_reset_cause(void)¶
Read latched boot reset causes captured before clearing flags.
备注
No implicit acknowledgement, reboot or product classification.
- 返回:
Bitmask of NX_RESET_*; multiple causes may be reported.
-
struct nx_watchdog_state_t¶
- #include <watchdog.h>
Hardware-selected timeout bounds, including declared LSI uncertainty.
-
struct nx_watchdog_ops_t¶
- #include <watchdog.h>
Shared read-only methods using one provider state.
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
Public Members
-
nx_result_t (*enable)(void *context, uint32_t timeout_us, bool debug_freeze, nx_watchdog_state_t *state)¶
-
nx_result_t (*feed)(void *context)¶
-
nx_result_t (*state)(const void *context, nx_watchdog_state_t *state)¶
-
nx_result_t (*enable)(void *context, uint32_t timeout_us, bool debug_freeze, nx_watchdog_state_t *state)¶
-
struct nx_watchdog_port¶
- #include <watchdog.h>
Immutable interface pointing to caller-owned state.
备注
Face and state outlive callers, IRQs and retained borrows. Factory lookup neither initializes nor acquires hardware.