libjoybus
Joybus implementation for 32-bit MCUs
Loading...
Searching...
No Matches
gecko_sdk Directory Reference

Detailed Description

Gecko Backend for libjoybus

Usage

// Store the bus instance somewhere
struct joybus_gecko gecko_bus;
// Initialize the Gecko joybus interface
// Parameters: (joybus_gecko instance, GPIO port, GPIO pin, TIMER, USART)
joybus_gecko_init(&gecko_bus, gpioPortD, 3, TIMER0, USART0);
// Cast to a generic joybus pointer, for ease of use with libjoybus functions
struct joybus *bus = JOYBUS(&gecko_bus);
// Enable the bus
// Use the bus
joybus_transfer(bus, ...);
int joybus_gecko_init(struct joybus_gecko *gecko_bus, GPIO_Port_TypeDef port, uint8_t pin, TIMER_TypeDef *rx_timer, USART_TypeDef *tx_usart)
Initialize a Gecko Joybus instance.
Definition joybus.c:790
static int joybus_enable(struct joybus *bus)
Enable the Joybus instance.
Definition bus.h:71
static 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)
Perform a Joybus "write then read" transfer.
Definition bus.h:102
#define JOYBUS(bus)
Macro to cast a backend-specific Joybus instance to a generic Joybus instance.
Definition bus.h:35
A Gecko Joybus instance.
Definition gecko.h:108
A Joybus instance.
Definition bus.h:59

Checklist

  • Backend must implement all functions in joybus_api
  • Transfers must fail with JOYBUS_ERR_DISABLED if backend is not enabled
  • Transfers must fail with JOYBUS_ERR_BUSY if another transfer is in progress
  • Transfers must fail with JOYBUS_ERR_TIMEOUT if target does not begin replying within 100 µs
  • Transfers must fail with JOYBUS_ERR_TIMEOUT if each subsequent byte is not received within 100 µs
  • Backend must enforce a minimum delay of 20 µs between each transfer
  • Target must begin responding to any command within 100 µs
  • When target read mode is enabled, the bus must be idle before reading data to ensure we are not in the middle of a transfer
  • If an error occurs during a target read, wait for the bus to be idle before starting to read the next command

Ideally, your backend should also meet the following criteria:

  • Target must begin responding to any command within 10 µs
  • Backend supports 4 simultaneous buses
  • Zephyr implementation available