Bridle API 4.1.99
A Zephyr based application framework
Loading...
Searching...
No Matches
mfd_sc18is604_emul.c File Reference
#include <stdint.h>
#include <zephyr/drivers/emul.h>
#include <zephyr/drivers/gpio/gpio_emul.h>
#include <zephyr/drivers/mfd/sc18is604.h>
#include <zephyr/drivers/mfd/sc18is604_emul.h>
#include "mfd_sc18is604.h"
#include <zephyr/logging/log.h>

Data Structures

struct  mfd_sc18is604_emul_data
 
struct  mfd_sc18is604_emul_config
 

Macros

#define DT_DRV_COMPAT   nxp_sc18is604
 
#define SC18IS604_N_REGISTERS   6 /* 0x00 through 0x05 */
 
#define MFD_SC18IS604_EMUL_DEFINE(inst)
 

Functions

 LOG_MODULE_REGISTER (mfd_sc18is604_emul, CONFIG_MFD_LOG_LEVEL)
 
int mfd_sc18is604_emul_i2c_set_rx (const struct emul *target, uint8_t *buf, size_t len)
 Simulate the device receiving a message.
 
int mfd_sc18is604_emul_i2c_get_last_tx (const struct emul *target, struct mfd_sc18is604_emul_transmission *transmission)
 Get the last transmission sent by the device.
 
int mfd_sc18is604_emul_gpio_set_input (const struct emul *target, uint8_t pin, uint8_t value)
 Simulate a GPIO input pin being set to a specific value.
 
int mfd_sc18is604_emul_gpio_get_output (const struct emul *target, uint8_t pin, uint8_t *value)
 Get the value of a GPIO output pin.
 
static void mfd_sc18is604_emul_version_string_into_rx_buffer (const struct emul *target)
 
static void mfd_sc18is604_get_rx_buffer (const struct emul *target, uint8_t *rx_buf, size_t len)
 
static uint8_t mfd_sc18is604_get_register (const struct emul *target, uint8_t reg)
 
static void mfd_sc18is604_set_register (const struct emul *target, uint8_t reg, uint8_t val)
 
static void mfd_sc18is604_emul_read_i2c (const struct emul *target, size_t len)
 
static void mfd_sc18is604_emul_write_i2c (const struct emul *target, uint8_t addr, const uint8_t *msg, size_t len)
 
static int mfd_sc18is604_emul_io_spi (const struct emul *target, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs)
 
static int mfd_sc18is604_emul_init (const struct emul *target, const struct device *parent)
 
 DT_INST_FOREACH_STATUS_OKAY (MFD_SC18IS604_EMUL_DEFINE)
 

Variables

static const uint8_t sc18is604_reg_defaults [6]
 
static struct spi_emul_api mfd_sc18is604_emul_api
 

Macro Definition Documentation

◆ DT_DRV_COMPAT

#define DT_DRV_COMPAT   nxp_sc18is604

◆ MFD_SC18IS604_EMUL_DEFINE

