; general device setup ; this is for the ATtiny 45/85 ; .NOLIST ; Disable listfile generation .include "tn45def.inc" .LIST ; ****************************************************************** ; todays project: ; build a drop-in replacement for the HS1527 OTP encoder ; base is the RCT-08 encoder from Pollin ( replacement transmitter for the home - 3 dimmers included bundle) ; constants @ 8 Mhz clk ; ****************************************************************** ; might contain remains of a similar ATTiny 2313 project ; timings .equ atomtime = 250 ; usecs ; 8 bit / 8 timer ( 8 usecs) .equ shorttime = 256-30 .equ longtime = 256-95 .equ pretime = 256-9300 ; .equ ROMSTART = 0x0100 .equ RAMSTART = SRAM_START .equ cr = 0x0d .equ lf = 0x0a .equ spc = 0x20 .equ US30 = 0x02 .equ MS1 = 0x14 .equ MS5 = 0x28 .equ MS7 = 0x2b .equ MS10 = 0x33 .equ MS30 = 0x4b .equ MS100 = 0x71 ; roughly 100mS with wozwait @ 8Mhz .equ MS500 = 0xc8 ; roughly 500mS with wozwait @ 8Mhz .equ second = 0xe6 ; roughly a second with wozwait @ 8Mhz ; ; pinning on the ATTiny 45 mimics former 1527 ; if soldered one pin shifted (tiny GND = HS GND ) ; port B .equ SCK = 4 ; TX .equ TXDATA = SCK ; inputs from keys ; ; pin names from HS1527 .equ DATA3 = 3 ; K4 .equ DATA0 = 0 ; K0 ; row inputs .equ DATA1 = 1 ; K1 .equ DATA2 = 2 ; K2 ; ; ; irq registers .def irqstor = r12 ; IRQ routine SREG safe place ; general purpose non-immediate .def lowtemp = r13 ; immediate registers .def temp = r16 ;misc usage, general purpose .def loop = r17 .def del = r18 ; delay counter .def tilo = r19 ; timerloader .def tihi = r20 ; timerloader .def buffer = r21 ; sendbyte .def counter = r22 ; bitbanger .def command = r23 ; button ; flags for operation ;7 6 5 4 3 2 1 0 ;start .def flags = r25 ; flags ; ************** MAIN PROGRAM STARTS HERE ************************* .CSEG .ORG 0x0 ; for ATTiny 25/45/85 rjmp RESET ; Reset Handler rjmp EXT_INT0 ; IRQ0 Handler rjmp PC_INT0 ; PCINT0 Handler rjmp TIM1_COMPA ; Timer 1 compare match A rjmp TIM1_OVF ; timer 1 overflow rjmp TIM0_OVF ; Timer0 Overflow Handler rjmp EE_RDY ; EEPROM Ready Handler rjmp ANA_COMP ; Analog Comparator Handler rjmp ADC_INT ; ADC Conversion Handler rjmp TIM1_COMPB ; timer 1 compare match B rjmp TIM0_COMPA ; Timer0 CompareA Handler rjmp TIM0_COMPB ; Timer0 CompareB Handler rjmp WATCHDOG ; Watchdog Interrupt Handler rjmp USI_START ; usi start condition rjmp USI_OVF ; usi overflow ; ; IRQ routines are not used today ; stubs EXT_INT0: ; External Interrupt0 Handler PC_INT0: ; Pin Change Interrupt TIM1_COMPA: ; Timer1 CompareA Handler TIM1_OVF: ; Timer1 Overflow Handler TIM0_OVF: ; Timer0 Overflow Handler EE_RDY: ; EEPROM Ready Handler ANA_COMP: ; Analog Comparator Handler ADC_INT: ; ADC ready TIM1_COMPB: ; Timer1 Compare B Handler TIM0_COMPA: ; Timer0 Compare A Handler TIM0_COMPB: ; Timer0 Compare B Handler USI_START: ; USI Start Handler USI_OVF: ; USI Overflow Handler WATCHDOG: ; Watchdog Overflow Handler reti RESET: nop nop ldi temp,low(RAMEND) out SPL,temp ; the Tiny25 doesn't come with SPH #ifndef _TN25DEF_INC_ ldi temp,high(RAMEND) out SPH, temphi #endif cli ; switch off the WDT wdr in temp,MCUSR andi temp,(0xff & (0<