From 026d40ffabb3b3466c7a94961cc3cf790e0a4b11 Mon Sep 17 00:00:00 2001 From: Gabriel Somlo Date: Mon, 5 Oct 2020 14:32:06 -0400 Subject: [PATCH] bios: add command returning card-detect pin status --- litex/soc/software/bios/cmds/cmd_litesdcard.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/litex/soc/software/bios/cmds/cmd_litesdcard.c b/litex/soc/software/bios/cmds/cmd_litesdcard.c index 1cea08a09..c22bab608 100644 --- a/litex/soc/software/bios/cmds/cmd_litesdcard.c +++ b/litex/soc/software/bios/cmds/cmd_litesdcard.c @@ -10,6 +10,22 @@ #include "../command.h" #include "../helpers.h" +/** + * Command "sdcard_detect" + * + * Detect SDcard + * + */ +#ifdef CSR_SDPHY_BASE +static void sdcard_detect_handler(int nb_params, char **params) +{ + uint8_t cd = sdphy_card_detect_read(); + printf("SDCard %sinserted.\n", cd ? "not " : ""); +} + +define_command(sdcard_detect, sdcard_detect_handler, "Detect SDCard", LITESDCARD_CMDS); +#endif + /** * Command "sdcard_init" *