File: spi.tcl

package info (click to toggle)
simulavr 1.0.0%2Bgit20160221.e53413b-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 5,748 kB
  • sloc: cpp: 35,491; python: 6,991; ansic: 3,567; makefile: 1,072; sh: 653; asm: 414; tcl: 320
file content (73 lines) | stat: -rw-r--r-- 1,677 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#
#  Anacomp user extension set for simulavr.tcl
#
#  $Id$
#

switch ${extensionPoint} {
  Initialization {}

  CPU {
    if { ! [info exists dev1] } {
      error "MCU Device Required"
    }

    set netB0	[new_Net]
    set netB1	[new_Net]
    set netB2	[new_Net]
    set netB3	[new_Net]

    [AvrDevice_GetPin $dev1 "B0"] SetOutState $Pin_PULLUP

    $netB0 Add [AvrDevice_GetPin $dev1 "B0"]
    $netB1 Add [AvrDevice_GetPin $dev1 "B1"]
    $netB2 Add [AvrDevice_GetPin $dev1 "B2"]
    $netB3 Add [AvrDevice_GetPin $dev1 "B3"]

    SpiSource spiSource "spidata" $netB0 $netB1 $netB2
    SpiSink spiSink $netB0 $netB1 $netB3
    set pinMonPinNameStr	"A0"
    set pinMonPinDescStr	"PORTA0"
    set pinMonPinHighStr	"NEGATE"
    set pinMonPinLowStr	"ASSERT"

    # This line did not work since the string "constants" are
    # apparently de-allocated after the constructor, and the
    # PinMonitor class keeps the pointers, not a copy to
    # the strings!
    #PinMonitor pinmon $dev1 "A0" "PORTA0" "NEGATE" "ASSERT"

    # This works because the variables do not get de-allocated.
    PinMonitor pinmon $dev1 $pinMonPinNameStr $pinMonPinDescStr $pinMonPinHighStr $pinMonPinLowStr

    set netF0	[new_Net]
    set netAref	[new_Net]

    $netF0 Add [AvrDevice_GetPin $dev1 "F0"]

    AdcPin	adcPinSource "anadata" $netF0

    $netAref Add [AvrDevice_GetPin $dev1 "AREF"]

    set aRef [new_AdcAnalogPin]

    $aRef SetOutState $Pin_ANALOG

    $netAref Add $aRef

    $aRef setAnalogValue 5000000

    $sc Add spiSource
    $sc Add spiSink
    $sc Add adcPinSource
  }

  Gui {
  }

  GdbCommands {
    if { ! [info exists f] } {
      error "File handle required"
    }
  }
}