view program @ 6:acbd0ddd002b

Add shared 1ms timer code Now blinks in a slightly useful manner Now has several submodes for acceptor state machine Clean ups
author Frank Kingswood <frank@kingswood-consulting.co.uk>
date Tue, 01 Apr 2014 20:35:06 +0100
parents 1a405bda2ffe
children 1969a435a7a2
line wrap: on
line source
1 #!/bin/sh
2 set -e
4 if [ $# -lt 3 ] || [ "$1" = "--help" ] ; then
5 echo "Called from Makefile to program USB-GPIB"
6 exit 1
7 fi
9 DASHV=
10 DASHQ=-q
11 if [ "$1" = "-v" ] ; then
12 shift
13 DASHV=-v
14 DASHQ=
15 fi
17 for DEV in /dev/ttyUSB0* ; do
18 true
19 done
21 MODE=
22 if lsusb -d 2341:8036 >/dev/null ; then
23 MODE=AVR109
25 elif lsusb -d 16c0:0478 >/dev/null ; then
26 MODE=Teensy
28 elif lsusb -d 16c0:047a >/dev/null ; then
29 echo "Autodetecting USB-GPIB"
30 trap "true" ALRM
32 exec 3<>$DEV
34 set +e
35 for I in $(seq 3) ; do
36 (
37 sleep 0.3
38 kill -ALRM $$
39 ) &
40 while read X ; do echo $X ; done
41 done
43 V=
44 for I in $(seq 5) ; do
45 (
46 sleep 0.3
47 kill -ALRM $$
48 ) &
49 echo "++ver" >&3
50 read V <&3
52 case "$V" in
53 *USB-GPIB-32U4*)
54 echo "Found USB-GPIB"
55 break
56 ;;
57 *)
58 ;;
59 esac
60 done
61 set -e
63 # call the boot loader
64 case "$V" in
65 *Teensy*)
66 echo "++DEBUG 0x7e00" >&3
67 MODE=Teensy
68 ;;
69 *MicroPro*)
70 echo "++DEBUG 0x7800" >&3
71 MODE=AVR109
72 ;;
73 *)
74 exit 2
75 ;;
76 esac
78 exec 3>&-
79 sleep 0.5
80 trap - ALRM
82 else
83 echo "No device found"
84 exit 1
85 fi
87 echo "$MODE boot loader"
89 if [ "$1" != "--program" ] ; then
90 exit 1
91 fi
93 sleep 0.5
94 set -x
96 case "$MODE" in
97 Teensy)
98 teensy_loader_cli -mmcu="$2" -w -v $DASHV "$3"
99 ;;
100 AVR109)
101 avrdude -c avr109 -P $DEV -p "$2" -q $DASHQ -U flash:w:"$3"
102 ;;
103 esac