Skip to content

Commit

Permalink
eMMC: Support power control pin
Browse files Browse the repository at this point in the history
  • Loading branch information
SPRESENSE committed Nov 11, 2022
1 parent 88a5773 commit a482bed
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@

eMMCClass::eMMCClass() : StorageClass(EMMC_MOUNT_POINT), mshandle(NULL)
{
power_pin = 0xff;
}

boolean eMMCClass::begin(uint8_t pin)
{
power_pin = pin;

pinMode(power_pin, OUTPUT);
digitalWrite(power_pin, HIGH);

/* device bootup time */
delay(5);

return begin();
}

boolean eMMCClass::begin()
Expand All @@ -62,9 +76,28 @@ boolean eMMCClass::begin()

/* Initialize and mount the eMMC device */
ret = board_emmc_initialize();
if (ret != 0) {
return false;
}
if (ret != 0)
{
return false;
}

return true;
}

boolean eMMCClass::end()
{
/* Finalize and unmount the eMMC device */
int ret = board_emmc_finalize();
if (ret != 0)
{
return false;
}

if(power_pin != 0xff)
{
digitalWrite(power_pin, LOW);
power_pin = 0xff;
}

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,25 @@ class eMMCClass : public StorageClass {
*/
boolean begin();

/**
* @brief Initialize the eMMC library with Power on PIN
*
* @details This will check that the eMMC is mounted or not after being initialized it.
* This needs to be called to set up the connection to the eMMC
* before other methods are used.
* @param [in] Power control pin for eMMC
* @return true if the eMMC is mounted, false if not
*/
boolean begin(uint8_t);

/**
* @brief Finalize the eMMC library
*
* @details This function unmount, finalize device and power off device.
* @return true if the eMMC finalization complete, false if not
*/
boolean end();

/**
* @brief Start USB Mass Storage Class
*/
Expand All @@ -87,6 +106,7 @@ class eMMCClass : public StorageClass {

private:
void *mshandle;
uint8_t power_pin;
};

extern eMMCClass eMMC;
Expand Down

0 comments on commit a482bed

Please sign in to comment.