Datasheet

' Unlock the Davis VP2/Vue console serial line using the ATtiny85 and a
' random device ID. Using algorithm as described by WXForum.net user
' "watson" on November 28, 2013.
'
' NOTE: The ATtiny25 does NOT have sufficient SRAM for this implementation.
'
' Torkel M. Jodalen <tmj@bitwrap.no> - http://www.annoyingdesigns.com
' Revised: 2013-11-30
$PROG &HFF,&HC1,&HDF,&HFF ' Lock, FuseLow, FuseHigh, FuseExtended
$REGFILE = "ATtiny85.DAT"
$HWSTACK = 64
$SWSTACK = 16
$FRAMESIZE = 32
Config BASE = 0
Const CMD_STATUS = &HD7 ' Chip status command
Const CMD_SECURITY = &H77 ' Dump security register command
Const CMD_DEVICEID = &H9F ' Manufacturer & Device ID command
Const RESPONSE_STATUS = &H8C ' Response to CMD_STATUS
Dim Response(128) As Byte ' Will contain 128-byte reply to CMD_SECURITY command
Dim I As Byte ' The infamous loop counter
Dim COMMAND As Byte ' Command byte as received from console
Dim USI_DATA_READY As Bit ' Status flag
Declare Function Calculate(ByteNo As Byte) As Byte
' Fill in a random device ID, bytes 64-127
For I = 64 To 127
Response(I) = RND(256)
Next I
' Fill in appropriate security register values, bytes 3-63
For I = 3 To 63
Response(I) = Calculate(I)
Next I
' Fill in a serial number(?), bytes 0-2
Response(0) = &H9A ' 9A 2F 21 are values found in an original
Response(1) = &H2F ' logger. This may or may not be a device
Response(2) = &H21 ' serial number. Doesn't seem to matter.
' Slave select / chip select
SS Alias PinB.4 ' Use PINB for READ, PORTB for WRITE
Config PortB.4 = Input ' This will be a READ-ONLY pin, read from "SS"
Set PortB.4
' Perform the SPI setup
Set USICR.USIWM0 ' SPI mode
Reset USICR.USIWM1 ' SPI mode
Set USICR.USICS1 ' External clock (clocked by the ATmega128 in the console)
Reset USICR.USICLK ' External clock
Reset USICR.USICS0 ' Positive edge
Set USICR.USIOIE ' Enable counter overflow interrupt
' Enable USI overflow interrupts
On USI_OVF USI_OVERFLOW_INT
Enable USI_OVF
Enable Interrupts
Do
While SS = 1
' Wait for SS low
Wend
' Set up the ATTiny85 USI for SPI operation (SS has been pulled low)
Config PortB.0 = Input ' PB0 = MOSI
Config PortB.1 = Output ' PB1 = MISO
Config PortB.2 = Input ' PB2 = Clock
' NOTE: Code listing continued on next page!
Listing 2: Complete BASCOM-AVR source code listing for the Atmel ATtiny85 resulting in a random
device ID and corresponding security register values.
http://meteo.annoyingdesigns.com 21