![Vlsi VS1063a Скачать руководство пользователя страница 22](http://html.mh-extra.com/html/vlsi/vs1063a/vs1063a_programmers-manual_1042916022.webp)
PRELIMINARY
VS1063a Prog. Guide
8
VS1063A LOAD FILE FORMATS
8.1.2
Example VS1063a Microcontroller Plugin Decoder
Assuming the vector is in vector
u_int16 plugin[X]
, a full decoder in C language is provided
below:
/* This support function that writes one word through SCI is needed. */
void WriteVS10xxRegister(unsigned short addr, unsigned short value);
void LoadPlugin(void) {
int i = 0;
/* Execute fo reach word in plugin */
while (i<sizeof(plugin)/sizeof(plugin[0])) {
unsigned short addr, n, val;
/* Get address and number of words in current segment */
addr = plugin[i++];
n = plugin[i++];
if (n & 0x8000U) {
/* RLE run, replicate n & 0x7FFF samples */
n &= 0x7FFF;
val = plugin[i++];
while (n--) {
WriteVS10xxRegister(addr, val);
}
} else { /* if (!(n & 0x8000U)) */
/* Copy run, copy n samples */
while (n--) {
val = plugin[i++];
WriteVS10xxRegister(addr, val);
}
} /* if (!(n & 0x8000U)) */
} /* while (i<sizeof(plugin)/sizeof(plugin[0])) */
}
Version: 0.40, 2011-09-02
22