|
|
|
|
|
|
|
|
bool AudioPlaySdRaw::play(const char *filename) |
|
|
bool AudioPlaySdRaw::play(const char *filename) |
|
|
{ |
|
|
{ |
|
|
stop(); |
|
|
stop(); |
|
|
|
|
|
#if defined(HAS_KINETIS_SDHC) |
|
|
|
|
|
if (!(SIM_SCGC3 & SIM_SCGC3_SDHC)) AudioStartUsingSPI(); |
|
|
|
|
|
#else |
|
|
AudioStartUsingSPI(); |
|
|
AudioStartUsingSPI(); |
|
|
|
|
|
#endif |
|
|
|
|
|
__disable_irq(); |
|
|
rawfile = SD.open(filename); |
|
|
rawfile = SD.open(filename); |
|
|
|
|
|
__enable_irq(); |
|
|
if (!rawfile) { |
|
|
if (!rawfile) { |
|
|
//Serial.println("unable to open file"); |
|
|
//Serial.println("unable to open file"); |
|
|
AudioStopUsingSPI(); |
|
|
|
|
|
|
|
|
#if defined(HAS_KINETIS_SDHC) |
|
|
|
|
|
if (!(SIM_SCGC3 & SIM_SCGC3_SDHC)) AudioStopUsingSPI(); |
|
|
|
|
|
#else |
|
|
|
|
|
AudioStopUsingSPI(); |
|
|
|
|
|
#endif |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
file_size = rawfile.size(); |
|
|
file_size = rawfile.size(); |
|
|
|
|
|
|
|
|
playing = false; |
|
|
playing = false; |
|
|
__enable_irq(); |
|
|
__enable_irq(); |
|
|
rawfile.close(); |
|
|
rawfile.close(); |
|
|
AudioStopUsingSPI(); |
|
|
|
|
|
|
|
|
#if defined(HAS_KINETIS_SDHC) |
|
|
|
|
|
if (!(SIM_SCGC3 & SIM_SCGC3_SDHC)) AudioStopUsingSPI(); |
|
|
|
|
|
#else |
|
|
|
|
|
AudioStopUsingSPI(); |
|
|
|
|
|
#endif |
|
|
} else { |
|
|
} else { |
|
|
__enable_irq(); |
|
|
__enable_irq(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
transmit(block); |
|
|
transmit(block); |
|
|
} else { |
|
|
} else { |
|
|
rawfile.close(); |
|
|
rawfile.close(); |
|
|
AudioStopUsingSPI(); |
|
|
|
|
|
|
|
|
#if defined(HAS_KINETIS_SDHC) |
|
|
|
|
|
if (!(SIM_SCGC3 & SIM_SCGC3_SDHC)) AudioStopUsingSPI(); |
|
|
|
|
|
#else |
|
|
|
|
|
AudioStopUsingSPI(); |
|
|
|
|
|
#endif |
|
|
playing = false; |
|
|
playing = false; |
|
|
} |
|
|
} |
|
|
release(block); |
|
|
release(block); |
|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
return ((uint64_t)file_size * B2M) >> 32; |
|
|
return ((uint64_t)file_size * B2M) >> 32; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|