60#define SMBUS_CMD_ENTRY(_cmd, _pec, _trans_type, _rcv, _send) \
63 .def = {.pec = (_pec), \
64 .trans_type = (_trans_type), \
65 .rcv_handler = (_rcv), \
66 .send_handler = (_send)}, \
72#define SMBUS_CMD_HANDLER_FIELDS_WRITE(_func) .rcv_handler = (_func), .send_handler = NULL
77#define SMBUS_CMD_HANDLER_FIELDS_READ(_func) .rcv_handler = NULL, .send_handler = (_func)
84#define SMBUS_CMD_GEN_ENTRY(_cmd, _pec, _dir, _kind, _func) \
87 .def = {.pec = (_pec), \
88 .trans_type = SMBUS_TRANS_##_dir##_##_kind, \
89 SMBUS_CMD_HANDLER_FIELDS_##_dir(_func)}, \
95#define SMBUS_CMD_BLOCK_RD_ENTRY(_cmd, _pec, _send) \
96 SMBUS_CMD_GEN_ENTRY(_cmd, _pec, READ, BLOCK, _send)
101#define SMBUS_CMD_BLOCK_WR_ENTRY(_cmd, _pec, _rcv) \
102 SMBUS_CMD_GEN_ENTRY(_cmd, _pec, WRITE, BLOCK, _rcv)
107#define SMBUS_CMD_READ_BYTE_ENTRY(_cmd, _pec, _send) \
108 SMBUS_CMD_GEN_ENTRY(_cmd, _pec, READ, BYTE, _send)
113#define SMBUS_CMD_WRITE_BYTE_ENTRY(_cmd, _pec, _rcv) \
114 SMBUS_CMD_GEN_ENTRY(_cmd, _pec, WRITE, BYTE, _rcv)
119#define SMBUS_CMD_READ_WORD_ENTRY(_cmd, _pec, _send) \
120 SMBUS_CMD_GEN_ENTRY(_cmd, _pec, READ, WORD, _send)
125#define SMBUS_CMD_WRITE_WORD_ENTRY(_cmd, _pec, _rcv) \
126 SMBUS_CMD_GEN_ENTRY(_cmd, _pec, WRITE, WORD, _rcv)
131#define SMBUS_CMD_BLOCK_WR_BLOCK_RD_ENTRY(_cmd, _pec, _rcv, _send) \
132 SMBUS_CMD_ENTRY(_cmd, _pec, SMBUS_TRANS_READ_WRITE_BLOCK, _rcv, _send)
int32_t smbus_target_register_cmd(const struct device *dev, uint8_t cmd_id, const struct smbus_cmd_def *smbus_cmd)
Register the given command to the SMBUS target implementation.
Definition smbus_target.c:402
smbus_trans_type
A list of supported SMBUS transaction types.
Definition smbus_target.h:16
@ SMBUS_TRANS_READ_BYTE
Definition smbus_target.h:18
@ SMBUS_TRANS_READ_WRITE_BLOCK
Definition smbus_target.h:23
@ SMBUS_TRANS_WRITE_BYTE
Definition smbus_target.h:17
@ SMBUS_TRANS_WRITE_BLOCK
Definition smbus_target.h:21
@ SMBUS_TRANS_WRITE_WORD
Definition smbus_target.h:19
@ SMBUS_TRANS_READ_BLOCK
Definition smbus_target.h:22
@ SMBUS_TRANS_READ_WORD
Definition smbus_target.h:20
uint32_t smbus_target_get_error_count(const struct device *dev)
Get total number of SMBUS target errors.
Definition smbus_target.c:333
int32_t(* smbus_rcv_handler)(const uint8_t *data, uint8_t size)
Definition of a SMBUS receive handler.
Definition smbus_target.h:32
int32_t smbus_target_register_cmds(const struct device *dev, const struct smbus_cmd_registration *cmds, size_t num_cmds)
Register a table of commands to the SMBUS target implementation.
Definition smbus_target.c:416
int32_t(* smbus_send_handler)(uint8_t *data, uint8_t *size)
Definition of a SMBUS send handler.
Definition smbus_target.h:40
Definition smbus_target.h:42
uint8_t pec
Definition smbus_target.h:46
smbus_rcv_handler rcv_handler
Definition smbus_target.h:44
smbus_send_handler send_handler
Definition smbus_target.h:45
enum smbus_trans_type trans_type
Definition smbus_target.h:43
Command registration entry for table-driven SMBus setup.
Definition smbus_target.h:52
struct smbus_cmd_def def
Definition smbus_target.h:54
uint8_t cmd
Definition smbus_target.h:53