Bridle API 4.1.99
A Zephyr based application framework
Loading...
Searching...
No Matches
i2c_sc18is604_callback.c File Reference

Driver Callback for the I2C controller part of an SC18IM604 bridge. More...

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/mfd/sc18is604.h>
#include "i2c_sc18is604.h"

Data Structures

struct  i2c_sc18is604_xfr_cb_work
 Data structure for tracking a asynchronous I2C transfer. More...
 

Functions

static void i2c_sc18is604_transfer_cb_process_done (struct i2c_sc18is604_xfr_cb_work *transfer_work, int result)
 
static void i2c_sc18is604_init_msg_read (struct i2c_sc18is604_xfr_cb_work *transfer_work, uint16_t addr, struct i2c_msg *msg)
 
static void i2c_sc18is604_init_msg_write (struct i2c_sc18is604_xfr_cb_work *transfer_work, uint16_t addr, struct i2c_msg *msg)
 
static void i2c_sc18is604_init_msg_work_fn (struct k_work *work)
 
static void i2c_sc18is604_buffer_readout_work_fn (struct k_work *work)
 
static void i2c_sc18is604_finish_msg_work_fn (struct k_work *work)
 
int i2c_sc18is604_transfer_cb (const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr, i2c_callback_t cb, void *userdata)
 Transfer I2C messages asynchronously.
 

Detailed Description

Driver Callback for the I2C controller part of an SC18IM604 bridge.

Asynchronous message transfers are processed by a tracking structure being passed between 3 separate work items: One for initiating transfers, one for performing RX buffer readouts, and one for awaiting completion of one message being processed.

These work items can both re-schedule themselves to wait on data or locks without blocking, and they schedule each other to progress message processing.

On completion, or if unrecoverable errors occur, each work item can call out to a shared completion function, which propagates the final return value to the user provided callback.

A driver instance wide lock ensures that only one packet of messages given to i2c_transfer_cb is processed at the same time. Multiple calls can still be made in succession, but it is not guaranteed that they will be processed in the order they are submitted.

Function Documentation

◆ i2c_sc18is604_buffer_readout_work_fn()

static void i2c_sc18is604_buffer_readout_work_fn ( struct k_work *  work)
static

◆ i2c_sc18is604_finish_msg_work_fn()

static void i2c_sc18is604_finish_msg_work_fn ( struct k_work *  work)
static

◆ i2c_sc18is604_init_msg_read()

static void i2c_sc18is604_init_msg_read ( struct i2c_sc18is604_xfr_cb_work transfer_work,
uint16_t  addr,
struct i2c_msg *  msg 
)
static

◆ i2c_sc18is604_init_msg_work_fn()

static void i2c_sc18is604_init_msg_work_fn ( struct k_work *  work)
static

◆ i2c_sc18is604_init_msg_write()

static void i2c_sc18is604_init_msg_write ( struct i2c_sc18is604_xfr_cb_work transfer_work,
uint16_t  addr,
struct i2c_msg *  msg 
)
static

◆ i2c_sc18is604_transfer_cb()

int i2c_sc18is604_transfer_cb ( const struct device *  dev,
struct i2c_msg *  msgs,
uint8_t  num_msgs,
uint16_t  addr,
i2c_callback_t  cb,
void *  userdata 
)

Transfer I2C messages asynchronously.

Parameters
devAn SC18IS604 I2C controller.
msgsI2C messages to be transmitted. Pointer must remain valid for the duration of the transfer.
num_msgsNumber of messages to be transmitted.
addrI2C address of the target device.
cbCallback to be invoked on transfer completion (or failure).
userdataUser data passed to callback.

◆ i2c_sc18is604_transfer_cb_process_done()

static void i2c_sc18is604_transfer_cb_process_done ( struct i2c_sc18is604_xfr_cb_work transfer_work,
int  result 
)
static