mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-11 22:25:17 -05:00
Use I2C2_DACNT register (number of pending i2c bytes to read/write) to determine if an ascodec i2c transfer is done. This should fix i2c problems with MMU enabled.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21150 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
29d7db4a46
commit
9067c915ad
1 changed files with 27 additions and 39 deletions
|
|
@ -97,19 +97,14 @@ static int i2c_busy(void)
|
||||||
return (I2C2_SR & 1);
|
return (I2C2_SR & 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* returns 0 on success, <0 otherwise */
|
/* returns 0 on success, <0 otherwise */
|
||||||
int ascodec_write(unsigned int index, unsigned int value)
|
int ascodec_write(unsigned int index, unsigned int value)
|
||||||
{
|
{
|
||||||
int retval;
|
|
||||||
|
|
||||||
ascodec_lock();
|
ascodec_lock();
|
||||||
|
|
||||||
/* check if still busy */
|
/* wait if still busy */
|
||||||
if (i2c_busy()) {
|
while (i2c_busy());
|
||||||
retval = -1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (index == AS3514_CVDD_DCDC3) {
|
if (index == AS3514_CVDD_DCDC3) {
|
||||||
/* prevent setting of the LREG_CP_not bit */
|
/* prevent setting of the LREG_CP_not bit */
|
||||||
value &= ~(1 << 5);
|
value &= ~(1 << 5);
|
||||||
|
|
@ -122,14 +117,11 @@ int ascodec_write(unsigned int index, unsigned int value)
|
||||||
I2C2_DACNT = 1;
|
I2C2_DACNT = 1;
|
||||||
|
|
||||||
/* wait for transfer */
|
/* wait for transfer */
|
||||||
while (i2c_busy());
|
while (I2C2_DACNT != 0);
|
||||||
|
|
||||||
retval = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ascodec_unlock();
|
ascodec_unlock();
|
||||||
|
|
||||||
return retval;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -140,21 +132,17 @@ int ascodec_read(unsigned int index)
|
||||||
|
|
||||||
ascodec_lock();
|
ascodec_lock();
|
||||||
|
|
||||||
/* check if still busy */
|
/* wait if still busy */
|
||||||
if (i2c_busy()) {
|
while (i2c_busy());
|
||||||
data = -1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* start transfer */
|
/* start transfer */
|
||||||
I2C2_SADDR = index;
|
I2C2_SADDR = index;
|
||||||
I2C2_CNTRL |= (1 << 1);
|
I2C2_CNTRL |= (1 << 1);
|
||||||
I2C2_DACNT = 1;
|
I2C2_DACNT = 1;
|
||||||
|
|
||||||
/* wait for transfer*/
|
/* wait for transfer*/
|
||||||
while (i2c_busy());
|
while (I2C2_DACNT != 0);
|
||||||
|
|
||||||
data = I2C2_DATA;
|
data = I2C2_DATA;
|
||||||
}
|
|
||||||
|
|
||||||
ascodec_unlock();
|
ascodec_unlock();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue