Added error propogation from frequency functions

pull/7774/head
Christopher Haster 2017-07-05 12:24:26 -05:00
parent 15f33154c6
commit b11b635775
1 changed files with 12 additions and 6 deletions

View File

@ -145,6 +145,7 @@
#include "SDBlockDevice.h"
#include "mbed_debug.h"
#include <errno.h>
#define SD_COMMAND_TIMEOUT 5000 /*!< Timeout in ms for response */
#define SD_CMD0_GO_IDLE_STATE_RETRIES 5 /*!< Number of retries for sending CMDO */
@ -352,7 +353,12 @@ int SDBlockDevice::init()
}
// Set SCK for data transfer
_freq();
err = _freq();
if (err) {
_lock.unlock();
return err;
}
_lock.unlock();
return BD_ERROR_OK;
}
@ -593,9 +599,9 @@ int SDBlockDevice::frequency(uint64_t freq)
{
_lock.lock();
_transfer_sck = freq;
_freq();
int err = _freq();
_lock.unlock();
return 0;
return err;
}
// PRIVATE FUNCTIONS
@ -604,12 +610,12 @@ int SDBlockDevice::_freq(void)
// Max frequency supported is 25MHZ
if (_transfer_sck <= 25000000) {
_spi.frequency(_transfer_sck);
}
else { // TODO: Switch function to be implemented for higher frequency
return 0;
} else { // TODO: Switch function to be implemented for higher frequency
_transfer_sck = 25000000;
_spi.frequency(_transfer_sck);
return -EINVAL;
}
return 0;
}
uint8_t SDBlockDevice::_cmd_spi(SDBlockDevice::cmdSupported cmd, uint32_t arg) {