summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/arm/tms320dm320/i2c-dm320.c6
-rw-r--r--firmware/target/arm/tms320dm320/i2c-dm320.h12
-rw-r--r--firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c32
-rw-r--r--firmware/target/arm/tms320dm320/sansa-connect/power-sansaconnect.c6
4 files changed, 51 insertions, 5 deletions
diff --git a/firmware/target/arm/tms320dm320/i2c-dm320.c b/firmware/target/arm/tms320dm320/i2c-dm320.c
index 990dad0721..2530209402 100644
--- a/firmware/target/arm/tms320dm320/i2c-dm320.c
+++ b/firmware/target/arm/tms320dm320/i2c-dm320.c
@@ -287,4 +287,10 @@ int i2c_read(unsigned short address, unsigned char* buf, int count)
287 return i2c_read_data(dm320_i2c_bus, address, -1, buf, count); 287 return i2c_read_data(dm320_i2c_bus, address, -1, buf, count);
288} 288}
289 289
290int i2c_read_bytes(unsigned short address, unsigned short reg,
291 unsigned char* buf, int count)
292{
293 return i2c_read_data(dm320_i2c_bus, address, reg, buf, count);
294}
295
290#endif 296#endif
diff --git a/firmware/target/arm/tms320dm320/i2c-dm320.h b/firmware/target/arm/tms320dm320/i2c-dm320.h
index be7d02ed4d..7dfc19f046 100644
--- a/firmware/target/arm/tms320dm320/i2c-dm320.h
+++ b/firmware/target/arm/tms320dm320/i2c-dm320.h
@@ -19,6 +19,18 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22#ifndef I2C_DM320_H
23#define I2C_DM320_H
24
25#include "system.h"
26
22void i2c_init(void); 27void i2c_init(void);
23int i2c_write(unsigned short address, const unsigned char *data, int count); 28int i2c_write(unsigned short address, const unsigned char *data, int count);
24int i2c_read(unsigned short address, unsigned char* buf, int count); 29int i2c_read(unsigned short address, unsigned char* buf, int count);
30
31#ifdef HAVE_SOFTWARE_I2C
32int i2c_read_bytes(unsigned short address, unsigned short reg,
33 unsigned char* buf, int count);
34#endif
35
36#endif
diff --git a/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c b/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c
index 036b7db127..dedd017cf7 100644
--- a/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c
+++ b/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c
@@ -29,6 +29,7 @@
29#include "button.h" 29#include "button.h"
30#include "backlight.h" 30#include "backlight.h"
31#include "powermgmt.h" 31#include "powermgmt.h"
32#include "aic3x.h"
32 33
33//#define BUTTON_DEBUG 34//#define BUTTON_DEBUG
34 35
@@ -405,6 +406,26 @@ void GIO0(void)
405 /* interrupt will be enabled back after button read */ 406 /* interrupt will be enabled back after button read */
406 queue_post(&btn_queue, BTN_INTERRUPT, 0); 407 queue_post(&btn_queue, BTN_INTERRUPT, 0);
407} 408}
409
410void GIO2(void) __attribute__ ((section(".icode")));
411void GIO2(void)
412{
413 /* Clear interrupt */
414 IO_INTC_IRQ1 = (1 << 7);
415 /* Disable interrupt */
416 IO_INTC_EINT1 &= ~INTR_EINT1_EXT2;
417
418 if (IO_GIO_BITSET0 & 0x04)
419 {
420 aic3x_switch_output(false);
421 }
422 else
423 {
424 aic3x_switch_output(true);
425 }
426
427 IO_INTC_EINT1 |= INTR_EINT1_EXT2;
428}
408#endif 429#endif
409 430
410void button_init_device(void) 431void button_init_device(void)
@@ -425,12 +446,13 @@ void button_init_device(void)
425 avr_hid_get_state(); 446 avr_hid_get_state();
426 447
427#ifndef BOOTLOADER 448#ifndef BOOTLOADER
428 IO_GIO_IRQPORT |= 0x01; /* Enable GIO0 external interrupt */ 449 IO_GIO_IRQPORT |= 0x05; /* Enable GIO0/GIO2 external interrupt */
429 IO_GIO_INV0 &= ~0x01; /* Clear INV for GIO0 (falling edge detection) */ 450 IO_GIO_INV0 &= ~0x05; /* Clear INV for GIO0/GIO2 */
430 IO_GIO_IRQEDGE &= ~0x01; /* Set edge detection (falling) */ 451 /* falling edge detection on GIO0, any edge on GIO2 */
452 IO_GIO_IRQEDGE = (IO_GIO_IRQEDGE & ~0x01) | 0x04;
431 453
432 /* Enable GIO0 interrupt */ 454 /* Enable GIO0 and GIO2 interrupts */
433 IO_INTC_EINT1 |= INTR_EINT1_EXT0; 455 IO_INTC_EINT1 |= INTR_EINT1_EXT0 | INTR_EINT1_EXT2;
434#endif 456#endif
435} 457}
436 458
diff --git a/firmware/target/arm/tms320dm320/sansa-connect/power-sansaconnect.c b/firmware/target/arm/tms320dm320/sansa-connect/power-sansaconnect.c
index 07c80a07c3..f73df98641 100644
--- a/firmware/target/arm/tms320dm320/sansa-connect/power-sansaconnect.c
+++ b/firmware/target/arm/tms320dm320/sansa-connect/power-sansaconnect.c
@@ -49,6 +49,9 @@ static void tps65021_write_reg(unsigned reg, unsigned value)
49 49
50void power_init(void) 50void power_init(void)
51{ 51{
52 /* Enable LDO */
53 tps65021_write_reg(0x03, 0xFD);
54
52 /* PWM mode */ 55 /* PWM mode */
53 tps65021_write_reg(0x04, 0xB2); 56 tps65021_write_reg(0x04, 0xB2);
54 57
@@ -61,6 +64,9 @@ void power_init(void)
61 64
62void power_off(void) 65void power_off(void)
63{ 66{
67 /* Disable GIO0 and GIO2 interrupts */
68 IO_INTC_EINT1 &= ~(INTR_EINT1_EXT2 | INTR_EINT1_EXT0);
69
64 avr_hid_reset_codec(); 70 avr_hid_reset_codec();
65 avr_hid_power_off(); 71 avr_hid_power_off();
66} 72}