iPod Nano 2G: Set I2C clock to 374400 Hz, now that we know what it is derived from.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28589 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sparmann 2010-11-14 15:19:30 +00:00
parent b18d220e48
commit 81381a36b4

View file

@ -58,7 +58,7 @@ void i2c_init(void)
(0 << 6) | /* CLKSEL = PCLK/16 */ (0 << 6) | /* CLKSEL = PCLK/16 */
(1 << 5) | /* INT_EN */ (1 << 5) | /* INT_EN */
(1 << 4) | /* IRQ clear */ (1 << 4) | /* IRQ clear */
(7 << 0); /* CK_REG */ (3 << 0); /* CK_REG */
/* serial output on */ /* serial output on */
IICSTAT = (1 << 4); IICSTAT = (1 << 4);
@ -72,7 +72,7 @@ int i2c_write(unsigned char slave, int address, int len, const unsigned char *da
/* START */ /* START */
IICDS = slave & ~1; IICDS = slave & ~1;
IICSTAT = 0xF0; IICSTAT = 0xF0;
IICCON = 0xB7; IICCON = 0xB3;
while ((IICCON & 0x10) == 0) while ((IICCON & 0x10) == 0)
if (TIME_AFTER(current_tick, timeout)) if (TIME_AFTER(current_tick, timeout))
{ {
@ -84,7 +84,7 @@ int i2c_write(unsigned char slave, int address, int len, const unsigned char *da
if (address >= 0) { if (address >= 0) {
/* write address */ /* write address */
IICDS = address; IICDS = address;
IICCON = 0xB7; IICCON = 0xB3;
while ((IICCON & 0x10) == 0) while ((IICCON & 0x10) == 0)
if (TIME_AFTER(current_tick, timeout)) if (TIME_AFTER(current_tick, timeout))
{ {
@ -96,7 +96,7 @@ int i2c_write(unsigned char slave, int address, int len, const unsigned char *da
/* write data */ /* write data */
while (len--) { while (len--) {
IICDS = *data++; IICDS = *data++;
IICCON = 0xB7; IICCON = 0xB3;
while ((IICCON & 0x10) == 0) while ((IICCON & 0x10) == 0)
if (TIME_AFTER(current_tick, timeout)) if (TIME_AFTER(current_tick, timeout))
{ {
@ -107,7 +107,7 @@ int i2c_write(unsigned char slave, int address, int len, const unsigned char *da
/* STOP */ /* STOP */
IICSTAT = 0xD0; IICSTAT = 0xD0;
IICCON = 0xB7; IICCON = 0xB3;
while ((IICSTAT & (1 << 5)) != 0) while ((IICSTAT & (1 << 5)) != 0)
if (TIME_AFTER(current_tick, timeout)) if (TIME_AFTER(current_tick, timeout))
{ {
@ -128,7 +128,7 @@ int i2c_read(unsigned char slave, int address, int len, unsigned char *data)
/* START */ /* START */
IICDS = slave & ~1; IICDS = slave & ~1;
IICSTAT = 0xF0; IICSTAT = 0xF0;
IICCON = 0xB7; IICCON = 0xB3;
while ((IICCON & 0x10) == 0) while ((IICCON & 0x10) == 0)
if (TIME_AFTER(current_tick, timeout)) if (TIME_AFTER(current_tick, timeout))
{ {
@ -138,7 +138,7 @@ int i2c_read(unsigned char slave, int address, int len, unsigned char *data)
/* write address */ /* write address */
IICDS = address; IICDS = address;
IICCON = 0xB7; IICCON = 0xB3;
while ((IICCON & 0x10) == 0) while ((IICCON & 0x10) == 0)
if (TIME_AFTER(current_tick, timeout)) if (TIME_AFTER(current_tick, timeout))
{ {
@ -150,7 +150,7 @@ int i2c_read(unsigned char slave, int address, int len, unsigned char *data)
/* (repeated) START */ /* (repeated) START */
IICDS = slave | 1; IICDS = slave | 1;
IICSTAT = 0xB0; IICSTAT = 0xB0;
IICCON = 0xB7; IICCON = 0xB3;
while ((IICCON & 0x10) == 0) while ((IICCON & 0x10) == 0)
if (TIME_AFTER(current_tick, timeout)) if (TIME_AFTER(current_tick, timeout))
{ {
@ -159,7 +159,7 @@ int i2c_read(unsigned char slave, int address, int len, unsigned char *data)
} }
while (len--) { while (len--) {
IICCON = (len == 0) ? 0x37 : 0xB7; /* NACK or ACK */ IICCON = (len == 0) ? 0x33 : 0xB3; /* NAK or ACK */
while ((IICCON & 0x10) == 0) while ((IICCON & 0x10) == 0)
if (TIME_AFTER(current_tick, timeout)) if (TIME_AFTER(current_tick, timeout))
{ {
@ -171,7 +171,7 @@ int i2c_read(unsigned char slave, int address, int len, unsigned char *data)
/* STOP */ /* STOP */
IICSTAT = 0x90; IICSTAT = 0x90;
IICCON = 0xB7; IICCON = 0xB3;
while ((IICSTAT & (1 << 5)) != 0) while ((IICSTAT & (1 << 5)) != 0)
if (TIME_AFTER(current_tick, timeout)) if (TIME_AFTER(current_tick, timeout))
{ {