mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 13:15:18 -05:00
ypr0: Fix ascodec_readbytes().
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31429 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
1dcc834e59
commit
16784598ac
1 changed files with 6 additions and 4 deletions
|
|
@ -104,13 +104,14 @@ int ascodec_readbytes(unsigned int index, unsigned int len, unsigned char *data)
|
|||
{
|
||||
int i, val, ret = 0;
|
||||
|
||||
for (i = index; i < (int)len; i++) {
|
||||
val = ascodec_read(i);
|
||||
for (i = 0; i < (int)len; i++)
|
||||
{
|
||||
val = ascodec_read(i + index);
|
||||
if (val >= 0) data[i] = val;
|
||||
else ret = -1;
|
||||
}
|
||||
|
||||
return ret ?: i; /* i means success */
|
||||
return (ret ?: (int)len);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -144,7 +145,8 @@ unsigned short adc_read(int channel)
|
|||
unsigned char buf[2];
|
||||
|
||||
/* Read data */
|
||||
ascodec_readbytes(AS3514_ADC_0, sizeof(buf), buf);
|
||||
if (ascodec_readbytes(AS3514_ADC_0, 2, buf) < 0)
|
||||
return 0;
|
||||
|
||||
/* decode to 10-bit and return */
|
||||
return (((buf[0] & 0x3) << 8) | buf[1]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue