LibJuno 0.23.0
LibJuno is a lightweight C99 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
i2c_io_api.h
Go to the documentation of this file.
1/*
2 MIT License
3
4 Copyright (c) 2025 Robin A. Onsay
5
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files
8 (the "Software"), to deal in the Software without restriction,
9 including without limitation the rights to use, copy, modify, merge,
10 publish, distribute, sublicense, and/or sell copies of the Software,
11 and to permit persons to whom the Software is furnished to do so,
12 subject to the following conditions:
13
14 The above copyright notice and this permission notice shall be
15 included in all copies or substantial portions of the Software.
16*/
17
27#ifndef JUNO_I2C_IO_API_H
28#define JUNO_I2C_IO_API_H
29#include "juno/status.h"
30#include "juno/module.h"
31#include "juno/time/time_api.h"
32#include <stdbool.h>
33#include <stdint.h>
34#ifdef __cplusplus
35extern "C"
36{
37#endif
38
44JUNO_MODULE_DECLARE(JUNO_I2C_IO_T);
45JUNO_MODULE_BASE_DECLARE(JUNO_I2C_IO_BASE_T);
46
53
59
66
73
80
81#define ReadMsg(iAddr, pcBuff, zBuffSize) \
82(JUNO_I2C_IO_MSG_T) \
83{ \
84 .tRead = (JUNO_I2C_IO_MSG_R_T) \
85 { \
86 .tHdr = {JUNO_I2C_IO_MSG_TYPE_R, iAddr}, \
87 .ptReadBuff = pcBuff, \
88 .zReadBuffSize = zBuffSize \
89 } \
90}
91
92#define WriteMsg(iAddr, pvBuff, zBuffSize) \
93(JUNO_I2C_IO_MSG_T) \
94{ \
95 .tWrite = (JUNO_I2C_IO_MSG_W_T) \
96 { \
97 .tHdr = {JUNO_I2C_IO_MSG_TYPE_W, iAddr}, \
98 .ptWriteBuff = pvBuff, \
99 .zWriteBuffSize = zBuffSize \
100 } \
101}
102
104
105#define JUNO_I2C_IO_TRANSFER(...) (JUNO_I2C_IO_MSG_T[]){__VA_ARGS__}
106
108{
120 JUNO_STATUS_T (*Transfer)(JUNO_I2C_IO_T *ptI2c, const JUNO_I2C_IO_MSG_T *ptArrMsgs, size_t zMsgArrLen);
121};
122
123#ifdef __cplusplus
124}
125#endif
126#endif // JUNO_I2C_IO_API_H
enum JUNO_I2C_IO_MSG_TYPE_TAG JUNO_I2C_IO_MSG_TYPE_T
JUNO_I2C_IO_MSG_TYPE_TAG
Definition i2c_io_api.h:48
@ JUNO_I2C_IO_MSG_TYPE_R
Definition i2c_io_api.h:51
@ JUNO_I2C_IO_MSG_TYPE_RESERVED
Definition i2c_io_api.h:49
@ JUNO_I2C_IO_MSG_TYPE_W
Definition i2c_io_api.h:50
#define JUNO_MODULE_BASE(name, API, members)
Definition module.h:81
#define JUNO_MODULE_EMPTY
Definition module.h:50
#define JUNO_MODULE_BASE_DECLARE(name)
Definition module.h:31
#define JUNO_MODULE_DECLARE(name)
Definition module.h:26
enum JUNO_STATUS_TAG JUNO_STATUS_T
Definition i2c_io_api.h:108
JUNO_STATUS_T(* Transfer)(JUNO_I2C_IO_T *ptI2c, const JUNO_I2C_IO_MSG_T *ptArrMsgs, size_t zMsgArrLen)
Definition i2c_io_api.h:120
Definition i2c_io_api.h:55
JUNO_I2C_IO_MSG_TYPE_T tType
Definition i2c_io_api.h:56
uint8_t iAddr
Definition i2c_io_api.h:57
Definition i2c_io_api.h:61
uint8_t * ptReadBuff
Definition i2c_io_api.h:63
size_t zReadBuffSize
Definition i2c_io_api.h:64
JUNO_I2C_IO_MSG_HDR_T tHdr
Definition i2c_io_api.h:62
Definition i2c_io_api.h:68
const void * ptWriteBuff
Definition i2c_io_api.h:70
JUNO_I2C_IO_MSG_HDR_T tHdr
Definition i2c_io_api.h:69
size_t zWriteBuffSize
Definition i2c_io_api.h:71
Definition i2c_io_api.h:75
JUNO_I2C_IO_MSG_W_T tWrite
Definition i2c_io_api.h:77
JUNO_I2C_IO_MSG_HDR_T tHdr
Definition i2c_io_api.h:76
JUNO_I2C_IO_MSG_R_T tRead
Definition i2c_io_api.h:78