mirror of https://github.com/ARMmbed/mbed-os.git
Added error propogation from frequency functions
parent
15f33154c6
commit
b11b635775
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue