CardSight 0.1.0
C API reference for the CardSight firmware and application
Loading...
Searching...
No Matches
core.h File Reference

SD/MMC core: the description of the card and the disk it creates ("mmcblk0"). More...

#include <hal/mmc/card.h>
#include <hal/mmc/host.h>

Go to the source code of this file.

Functions

bool mmc_card_ready (const struct mmc_card *card)
 Whether the card was identified and has not been removed.
int mmc_card_info (const struct mmc_card *card, struct mmc_card_info *info)
 Copy what the card reports.
int mmc_blk_init (void)
 Register the disk driver.
const char * mmc_last_error (void)
 The last command-level card failure.
void mmc_last_error_clear (void)
 Forget the last command-level failure.
int mmc_probe_error (void)
 The last identification result.
bool mmc_slot_detecting (void)
 Whether a card is in the slot but has not been identified yet.

Detailed Description

SD/MMC core: the description of the card and the disk it creates ("mmcblk0").

Return values are 0 or a negative errno. A card reference keeps the structure alive after the card went away; its description stays readable.

Function Documentation

◆ mmc_blk_init()

int mmc_blk_init ( void )

Register the disk driver.

Initializes the card lock, waits for the slot power delay, probes a card when one is present, and registers the card as the block device "mmcblk0".

Returns
0 on success, a negative errno when the probe fails, or 0 when the slot is empty.

◆ mmc_card_info()

int mmc_card_info ( const struct mmc_card * card,
struct mmc_card_info * info )

Copy what the card reports.

Parameters
[in]cardCard to query.
[out]infoReceives a snapshot of the card description.
Returns
0 on success, or -ENODEV without a ready card.

◆ mmc_card_ready()

bool mmc_card_ready ( const struct mmc_card * card)

Whether the card was identified and has not been removed.

Parameters
[in]cardCard to check; NULL is not ready.
Returns
true for the live, identified card.

◆ mmc_last_error()

const char * mmc_last_error ( void )

The last command-level card failure.

Returns
A message such as "CMD5 Read Timeout", or an empty string before one.

◆ mmc_probe_error()

int mmc_probe_error ( void )

The last identification result.

Returns
0 after a good probe, or a negative errno while a card in the slot cannot be brought up.

◆ mmc_slot_detecting()

bool mmc_slot_detecting ( void )

Whether a card is in the slot but has not been identified yet.

Returns
true while a present card is still being brought up.