diff options
-rw-r--r-- | apps/debug_menu.c | 28 | ||||
-rw-r--r-- | firmware/export/as3514.h | 9 | ||||
-rw-r--r-- | firmware/export/config-e200.h | 2 | ||||
-rw-r--r-- | firmware/target/arm/sandisk/sansa-e200/adc-e200.c | 24 | ||||
-rw-r--r-- | firmware/target/arm/sandisk/sansa-e200/adc-target.h | 22 |
5 files changed, 70 insertions, 15 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index b08fcb461f..996f13d55c 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -1190,6 +1190,34 @@ bool dbg_ports(void) | |||
1190 | lcd_puts(0, line++, buf); | 1190 | lcd_puts(0, line++, buf); |
1191 | snprintf(buf, sizeof(buf), "ADC_SCROLLPAD: %02x", adc_read(ADC_SCROLLPAD)); | 1191 | snprintf(buf, sizeof(buf), "ADC_SCROLLPAD: %02x", adc_read(ADC_SCROLLPAD)); |
1192 | lcd_puts(0, line++, buf); | 1192 | lcd_puts(0, line++, buf); |
1193 | #elif defined(SANSA_E200) | ||
1194 | line++; | ||
1195 | snprintf(buf, sizeof(buf), "ADC_BVDD: %02x", adc_read(ADC_BVDD)); | ||
1196 | lcd_puts(0, line++, buf); | ||
1197 | snprintf(buf, sizeof(buf), "ADC_RTCSUP: %02x", adc_read(ADC_RTCSUP)); | ||
1198 | lcd_puts(0, line++, buf); | ||
1199 | snprintf(buf, sizeof(buf), "ADC_UVDD: %02x", adc_read(ADC_UVDD)); | ||
1200 | lcd_puts(0, line++, buf); | ||
1201 | snprintf(buf, sizeof(buf), "ADC_CHG_IN: %02x", adc_read(ADC_CHG_IN)); | ||
1202 | lcd_puts(0, line++, buf); | ||
1203 | snprintf(buf, sizeof(buf), "ADC_CVDD: %02x", adc_read(ADC_CVDD)); | ||
1204 | lcd_puts(0, line++, buf); | ||
1205 | snprintf(buf, sizeof(buf), "ADC_BATTEMP: %02x", adc_read(ADC_BATTEMP)); | ||
1206 | lcd_puts(0, line++, buf); | ||
1207 | snprintf(buf, sizeof(buf), "ADC_MICSUP1: %02x", adc_read(ADC_MICSUP1)); | ||
1208 | lcd_puts(0, line++, buf); | ||
1209 | snprintf(buf, sizeof(buf), "ADC_MICSUP2: %02x", adc_read(ADC_MICSUP2)); | ||
1210 | lcd_puts(0, line++, buf); | ||
1211 | snprintf(buf, sizeof(buf), "ADC_VBE1: %02x", adc_read(ADC_VBE1)); | ||
1212 | lcd_puts(0, line++, buf); | ||
1213 | snprintf(buf, sizeof(buf), "ADC_VBE2: %02x", adc_read(ADC_VBE2)); | ||
1214 | lcd_puts(0, line++, buf); | ||
1215 | snprintf(buf, sizeof(buf), "ADC_I_MICSUP1: %02x", adc_read(ADC_I_MICSUP1)); | ||
1216 | lcd_puts(0, line++, buf); | ||
1217 | snprintf(buf, sizeof(buf), "ADC_I_MICSUP2: %02x", adc_read(ADC_I_MICSUP2)); | ||
1218 | lcd_puts(0, line++, buf); | ||
1219 | snprintf(buf, sizeof(buf), "ADC_VBAT: %02x", adc_read(ADC_VBAT)); | ||
1220 | lcd_puts(0, line++, buf); | ||
1193 | #endif | 1221 | #endif |
1194 | lcd_update(); | 1222 | lcd_update(); |
1195 | if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL)) | 1223 | if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL)) |
diff --git a/firmware/export/as3514.h b/firmware/export/as3514.h index 0bf87dbc46..3261765f7f 100644 --- a/firmware/export/as3514.h +++ b/firmware/export/as3514.h | |||
@@ -20,6 +20,8 @@ | |||
20 | #ifndef _AS3514_H | 20 | #ifndef _AS3514_H |
21 | #define _AS3514_H | 21 | #define _AS3514_H |
22 | 22 | ||
23 | #include <stdbool.h> | ||
24 | |||
23 | extern int tenthdb2master(int db); | 25 | extern int tenthdb2master(int db); |
24 | extern int tenthdb2mixer(int db); | 26 | extern int tenthdb2mixer(int db); |
25 | 27 | ||
@@ -67,6 +69,13 @@ extern void audiohw_set_equalizer_band(int band, int freq, int bw, int gain); | |||
67 | #define AUDIOSET3 0x16 | 69 | #define AUDIOSET3 0x16 |
68 | #define PLLMODE 0x1d | 70 | #define PLLMODE 0x1d |
69 | 71 | ||
72 | #define IRQ_ENRD0 0x25 | ||
73 | #define IRQ_ENRD1 0x26 | ||
74 | #define IRQ_ENRD2 0x27 | ||
75 | |||
76 | #define ADC_0 0x2e | ||
77 | #define ADC_1 0x2f | ||
78 | |||
70 | /* Headphone volume goes from -45.43 - 1.07dB */ | 79 | /* Headphone volume goes from -45.43 - 1.07dB */ |
71 | #define VOLUME_MIN -454 | 80 | #define VOLUME_MIN -454 |
72 | #define VOLUME_MAX 10 | 81 | #define VOLUME_MAX 10 |
diff --git a/firmware/export/config-e200.h b/firmware/export/config-e200.h index 1b3404a148..304c7062e5 100644 --- a/firmware/export/config-e200.h +++ b/firmware/export/config-e200.h | |||
@@ -88,7 +88,7 @@ | |||
88 | #define BATTERY_CAPACITY_MAX 750 /* max. capacity selectable */ | 88 | #define BATTERY_CAPACITY_MAX 750 /* max. capacity selectable */ |
89 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ | 89 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ |
90 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 90 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
91 | #define BATTERY_SCALE_FACTOR 5054 | 91 | #define BATTERY_SCALE_FACTOR 5005 /* ADC should read 0x3ff=5.12V */ |
92 | 92 | ||
93 | /* Hardware controlled charging? FIXME */ | 93 | /* Hardware controlled charging? FIXME */ |
94 | #define CONFIG_CHARGING CHARGING_SIMPLE | 94 | #define CONFIG_CHARGING CHARGING_SIMPLE |
diff --git a/firmware/target/arm/sandisk/sansa-e200/adc-e200.c b/firmware/target/arm/sandisk/sansa-e200/adc-e200.c index b3206d68d1..5e57e4bec5 100644 --- a/firmware/target/arm/sandisk/sansa-e200/adc-e200.c +++ b/firmware/target/arm/sandisk/sansa-e200/adc-e200.c | |||
@@ -18,23 +18,25 @@ | |||
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include "adc.h" | 19 | #include "adc.h" |
20 | #include "i2c-pp.h" | 20 | #include "i2c-pp.h" |
21 | #include "logf.h" | 21 | #include "as3514.h" |
22 | 22 | ||
23 | /* Read 10-bit channel data */ | 23 | /* Read 10-bit channel data */ |
24 | unsigned short adc_read(int channel) | 24 | unsigned short adc_read(int channel) |
25 | { | 25 | { |
26 | unsigned char bat[2]; | 26 | unsigned char buf[2]; |
27 | unsigned short data = 0; | 27 | unsigned short data = 0; |
28 | 28 | ||
29 | switch( channel) | 29 | /* Select channel */ |
30 | { | 30 | pp_i2c_send( AS3514_I2C_ADDR, ADC_0, (channel << 4)); |
31 | case ADC_UNREG_POWER: | 31 | |
32 | pp_i2c_send( 0x46, 0x2e, 0x0); | 32 | /* Wait for conversion to be complete */ |
33 | pp_i2c_send( 0x46, 0x27, 0x1); | 33 | pp_i2c_send( AS3514_I2C_ADDR, IRQ_ENRD2, 0x1); |
34 | i2c_readbytes( 0x46, 0x2e, 2, bat); | 34 | while( (i2c_readbyte( AS3514_I2C_ADDR, IRQ_ENRD2) & 0x1) == 0); |
35 | data = ((bat[0]<<8) | bat[1]); | 35 | |
36 | break; | 36 | /* Read data */ |
37 | } | 37 | i2c_readbytes( AS3514_I2C_ADDR, ADC_0, 2, buf); |
38 | data = (((buf[0] & 0x3) << 8) | buf[1]); | ||
39 | |||
38 | return data; | 40 | return data; |
39 | } | 41 | } |
40 | 42 | ||
diff --git a/firmware/target/arm/sandisk/sansa-e200/adc-target.h b/firmware/target/arm/sandisk/sansa-e200/adc-target.h index e9bff42a52..56efdf7574 100644 --- a/firmware/target/arm/sandisk/sansa-e200/adc-target.h +++ b/firmware/target/arm/sandisk/sansa-e200/adc-target.h | |||
@@ -19,9 +19,25 @@ | |||
19 | #ifndef _ADC_TARGET_H_ | 19 | #ifndef _ADC_TARGET_H_ |
20 | #define _ADC_TARGET_H_ | 20 | #define _ADC_TARGET_H_ |
21 | 21 | ||
22 | #define NUM_ADC_CHANNELS 1 | 22 | /* ADC channels */ |
23 | #define NUM_ADC_CHANNELS 13 | ||
23 | 24 | ||
24 | #define ADC_BATTERY 0 | 25 | #define ADC_BVDD 0 /* Battery voltage of 4V LiIo accumulator */ |
25 | #define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ | 26 | #define ADC_RTCSUP 1 /* RTC backup battery voltage */ |
27 | #define ADC_UVDD 2 /* USB host voltage */ | ||
28 | #define ADC_CHG_IN 3 /* Charger input voltage */ | ||
29 | #define ADC_CVDD 4 /* Charger pump output voltage */ | ||
30 | #define ADC_BATTEMP 5 /* Battery charging temperature */ | ||
31 | #define ADC_MICSUP1 6 /* Voltage on MicSup1 for remote control | ||
32 | or external voltage measurement */ | ||
33 | #define ADC_MICSUP2 7 /* Voltage on MicSup1 for remote control | ||
34 | or external voltage measurement */ | ||
35 | #define ADC_VBE1 8 /* Measuring junction temperature @ 2uA */ | ||
36 | #define ADC_VBE2 9 /* Measuring junction temperature @ 1uA */ | ||
37 | #define ADC_I_MICSUP1 10 /* Current of MicSup1 for remote control detection */ | ||
38 | #define ADC_I_MICSUP2 11 /* Current of MicSup2 for remote control detection */ | ||
39 | #define ADC_VBAT 12 /* Single cell battery voltage */ | ||
40 | |||
41 | #define ADC_UNREG_POWER ADC_BVDD /* For compatibility */ | ||
26 | 42 | ||
27 | #endif | 43 | #endif |