Send commitlog mailing list submissions to
[EMAIL PROTECTED]
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
[EMAIL PROTECTED]
You can reach the person managing the list at
[EMAIL PROTECTED]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:
1. r1743 - developers/werner/usb-pullup ([EMAIL PROTECTED])
2. r1744 - trunk/src/target/OM-2007/openmoko-libs/libmokogsmd
([EMAIL PROTECTED])
3. r1745 - trunk/src/target/OM-2007/openmoko-libs
([EMAIL PROTECTED])
4. r1746 - trunk/src/target/OM-2007/openmoko-libs
([EMAIL PROTECTED])
--- Begin Message ---
Author: werner
Date: 2007-04-14 00:31:20 +0200 (Sat, 14 Apr 2007)
New Revision: 1743
Modified:
developers/werner/usb-pullup/README
developers/werner/usb-pullup/new.fig
developers/werner/usb-pullup/new.spice
developers/werner/usb-pullup/runs
developers/werner/usb-pullup/si.pl
Log:
Improved performance with high-impedance load on D+.
Modified: developers/werner/usb-pullup/README
===================================================================
--- developers/werner/usb-pullup/README 2007-04-13 19:58:31 UTC (rev 1742)
+++ developers/werner/usb-pullup/README 2007-04-13 22:31:20 UTC (rev 1743)
@@ -6,13 +6,9 @@
2) Replace R1911, Q4901, R4910, and D4910 with the circuit shown
in new.fig
- For Q1, Q2, RB1, and RB2 an NXP PEMH19 can be used, so the number
+ For Q1, Q2, RB1, and RB2 an NXP PEMH14 can be used, so the number
of components stays the same.
- R4910 is split into R1 and R2 in order to bias both transistors.
- The value of R1 and R2 has been slightly adjusted to compensate
- for losses over Q1 and Q2.
-
This two-transistor solution also eliminates the USB_PULLUP to
nRESET path that might allow mis-configured GPIO to keep the
device out of reset.
@@ -44,22 +40,19 @@
The simulation also models the 10 uA the CPU may draw on nRESET.
To perform all simulations shown here, simply run "./runs".
-USB attached:
+An example:
-Switches Q2.IE I(IO_3V3) V(nRESET)
-USB: 2.09 mA 2.10 mA 2.63 V pull-up enabled
-USB+UG: 2.26 pA 58.11 uA 2.96 V pull-up disabled
-USB+UP: 2.31 mA 2.32 mA 2.61 V invalid !
-USB+RG: 3.04 pA 100.00 uA 90.00 nV reset
-USB+RG+UG: 0.00 pA 100.00 uA 90.00 nV reset
-USB+RG+UP: 184.93 uA 284.92 uA 90.00 nV reset (*)
+RUSB=1000:
+Switches Q2.IE V(RUSB) I(IO_3V3) V(nRESET)
+: 1.24 mA 1.24 V 1.25 mA 3.02 V pull-up enabled
+UG: 2.92 pA 2.92 nV 80.21 uA 3.20 V pull-up disabled
+UP: 1.26 mA 1.26 V 1.27 mA 3.01 V invalid !
+RG: 27.38 uA 27.38 mV 357.38 uA 320.00 nV reset
+RG+UG: 1.10 pA 1.10 nV 400.21 uA 320.00 nV reset
+RG+UP: 53.83 uA 53.83 mV 383.83 uA 320.00 nV reset (*)
+Here, the external load on D+ is 1000 kOhm to ground. The columns
+show the current into the load, the voltage on D+, the total
+current drawn from IO_3V3, and the resulting voltage on nRESET.
-Without USB:
-
-Switches Q2.IE I(IO_3V3) V(nRESET)
-: 0.00 pA 10.00 uA 2.97 V pull-up enabled
-UG: 0.00 pA 58.11 uA 2.96 V pull-up disabled
-RG: 0.00 pA 100.00 uA 90.00 nV reset
-
(*) Is such a high Q2.IE acceptable in this (probably rare) state ?
Modified: developers/werner/usb-pullup/new.fig
===================================================================
--- developers/werner/usb-pullup/new.fig 2007-04-13 19:58:31 UTC (rev
1742)
+++ developers/werner/usb-pullup/new.fig 2007-04-13 22:31:20 UTC (rev
1743)
@@ -7,121 +7,129 @@
Single
-2
1200 2
-6 3225 3975 3900 4125
+6 10500 7800 11100 8700
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 10800 7800 10800 8400
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 10500 8400 11100 8400
+4 1 0 50 -1 2 12 0.0000 4 135 90 10800 8700 0\001
+-6
+6 5625 3375 6300 3525
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 3225 3975 3375 3975 3375 4125 3225 4125 3225 3975
-4 0 0 50 -1 0 12 0.0000 4 135 375 3525 4125 RRG\001
+ 5625 3375 5775 3375 5775 3525 5625 3525 5625 3375
+4 0 0 50 -1 0 12 0.0000 4 135 375 5925 3525 RRG\001
-6
-6 8250 7200 8850 8100
+1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 4800 3450 300 300 4800 3450 5100 3450
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+ 6000 5700 6300 5700 6300 6600 6000 6600 6000 5700
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+ 6600 7200 7500 7200 7500 7500 6600 7500 6600 7200
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 8550 7200 8550 7800
+ 8100 6900 8100 7800
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 8250 7800 8850 7800
-4 1 0 50 -1 2 12 0.0000 4 135 90 8550 8100 0\001
--6
-1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 2400 4050 300 300 2400 4050 2700 4050
+ 3600 7350 6600 7350
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 6150 6600 6150 7350
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 7500 7350 8100 7350
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 3600 8100 3600 6450
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 3300 8100 3900 8100
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 3600 6300 3600 6000
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 3450 6150 3750 6150
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 3900 3300 4800 3300 4800 3600 3900 3600 3900 3300
+ 3525 6825 3675 6825 3675 6975 3525 6975 3525 6825
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+ 3525 7575 3675 7575 3675 7725 3525 7725 3525 7575
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+ 9300 7650 10200 7650 10200 7950 9300 7950 9300 7650
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 8550 7800 9300 7800
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 10200 7800 10800 7800
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 3
+ 1 0 1.00 60.00 120.00
+ 8550 6900 8100 7350 8550 7800
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+ 6300 2700 7200 2700 7200 3000 6300 3000 6300 2700
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
- 3900 3450 3300 3450 3300 4800
+ 6300 2850 5700 2850 5700 4200
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 3300 3450 3300 2700
+ 5700 2850 5700 2100
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 5700 3000 5700 3900
+ 8100 2400 8100 3300
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 4800 3450 5700 3450
+ 7200 2850 8100 2850
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
1 0 1.00 60.00 120.00
- 5700 3450 6150 3900
+ 8100 2850 8550 3300
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 6000 1800 6300 1800 6300 2700 6000 2700 6000 1800
+ 8400 1200 8700 1200 8700 2100 8400 2100 8400 1200
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 6150 1350 6150 1800
+ 8550 750 8550 1200
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
- 6150 2700 6150 3000 5700 3450
+ 8550 2100 8550 2400 8100 2850
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 6150 3900 6150 5100
+ 5700 300 5700 600
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 3300 900 3300 1200
+ 5550 450 5850 450
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 3150 1050 3450 1050
+ 8550 300 8550 600
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 6150 900 6150 1200
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 6000 1050 6300 1050
+ 8400 450 8700 450
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 3150 1800 3450 1800 3450 2700 3150 2700 3150 1800
+ 5550 1200 5850 1200 5850 2100 5550 2100 5550 1200
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 3300 1350 3300 1800
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 6900 4350 7800 4350 7800 4650 6900 4650 6900 4350
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 6150 4500 6900 4500
+ 5700 750 5700 1200
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
- 3300 3450 2400 3450 2400 3750
+ 5700 2850 4800 2850 4800 3150
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
1 0 1.00 60.00 120.00
- 2400 3825 2400 4275
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 5
- 1 0 1.00 60.00 120.00
- 7800 4500 8550 4500 8550 6300 8100 6750 8550 7200
+ 4800 3225 4800 3675
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 3000 4800 3600 4800
+ 5400 4200 6000 4200
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 2100 4800 2700 4800
+ 4500 4200 5100 4200
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 2400 4350 2400 4800
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 6000 5100 6300 5100 6300 6000 6000 6000 6000 5100
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 6600 6600 7500 6600 7500 6900 6600 6900 6600 6600
+ 4800 3750 4800 4200
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 8100 6300 8100 7200
+ 6150 5250 6150 5700
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 3600 6750 6600 6750
+ 6000 4950 6300 4950
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 6150 6000 6150 6750
+ 6150 4800 6150 5100
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 7500 6750 8100 6750
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 3600 7500 3600 5850
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 3300 7500 3900 7500
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 3600 5700 3600 5400
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 3450 5550 3750 5550
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 3525 6225 3675 6225 3675 6375 3525 6375 3525 6225
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 3525 6975 3675 6975 3675 7125 3525 7125 3525 6975
-4 0 0 50 -1 0 12 0.0000 4 135 705 3600 2325 RR = 33k\001
-4 0 0 50 -1 0 12 0.0000 4 135 675 6450 2325 R1 = 680\001
-4 1 0 50 -1 0 12 0.0000 4 135 795 4350 3150 RB1 = 22k\001
-4 0 0 50 -1 0 12 0.0000 4 180 1200 6000 3525 Q1 (hFE = 200)\001
-4 0 0 50 -1 2 12 0.0000 4 135 90 3450 1725 1\001
-4 0 0 50 -1 2 12 0.0000 4 135 90 6300 1725 1\001
-4 1 0 50 -1 2 12 0.0000 4 135 90 5250 3300 3\001
-4 1 0 50 -1 2 12 0.0000 4 135 90 6300 3075 4\001
-4 1 0 50 -1 0 12 0.0000 4 135 675 7350 4200 R2 = 680\001
-4 1 0 50 -1 2 12 0.0000 4 135 90 6000 4575 5\001
-4 1 0 50 -1 2 12 0.0000 4 135 90 3150 3300 2\001
-4 0 0 50 -1 0 12 0.0000 4 135 840 3600 1125 VIO =3.3V\001
-4 1 0 50 -1 2 12 0.0000 4 135 90 3000 1125 1\001
-4 1 0 50 -1 2 12 0.0000 4 135 90 5850 1125 1\001
-4 1 0 50 -1 2 12 0.0000 4 135 90 3300 5100 0\001
-4 1 0 50 -1 2 12 0.0000 4 135 90 2400 5100 0\001
-4 1 0 50 -1 0 12 0.0000 4 135 795 7050 6450 RB2 = 22k\001
-4 0 0 50 -1 0 12 0.0000 4 180 1200 8400 6825 Q2 (hFE = 200)\001
-4 0 0 50 -1 0 12 0.0000 4 135 720 6450 5625 RU = 47k\001
-4 1 0 50 -1 2 12 0.0000 4 135 90 3600 7800 0\001
-4 1 0 50 -1 2 12 0.0000 4 135 90 5850 6600 7\001
-4 1 0 50 -1 2 12 0.0000 4 135 90 8700 5625 8\001
-4 1 0 50 -1 2 12 0.0000 4 135 90 7800 6600 9\001
-4 1 0 50 -1 2 12 0.0000 4 135 180 8700 7275 10\001
-4 0 0 50 -1 0 12 0.0000 4 135 360 3825 6375 RUP\001
-4 0 0 50 -1 0 12 0.0000 4 135 390 3750 7125 RUG\001
-4 0 0 50 -1 0 12 0.0000 4 180 5145 3600 8925 Q1, Q2, RB1, and RB2 are
integrated in an NXP PEMH19 dual NPN\001
-4 1 0 50 -1 2 12 0.0000 4 135 90 3300 5625 1\001
-4 2 0 50 -1 0 12 0.0000 4 135 555 1950 4275 = 10uA\001
-4 2 0 50 -1 0 12 0.0000 4 135 630 1950 3975 IRESET\001
+ 8550 3300 8550 6900
+4 1 0 50 -1 0 12 0.0000 4 135 795 7050 7050 RB2 = 22k\001
+4 0 0 50 -1 0 12 0.0000 4 180 1200 8400 7425 Q2 (hFE = 200)\001
+4 0 0 50 -1 0 12 0.0000 4 135 720 6450 6225 RU = 47k\001
+4 1 0 50 -1 2 12 0.0000 4 135 90 3600 8400 0\001
+4 1 0 50 -1 2 12 0.0000 4 135 90 5850 7200 7\001
+4 1 0 50 -1 2 12 0.0000 4 135 90 7800 7200 9\001
+4 0 0 50 -1 0 12 0.0000 4 135 360 3825 6975 RUP\001
+4 0 0 50 -1 0 12 0.0000 4 135 390 3750 7725 RUG\001
+4 0 0 50 -1 0 12 0.0000 4 180 5145 3600 9525 Q1, Q2, RB1, and RB2 are
integrated in an NXP PEMH19 dual NPN\001
+4 1 0 50 -1 2 12 0.0000 4 135 90 3300 6225 1\001
+4 1 0 50 -1 0 12 0.0000 4 135 480 9750 7875 RUSB\001
+4 1 0 50 -1 2 12 0.0000 4 135 180 8700 8025 10\001
+4 0 0 50 -1 0 12 0.0000 4 135 705 6000 1725 RR = 33k\001
+4 0 0 50 -1 0 12 0.0000 4 135 765 8850 1725 R1 = 1500\001
+4 1 0 50 -1 0 12 0.0000 4 135 795 6750 2550 RB1 = 22k\001
+4 0 0 50 -1 0 12 0.0000 4 180 1200 8400 2925 Q1 (hFE = 200)\001
+4 0 0 50 -1 2 12 0.0000 4 135 90 5850 1125 1\001
+4 0 0 50 -1 2 12 0.0000 4 135 90 8700 1125 1\001
+4 1 0 50 -1 2 12 0.0000 4 135 90 7650 2700 3\001
+4 1 0 50 -1 2 12 0.0000 4 135 90 8700 2475 4\001
+4 1 0 50 -1 2 12 0.0000 4 135 90 5550 2700 2\001
+4 0 0 50 -1 0 12 0.0000 4 135 840 6000 525 VIO =3.3V\001
+4 1 0 50 -1 2 12 0.0000 4 135 90 5400 525 1\001
+4 1 0 50 -1 2 12 0.0000 4 135 90 8250 525 1\001
+4 1 0 50 -1 2 12 0.0000 4 135 90 5700 4500 0\001
+4 1 0 50 -1 2 12 0.0000 4 135 90 4800 4500 0\001
+4 2 0 50 -1 0 12 0.0000 4 135 555 4350 3675 = 10uA\001
+4 2 0 50 -1 0 12 0.0000 4 135 630 4350 3375 IRESET\001
+4 1 0 50 -1 2 12 0.0000 4 135 90 5850 5025 1\001
+4 1 0 50 -1 2 12 0.0000 4 135 90 8700 5025 5\001
Modified: developers/werner/usb-pullup/new.spice
===================================================================
--- developers/werner/usb-pullup/new.spice 2007-04-13 19:58:31 UTC (rev
1742)
+++ developers/werner/usb-pullup/new.spice 2007-04-13 22:31:20 UTC (rev
1743)
@@ -3,28 +3,27 @@
VIO 1 0 DC 3.3
IRESET 2 0 DC 0.00001
-RR 1 2 33000
-RB1 2 3 22000
-RB2 7 9 22000
-RU 5 7 47000
+RR 1 2 10000
+RB1 2 3 47000
+RB2 7 9 47000
+RU 1 7 47000
-* Drop IO_3V3 in two steps, so that we get a useful bias on each transistor
-R1 1 4 680
-R3 5 8 680
+R1 1 4 1500
Q1 4 3 5 QMOD
-Q2 8 9 10 QMOD
+Q2 5 9 10 QMOD
+* Change <RUSB> to the respective resistance of the load
+RUSB 10 0 <RUSB>
+
* Switch: uncomment to pull nRESET low
*RRG 2 0 0.001
* Switch: uncomment to drive USB_PULLUP high (invalid !)
*RUP 1 7 0.001
* Switch: uncomment to drive USB_PULLUP low
*RUG 7 0 0.001
-* Switch: uncomment to connect USB
-*RUSB 10 0 0.001
.MODEL QMOD NPN BF=200
.OP
-.PRINT OP @Q2[IE] I(VIO) V(2)
+.PRINT OP @Q2[IE] V(10) I(VIO) V(2)
.END
Modified: developers/werner/usb-pullup/runs
===================================================================
--- developers/werner/usb-pullup/runs 2007-04-13 19:58:31 UTC (rev 1742)
+++ developers/werner/usb-pullup/runs 2007-04-13 22:31:20 UTC (rev 1743)
@@ -1,13 +1,17 @@
#!/bin/sh
-echo "Switches Q2.IE I(IO_3V3) V(nRESET)"
-for n in USB USB+UG USB+UP USB+RG USB+RG+UG USB+RG+UP \
- '' UG RG; do
- printf "%-16s" "$n:"
- sed '/^\*R\('`echo "$n" |
- sed 's/+/\\\\|/g'`'\) /s/^.//' <new.spice |
- spice -b 2>/dev/null |
- sed '/^0 */s///p;d' |
- perl si.pl A A V
+for r in 0.0001 1000 10000 1000000; do
+ echo
+ echo "RUSB=$r:"
+ echo "Switches Q2.IE V(RUSB) I(IO_3V3) V(nRESET)"
+ for n in '' UG UP RG RG+UG RG+UP; do
+ printf "%-12s" "$n:"
+ sed '/^\*R\('`echo "$n" |
+ sed 's/+/\\\\|/g'`'\) /s/^.//' <new.spice |
+ sed 's/<RUSB>/'$r'/' |
+ spice -b 2>/dev/null |
+ sed '/^0 */s///p;d' |
+ perl si.pl A V A V
+ done
done
# Don't know why SPICE complains about my .PRINT commands. It does the right
Modified: developers/werner/usb-pullup/si.pl
===================================================================
--- developers/werner/usb-pullup/si.pl 2007-04-13 19:58:31 UTC (rev 1742)
+++ developers/werner/usb-pullup/si.pl 2007-04-13 22:31:20 UTC (rev 1743)
@@ -2,33 +2,47 @@
sub cvt
{
- $_[0] =~ /-?(\d.\d+)e[-+](\d+)/ || die "$_[0]";
+ $_[0] =~ /-?(\d.\d+)e([-+]\d+)/ || die "$_[0]";
$m = $1;
$e = $2;
- $p = " ";
- while ($e % 3) {
+ while (abs($e) % 3) {
$m *= 10;
- $e++;
+ $e--;
}
- if ($e > 9) {
+ if ($e < -9) {
$p = "p";
- $e -= 12;
+ $e += 12;
}
- elsif ($e > 6) {
+ elsif ($e < -6) {
$p = "n";
- $e -= 9;
+ $e += 9;
}
- elsif ($e > 3) {
+ elsif ($e < -3) {
$p = "u";
- $e -= 6;
+ $e += 6;
}
- elsif ($e > 0) {
+ elsif ($e < 0) {
$p = "m";
+ $e += 3;
+ }
+ elsif ($e < 3) {
+ $p = " ";
+ }
+ elsif ($e < 6) {
+ $p = "k";
$e -= 3;
}
- while ($e > 0) {
+ elsif ($e < 9) {
+ $p = "M";
+ $e -= 6;
+ }
+ elsif ($e < 12) {
+ $p = "G";
+ $e -= 9;
+ }
+ while ($e < 0) {
$m /= 10;
- $e--;
+ $e++;
}
print sprintf("%6.2f",$m)." $p";
}
--- End Message ---
--- Begin Message ---
Author: mickey
Date: 2007-04-14 00:43:12 +0200 (Sat, 14 Apr 2007)
New Revision: 1744
Modified:
trunk/src/target/OM-2007/openmoko-libs/libmokogsmd/moko-gsmd-connection.c
trunk/src/target/OM-2007/openmoko-libs/libmokogsmd/moko-gsmd-connection.h
Log:
libmokogsmd: create first object signals.
NOTE: getting e.g. the gsm signal strength in an applet is now down to 2 lines:
MokoGsmdConnection* gsm = moko_gsmd_connection_new();
g_signal_connect( G_OBJECT(gsm), "signal-strength-changed",
G_CALLBACK(<showit>), 0 );
Modified:
trunk/src/target/OM-2007/openmoko-libs/libmokogsmd/moko-gsmd-connection.c
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokogsmd/moko-gsmd-connection.c
2007-04-13 22:31:20 UTC (rev 1743)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokogsmd/moko-gsmd-connection.c
2007-04-13 22:43:12 UTC (rev 1744)
@@ -19,6 +19,9 @@
#include <libgsmd/libgsmd.h>
+#include <string.h>
+#include <errno.h>
+
#undef DEBUG_THIS_FILE
#define DEBUG_THIS_FILE
@@ -28,25 +31,66 @@
#define moko_debug(fmt,...)
#endif
-G_DEFINE_TYPE (MokoGsmdConnection, moko_gsmd_connection, G_TYPE_OBJECT);
+G_DEFINE_TYPE (MokoGsmdConnection, moko_gsmd_connection, G_TYPE_OBJECT)
#define GSMD_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o),
MOKO_TYPE_GSMD_CONNECTION, MokoGsmdConnectionPrivate))
+/* ugly temp. hack until libgsmd features a user_data pointer for its callbacks
+ Note that this effectively means you can only have one MokoGsmdConnection
object
+ per process (which should be ok anyway...) :M: */
+static MokoGsmdConnection* moko_gsmd_connection_instance = 0;
+
+typedef struct _MokoGsmdConnectionSource
+{
+ GSource source;
+ GPollFD pollfd;
+ struct lgsm_handle* handle;
+} MokoGsmdConnectionSource;
+
typedef struct _MokoGsmdConnectionPrivate
{
struct lgsm_handle* handle;
- GPollFD fd;
+ MokoGsmdConnectionSource* source;
} MokoGsmdConnectionPrivate;
+/* signals */
+enum {
+ SIGNAL_GSMD_EVT_IN_CALL = 1, /* Incoming call */
+ SIGNAL_GSMD_EVT_IN_SMS = 2, /* Incoming SMS */
+ SIGNAL_GSMD_EVT_IN_GPRS = 3, /* Network initiated GPRS */
+ SIGNAL_GSMD_EVT_IN_CLIP = 4, /* Incoming CLIP */
+ SIGNAL_GSMD_EVT_NETREG = 5, /* Network (un)registration event */
+ SIGNAL_GSMD_EVT_SIGNAL = 6, /* Signal quality event */
+ SIGNAL_GSMD_EVT_PIN = 7, /* Modem is waiting for some
PIN/PUK */
+ SIGNAL_GSMD_EVT_OUT_STATUS = 8, /* Outgoing call status */
+ SIGNAL_GSMD_EVT_OUT_COLP = 9, /* Outgoing COLP */
+ SIGNAL_GSMD_EVT_CALL_WAIT = 10, /* Call Waiting */
+ SIGNAL_GSMD_EVT_TIMEZONE = 11, /* Timezone change */
+ SIGNAL_GSMD_EVT_SUBSCRIPTIONS = 12, /* To which events are we
subscribed to */
+ SIGNAL_GSMD_EVT_CIPHER = 13, /* Chiphering Information */
+ LAST_SIGNAL,
+};
+static guint moko_gsmd_connection_signals[LAST_SIGNAL] = { 0 };
+
/* parent class pointer */
GObjectClass* parent_class = NULL;
/* forward declarations */
-/* ... */
+static gboolean _moko_gsmd_connection_source_prepare(
MokoGsmdConnectionSource* self, gint* timeout );
+static gboolean _moko_gsmd_connection_source_check( MokoGsmdConnectionSource*
self );
+static gboolean _moko_gsmd_connection_source_check( MokoGsmdConnectionSource*
self );
+static int _moko_gsmd_connection_eventhandler(struct lgsm_handle *lh, int
evt_type, struct gsmd_evt_auxdata *aux);
+/* class definition */
+
static void
moko_gsmd_connection_dispose(GObject* object)
{
+ moko_debug( "dispose" );
+ MokoGsmdConnectionPrivate* priv = GSMD_CONNECTION_GET_PRIVATE(
MOKO_GSMD_CONNECTION( object ) );
+ g_source_destroy( (GSource*) priv->source );
+ lgsm_exit( priv->handle );
+ // call parent destructor
if (G_OBJECT_CLASS (moko_gsmd_connection_parent_class)->dispose)
G_OBJECT_CLASS (moko_gsmd_connection_parent_class)->dispose (object);
}
@@ -55,7 +99,6 @@
moko_gsmd_connection_finalize(GObject* object)
{
moko_debug( "finalize" );
- //TODO remove source from mainloop and cleanup w/ libgsmd
G_OBJECT_CLASS (moko_gsmd_connection_parent_class)->finalize (object);
}
@@ -73,6 +116,36 @@
object_class->dispose = moko_gsmd_connection_dispose;
object_class->finalize = moko_gsmd_connection_finalize;
+ /* register signals */
+ moko_gsmd_connection_signals[SIGNAL_GSMD_EVT_IN_CALL] = g_signal_new
+ ("incoming-call",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
+ NULL,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_INT,
+ NULL );
+
+ //TODO add SIGNAL_GSMD_EVT_IN_SMS once libgsmd has it
+ //TODO add SIGNAL_GSMD_EVT_IN_GPRS once libgsmd has it
+
+ moko_gsmd_connection_signals[SIGNAL_GSMD_EVT_SIGNAL] = g_signal_new
+ ("signal-strength-changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
+ NULL,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_INT,
+ NULL);
+
/* virtual methods */
/* install properties */
@@ -84,10 +157,75 @@
return g_object_new(MOKO_TYPE_GSMD_CONNECTION, NULL);
}
+gboolean _moko_gsmd_connection_source_prepare( MokoGsmdConnectionSource* self,
gint* timeout )
+{
+ moko_debug( "moko_gsmd_connection_source_prepare" );
+ return FALSE;
+}
+
+gboolean _moko_gsmd_connection_source_check( MokoGsmdConnectionSource* self )
+{
+ moko_debug( "moko_gsmd_connection_source_check" );
+ return self->pollfd.revents & G_IO_IN;
+}
+
+gboolean _moko_gsmd_connection_source_dispatch( MokoGsmdConnectionSource*
self, GSourceFunc callback, gpointer data )
+{
+ moko_debug( "moko_gsmd_connection_source_dispatch" );
+ char buf[1025];
+ int size = read( self->pollfd.fd, &buf, sizeof( buf ) );
+ if ( size < 0 )
+ g_warning( "moko_gsmd_connection_source_dispatch: read error from
libgsmd: %s", strerror( errno ) );
+ else
+ lgsm_handle_packet( self->handle, buf, size );
+ return TRUE;
+}
+
+int _moko_gsmd_connection_eventhandler(struct lgsm_handle *lh, int evt_type,
struct gsmd_evt_auxdata *aux)
+{
+ moko_debug( "moko_gsmd_connection_eventhandler type = %d", evt_type );
+ MokoGsmdConnection* self = moko_gsmd_connection_instance; // temporary
(see note above)
+ switch(evt_type)
+ {
+ case GSMD_EVT_IN_CALL:
+ g_signal_emit( G_OBJECT(self),
moko_gsmd_connection_signals[SIGNAL_GSMD_EVT_IN_CALL], 0 ); break;
+ case GSMD_EVT_IN_SMS:
+ //moko_gsmd_connection_signals[SIGNAL_GSMD_EVT_IN_SMS]; break;
+ case GSMD_EVT_IN_GPRS:
+ //moko_gsmd_connection_signals[SIGNAL_GSMD_EVT_IN_GPRS]; break;
+ case GSMD_EVT_IN_CLIP:
+ //moko_gsmd_connection_signals[SIGNAL_GSMD_EVT_IN_CLIP]; break;
+ case GSMD_EVT_NETREG:
+ //moko_gsmd_connection_signals[SIGNAL_GSMD_EVT_NETREG]; break;
+ case GSMD_EVT_SIGNAL:
+ moko_debug( "-- signal strength = %d", aux->u.signal.sigq.rssi );
+ g_signal_emit( G_OBJECT(self),
moko_gsmd_connection_signals[SIGNAL_GSMD_EVT_SIGNAL], 0,
aux->u.signal.sigq.rssi ); break;
+ case GSMD_EVT_PIN:
+ //moko_gsmd_connection_signals[SIGNAL_GSMD_EVT_PIN]; break;
+ case GSMD_EVT_OUT_STATUS:
+ //emit = moko_gsmd_connection_signals[SIGNAL_GSMD_EVT_OUT_STATUS];
break;
+ case GSMD_EVT_OUT_COLP:
+ //moko_gsmd_connection_signals[SIGNAL_GSMD_EVT_OUT_COLP]; break;
+ case GSMD_EVT_CALL_WAIT:
+ //moko_gsmd_connection_signals[SIGNAL_GSMD_EVT_CALL_WAIT]; break;
+ case GSMD_EVT_TIMEZONE:
+ //moko_gsmd_connection_signals[SIGNAL_GSMD_EVT_TIMEZONE]; break;
+ case GSMD_EVT_SUBSCRIPTIONS:
+ //moko_gsmd_connection_signals[SIGNAL_GSMD_EVT_SUBSCRIPTIONS];
break;
+ case GSMD_EVT_CIPHER:
+ //moko_gsmd_connection_signals[SIGNAL_GSMD_EVT_CIPHER]; break;
+ default: g_assert( FALSE ); // fail here on unknown event
+ }
+ return 0;
+}
+
static void
moko_gsmd_connection_init(MokoGsmdConnection* self)
{
- moko_debug( "moko_gsmd_connection_init()" );
+ moko_debug( "moko_gsmd_connection_init" );
+ g_assert( !moko_gsmd_connection_instance); // fail here on more than one
MokoGsmdConnection object per process
+ moko_gsmd_connection_instance = self;
+
MokoGsmdConnectionPrivate* priv = GSMD_CONNECTION_GET_PRIVATE(self);
priv->handle = lgsm_init( LGSMD_DEVICE_GSMD );
@@ -99,4 +237,28 @@
{
moko_debug( "-- connected to gsmd (socketfd = %d)", lgsm_fd(
priv->handle ) );
}
+
+ static GSourceFuncs funcs = {
+ _moko_gsmd_connection_source_prepare,
+ _moko_gsmd_connection_source_check,
+ _moko_gsmd_connection_source_dispatch,
+ NULL,
+ };
+
+ priv->source = (MokoGsmdConnectionSource*) g_source_new( &funcs, sizeof(
MokoGsmdConnectionSource) );
+ priv->source->handle = priv->handle;
+ priv->source->pollfd.fd = lgsm_fd( priv->handle );
+ priv->source->pollfd.events = G_IO_IN | G_IO_HUP | G_IO_ERR;
+ priv->source->pollfd.revents = 0;
+ g_source_add_poll( priv->source, &priv->source->pollfd );
+ g_source_attach( priv->source, NULL );
+
+ int rc = 0;
+ for ( int i = GSMD_EVT_IN_CALL; i < __NUM_GSMD_EVT; ++i )
+ {
+ rc |= lgsm_evt_handler_register( priv->handle, i,
_moko_gsmd_connection_eventhandler );
+ moko_debug( "-- registered for event %d, return code %d", i, rc );
+ }
+
}
+
Modified:
trunk/src/target/OM-2007/openmoko-libs/libmokogsmd/moko-gsmd-connection.h
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokogsmd/moko-gsmd-connection.h
2007-04-13 22:31:20 UTC (rev 1743)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokogsmd/moko-gsmd-connection.h
2007-04-13 22:43:12 UTC (rev 1744)
@@ -40,6 +40,10 @@
GType moko_gsmd_connection_get_type();
MokoGsmdConnection* moko_gsmd_connection_new();
+/* signals */
+void moko_gsmd_connection_incoming_call(MokoGsmdConnection* self, int type);
+void moko_gsmd_connection_signal_strength_changed(MokoGsmdConnection* self,
int strength);
+
G_END_DECLS
#endif // _MOKO_GSMD_CONNECTION_H_
--- End Message ---
--- Begin Message ---
Author: mickey
Date: 2007-04-14 00:45:06 +0200 (Sat, 14 Apr 2007)
New Revision: 1745
Modified:
trunk/src/target/OM-2007/openmoko-libs/configure.ac
Log:
openmoko-libs: requires gsmd now (thanks to libmokogsmd)
Modified: trunk/src/target/OM-2007/openmoko-libs/configure.ac
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/configure.ac 2007-04-13 22:43:12 UTC
(rev 1744)
+++ trunk/src/target/OM-2007/openmoko-libs/configure.ac 2007-04-13 22:45:06 UTC
(rev 1745)
@@ -17,7 +17,8 @@
PKG_CHECK_MODULES(DEPS,
gtk+-2.0 >= $GTK_VERSION
libecal-1.2 >= $LIBECAL_VERSION
- gdk-pixbuf-2.0)
+ gdk-pixbuf-2.0
+ libgsmd)
if test x$MOKO_DEVEL = xon ; then
AC_MSG_NOTICE([removing -O2 from CFLAGS])
--- End Message ---
--- Begin Message ---
Author: mickey
Date: 2007-04-14 00:57:03 +0200 (Sat, 14 Apr 2007)
New Revision: 1746
Modified:
trunk/src/target/OM-2007/openmoko-libs/Makefile.am
Log:
openmoko-libs: compile libmokogsmd
Modified: trunk/src/target/OM-2007/openmoko-libs/Makefile.am
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/Makefile.am 2007-04-13 22:45:06 UTC
(rev 1745)
+++ trunk/src/target/OM-2007/openmoko-libs/Makefile.am 2007-04-13 22:57:03 UTC
(rev 1746)
@@ -1,4 +1,4 @@
-SUBDIRS = libmokoui libmokojournal data
+SUBDIRS = libmokogsmd libmokoui libmokojournal data
pcdata_DATA= openmoko-libs.pc
pcdatadir= $(libdir)/pkgconfig
--- End Message ---
_______________________________________________
commitlog mailing list
[EMAIL PROTECTED]
http://lists.openmoko.org/mailman/listinfo/commitlog