From a0b0cfa97dac91182f7e4525d90d80b9de8f8516 Mon Sep 17 00:00:00 2001 From: Dmitriy Logachov Date: Fri, 15 Jan 2021 22:08:21 +0500 Subject: [PATCH] Fixed bug of detecting the presence of a card when setting the SD_DETECT inversion. --- hardware/sdcard/diskio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hardware/sdcard/diskio.c b/hardware/sdcard/diskio.c index c9644a1..b3e4541 100755 --- a/hardware/sdcard/diskio.c +++ b/hardware/sdcard/diskio.c @@ -22,7 +22,7 @@ /* Port controls (Platform dependent) */ #define CS_LOW() SD_CS_PORT &= ~(_BV(SD_CS_PIN)) /* CS=low */ #define CS_HIGH() SD_CS_PORT |= _BV(SD_CS_PIN) /* CS=high */ -#define MMC_CD (config_invert_sddetect == false ? (SD_DETECT_INPUT & _BV(SD_DETECT_PIN)) : (SD_DETECT_INPUT & ~_BV(SD_DETECT_PIN))) /* Card detected. yes:true, no:false, default:true */ +#define MMC_CD (config_invert_sddetect == false ? (SD_DETECT_INPUT & _BV(SD_DETECT_PIN)) : ((SD_DETECT_INPUT & _BV(SD_DETECT_PIN)) == 0)) /* Card detected. yes:true, no:false, default:true */ #define MMC_WP (false) /* Write protected. yes:true, no:false, default:false */ #define FCLK_SLOW() SPCR = 0x52 /* Set slow clock (F_CPU / 64) */ #define FCLK_FAST() SPCR = 0x50 /* Set fast clock (F_CPU / 2) */ @@ -579,6 +579,6 @@ void disk_timerproc(void) { } else { s |= (STA_NODISK | STA_NOINIT); /* Socket empty */ } - + Stat = s; /* Update MMC status */ }