类型化 I/O:设备与执行合同¶
这些声明来自公共头文件。选择、生命周期、支持的执行模式和物理资源授权范围仍以对应设计及支持记录为准。
adc.h¶
已审查的 ADC 单次采样与低速轮询扫描。
作者 Nexus Team
类型定义
-
typedef struct nx_adc_port nx_adc_port_t¶
函数
-
nx_result_t nx_adc_port_info(const nx_adc_port_t *port, nx_adc_info_t *info)¶
查询固定、已审查的 ADC 序列与原始计数格式。
- 参数:
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)¶
读取固定通道顺序与完整扫描的时序事实。
- 参数:
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)¶
采集开始前附加可选观察者存储。
备注
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)¶
查询一个存活消费者借用的软件完成记录。
- 参数:
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)¶
通过有界轮询采样固定单次/扫描序列。
备注
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)¶
使用调用者存储启动选定的触发/块采集。
备注
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)¶
停止触发与内存写入源,不撤销消费者借用。
备注
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)¶
消费者排空后,显式恢复离散块采集。
备注
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)¶
检查发布者 IRQ 优先级后,附加可选提示接收端。
备注
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_sequence_info_t¶
- #include <adc.h>
选定模式下不可变的完整扫描时序事实。
备注
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>
使用同一个提供者状态的共享只读方法。
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
公共成员
-
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¶
调用者拥有的可选 ADC 发布观察。
作者 Nexus Team
宏定义
-
NX_ADC_OBSERVATION_DISCONTINUITY¶
函数
-
nx_result_t nx_adc_observer_initialize(nx_adc_observer_t *observer, nx_adc_observation_t *records, size_t count)¶
初始化全新、尚未借用的可选观察存储。
- 参数:
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)¶
仅提供者可执行的冷绑定;第一次 DMA 借用之前验证每个元数据/载荷范围。
- 参数:
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)¶
仅提供者可执行的记录,必须先于对应的 release 发布。
- 参数:
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)¶
只读取当前已取得块的准确 epoch 记录。
- 参数:
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)¶
全部生产者/消费者借用完成 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>
一个借用的软件观察,绝不表示采样孔径。
备注
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>
调用者拥有的可选观察者控制与准确记录。
备注
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.
公共成员
-
nx_stream_t *stream¶
-
nx_adc_observation_t *records¶
-
size_t count¶
-
uint64_t sequence¶
-
bool discontinuity¶
-
nx_stream_t *stream¶
advanced_pwm.h¶
可选固定互补 PWM 与锁存刹车。
作者 Nexus Team
函数
-
nx_result_t nx_advanced_pwm_set_duty(const nx_advanced_pwm_t *port, uint32_t duty_ticks)¶
依据固定声明的 PSC/ARR 与互补通道对暂存占空比。
备注
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)¶
仅刹车未激活且无锁存故障时启用输出。
备注
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)¶
禁用并读回主输出与两个通道源。
备注
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)¶
查询暂存占空比、实际启用状态与锁存刹车事实。
- 参数:
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)¶
仅已禁用且 BKIN 未激活时清除软件故障。
备注
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>
计数使用固定预分频后的时钟;死区使用 tDTS。
-
struct nx_advanced_pwm_ops_t¶
- #include <advanced_pwm.h>
共享不可变控制;配置是冷装配事实。
公共成员
-
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>
不可变身份;控制器状态与配置必须在所有 IRQ 完全退出前保持有效。
can.h¶
经典 CAN 值帧与调用者拥有的邮箱请求。
作者 Nexus Team
宏定义
-
NX_CAN_LOSS_SOFTWARE¶
-
NX_CAN_LOSS_HARDWARE_LOWER_BOUND¶
-
NX_CAN_LOSS_SATURATED¶
-
NX_CAN_DLC_NORMALIZED¶
枚举
函数
-
nx_result_t nx_can_tx_prepare(nx_can_tx_request_t *request, const nx_can_frame_t *frame, nx_time_us_t deadline)¶
验证并复制经典帧到未被借用的请求存储。
备注
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)¶
将一个帧准入到三个硬件邮箱之一。
备注
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)¶
请求中止,不撤销请求借用。
备注
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)¶
处理锁存完成状态与绝对超时/排空截止时间。
备注
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)¶
消费值事件,不覆盖此前尚未消费的事实。
备注
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)¶
即使 RX 已满,仍复制权威错误/准入状态。
备注
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)¶
关闭准入、中止 TX、撤离 IRQ/RX 发布者。
备注
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)¶
bus-off 且完整排空之后,显式重新进入初始化。
备注
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)¶
检查全部四个实际 IRQ 后,借用可选唤醒目标。
备注
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_event_t¶
- #include <can.h>
值接收事实或有序丢失边界。
备注
Timestamp is IRQ acquisition/report time, not hardware SOF. Hardware overrun proves only a lower bound. Raw DLC 9..15 is normalized to 8.
公共成员
-
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_ops_t¶
- #include <can.h>
共享不可变操作;执行所有者串行执行 Task 方法。
公共成员
-
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¶
显式 DMA 内存域、物理流与排空事实。
作者 Nexus Team
枚举
函数
-
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)¶
验证整个缓冲区位于一个显式内存域内。
备注
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)¶
拒绝装配资源集合中重复的物理流。
备注
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)¶
分别要求 DMA 引擎、IRQ 与外设排空。
备注
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>
已审查的 DMA 可见内存区间,不等同于 CPU 可访问性。
备注
begin plus size must not wrap. Cache maintenance remains a provider responsibility on cached architectures.
ethernet.h¶
调用者拥有的无标签 Ethernet II 帧与接收借用。
作者 Nexus Team
宏定义
-
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¶
函数
-
nx_result_t nx_eth_tx_prepare(nx_eth_tx_request_t *request, const void *data, size_t length, nx_time_us_t deadline)¶
准备已初始化、未借用的请求及不可变帧。
备注
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)¶
将一个帧准入到调用者拥有的硬件描述符。
备注
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)¶
关闭 TX 准入并排空共享 TX 引擎,不重放传输。
备注
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 所有者有界推进;不含执行任务、锁、池或等待。
- 参数:
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 消费者取得完整帧借用;EMPTY 不产生借用。
- 参数:
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)¶
消费者最后一次访问;拒绝过期、外来及重复释放。
备注
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)¶
复制锁存的实例/链路/错误事实;不保留输出。
- 参数:
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)¶
应用外部 PHY 观察,不自动协商或虚构链路。
备注
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)¶
关闭准入,通过读回确认撤离 MAC/DMA/IRQ 源。
备注
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)¶
验证实际 IRQ 策略后绑定可选借用提示。
备注
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>
调用者拥有的不可变连续帧,不含硬件 FCS。
-
struct nx_eth_link_t¶
- #include <ethernet.h>
观察到的 PHY 事实,由外部链路所有者显式供给。
-
struct nx_eth_rx_frame_t¶
- #include <ethernet.h>
完整不可变帧;释放必须匹配准确实例世代。
备注
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>
锁存事实不因接收背压或唤醒提示失败而丢失。
-
struct nx_eth_ops_t¶
- #include <ethernet.h>
公共成员
-
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¶
静态 EXTI 线路绑定、有界事件存储与排空。
作者 Nexus Team
类型定义
-
typedef struct nx_exti_port nx_exti_port_t¶
枚举
函数
-
nx_result_t nx_exti_port_read(const nx_exti_port_t *port, nx_exti_event_t *events, size_t capacity, size_t *count)¶
从准确静态线路绑定读取排队 EXTI 事件。
- 参数:
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)¶
禁用线路源、清除 pending 并排空处理函数。
备注
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)¶
附加或解除显式事件/丢失 IRQ 唤醒目标。
备注
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>
边沿事实;时间戳精度与合并行为由提供者决定。
备注
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>
使用同一个提供者状态的共享只读方法。
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
公共成员
-
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¶
完整物理 Flash 几何与显式有界区域。
作者 Nexus Team
类型定义
-
typedef struct nx_flash_port nx_flash_port_t¶
函数
-
const nx_flash_geometry_t *nx_flash_port_geometry(const nx_flash_port_t *port)¶
无副作用地查询准确物理 Flash 几何。
- 参数:
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)¶
有界读取物理 Flash,不保留目标存储。
- 参数:
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)¶
对齐编程物理 Flash,并结清全部硬件脉冲。
备注
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)¶
擦除完整物理扇区范围,并结清脉冲。
- 参数:
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)¶
根据物理几何验证区域边界。
- 参数:
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)¶
在显式物理区域内读取。
- 参数:
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)¶
在显式可写物理区域内编程。
- 参数:
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)¶
在可写区域内擦除完整物理扇区。
- 参数:
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_ops_t¶
- #include <flash.h>
使用同一个提供者状态的共享只读方法。
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
公共成员
-
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¶
固定 GPIO 授权掩码与有界端口操作。
作者 Nexus Team
类型定义
-
typedef struct nx_gpio_port nx_gpio_port_t¶
函数
-
nx_result_t nx_gpio_port_write(const nx_gpio_port_t *port, uint32_t set_mask, uint32_t reset_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)¶
读取受绑定掩码限制的单次输入快照。
- 参数:
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)¶
在单写者合同下翻转授权输出。
备注
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>
使用同一个提供者状态的共享只读方法。
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
公共成员
-
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¶
地址端点、重复 START 与显式 STOP 结清。
作者 Nexus Team
函数
-
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)¶
执行一个轮询、7 位地址消息事务。
备注
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)¶
总线故障后恢复空闲控制器。
- 参数:
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)¶
准备未借用请求,不复制载荷。
备注
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)¶
验证有限描述符以及载荷/控制存储分离。
备注
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)¶
准入一个有限、异步、重复 START 事务。
备注
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)¶
启动已借用的 QUEUED 请求,不重复准入。
备注
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)¶
证明控制器身份,不产生硬件效果。
- 参数:
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)¶
请求取消,不回收任何存储。
- 参数:
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)¶
在有界 Task 上下文处理截止时间,并推进 STOP/DMA 排空。
备注
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)¶
关闭准入,全部借用者排空后才停止。
- 参数:
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)¶
检查实际 IRQ 策略后附加一个可选提示接收端。
备注
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_request_t¶
- #include <i2c.h>
调用者拥有的有限消息序列。
备注
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>
使用同一个提供者状态的共享只读方法。
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
公共成员
-
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>
指向调用者自有状态的不可变接口。
备注
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>
使用同一个提供者状态的共享只读方法。
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
公共成员
-
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¶
显式开漏 I2C 总线清理,保留租约。
作者 Nexus Team
宏定义
-
NX_I2C_BUS_CLEAR_MAX_PULSES¶
每次尝试中允许完成的恢复低/高电平周期上限。
函数
-
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)¶
绑定显式电气操作,不接触引脚。
- 参数:
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)¶
用至多九个脉冲清理一个空闲、已授权总线。
备注
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)¶
仅重试保留的 STOP 清理与所有权归还。
- 参数:
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>
授权双引脚 GPIO 交接的只读方法。
备注
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.
公共成员
-
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>
显式不可变 GPIO 方法与调用者拥有的适配器状态。
-
struct nx_i2c_bus_clear_timing_t¶
- #include <i2c_bus_clear.h>
调用者选择的电气时序,单位为微秒。
备注
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>
分别记录恢复结果与 STOP/所有权归还结果。
备注
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.
-
struct nx_i2c_bus_clear_t¶
- #include <i2c_bus_clear.h>
调用者拥有、零初始化的单执行者会话。
备注
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.
公共成员
-
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¶
使用绝对截止时间的窄接口 Clause22 站点管理。
作者 Nexus Team
函数
-
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)¶
读取一个 Clause22 PHY 寄存器,不保留输出存储。
备注
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)¶
写入一个 Clause22 PHY 寄存器,不实现特定 PHY 策略序列。
备注
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>
公共成员
-
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¶
显式主机模型夹具,不建立物理 MCU 资格。
作者 Nexus Team
函数
-
nx_result_t nx_native_clock_configure(bool enabled, nx_time_us_t now)¶
将主机模型切换到确定性时钟域。
- 参数:
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)¶
推进确定性时间,不隐式触发硬件 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)¶
写者静止后配置固定 GPIO 模型。
- 参数:
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)¶
在确定性模型中注入一个 GPIO 输入快照。
- 参数:
value – [in] Physical-port snapshot; read masks unauthorized bits.
-
uint32_t nx_native_gpio_output(void)¶
观察输出状态,用于主机行为断言。
- 返回:
Model output snapshot; no measured waveform semantics.
-
nx_result_t nx_native_uart_configure(const nx_native_uart_config_t *config)¶
在固定 UART 上配置准确的 RX/TX 夹具容量。
- 参数:
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)¶
为选定 RS485 绑定验证准确 Native TX 上下文。
备注
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)¶
将显式 IRQ 事实复制到静止的主机 UART 模型。
备注
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)¶
执行一个确定性 TX IRQ 字节/TC 事件。
备注
No actual hardware IRQ, latency or wire timing is simulated.
-
nx_result_t nx_native_uart_receive(uint8_t byte, uint32_t flags)¶
将一个 RX IRQ 事实注入有界、选定配置的存储。
- 参数:
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)¶
配置启动失败或无法证明硬件排空。
- 参数:
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)¶
观察捕获的 TX 字节。
- 返回:
Number captured in caller-owned tx_log.
-
nx_result_t nx_native_spi_configure(uint8_t *registers, size_t length)¶
配置固定 SPI 回显或寄存器文件模型。
- 参数:
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)¶
注入有界 SPI 部分失败或控制器占用。
- 参数:
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)¶
事务结束后检查模型 CS 电平。
- 返回:
True while model transaction owns active CS.
-
nx_result_t nx_native_i2c_configure(uint8_t *memory, size_t length, uint8_t address)¶
配置一个 7 位地址的寄存器文件 I2C 模型。
- 参数:
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)¶
注入 NACK、仲裁丢失或总线卡死。
- 参数:
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)¶
配置物理几何 RAM 模型,明确不具备持久性。
- 参数:
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)¶
完整模型脉冲之后注入编程/擦除失败。
- 参数:
pulse_count – [in] Complete pulses allowed; SIZE_MAX disables fault.
-
void nx_native_watchdog_boot(uint32_t causes)¶
复位看门狗夹具,模拟新一次启动。
备注
Test-only; production IWDG cannot be disabled by this action.
- 参数:
causes – [in] Latched reset cause mask.
-
bool nx_native_watchdog_expired(void)¶
观察已启用确定性 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)¶
为一个静态 EXTI 线路配置准确存储。
- 参数:
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)¶
注入一个带时间戳的选定边沿事实。
- 参数:
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)¶
写者静止后配置固定 PWM 模型定时器事实。
- 参数:
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)¶
配置固定 ADC 原始计数序列与格式。
- 参数:
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)¶
若干完整样本之后注入 ADC 失败。
- 参数:
sample_count – [in] Complete samples allowed; SIZE_MAX disables.
-
void nx_native_gpio_model_input(const nx_gpio_port_t *binding, uint32_t value)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
仅操作选定的 Native 模型接口面。
备注
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)¶
选择显式或自动模型 SPI IRQ 推进。
备注
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)¶
在准确 Native 总线上注入一个有界 SPI 字节/空闲事件。
-
void nx_native_spi_model_drain_hold(const nx_spi_port_t *binding, bool hold)¶
注入无法证明 SPI 硬件排空的失败。
备注
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)¶
注入 UART IDLE,并发布当前有效字节前缀。
- 返回:
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)¶
向选定空闲块注入一次 ADC 定时器触发扫描。
备注
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.
变量
-
const nx_gpio_port_t *const nx_native_gpio¶
固定模型绑定;不分配、不查找、不探测、不构造。
-
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¶
单执行者轮询 SPI 端点与完整 CS 事务。
作者 Nexus Team
函数
-
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)¶
执行一个有界、全双工、8 位轮询事务。
备注
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)¶
保留故障后恢复空闲 SPI 控制器。
- 参数:
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)¶
准备未借用的有限请求,不复制缓冲区。
- 参数:
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)¶
提交一个有限、异步、覆盖整个 CS 区间的事务。
备注
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)¶
提交显式递增或单元素 DMA 内存。
备注
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)¶
启动适配器已准入的 QUEUED 请求,不重复准入。
- 参数:
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)¶
验证端点属于所推进的总线。
备注
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)¶
请求取消,不撤销 DMA/CS 缓冲区借用。
备注
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)¶
由唯一 Task 执行者推进一个异步总线。
备注
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)¶
关闭准入,完整排空之前保留活动源。
- 参数:
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)¶
向异步总线 IRQ 发布者附加可选提示接收端。
备注
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>
调用者拥有的有限 SPI 请求,包含一个完整 CS 区间。
备注
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>
使用同一个提供者状态的共享只读方法。
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
公共成员
-
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>
指向调用者自有状态的不可变接口。
备注
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>
使用同一个提供者状态的共享只读方法。
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
公共成员
-
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¶
调用者拥有的有界块与显式生产者/消费者借用。
作者 Nexus Team
宏定义
-
NX_STREAM_BOUNDARY_IDLE¶
-
NX_STREAM_BOUNDARY_TRIGGER¶
-
NX_STREAM_BOUNDARY_LOSS¶
-
NX_STREAM_BOUNDARY_ERROR¶
枚举
函数
-
nx_result_t nx_stream_initialize(nx_stream_t *stream, nx_stream_slot_t *slots, size_t count)¶
初始化未借用的 stream 与准确供给的块数组。
备注
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)¶
为一个串行生产者预留下一个空闲块。
备注
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)¶
查询下一个物理槽,不产生借用或丢失。
备注
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)¶
锁存明确观察到的生产者丢弃边界。
备注
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)¶
全部硬件写引用撤离后,发布完整块。
备注
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)¶
一个串行消费者取得下一个就绪块。
备注
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)¶
最终使用之后,仅释放匹配的消费者实例世代。
备注
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)¶
仅内存写入源撤离之后中止生产者借用。
备注
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)¶
关闭生产者准入,保留每一个未结清借用。
备注
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)¶
将预提交生产者绑定到静止、已初始化的 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)¶
查询下一个预提交槽,不产生借用或猜测丢失。
备注
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)¶
预留未来填充,不提前使更早的块就绪。
备注
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)¶
仅发布最早 pending 且已撤离引用的生产者借用。
备注
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)¶
证明内存排空后,取消最新 pending 填充。
备注
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>
调用者拥有的块元数据;仅初始化 data 与 capacity。
备注
Storage remains live through producer and consumer quiescence.
-
struct nx_stream_t¶
- #include <stream.h>
调用者拥有的 stream 控制,必须先初始化再发布。
备注
outstanding counts nonfree blocks, including filling, ready and borrowed states. Only stream operations mutate it.
-
struct nx_stream_producer_t¶
- #include <stream.h>
调用者显式选择的预提交生产者,不产生默认成本。
备注
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¶
可选恒定工作量快照与经过检查的冷态容量计算。
作者 Nexus Team
函数
-
nx_result_t nx_stream_observe(const nx_stream_t *stream, nx_stream_observation_t *out)¶
在一个短 IRQ 临界区内快照维护的元数据。
备注
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)¶
经过检查的冷态计算,不修改 stream 或分配存储。
备注
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) 汇总事实;总空闲容量不证明游标位置空闲。
-
struct nx_stream_budget_t¶
- #include <stream_budget.h>
显式工程假设,不推断硬件速率。
备注
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.
公共成员
-
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>
依据声明假设得到的保守预算,绝不作为物理证据。
timer.h¶
固定定时器/通道 PWM,共享同一个基准配置。
作者 Nexus Team
类型定义
-
typedef struct nx_pwm_port nx_pwm_port_t¶
函数
-
nx_result_t nx_pwm_port_set(const nx_pwm_port_t *port, uint32_t period_ticks, uint32_t duty_ticks)¶
原子暂存已审查固定基准 PWM 的占空比。
备注
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)¶
启用此前已配置的固定 PWM 输出。
- 参数:
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)¶
以声明的 Board 非活动电气电平停止 PWM。
- 参数:
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)¶
查询暂存 PWM 计数与选定定时器时钟。
- 参数:
port – [in] Fixed initialized channel.
state – [out] Staged counts, clock and running state.
- 返回:
Success or INVALID.
-
struct nx_pwm_ops_t¶
- #include <timer.h>
使用同一个提供者状态的共享只读方法。
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
公共成员
-
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¶
可选原始定时器边沿捕获与调用者拥有的事件。
作者 Nexus Team
枚举
函数
-
nx_result_t nx_timer_capture_start(const nx_timer_capture_t *port, nx_timer_capture_event_t *events, size_t capacity)¶
借用准确事件环并启用固定捕获通道。
备注
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)¶
归还存储之前禁用并读回通道/IRQ 源。
备注
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)¶
在短且保存原屏蔽状态的元数据临界区内复制最早事件。
- 参数:
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)¶
查询计数器单位与可观察队列/丢失事实。
备注
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>
硬件模计数器与独立的 IRQ 观察时间。
-
struct nx_timer_capture_state_t¶
- #include <timer_capture.h>
固定计数器单位与当前软件保留状态。
-
struct nx_timer_capture_ops_t¶
- #include <timer_capture.h>
共享不可变方法;不逐次取得资源或分配。
公共成员
-
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>
不可变身份;状态和方法必须在所有调用与 IRQ 完全退出前保持有效。
uart.h¶
IRQ TX 请求与分别预算的字节/事件接收。
作者 Nexus Team
宏定义
-
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¶
类型定义
-
typedef struct nx_uart_port nx_uart_port_t¶
枚举
函数
-
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)¶
准备未借用 IRQ TX 描述符,不复制数据。
- 参数:
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)¶
向单执行者 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)¶
启动适配器已准入的 QUEUED 请求,不重复准入。
- 参数:
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)¶
请求取消;接受取消不表示请求结清。
- 参数:
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)¶
观察时间/硬件完成并排空一个活动请求。
备注
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)¶
从选定事件配置读取缓冲的 RX 事件。
- 参数:
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)¶
从选定字节配置读取缓冲字节。
- 参数:
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)¶
关闭准入,并在释放硬件之前排空 TX。
备注
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)¶
附加或解除一个显式 IRQ 唤醒目标。
备注
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)¶
使用调用者准确存储启动选定 RX 块模式。
备注
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)¶
停止 RX 块生产,不撤销消费者借用。
备注
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>
时间戳属于提供者时钟;精度由硬件决定。
备注
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_ops_t¶
- #include <uart.h>
使用同一个提供者状态的共享只读方法。
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
公共成员
-
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¶
可选单所有者 RS485 方向与线尾适配器。
作者 Nexus Team
类型定义
-
typedef nx_result_t (*nx_uart_tx_validate_fn)(void *context, const nx_uart_tx_request_t *request)¶
准确传输端口的无副作用 TX 准入验证器。
备注
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.
- 参数 context:
[in] The immutable transport face’s exact context.
- 参数 request:
[in] Live READY or QUEUED descriptor, never retained.
- 返回值:
Same rejectable checks used by the transport submit/start.
函数
-
nx_result_t nx_uart_rs485_initialize(nx_uart_rs485_state_t *state, const nx_uart_rs485_config_t *config)¶
绑定独占传输端口并建立非活动 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.
变量
-
const nx_uart_ops_t nx_uart_rs485_ops¶
-
struct nx_uart_rs485_config_t¶
- #include <uart_rs485.h>
不可变的选定电气/时序事实,不含任务或堆。
备注
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.
公共成员
-
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>
调用者显式选择的适配器,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.
公共成员
-
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¶
全速设备数据包与调用者拥有的端点借用。
作者 Nexus Team
枚举
函数
-
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)¶
准备一个 IN 数据包,不读取或借用其字节。
- 参数:
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)¶
准备 OUT 数据包容量,不修改其存储。
- 参数:
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)¶
仅准入一个数据包,不隐式建立队列或执行完整 USB 事务。
备注
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)¶
请求端点禁用/排空,不撤销缓冲区借用。
备注
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)¶
仅端点无存活传输时设置/清除 STALL。
- 参数:
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 有界推进;截止时间绝不依赖 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)¶
消费有界值事件,绝不保留输出。
备注
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 的权威快照,与事件环可用空间无关。
- 参数:
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)¶
为匹配的零数据标准 SETUP 暂存 SET_ADDRESS。
- 参数:
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)¶
附加/解除被借用且兼容 Task/IRQ 的唤醒提示。
- 参数:
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)¶
断开连接、禁用、排空、撤离 IRQ,再释放时钟消费者。
备注
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>
公共成员
-
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>
-
struct nx_usb_device_state_t¶
- #include <usb_device.h>
-
struct nx_usb_endpoint_ops_t¶
- #include <usb_device.h>
共享只读数据包方法;上下文为选定端点。
公共成员
-
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>
控制器身份与端点身份保持分离。
公共成员
-
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¶
显式借用 IRQ 唤醒目标与系统调用阈值检查。
作者 Nexus Team
枚举
函数
-
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)¶
依据显式内核策略验证实际 IRQ 事实。
备注
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)¶
权威状态锁存后发送一个有界提示。
备注
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>
IRQ 提供者借用的可选不可变唤醒目标。
备注
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>
用于冷态唤醒绑定的不可变 CPU 与内核事实。
备注
NONE and PRIMASK require a zero syscall ceiling. BASEPRI requires a nonzero unshifted ceiling. Configuration owns these facts; a wake target cannot weaken them.
公共成员
-
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¶
不可逆 IWDG 效果与中立硬件复位原因。
作者 Nexus Team
宏定义
-
NX_RESET_POWER_ON¶
-
NX_RESET_PIN¶
-
NX_RESET_SOFTWARE¶
-
NX_RESET_IWDG¶
-
NX_RESET_WWDG¶
-
NX_RESET_LOW_POWER¶
-
NX_RESET_BROWNOUT¶
类型定义
-
typedef struct nx_watchdog_port nx_watchdog_port_t¶
函数
-
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)¶
在已审查边界内启用 IWDG;激活不可逆。
- 参数:
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)¶
喂已启用 IWDG,不改变产品健康策略。
- 参数:
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)¶
查询当前看门狗效果与超时不确定性。
- 参数:
port – [in] Fixed provider.
state – [out] Current hardware/remembered initialization state.
- 返回:
Success or INVALID.
-
uint32_t nx_reset_cause(void)¶
读取清除标志前捕获的锁存启动复位原因。
备注
No implicit acknowledgement, reboot or product classification.
- 返回:
Bitmask of NX_RESET_*; multiple causes may be reported.
-
struct nx_watchdog_state_t¶
- #include <watchdog.h>
硬件选定的超时边界,包含声明的 LSI 不确定性。
-
struct nx_watchdog_ops_t¶
- #include <watchdog.h>
使用同一个提供者状态的共享只读方法。
备注
Methods follow each public operation’s ownership contract. Missing optional methods report UNSUPPORTED.
公共成员
-
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>
指向调用者自有状态的不可变接口。
备注
Face and state outlive callers, IRQs and retained borrows. Factory lookup neither initializes nor acquires hardware.