//--------------------------------
// load a plugin
// 1 Read register address number addr and repeat number n;
// 2 if (n & 0x8000u),write the next word n times to register addr;
// 3.Else write next n words to register addr;
// 4.continue until array has been exhausted.
//---------------------------------
void LoadUserCode(void)
{
int i = 0;
unsigned int addr, n, val;
unsigned char valh,vall;
i =sizeof(plugin[0]);
while (i<sizeof(plugin)/sizeof(plugin[0]))
{
addr = plugin[i++];
n = plugin[i++];
if (n & 0x8000U)
{ /* RLE run, replicate n samples */
n &= 0x7FFF;
val = plugin[i++];
valh = (val&0xff00) >>8;
vall = val&0x00ff;
while (n--)
{
Vs1053WriteRegister(addr,valh,vall);
}
}
else
{ /* Copy run, copy n samples */
while (n--)
{
val = plugin[i++];
valh = (val&0xff00) >>8;
vall = val&0x00ff;
Vs1053WriteRegister(addr,valh,vall);
}
}
}
}
文章评论(0条评论)
登录后参与讨论