diff options
Diffstat (limited to 'firmware/target')
-rw-r--r-- | firmware/target/arm/as3525/ata_sd_as3525.c | 19 | ||||
-rw-r--r-- | firmware/target/arm/as3525/debug-as3525.c | 2 | ||||
-rw-r--r-- | firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c | 54 |
3 files changed, 25 insertions, 50 deletions
diff --git a/firmware/target/arm/as3525/ata_sd_as3525.c b/firmware/target/arm/as3525/ata_sd_as3525.c index 8ec90c5ced..a6265b37f4 100644 --- a/firmware/target/arm/as3525/ata_sd_as3525.c +++ b/firmware/target/arm/as3525/ata_sd_as3525.c | |||
@@ -122,7 +122,7 @@ static volatile bool retry; | |||
122 | static inline void mci_delay(void) { int i = 0xffff; while(i--) ; } | 122 | static inline void mci_delay(void) { int i = 0xffff; while(i--) ; } |
123 | 123 | ||
124 | #ifdef HAVE_HOTSWAP | 124 | #ifdef HAVE_HOTSWAP |
125 | #if defined(SANSA_E200V2) || defined(SANSA_FUZE) | 125 | #if defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_C200V2) |
126 | static int sd1_oneshot_callback(struct timeout *tmo) | 126 | static int sd1_oneshot_callback(struct timeout *tmo) |
127 | { | 127 | { |
128 | (void)tmo; | 128 | (void)tmo; |
@@ -146,7 +146,7 @@ void INT_GPIOA(void) | |||
146 | GPIOA_IC = (1<<2); | 146 | GPIOA_IC = (1<<2); |
147 | timeout_register(&sd1_oneshot, sd1_oneshot_callback, (3*HZ/10), 0); | 147 | timeout_register(&sd1_oneshot, sd1_oneshot_callback, (3*HZ/10), 0); |
148 | } | 148 | } |
149 | #endif /* defined(SANSA_E200V2) || defined(SANSA_FUZE) */ | 149 | #endif /* defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_C200V2) */ |
150 | #endif /* HAVE_HOTSWAP */ | 150 | #endif /* HAVE_HOTSWAP */ |
151 | 151 | ||
152 | void INT_NAND(void) | 152 | void INT_NAND(void) |
@@ -437,7 +437,7 @@ static void init_pl180_controller(const int drive) | |||
437 | VIC_INT_ENABLE |= | 437 | VIC_INT_ENABLE |= |
438 | (drive == INTERNAL_AS3525) ? INTERRUPT_NAND : INTERRUPT_MCI0; | 438 | (drive == INTERNAL_AS3525) ? INTERRUPT_NAND : INTERRUPT_MCI0; |
439 | 439 | ||
440 | #if defined(SANSA_E200V2) || defined(SANSA_FUZE) | 440 | #if defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_C200V2) |
441 | /* setup isr for microsd monitoring */ | 441 | /* setup isr for microsd monitoring */ |
442 | VIC_INT_ENABLE |= (INTERRUPT_GPIOA); | 442 | VIC_INT_ENABLE |= (INTERRUPT_GPIOA); |
443 | /* clear previous irq */ | 443 | /* clear previous irq */ |
@@ -886,13 +886,12 @@ tCardInfo *card_get_info_target(int card_no) | |||
886 | 886 | ||
887 | bool card_detect_target(void) | 887 | bool card_detect_target(void) |
888 | { | 888 | { |
889 | #ifdef HAVE_HOTSWAP | 889 | #if defined(HAVE_HOTSWAP) && \ |
890 | /* TODO: add e200/c200 */ | 890 | (defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_C200V2)) |
891 | #if defined(SANSA_E200V2) || defined(SANSA_FUZE) | ||
892 | return !(GPIOA_PIN(2)); | 891 | return !(GPIOA_PIN(2)); |
893 | #endif | 892 | #else |
894 | #endif | ||
895 | return false; | 893 | return false; |
894 | #endif | ||
896 | } | 895 | } |
897 | 896 | ||
898 | #ifdef HAVE_HOTSWAP | 897 | #ifdef HAVE_HOTSWAP |
@@ -901,14 +900,14 @@ void card_enable_monitoring_target(bool on) | |||
901 | if (on) | 900 | if (on) |
902 | { | 901 | { |
903 | /* add e200v2/c200v2 here */ | 902 | /* add e200v2/c200v2 here */ |
904 | #if defined(SANSA_E200V2) || defined(SANSA_FUZE) | 903 | #if defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_C200V2) |
905 | /* enable isr*/ | 904 | /* enable isr*/ |
906 | GPIOA_IE |= (1<<2); | 905 | GPIOA_IE |= (1<<2); |
907 | #endif | 906 | #endif |
908 | } | 907 | } |
909 | else | 908 | else |
910 | { | 909 | { |
911 | #if defined(SANSA_E200V2) || defined(SANSA_FUZE) | 910 | #if defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_C200V2) |
912 | /* edisable isr*/ | 911 | /* edisable isr*/ |
913 | GPIOA_IE &= ~(1<<2); | 912 | GPIOA_IE &= ~(1<<2); |
914 | #endif | 913 | #endif |
diff --git a/firmware/target/arm/as3525/debug-as3525.c b/firmware/target/arm/as3525/debug-as3525.c index 7585f76431..405b7109b1 100644 --- a/firmware/target/arm/as3525/debug-as3525.c +++ b/firmware/target/arm/as3525/debug-as3525.c | |||
@@ -65,7 +65,7 @@ | |||
65 | /* FIXME: target tree is including ./debug-target.h rather than the one in | 65 | /* FIXME: target tree is including ./debug-target.h rather than the one in |
66 | * sansa-fuze/, even though deps contains the correct one | 66 | * sansa-fuze/, even though deps contains the correct one |
67 | * if I put the below into a sansa-fuze/debug-target.h, it doesn't work*/ | 67 | * if I put the below into a sansa-fuze/debug-target.h, it doesn't work*/ |
68 | #if defined(SANSA_FUZE) || defined(SANSA_E200V2) | 68 | #if defined(SANSA_FUZE) || defined(SANSA_E200V2) || defined(SANSA_C200V2) |
69 | #define DEBUG_DBOP | 69 | #define DEBUG_DBOP |
70 | unsigned short button_dbop_data(void); | 70 | unsigned short button_dbop_data(void); |
71 | #endif | 71 | #endif |
diff --git a/firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c b/firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c index d3504c97e9..965006ce61 100644 --- a/firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c +++ b/firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c | |||
@@ -36,6 +36,12 @@ static bool hold_button = false; | |||
36 | static bool hold_button_old = false; | 36 | static bool hold_button_old = false; |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | /* for the debug menu */ | ||
40 | unsigned short button_dbop_data(void) | ||
41 | { | ||
42 | return _dbop_din; | ||
43 | } | ||
44 | |||
39 | void button_init_device(void) | 45 | void button_init_device(void) |
40 | { | 46 | { |
41 | GPIOA_DIR &= ~(1<<3); | 47 | GPIOA_DIR &= ~(1<<3); |
@@ -54,9 +60,6 @@ static void button_read_dbop(void) | |||
54 | DBOP_TIMPOL_01 = 0xe167e167; /* Set Timing & Polarity regs 0 & 1 */ | 60 | DBOP_TIMPOL_01 = 0xe167e167; /* Set Timing & Polarity regs 0 & 1 */ |
55 | DBOP_TIMPOL_23 = 0xe167006e; /* Set Timing & Polarity regs 2 & 3 */ | 61 | DBOP_TIMPOL_23 = 0xe167006e; /* Set Timing & Polarity regs 2 & 3 */ |
56 | 62 | ||
57 | int i = 50; | ||
58 | while(i--) asm volatile ("nop\n"); | ||
59 | |||
60 | DBOP_CTRL |= (1<<15); /* start read */ | 63 | DBOP_CTRL |= (1<<15); /* start read */ |
61 | while (!(DBOP_STAT & (1<<16))); /* wait for valid data */ | 64 | while (!(DBOP_STAT & (1<<16))); /* wait for valid data */ |
62 | 65 | ||
@@ -74,52 +77,25 @@ static void button_read_dbop(void) | |||
74 | */ | 77 | */ |
75 | int button_read_device(void) | 78 | int button_read_device(void) |
76 | { | 79 | { |
77 | int delay; | ||
78 | int dir_save_c = 0; | ||
79 | int afsel_save_c = 0; | ||
80 | int btn = BUTTON_NONE; | 80 | int btn = BUTTON_NONE; |
81 | 81 | ||
82 | /* Save the current direction and afsel */ | ||
83 | dir_save_c = GPIOC_DIR; | ||
84 | afsel_save_c = GPIOC_AFSEL; | ||
85 | |||
86 | GPIOC_AFSEL &= ~(1<<6|1<<5|1<<4|1<<3); | ||
87 | GPIOC_DIR |= (1<<6|1<<5|1<<4|1<<3); | ||
88 | |||
89 | /* These should not be needed with button event interupts */ | ||
90 | /* they are necessary now to clear out lcd data */ | ||
91 | |||
92 | GPIOC_PIN(6) = (1<<6); | ||
93 | GPIOC_PIN(5) = (1<<5); | ||
94 | GPIOC_PIN(4) = (1<<4); | ||
95 | GPIOC_PIN(3) = (1<<3); | ||
96 | GPIOC_DIR &= ~(1<<6|1<<5|1<<4|1<<3); | ||
97 | |||
98 | delay = 100; | ||
99 | while(delay--) | ||
100 | asm volatile("nop\n"); | ||
101 | |||
102 | /* direct GPIO connections */ | 82 | /* direct GPIO connections */ |
103 | if (GPIOA_PIN(3)) | 83 | if (GPIOA_PIN(3)) |
104 | btn |= BUTTON_POWER; | 84 | btn |= BUTTON_POWER; |
105 | if (!GPIOC_PIN(6)) | ||
106 | btn |= BUTTON_RIGHT; | ||
107 | if (!GPIOC_PIN(5)) | ||
108 | btn |= BUTTON_UP; | ||
109 | if (!GPIOC_PIN(4)) | ||
110 | btn |= BUTTON_SELECT; | ||
111 | if (!GPIOC_PIN(3)) | ||
112 | btn |= BUTTON_DOWN; | ||
113 | |||
114 | /* return to settings needed for lcd */ | ||
115 | GPIOC_DIR = dir_save_c; | ||
116 | GPIOC_AFSEL = afsel_save_c; | ||
117 | 85 | ||
118 | if(lcd_button_support()) | 86 | if(lcd_button_support()) |
119 | button_read_dbop(); | 87 | button_read_dbop(); |
120 | 88 | ||
121 | if(_dbop_din & (1<<6)) | 89 | if(!(_dbop_din & (1<<2))) |
122 | btn |= BUTTON_LEFT; | 90 | btn |= BUTTON_LEFT; |
91 | if(!(_dbop_din & (1<<3))) | ||
92 | btn |= BUTTON_DOWN; | ||
93 | if(!(_dbop_din & (1<<4))) | ||
94 | btn |= BUTTON_SELECT; | ||
95 | if(!(_dbop_din & (1<<5))) | ||
96 | btn |= BUTTON_UP; | ||
97 | if(!(_dbop_din & (1<<6))) | ||
98 | btn |= BUTTON_RIGHT; | ||
123 | 99 | ||
124 | #ifndef BOOTLOADER | 100 | #ifndef BOOTLOADER |
125 | /* light handling */ | 101 | /* light handling */ |