Nexus Embedded Platform 1.0.0
Statically assembled reusable embedded mechanisms
Loading...
Searching...
No Matches
i2c.h
Go to the documentation of this file.
1
9#ifndef NEXUS_I2C_H
10#define NEXUS_I2C_H
11
12#include "nexus/core/request.h"
13#include "nexus/io/wake.h"
14#ifdef __cplusplus
15extern "C" {
16#endif
22#define NX_I2C_MAX_MESSAGES 8U
23#define NX_I2C_MAX_MESSAGE_BYTES 256U
28typedef struct {
29 uint8_t* data;
30 size_t length;
31 bool read;
33
45
52typedef struct {
53 nx_result_t (*recover)(void* context);
54 nx_result_t (*cancel)(void* context, nx_i2c_request_t* request);
55 void (*service)(void* context);
56 nx_result_t (*stop)(void* context);
57 nx_result_t (*attach_wake)(void* context, const nx_irq_wake_t* wake,
58 uint8_t syscall_ceiling);
60
68 void* context;
69};
70
77typedef struct {
78 nx_result_t (*transaction)(void* context, nx_i2c_message_t* messages,
79 size_t count, nx_time_us_t deadline,
80 size_t* transferred);
81 nx_result_t (*submit)(void* context, nx_i2c_request_t* request);
82 nx_result_t (*start_admitted)(void* context, nx_i2c_request_t* request);
83 bool (*on_port)(const void* context, const nx_i2c_port_t* port);
85
95
120 nx_i2c_message_t* messages,
121 size_t count, nx_time_us_t deadline,
122 size_t* transferred);
132
144 nx_i2c_message_t* messages, size_t count,
145 nx_time_us_t deadline);
165 nx_i2c_request_t* request);
175 nx_i2c_request_t* request);
183 const nx_i2c_port_t* port);
191 nx_i2c_request_t* request);
215 const nx_irq_wake_t* wake,
216 uint8_t syscall_ceiling);
217#ifdef __cplusplus
218}
219#endif
220
221#endif
nx_result_t nx_i2c_port_attach_wake(const nx_i2c_port_t *port, const nx_irq_wake_t *wake, uint8_t syscall_ceiling)
Attach one optional hint sink after actual IRQ policy checks.
void nx_i2c_port_service(const nx_i2c_port_t *port)
Advance deadline and STOP/DMA drain in bounded task context.
bool nx_i2c_endpoint_on_port(const nx_i2c_endpoint_t *endpoint, const nx_i2c_port_t *port)
Prove controller identity without hardware effects.
nx_result_t nx_i2c_endpoint_submit(const nx_i2c_endpoint_t *endpoint, nx_i2c_request_t *request)
Admit one finite asynchronous repeated-START transaction.
struct nx_i2c_endpoint nx_i2c_endpoint_t
Definition i2c.h:18
struct nx_i2c_port nx_i2c_port_t
Definition i2c.h:17
nx_result_t nx_i2c_endpoint_transaction(const nx_i2c_endpoint_t *endpoint, nx_i2c_message_t *messages, size_t count, nx_time_us_t deadline, size_t *transferred)
Execute a polling 7-bit-address message transaction.
nx_result_t nx_i2c_port_stop(const nx_i2c_port_t *port)
Close admission and stop only after every borrower drains.
nx_result_t nx_i2c_request_validate(const nx_i2c_request_t *request)
Validate finite descriptors and payload/control separation.
nx_result_t nx_i2c_endpoint_start_admitted(const nx_i2c_endpoint_t *endpoint, nx_i2c_request_t *request)
Start an already borrowed QUEUED request without readmission.
nx_result_t nx_i2c_port_cancel(const nx_i2c_port_t *port, nx_i2c_request_t *request)
Request cancellation without reclaiming any storage.
nx_result_t nx_i2c_request_prepare(nx_i2c_request_t *request, nx_i2c_message_t *messages, size_t count, nx_time_us_t deadline)
Prepare an unborrowed request without copying payload.
nx_result_t nx_i2c_port_recover(const nx_i2c_port_t *port)
Recover an idle controller after a bus fault.
Caller-owned admission, borrow, settlement and stable cancellation.
nx_result_t
Operation result; success at submission means admission only.
Definition status.h:21
Shared read-only methods using one provider state.
Definition i2c.h:77
bool(* on_port)(const void *context, const nx_i2c_port_t *port)
Definition i2c.h:83
nx_result_t(* submit)(void *context, nx_i2c_request_t *request)
Definition i2c.h:81
nx_result_t(* transaction)(void *context, nx_i2c_message_t *messages, size_t count, nx_time_us_t deadline, size_t *transferred)
Definition i2c.h:78
nx_result_t(* start_admitted)(void *context, nx_i2c_request_t *request)
Definition i2c.h:82
Immutable interface pointing to caller-owned state.
Definition i2c.h:91
void * context
Definition i2c.h:93
const nx_i2c_endpoint_ops_t * ops
Definition i2c.h:92
One message; a new message starts with repeated START, final with STOP.
Definition i2c.h:28
size_t length
Definition i2c.h:30
bool read
Definition i2c.h:31
uint8_t * data
Definition i2c.h:29
Shared read-only methods using one provider state.
Definition i2c.h:52
nx_result_t(* attach_wake)(void *context, const nx_irq_wake_t *wake, uint8_t syscall_ceiling)
Definition i2c.h:57
nx_result_t(* cancel)(void *context, nx_i2c_request_t *request)
Definition i2c.h:54
void(* service)(void *context)
Definition i2c.h:55
nx_result_t(* recover)(void *context)
Definition i2c.h:53
nx_result_t(* stop)(void *context)
Definition i2c.h:56
Immutable interface pointing to caller-owned state.
Definition i2c.h:66
void * context
Definition i2c.h:68
const nx_i2c_ops_t * ops
Definition i2c.h:67
Caller-owned finite message sequence.
Definition i2c.h:40
nx_request_t base
Definition i2c.h:41
nx_i2c_message_t * messages
Definition i2c.h:42
size_t count
Definition i2c.h:43
Optional immutable wake target borrowed by an IRQ provider.
Definition wake.h:26
Caller-owned request metadata, without payload or callbacks.
Definition request.h:38
uint64_t nx_time_us_t
Microseconds in one boot/clock domain; no wall-clock semantics.
Definition time.h:20
Explicit borrowed IRQ wake target and syscall-ceiling check.