Sansa AMS i2c : fix 2 problems identified by Jack Halpin & Bertrik Sikken

i2c clock frequency uses pclk as reference, not plla
i2c clock divider is only 10 bits, not 16

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20929 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Rafaël Carré 2009-05-14 09:36:56 +00:00
parent 1123115559
commit 49c25816f0
2 changed files with 3 additions and 3 deletions

View file

@ -72,8 +72,8 @@ void ascodec_init(void)
/* prescaler for i2c clock */ /* prescaler for i2c clock */
prescaler = CLK_DIV(AS3525_PCLK_FREQ, AS3525_I2C_FREQ); prescaler = CLK_DIV(AS3525_PCLK_FREQ, AS3525_I2C_FREQ);
I2C2_CPSR0 = prescaler & 0xFF; I2C2_CPSR0 = prescaler & 0xFF; /* 8 lsb */
I2C2_CPSR1 = (prescaler >> 8) & 0xFF; I2C2_CPSR1 = (prescaler >> 8) & 0x3; /* 2 msb */
/* set i2c slave address of codec part */ /* set i2c slave address of codec part */
I2C2_SLAD0 = AS3514_I2C_ADDR << 1; I2C2_SLAD0 = AS3514_I2C_ADDR << 1;

View file

@ -53,7 +53,7 @@
#endif #endif
#define AS3525_I2C_FREQ 400000 #define AS3525_I2C_FREQ 400000
#if (CLK_DIV(AS3525_PLLA_FREQ, AS3525_I2C_FREQ)) >= (1<<16) /* 2*8 bits */ #if (CLK_DIV(AS3525_PCLK_FREQ, AS3525_I2C_FREQ)) >= (1<<10) /* 2+8 bits */
#error I2C frequency is too low : clock divider will not fit ! #error I2C frequency is too low : clock divider will not fit !
#endif #endif