libjoybus
Joybus implementation for 32-bit MCUs
Loading...
Searching...
No Matches
target.h
1
5
6#pragma once
7
8#include <stdint.h>
9
10struct joybus_target;
11
15#define JOYBUS_TARGET(target) ((struct joybus_target *)(target))
16
24typedef void (*joybus_target_response_cb_t)(const uint8_t *response, uint8_t len, void *user_data);
25
26// API for a Joybus target.
38 int (*byte_received)(struct joybus_target *target, const uint8_t *command, uint8_t byte_idx,
39 joybus_target_response_cb_t send_response, void *user_data);
40};
41
46 const struct joybus_target_api *api;
47};
48
59static inline int joybus_target_byte_received(struct joybus_target *target, const uint8_t *command, uint8_t byte_idx,
60 joybus_target_response_cb_t send_response, void *user_data)
61{
62 return target->api->byte_received(target, command, byte_idx, send_response, user_data);
63}
64
void(* joybus_target_response_cb_t)(const uint8_t *response, uint8_t len, void *user_data)
Callback type for sending responses from target command handlers.
Definition target.h:24
static int joybus_target_byte_received(struct joybus_target *target, const uint8_t *command, uint8_t byte_idx, joybus_target_response_cb_t send_response, void *user_data)
Handle a received command byte for a Joybus target.
Definition target.h:59
Definition target.h:27
int(* byte_received)(struct joybus_target *target, const uint8_t *command, uint8_t byte_idx, joybus_target_response_cb_t send_response, void *user_data)
Handle a received command byte.
Definition target.h:38
A Joybus target, a device on the Joybus that can respond to commands.
Definition target.h:45