NHAL Interface
v0.5.0
Hardware Abstraction Layer Interface for Embedded Systems
Loading...
Searching...
No Matches
include
nhal_i2c_types.h
Go to the documentation of this file.
1
8
#ifndef NHAL_I2C_TYPES_H
9
#define NHAL_I2C_TYPES_H
10
11
#include <stddef.h>
12
#include <stdint.h>
13
14
#include "
nhal_common.h
"
15
16
typedef
uint8_t
nhal_i2c_bus_id
;
17
typedef
uint16_t
nhal_i2c_address
;
18
19
struct
nhal_i2c_config
{
20
uint32_t
clock_speed_hz
;
21
struct
nhal_i2c_impl_config *
impl_config
;
22
};
23
27
struct
nhal_i2c_context
{
28
nhal_i2c_bus_id
i2c_bus_id
;
29
30
struct
nhal_i2c_impl_ctx *
impl_ctx
;
31
32
// Async extensions handled separately in async context
33
};
34
35
36
typedef
enum
{
37
NHAL_I2C_TRANSFER_MSG_WRITE
= 1,
38
NHAL_I2C_TRANSFER_MSG_READ
= 1<<1,
39
NHAL_I2C_TRANSFER_MSG_TEN_BIT_ADDR
= 1<<2,
40
NHAL_I2C_TRANSFER_MSG_NO_START
= 1<<3,
42
NHAL_I2C_TRANSFER_MSG_NO_STOP
= 1<<4,
44
NHAL_I2C_TRANSFER_MSG_NO_ADDR
= 1<<5
45
}
nhal_i2c_transfer_bit_flags_t
;
46
52
typedef
struct
{
53
nhal_i2c_address
address
;
56
uint16_t
flags
;
62
union
{
66
struct
{
67
uint8_t *
buffer
;
68
size_t
length
;
69
} read;
73
struct
{
74
const
uint8_t *
bytes
;
75
size_t
length;
76
} write;
77
};
78
}
nhal_i2c_transfer_op_t
;
79
80
#endif
/* NHAL_I2C_TYPES_H */
nhal_common.h
nhal_i2c_transfer_bit_flags_t
nhal_i2c_transfer_bit_flags_t
Definition
nhal_i2c_types.h:36
NHAL_I2C_TRANSFER_MSG_NO_ADDR
@ NHAL_I2C_TRANSFER_MSG_NO_ADDR
Do not write the address first in this op.
Definition
nhal_i2c_types.h:44
NHAL_I2C_TRANSFER_MSG_READ
@ NHAL_I2C_TRANSFER_MSG_READ
Message is a read operation.
Definition
nhal_i2c_types.h:38
NHAL_I2C_TRANSFER_MSG_TEN_BIT_ADDR
@ NHAL_I2C_TRANSFER_MSG_TEN_BIT_ADDR
Use 10-bit addressing for this message.
Definition
nhal_i2c_types.h:39
NHAL_I2C_TRANSFER_MSG_NO_STOP
@ NHAL_I2C_TRANSFER_MSG_NO_STOP
Do not send a STOP condition after this message.
Definition
nhal_i2c_types.h:42
NHAL_I2C_TRANSFER_MSG_NO_START
@ NHAL_I2C_TRANSFER_MSG_NO_START
Do not send a START condition before this message.
Definition
nhal_i2c_types.h:40
NHAL_I2C_TRANSFER_MSG_WRITE
@ NHAL_I2C_TRANSFER_MSG_WRITE
Message is a write operation (default).
Definition
nhal_i2c_types.h:37
nhal_i2c_address
uint16_t nhal_i2c_address
Definition
nhal_i2c_types.h:17
nhal_i2c_bus_id
uint8_t nhal_i2c_bus_id
Definition
nhal_i2c_types.h:16
nhal_i2c_config
Definition
nhal_i2c_types.h:19
nhal_i2c_config::clock_speed_hz
uint32_t clock_speed_hz
Definition
nhal_i2c_types.h:20
nhal_i2c_config::impl_config
struct nhal_i2c_impl_config * impl_config
Definition
nhal_i2c_types.h:21
nhal_i2c_context
Base I2C context - always present, minimal footprint.
Definition
nhal_i2c_types.h:27
nhal_i2c_context::i2c_bus_id
nhal_i2c_bus_id i2c_bus_id
Definition
nhal_i2c_types.h:28
nhal_i2c_context::impl_ctx
struct nhal_i2c_impl_ctx * impl_ctx
Definition
nhal_i2c_types.h:30
nhal_i2c_transfer_op_t
Structure describing a single I2C message segment within a transaction.
Definition
nhal_i2c_types.h:52
nhal_i2c_transfer_op_t::buffer
uint8_t * buffer
Pointer to buffer for received data (must be writable).
Definition
nhal_i2c_types.h:67
nhal_i2c_transfer_op_t::flags
uint16_t flags
Combination of nhal_i2c_transfer_bit_flags_t for this segment.
Definition
nhal_i2c_types.h:56
nhal_i2c_transfer_op_t::bytes
const uint8_t * bytes
Pointer to data to send (must be readable).
Definition
nhal_i2c_types.h:74
nhal_i2c_transfer_op_t::length
size_t length
Number of bytes to read into the buffer.
Definition
nhal_i2c_types.h:68
nhal_i2c_transfer_op_t::address
nhal_i2c_address address
7-bit or 10-bit address for this message segment.
Definition
nhal_i2c_types.h:53
Generated by
1.9.8