Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
sdhc_emul.h File Reference

Public test-accessor API for the SDHC emulator driver. More...

#include <zephyr/device.h>
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Functions

int sdhc_emul_set_fault (const struct device *dev, uint8_t cmd_index)
 Set fault injection on a specific CMD index.
int sdhc_emul_clear_fault (const struct device *dev)
 Clear any active fault injection.
int sdhc_emul_set_card_present (const struct device *dev, bool present)
 Set the virtual card presence state.
void sdhc_emul_trigger_sdio_irq (const struct device *dev, uint8_t fn)
 Trigger an SDIO interrupt.
uint8_t * sdhc_emul_get_storage (const struct device *dev)
 Get a pointer to the emulated card storage.
int sdhc_emul_get_block_count (const struct device *dev, uint32_t *count)
 Get the number of blocks in the emulated card.

Detailed Description

Public test-accessor API for the SDHC emulator driver.

These functions allow test code to manipulate the internal state of the emulated SDHC host controller (fault injection, card presence, SDIO IRQ triggering). They are not part of the stable Zephyr API and are intended only for ztest use.

Function Documentation

◆ sdhc_emul_clear_fault()

int sdhc_emul_clear_fault ( const struct device * dev)

Clear any active fault injection.

Restores normal operation so that all commands are processed.

Parameters
devSDHC emulator device.
Return values
0Success.
-ENODEVNo emulated card is registered.

◆ sdhc_emul_get_block_count()

int sdhc_emul_get_block_count ( const struct device * dev,
uint32_t * count )

Get the number of blocks in the emulated card.

Parameters
devSDHC emulator device.
countNumber of blocks.
Return values
0Success.
-ENODEVNo emulated card is registered.

◆ sdhc_emul_get_storage()

uint8_t * sdhc_emul_get_storage ( const struct device * dev)

Get a pointer to the emulated card storage.

Useful for test verification of written data without issuing additional read commands.

Parameters
devSDHC emulator device.
Returns
Pointer to the start of the block storage buffer.
Return values
NULLNo emulated card is registered.

◆ sdhc_emul_set_card_present()

int sdhc_emul_set_card_present ( const struct device * dev,
bool present )

Set the virtual card presence state.

Parameters
devSDHC emulator device.
presenttrue if the card should appear inserted.
Return values
0Success.
-ENODEVNo emulated card is registered.

◆ sdhc_emul_set_fault()

int sdhc_emul_set_fault ( const struct device * dev,
uint8_t cmd_index )

Set fault injection on a specific CMD index.

When a command with opcode == cmd_index is received by the emulator, it will return -EIO instead of processing the command.

Parameters
devSDHC emulator device.
cmd_indexCMD opcode to inject the fault on (0-63).
Return values
0Success.
-ENODEVNo emulated card is registered.

◆ sdhc_emul_trigger_sdio_irq()

void sdhc_emul_trigger_sdio_irq ( const struct device * dev,
uint8_t fn )

Trigger an SDIO interrupt.

Fires the registered SDHC interrupt callback with SDHC_INT_SDIO if that source is enabled. Does not modify the card CCCR interrupt pending register. fn is reserved for future use and is currently ignored.

Parameters
devSDHC emulator device.
fnSDIO function number (1-7); unused.