#define MFD_SC18IS604_EMUL_DEFINE (   inst)
Value:
static struct mfd_sc18is604_emul_data mfd_sc18is604_emul_data_##inst; \
static const struct mfd_sc18is604_emul_config mfd_sc18is604_emul_config_##inst; \
\
EMUL_DT_INST_DEFINE(inst, mfd_sc18is604_emul_init, &mfd_sc18is604_emul_data_##inst, \
&mfd_sc18is604_emul_config_##inst, &mfd_sc18is604_emul_api, NULL)
static int mfd_sc18is604_emul_init(const struct emul *target, const struct device *parent)
Definition mfd_sc18is604_emul.c:377
static struct spi_emul_api mfd_sc18is604_emul_api
Definition mfd_sc18is604_emul.c:373
Definition mfd_sc18is604_emul.c:36
Definition mfd_sc18is604_emul.c:29

◆ SC18IS604_N_REGISTERS

#define SC18IS604_N_REGISTERS   6 /* 0x00 through 0x05 */

Function Documentation

◆ DT_INST_FOREACH_STATUS_OKAY()

DT_INST_FOREACH_STATUS_OKAY ( MFD_SC18IS604_EMUL_DEFINE  )

◆ LOG_MODULE_REGISTER()

LOG_MODULE_REGISTER ( mfd_sc18is604_emul  ,
CONFIG_MFD_LOG_LEVEL   
)

◆ mfd_sc18is604_emul_gpio_get_output()

int mfd_sc18is604_emul_gpio_get_output ( const struct emul *  target,
uint8_t  pin,
uint8_t *  value 
)

Get the value of a GPIO output pin.

Parameters
targetThe emulated device to get the pin value from.
pinThe pin to get the value of.
[out]valueThe value of the pin.
Returns
0 On success.
A negative error code on failure.

◆ mfd_sc18is604_emul_gpio_set_input()

int mfd_sc18is604_emul_gpio_set_input ( const struct emul *  target,
uint8_t  pin,
uint8_t  value 
)

Simulate a GPIO input pin being set to a specific value.

Parameters
targetThe emulated device to set the pin on.
pinThe pin to set.
valueThe value to set the pin to.
Returns
0 On success.
A negative error code on failure.

◆ mfd_sc18is604_emul_i2c_get_last_tx()

int mfd_sc18is604_emul_i2c_get_last_tx ( const struct emul *  target,
struct mfd_sc18is604_emul_transmission transmission 
)

Get the last transmission sent by the device.

Parameters
targetThe amulated device to get the last transmission from.
[out]transmissionThe transmission to fill with the last transmission.
Return values
0On success
Returns
A negative error code on failure.

◆ mfd_sc18is604_emul_i2c_set_rx()

int mfd_sc18is604_emul_i2c_set_rx ( const struct emul *  target,
uint8_t *  buf,
size_t  len 
)

Simulate the device receiving a message.

The message will be moved to the RX buffer the next time a read is performed.

Parameters
targetThe emulated device to receive the message.
bufThe message to receive.
lenThe length of the message.
Returns
The number of bytes received, or a negative error code on failure.

◆ mfd_sc18is604_emul_init()

static int mfd_sc18is604_emul_init ( const struct emul *  target,
const struct device *  parent 
)
static

◆ mfd_sc18is604_emul_io_spi()

static int mfd_sc18is604_emul_io_spi ( const struct emul *  target,
const struct spi_config *  config,
const struct spi_buf_set *  tx_bufs,
const struct spi_buf_set *  rx_bufs 
)
static

◆ mfd_sc18is604_emul_read_i2c()

static void mfd_sc18is604_emul_read_i2c ( const struct emul *  target,
size_t  len 
)
static

◆ mfd_sc18is604_emul_version_string_into_rx_buffer()

static void mfd_sc18is604_emul_version_string_into_rx_buffer ( const struct emul *  target)
static

◆ mfd_sc18is604_emul_write_i2c()

static void mfd_sc18is604_emul_write_i2c ( const struct emul *  target,
uint8_t  addr,
const uint8_t *  msg,
size_t  len 
)
static

◆ mfd_sc18is604_get_register()

static uint8_t mfd_sc18is604_get_register ( const struct emul *  target,
uint8_t  reg 
)
static

◆ mfd_sc18is604_get_rx_buffer()

static void mfd_sc18is604_get_rx_buffer ( const struct emul *  target,
uint8_t *  rx_buf,
size_t  len 
)
static

◆ mfd_sc18is604_set_register()

static void mfd_sc18is604_set_register ( const struct emul *  target,
uint8_t  reg,
uint8_t  val 
)
static

Variable Documentation

◆ mfd_sc18is604_emul_api

struct spi_emul_api mfd_sc18is604_emul_api
static
Initial value:
= {
}
static int mfd_sc18is604_emul_io_spi(const struct emul *target, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs)
Definition mfd_sc18is604_emul.c:215

◆ sc18is604_reg_defaults

const uint8_t sc18is604_reg_defaults[6]
static
Initial value:
= {
0x00,
0x00,
0x19,
0x00,
0x00,
0x00,
}