Add optional power supply enable pin for SD card

This commit is contained in:
Richard Blakesley 2024-07-23 14:41:57 +02:00
parent 290627739e
commit f03dd96a47
4 changed files with 12 additions and 1 deletions

View File

@ -71,7 +71,9 @@ void jsfsReportError(const char *msg, FRESULT res) {
}
bool jsfsInit() {
#ifdef SD_POWER_PIN
jshPinOutput(SD_POWER_PIN, 1);
#endif
#ifndef LINUX
if (!fat_initialised) {
#ifndef USE_FLASHFS

View File

@ -521,6 +521,9 @@ void jswrap_pb_setLCDPower(bool isOn) {
"generate" : "jswrap_pb_init"
}*/
void jswrap_pb_init() {
#ifdef SD_POWER_PIN
jshPinOutput(SD_POWER_PIN, 1); // Power supply enable for the SD card is also used for the ES8388 audio codec
#endif
#ifdef USE_AUDIO_CODEC
// Initialise audio
STM32_I2S_Init();

View File

@ -446,6 +446,8 @@ if "LCD" in board.devices:
codeOutDevicePins("LCD","LCD");
if "SD" in board.devices:
if "pin_cd" in board.devices["SD"]: codeOutDevicePin("SD", "pin_cd", "SD_DETECT_PIN")
if "pin_pwr" in board.devices["SD"]: codeOutDevicePin("SD", "pin_pwr", "SD_POWER_PIN")
if not "pin_d3" in board.devices["SD"]: # NOT SDIO - normal SD
if "pin_cs" in board.devices["SD"]: codeOutDevicePin("SD", "pin_cs", "SD_CS_PIN")
if "pin_di" in board.devices["SD"]: codeOutDevicePin("SD", "pin_di", "SD_DI_PIN")

View File

@ -2622,6 +2622,10 @@ bool jshSleep(JsSysTime timeUntilWake) {
#endif
#endif // USB
#ifdef SD_POWER_PIN
jshPinOutput(SD_POWER_PIN, 0); // Turn off the power supply for the SD card (and the ES8388 audio codec)
#endif
if (timeUntilWake!=JSSYSTIME_MAX) { // set alarm
unsigned int ticks = (unsigned int)(timeUntilWake/jshGetTimeForSecond()); // ensure we round down and leave a little time