Sansa Connect: Revise codec initialization/shutdown.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31149 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Tomasz Moń 2011-12-05 09:53:23 +00:00
parent 4811b516a3
commit bac6a70184
6 changed files with 219 additions and 73 deletions

View file

@ -287,4 +287,10 @@ int i2c_read(unsigned short address, unsigned char* buf, int count)
return i2c_read_data(dm320_i2c_bus, address, -1, buf, count);
}
int i2c_read_bytes(unsigned short address, unsigned short reg,
unsigned char* buf, int count)
{
return i2c_read_data(dm320_i2c_bus, address, reg, buf, count);
}
#endif

View file

@ -19,6 +19,18 @@
*
****************************************************************************/
#ifndef I2C_DM320_H
#define I2C_DM320_H
#include "system.h"
void i2c_init(void);
int i2c_write(unsigned short address, const unsigned char *data, int count);
int i2c_read(unsigned short address, unsigned char* buf, int count);
#ifdef HAVE_SOFTWARE_I2C
int i2c_read_bytes(unsigned short address, unsigned short reg,
unsigned char* buf, int count);
#endif
#endif

View file

@ -29,6 +29,7 @@
#include "button.h"
#include "backlight.h"
#include "powermgmt.h"
#include "aic3x.h"
//#define BUTTON_DEBUG
@ -405,6 +406,26 @@ void GIO0(void)
/* interrupt will be enabled back after button read */
queue_post(&btn_queue, BTN_INTERRUPT, 0);
}
void GIO2(void) __attribute__ ((section(".icode")));
void GIO2(void)
{
/* Clear interrupt */
IO_INTC_IRQ1 = (1 << 7);
/* Disable interrupt */
IO_INTC_EINT1 &= ~INTR_EINT1_EXT2;
if (IO_GIO_BITSET0 & 0x04)
{
aic3x_switch_output(false);
}
else
{
aic3x_switch_output(true);
}
IO_INTC_EINT1 |= INTR_EINT1_EXT2;
}
#endif
void button_init_device(void)
@ -425,12 +446,13 @@ void button_init_device(void)
avr_hid_get_state();
#ifndef BOOTLOADER
IO_GIO_IRQPORT |= 0x01; /* Enable GIO0 external interrupt */
IO_GIO_INV0 &= ~0x01; /* Clear INV for GIO0 (falling edge detection) */
IO_GIO_IRQEDGE &= ~0x01; /* Set edge detection (falling) */
IO_GIO_IRQPORT |= 0x05; /* Enable GIO0/GIO2 external interrupt */
IO_GIO_INV0 &= ~0x05; /* Clear INV for GIO0/GIO2 */
/* falling edge detection on GIO0, any edge on GIO2 */
IO_GIO_IRQEDGE = (IO_GIO_IRQEDGE & ~0x01) | 0x04;
/* Enable GIO0 interrupt */
IO_INTC_EINT1 |= INTR_EINT1_EXT0;
/* Enable GIO0 and GIO2 interrupts */
IO_INTC_EINT1 |= INTR_EINT1_EXT0 | INTR_EINT1_EXT2;
#endif
}

View file

@ -49,6 +49,9 @@ static void tps65021_write_reg(unsigned reg, unsigned value)
void power_init(void)
{
/* Enable LDO */
tps65021_write_reg(0x03, 0xFD);
/* PWM mode */
tps65021_write_reg(0x04, 0xB2);
@ -61,6 +64,9 @@ void power_init(void)
void power_off(void)
{
/* Disable GIO0 and GIO2 interrupts */
IO_INTC_EINT1 &= ~(INTR_EINT1_EXT2 | INTR_EINT1_EXT0);
avr_hid_reset_codec();
avr_hid_power_off();
}