English
Language : 

VS1103B Datasheet, PDF (41/61 Pages) List of Unclassifed Manufacturers – MIDI/ADPCM AUDIO CODEC
VLSI
Solution y
VS1103b
VS1103B
7. OPERATION
void RecordAdpcm1103(void) { /* VS1003b/VS1023 */
u_int16 w = 0, idx = 0, n = 0;
s_int32 adpcmBlocks = -1;
... /* Check and locate free space on disk */
WriteMp3SpiReg(SCI_CLOCKF, 0xC3E8); /* 4.0x 12.288MHz */
WaitForDreq();
/* Wait for DREQ to go up again */
WriteMp3SpiReg(SCI_MODE, 0x0804); /* Normal SW reset + other bits */
WaitForDreq();
/* Wait for DREQ to go up again */
WriteMp3SpiReg(SCI_VOL, 0x1414); /* Recording monitor volume */
WriteMp3SpiReg(SCI_BASS,
0); /* Bass/treble disabled */
WriteMp3SpiReg(SCI_MIXERVOL, 0x8000U | (23<<10) | (23<<5) | (23));
WriteMp3SpiReg(SCI_ADPCMRECCTL,25+20); /* Auto gain to max +20 dB */
WriteMp3SpiReg(SCI_MODE, 0x08c8); /* Line in, SDI MIDI, SCI ADPCM, 8 kHz */
for (idx=0; idx < sizeof(header); idx++) /* Save header first */
db[idx] = header[idx];
db[24] = sampleRate;
/* Set sample rate */
db[25] = samplRate>>8;
/* Synchronize */
do {
n = 8 * ((ReadMp3SpiReg(SCI_IN1) >> 8) & 0xFF);
Yield(1);
/* Give control to other processes for 1 ms */
} while (n >= 480);
/* whole buffer size = 512 words */
/* Record loop */
while (recording_on) {
while (idx < 512) {
do {
n = 8 * ((ReadMp3SpiReg(SCI_IN1) >> 8) & 0xFF);
Yield(1);
/* Give control to other processes for 1 ms */
} while (n < 16); /* Only load data if >= 16 words available */
while (n--) {
w = ReadMp3SpiReg(SCI_IN0);
db[idx++] = w>>8;
db[idx++] = w&0xFF;
}
}
idx = 0;
write_block(datasector++, db); /* Write one disk block */
adpcmBlocks+=2;
/* Disk block contains 2 adpcm blocks */
}
if (adpcmBlocks >= 0) {
/* The previous algorithm will always write an unfinished ADPCM block.
It doesn’t matter as we consistently only tell of the data until
the last completely written block. */
dataSizeD
= adpcmBlocks*256;
chunkSizeF = dataSizeD+52:
numOfSamplesS = adpcmBlocks*505;
... /* Fix WAV header information */
}
}
Version 1.01, 2007-09-03
41