Joybus library core functionality.
More...
|
|
#define | JOYBUS_FREQ_GCC 250000 |
| | Bus frequency of an OEM GameCube controller.
|
|
#define | JOYBUS_FREQ_WAVEBIRD 225000 |
| | Bus frequency of WaveBird receiver.
|
|
#define | JOYBUS_FREQ_CONSOLE 200000 |
| | Bus frequency of a console.
|
|
#define | JOYBUS_BLOCK_SIZE 64 |
| | Maximum size of a Joybus transfer, in bytes.
|
|
#define | JOYBUS_INTER_TRANSFER_DELAY_US 20 |
| | Minimum delay between Joybus transfers, in microseconds.
|
|
#define | JOYBUS_REPLY_TIMEOUT_US 100 |
| | Timeout for waiting for a reply from a target, in microseconds.
|
| #define | JOYBUS(bus) |
| | Macro to cast a backend-specific Joybus instance to a generic Joybus instance.
|
|
| typedef void(* | joybus_transfer_cb_t) (struct joybus *bus, int result, void *user_data) |
| | Function type for transfer completion callbacks.
|
Joybus library core functionality.
◆ JOYBUS
Value:
A Joybus instance.
Definition bus.h:59
Macro to cast a backend-specific Joybus instance to a generic Joybus instance.
◆ joybus_transfer_cb_t
| typedef void(* joybus_transfer_cb_t) (struct joybus *bus, int result, void *user_data) |
Function type for transfer completion callbacks.
- Parameters
-
| bus | the Joybus associated with the transfer |
| result | positive number of bytes read on success, negative error code on failure |
| user_data | user data passed to the callback |
◆ joybus_disable()
| int joybus_disable |
( |
struct joybus * | bus | ) |
|
|
inlinestatic |
Disable the Joybus instance.
- Parameters
-
| bus | the Joybus instance to disable |
◆ joybus_enable()
| int joybus_enable |
( |
struct joybus * | bus | ) |
|
|
inlinestatic |
Enable the Joybus instance.
- Parameters
-
| bus | the Joybus instance to enable |
◆ joybus_target_register()
Enable Joybus "target" mode, and register a target to handle commands.
- Parameters
-
| bus | the Joybus instance to use |
| target | the target to register |
- Returns
- 0 on success, negative error code on failure
◆ joybus_target_unregister()
Unregister a Joybus target.
- Parameters
-
| bus | the Joybus instance to use |
| target | the target to unregister |
- Returns
- 0 on success, negative error code on failure
◆ joybus_transfer()
| int joybus_transfer |
( |
struct joybus * | bus, |
|
|
const uint8_t * | write_buf, |
|
|
uint8_t | write_len, |
|
|
uint8_t * | read_buf, |
|
|
uint8_t | read_len, |
|
|
joybus_transfer_cb_t | callback, |
|
|
void * | user_data ) |
|
inlinestatic |
Perform a Joybus "write then read" transfer.
Sends a command to a device, and reads the response. The provided buffers must be valid until the transfer is complete.
- Parameters
-
| bus | the Joybus instance to use |
| write_buf | the buffer containing the command to send |
| write_len | the number of bytes to write |
| read_buf | the buffer to store the response in |
| read_len | the number of bytes to read |
| callback | a callback function to call when the transfer is complete |
| user_data | user data to pass to the callback |
- Returns
- 0 on success, negative error code on failure