diff options
Diffstat (limited to 'firmware/target/sh/archos/fm_v2')
-rw-r--r-- | firmware/target/sh/archos/fm_v2/adc-target.h | 41 | ||||
-rw-r--r-- | firmware/target/sh/archos/fm_v2/backlight-target.h | 51 | ||||
-rw-r--r-- | firmware/target/sh/archos/fm_v2/button-fm_v2.c | 99 | ||||
-rw-r--r-- | firmware/target/sh/archos/fm_v2/button-target.h | 47 | ||||
-rw-r--r-- | firmware/target/sh/archos/fm_v2/power-fm_v2.c | 115 | ||||
-rw-r--r-- | firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c | 60 | ||||
-rw-r--r-- | firmware/target/sh/archos/fm_v2/usb-fm_v2.c | 49 |
7 files changed, 0 insertions, 462 deletions
diff --git a/firmware/target/sh/archos/fm_v2/adc-target.h b/firmware/target/sh/archos/fm_v2/adc-target.h deleted file mode 100644 index 0070828cf3..0000000000 --- a/firmware/target/sh/archos/fm_v2/adc-target.h +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef _ADC_TARGET_H_ | ||
22 | #define _ADC_TARGET_H_ | ||
23 | |||
24 | #define NUM_ADC_CHANNELS 8 | ||
25 | |||
26 | #define ADC_BATTERY 0 /* Battery voltage always reads 0x3FF due to | ||
27 | silly scaling */ | ||
28 | #define ADC_CHARGE_REGULATOR 0 /* Uh, we read the battery voltage? */ | ||
29 | #define ADC_USB_POWER 1 /* USB, reads 0x000 when USB is inserted */ | ||
30 | #define ADC_BUTTON_OFF 2 /* the off button, high value if pressed */ | ||
31 | #define ADC_BUTTON_ON 3 /* the on button, low value if pressed */ | ||
32 | #define ADC_BUTTON_ROW1 4 /* Used for scanning the keys, different | ||
33 | voltages for different keys */ | ||
34 | #define ADC_BUTTON_ROW2 5 /* Used for scanning the keys, different | ||
35 | voltages for different keys */ | ||
36 | #define ADC_UNREG_POWER 6 /* Battery voltage with a better scaling */ | ||
37 | #define ADC_EXT_POWER 7 /* The external power voltage, 0v or 2.7v */ | ||
38 | |||
39 | #define EXT_SCALE_FACTOR 14800 | ||
40 | |||
41 | #endif /* _ADC_TARGET_H_ */ | ||
diff --git a/firmware/target/sh/archos/fm_v2/backlight-target.h b/firmware/target/sh/archos/fm_v2/backlight-target.h deleted file mode 100644 index c3dd395eca..0000000000 --- a/firmware/target/sh/archos/fm_v2/backlight-target.h +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Jens Arnold | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef BACKLIGHT_TARGET_H | ||
22 | #define BACKLIGHT_TARGET_H | ||
23 | |||
24 | #include "config.h" | ||
25 | #include "rtc.h" | ||
26 | |||
27 | #define backlight_hw_init() true | ||
28 | |||
29 | static inline void backlight_hw_on(void) | ||
30 | { | ||
31 | rtc_write(0x13, 0x10); /* 32 kHz square wave */ | ||
32 | rtc_write(0x0a, rtc_read(0x0a) | 0x40); /* Enable square wave */ | ||
33 | } | ||
34 | |||
35 | static inline void backlight_hw_off(void) | ||
36 | { | ||
37 | /* While on, backlight is flashing at 32 kHz. If the square wave output | ||
38 | is disabled while the backlight is lit, it will become constantly lit, | ||
39 | (brighter) and slowly fade. This resets the square wave counter and | ||
40 | results in the unlit state */ | ||
41 | unsigned char rtc_0a = rtc_read(0x0a) & ~0x40; | ||
42 | rtc_write(0x0a, rtc_0a); /* Disable square wave */ | ||
43 | rtc_write(0x13, 0xF0); /* 1 Hz square wave */ | ||
44 | rtc_write(0x0a, rtc_0a | 0x40); /* Enable square wave */ | ||
45 | |||
46 | /* When the square wave output is disabled in the unlit state, | ||
47 | the backlight stays off */ | ||
48 | rtc_write(0x0a, rtc_0a); | ||
49 | } | ||
50 | |||
51 | #endif | ||
diff --git a/firmware/target/sh/archos/fm_v2/button-fm_v2.c b/firmware/target/sh/archos/fm_v2/button-fm_v2.c deleted file mode 100644 index 458917d2d5..0000000000 --- a/firmware/target/sh/archos/fm_v2/button-fm_v2.c +++ /dev/null | |||
@@ -1,99 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Jens Arnold | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "config.h" | ||
23 | #include "system.h" | ||
24 | #include "button.h" | ||
25 | #include "backlight.h" | ||
26 | #include "adc.h" | ||
27 | |||
28 | /* | ||
29 | Recorder FM/V2 hardware button hookup | ||
30 | ===================================== | ||
31 | |||
32 | F1, F2, F3, UP: connected to AN4 through a resistor network | ||
33 | DOWN, PLAY, LEFT, RIGHT: likewise connected to AN5 | ||
34 | |||
35 | The voltage on AN4/ AN5 depends on which keys (or key combo) is pressed | ||
36 | FM/V2 has PLAY and RIGHT switched compared to plain recorder | ||
37 | |||
38 | ON: AN3, low active | ||
39 | OFF: AN2, high active | ||
40 | */ | ||
41 | |||
42 | void button_init_device(void) | ||
43 | { | ||
44 | /* Set PB4 and PB8 as input pins */ | ||
45 | PBCR1 &= 0xfffc; /* PB8MD = 00 */ | ||
46 | PBCR2 &= 0xfcff; /* PB4MD = 00 */ | ||
47 | PBIOR &= ~0x0110; /* Inputs */ | ||
48 | } | ||
49 | |||
50 | int button_read_device(void) | ||
51 | { | ||
52 | int btn = BUTTON_NONE; | ||
53 | int data; | ||
54 | |||
55 | /* check F1..F3 and UP */ | ||
56 | data = adc_read(ADC_BUTTON_ROW1); | ||
57 | if (data >= 150) | ||
58 | { | ||
59 | if (data >= 545) | ||
60 | if (data >= 700) | ||
61 | btn = BUTTON_F3; | ||
62 | else | ||
63 | btn = BUTTON_UP; | ||
64 | else | ||
65 | if (data >= 385) | ||
66 | btn = BUTTON_F2; | ||
67 | else | ||
68 | btn = BUTTON_F1; | ||
69 | } | ||
70 | |||
71 | /* Some units have mushy keypads, so pressing UP also activates | ||
72 | the Left/Right buttons. Let's combat that by skipping the AN5 | ||
73 | checks when UP is pressed. */ | ||
74 | if(!(btn & BUTTON_UP)) | ||
75 | { | ||
76 | /* check DOWN, PLAY, LEFT, RIGHT */ | ||
77 | data = adc_read(ADC_BUTTON_ROW2); | ||
78 | if (data >= 150) | ||
79 | { | ||
80 | if (data >= 545) | ||
81 | if (data >= 700) | ||
82 | btn |= BUTTON_DOWN; | ||
83 | else | ||
84 | btn |= BUTTON_RIGHT; | ||
85 | else | ||
86 | if (data >= 385) | ||
87 | btn |= BUTTON_LEFT; | ||
88 | else | ||
89 | btn |= BUTTON_PLAY; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | if ( adc_read(ADC_BUTTON_ON) < 512 ) | ||
94 | btn |= BUTTON_ON; | ||
95 | if ( adc_read(ADC_BUTTON_OFF) > 512 ) | ||
96 | btn |= BUTTON_OFF; | ||
97 | |||
98 | return btn; | ||
99 | } | ||
diff --git a/firmware/target/sh/archos/fm_v2/button-target.h b/firmware/target/sh/archos/fm_v2/button-target.h deleted file mode 100644 index 47eb48c32d..0000000000 --- a/firmware/target/sh/archos/fm_v2/button-target.h +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Jens Arnold | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef _BUTTON_TARGET_H_ | ||
23 | #define _BUTTON_TARGET_H_ | ||
24 | |||
25 | /* Main unit's buttons */ | ||
26 | #define BUTTON_ON 0x00000001 | ||
27 | #define BUTTON_OFF 0x00000002 | ||
28 | |||
29 | #define BUTTON_LEFT 0x00000004 | ||
30 | #define BUTTON_RIGHT 0x00000008 | ||
31 | #define BUTTON_UP 0x00000010 | ||
32 | #define BUTTON_DOWN 0x00000020 | ||
33 | |||
34 | #define BUTTON_PLAY 0x00000040 | ||
35 | |||
36 | #define BUTTON_F1 0x00000080 | ||
37 | #define BUTTON_F2 0x00000100 | ||
38 | #define BUTTON_F3 0x00000200 | ||
39 | |||
40 | #define BUTTON_MAIN (BUTTON_ON|BUTTON_OFF|BUTTON_LEFT|BUTTON_RIGHT\ | ||
41 | |BUTTON_UP|BUTTON_DOWN|BUTTON_PLAY\ | ||
42 | |BUTTON_F1|BUTTON_F2|BUTTON_F3) | ||
43 | |||
44 | #define POWEROFF_BUTTON BUTTON_OFF | ||
45 | #define POWEROFF_COUNT 10 | ||
46 | |||
47 | #endif /* _BUTTON_TARGET_H_ */ | ||
diff --git a/firmware/target/sh/archos/fm_v2/power-fm_v2.c b/firmware/target/sh/archos/fm_v2/power-fm_v2.c deleted file mode 100644 index ce1ef19970..0000000000 --- a/firmware/target/sh/archos/fm_v2/power-fm_v2.c +++ /dev/null | |||
@@ -1,115 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "config.h" | ||
22 | #include "cpu.h" | ||
23 | #include <stdbool.h> | ||
24 | #include "adc.h" | ||
25 | #include "kernel.h" | ||
26 | #include "system.h" | ||
27 | #include "power.h" | ||
28 | #include "usb.h" | ||
29 | |||
30 | #if CONFIG_TUNER | ||
31 | bool tuner_power(bool status) | ||
32 | { | ||
33 | (void)status; | ||
34 | return true; | ||
35 | } | ||
36 | |||
37 | #endif /* #if CONFIG_TUNER */ | ||
38 | |||
39 | void power_init(void) | ||
40 | { | ||
41 | PBCR2 &= ~0x0c00; /* GPIO for PB5 */ | ||
42 | or_b(0x20, &PBIORL); | ||
43 | or_b(0x20, &PBDRL); /* hold power */ | ||
44 | } | ||
45 | |||
46 | unsigned int power_input_status(void) | ||
47 | { | ||
48 | unsigned int status = POWER_INPUT_NONE; | ||
49 | |||
50 | /* FM or V2 can also charge from the USB port */ | ||
51 | if (adc_read(ADC_CHARGE_REGULATOR) < 0x1FF) | ||
52 | status = POWER_INPUT_MAIN_CHARGER; | ||
53 | |||
54 | #ifdef HAVE_USB_POWER | ||
55 | if (usb_detect() == USB_INSERTED) | ||
56 | status |= POWER_INPUT_USB_CHARGER; | ||
57 | #endif | ||
58 | |||
59 | return status; | ||
60 | } | ||
61 | |||
62 | /* Returns true if the unit is charging the batteries. */ | ||
63 | bool charging_state(void) | ||
64 | { | ||
65 | /* We use the information from the ADC_EXT_POWER ADC channel, which | ||
66 | tells us the charging current from the LTC1734. When DC is | ||
67 | connected (either via the external adapter, or via USB), we try | ||
68 | to determine if it is actively charging or only maintaining the | ||
69 | charge. My tests show that ADC readings below about 0x80 means | ||
70 | that the LTC1734 is only maintaining the charge. */ | ||
71 | return adc_read(ADC_EXT_POWER) >= 0x80; | ||
72 | } | ||
73 | |||
74 | void ide_power_enable(bool on) | ||
75 | { | ||
76 | bool touched = false; | ||
77 | |||
78 | if(on) | ||
79 | { | ||
80 | or_b(0x20, &PADRL); | ||
81 | touched = true; | ||
82 | } | ||
83 | #ifdef HAVE_ATA_POWER_OFF | ||
84 | if(!on) | ||
85 | { | ||
86 | and_b(~0x20, &PADRL); | ||
87 | touched = true; | ||
88 | } | ||
89 | #endif /* HAVE_ATA_POWER_OFF */ | ||
90 | |||
91 | /* late port preparation, else problems with read/modify/write | ||
92 | of other bits on same port, while input and floating high */ | ||
93 | if (touched) | ||
94 | { | ||
95 | or_b(0x20, &PAIORL); /* PA5 is an output */ | ||
96 | PACR2 &= 0xFBFF; /* GPIO for PA5 */ | ||
97 | } | ||
98 | } | ||
99 | |||
100 | |||
101 | bool ide_powered(void) | ||
102 | { | ||
103 | if ((PACR2 & 0x0400) || !(PAIORL & 0x20)) /* not configured for output */ | ||
104 | return true; /* would be floating high, disk on */ | ||
105 | else | ||
106 | return (PADRL & 0x20) != 0; | ||
107 | } | ||
108 | |||
109 | void power_off(void) | ||
110 | { | ||
111 | disable_irq(); | ||
112 | and_b(~0x20, &PBDRL); | ||
113 | or_b(0x20, &PBIORL); | ||
114 | while(1); | ||
115 | } | ||
diff --git a/firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c b/firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c deleted file mode 100644 index 5dd7f26d2f..0000000000 --- a/firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese | ||
11 | * Revisions copyright (C) 2005 by Gerald Van Baren | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version 2 | ||
16 | * of the License, or (at your option) any later version. | ||
17 | * | ||
18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
19 | * KIND, either express or implied. | ||
20 | * | ||
21 | ****************************************************************************/ | ||
22 | |||
23 | #include "config.h" | ||
24 | #include "adc.h" | ||
25 | #include "powermgmt.h" | ||
26 | |||
27 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | ||
28 | { | ||
29 | 2800 | ||
30 | }; | ||
31 | |||
32 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = | ||
33 | { | ||
34 | 2580 | ||
35 | }; | ||
36 | |||
37 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ | ||
38 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = | ||
39 | { | ||
40 | /* measured values */ | ||
41 | { 2600, 2850, 2950, 3030, 3110, 3200, 3300, 3450, 3600, 3800, 4000 } | ||
42 | }; | ||
43 | |||
44 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ | ||
45 | const unsigned short percent_to_volt_charge[11] = | ||
46 | { | ||
47 | /* TODO: This is identical to the discharge curve. | ||
48 | * Calibrate charging curve using a battery_bench log. */ | ||
49 | 2600, 2850, 2950, 3030, 3110, 3200, 3300, 3450, 3600, 3800, 4000 | ||
50 | }; | ||
51 | |||
52 | /* Battery scale factor (guessed, seems to be 1,25 * value from recorder) */ | ||
53 | #define BATTERY_SCALE_FACTOR 8275 | ||
54 | /* full-scale ADC readout (2^10) in millivolt */ | ||
55 | |||
56 | /* Returns battery voltage from ADC [millivolts] */ | ||
57 | int _battery_voltage(void) | ||
58 | { | ||
59 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; | ||
60 | } | ||
diff --git a/firmware/target/sh/archos/fm_v2/usb-fm_v2.c b/firmware/target/sh/archos/fm_v2/usb-fm_v2.c deleted file mode 100644 index 5b11d778b6..0000000000 --- a/firmware/target/sh/archos/fm_v2/usb-fm_v2.c +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Jens Arnold | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "config.h" | ||
22 | #include <stdbool.h> | ||
23 | #include "adc.h" | ||
24 | #include "cpu.h" | ||
25 | #include "hwcompat.h" | ||
26 | #include "system.h" | ||
27 | #include "usb.h" | ||
28 | |||
29 | int usb_detect(void) | ||
30 | { | ||
31 | return (adc_read(ADC_USB_POWER) <= 512) ? USB_INSERTED : USB_EXTRACTED; | ||
32 | } | ||
33 | |||
34 | void usb_enable(bool on) | ||
35 | { | ||
36 | if(HW_MASK & USB_ACTIVE_HIGH) | ||
37 | on = !on; | ||
38 | |||
39 | if(on) | ||
40 | and_b(~0x04, &PADRH); /* enable USB */ | ||
41 | else | ||
42 | or_b(0x04, &PADRH); | ||
43 | } | ||
44 | |||
45 | void usb_init_device(void) | ||
46 | { | ||
47 | usb_enable(false); | ||
48 | or_b(0x04, &PAIORH); | ||
49 | } | ||