Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: IsuProject_LPC1768
Revision 5:cbf43dc9c947, committed 2013-12-19
- Comitter:
- kayekss
- Date:
- Thu Dec 19 19:14:15 2013 +0000
- Parent:
- 4:6e0fb5342efa
- Child:
- 6:1f57fbd3aeb5
- Commit message:
- Fixed a bug where stop function dows not work
Changed in this revision
| VS1053.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/VS1053.cpp Wed Dec 18 17:00:22 2013 +0000
+++ b/VS1053.cpp Thu Dec 19 19:14:15 2013 +0000
@@ -51,16 +51,16 @@
* @return Data length successfully sent.
*/
size_t VS1053::sendDataBlock(uint8_t* data, size_t length) {
- size_t sizeSent = 0, n;
+ size_t n, sizeSent = 0;
if (!data || !length) return 0;
- while (sizeSent < length) {
- n = length - sizeSent < 32 ? length - sizeSent : 32;
+ while (length) {
+ n = length < 32 ? length : 32;
while (!dreq);
bsync = 0;
for (uint32_t i = 0; i < n; i++) {
spi.write(*data++);
- sizeSent++;
+ sizeSent++; length--;
}
bsync = 1;
}
@@ -96,8 +96,8 @@
*/
bool VS1053::stop() {
uint16_t reg;
- uint8_t endFillByte;
- size_t length;
+ uint8_t endFillByte;
+ size_t n, length;
// If SM_CANCEL is still set, do nothing
reg = readReg(SCI_MODE);
@@ -113,14 +113,15 @@
endFillByte = reg & 0xff;
length = 2052;
while (length) {
+ n = length < 32 ? length : 32;
while (!dreq);
bsync = 0;
- for (uint8_t i = 0; i < 32 && length--; i++) {
+ for (uint32_t i = 0; i < n; i++) {
spi.write(endFillByte);
+ length--;
}
bsync = 1;
}
-
// Check if both HDAT0 and HDAT1 are cleared
return readReg(SCI_HDAT0) == 0x0000 && readReg(SCI_HDAT1) == 0x0000;
}