User Manual
VS1003
9 OPERATION
void RecordAdpcm1003(void) { /* VS1003b/VS1033c */
u_int16 w = 0, idx = 0;
... /* Check and locate free space on disk */
SetMp3Vol(0x1414); /* Recording monitor volume */
WriteMp3SpiReg(SCI_BASS, 0); /* Bass/treble disabled */
WriteMp3SpiReg(SCI_CLOCKF, 0x4430); /* 2.0x 12.288MHz */
Wait(100);
WriteMp3SpiReg(SCI_AICTRL0, 12); /* Div -> 12=8kHz 8=12kHz 6=16kHz */
Wait(100);
WriteMp3SpiReg(SCI_AICTRL1, 0); /* Auto gain */
Wait(100);
if (line_in) {
WriteMp3SpiReg(SCI_MODE, 0x5804); /* Normal SW reset + other bits */
} else {
WriteMp3SpiReg(SCI_MODE, 0x1804); /* Normal SW reset + other bits */
}
for (idx=0; idx < sizeof(header); idx++) { /* Save header first */
db[idx] = header[idx];
}
/* Fix rate if needed */
/*db[24] = rate;*/
/*db[25] = rate>>8;*/
/* Record loop */
while (recording_on) {
do {
w = ReadMp3SpiReg(SCI_HDAT1);
} while (w < 256 || w >= 896); /* wait until 512 bytes available */
while (idx < 512) {
w = ReadMp3SpiReg(SCI_HDAT0);
db[idx++] = w>>8;
db[idx++] = w&0xFF;
}
idx = 0;
write_block(datasector++, db); /* Write output block to disk */
}
... /* Fix WAV header information */
... /* Then update FAT information */
ResetMP3(); /* Normal reset, restore default settings */
SetMp3Vol(vol);
}
Version: 1.08, 2014-12-19 41