;**************************************************************************** ;**************************************************************************** ;* I2C slave CPU c2012 by Vladislav Shapovalov * ;* CPU: ATtiny2313 * ;* Clock: INT 8 MHz 3dfilm@mail.ru * ;!!!!!!!!!!!!! SCL DDR and PORT are ALWAYS =1 !!!!!!!!!!!!!!!!! * ;!!!!!!!!!!!!! SDA PORT are ALWAYS =1 !!!!!!!!!!!!!!!!! * ;**************************************************************************** ;**************************************************************************** .include "tn2313def.inc" .include "avr.inc" .equ MySlaveAddress = 0xAC .equ DDR_I2C = DDRB .equ PORT_I2C = PORTB .equ PIN_I2C = PINB .equ SCL = 7 ;!!!!!!!!!!!!!SCL DDR and PORT are ALWAYS =1 !!!!!!!!!!!!!!!!! .equ SDA = 5 ;!!!!!!!!!!!!!SDA PORT are ALWAYS =1 !!!!!!!!!!!!!!!!! .equ Flag = GPIOR1 .equ I2Cadr = 7 .equ I2Crw = 6 ;Read=1 .equ I2CsubAddr = 5 ;WriteSubAddr=1 .equ I2Cask = 4 ;=========================================================; .dseg .org SRAM_START ;RAMTOP I2CsubAddrBuf: .byte 1 ;**************************************************************************************** ;----------------------------------------------------------; .cseg .ORG 0 RJMP RESET .ORG USI_STARTaddr ;USI_STRaddr rjmp StartCondition .ORG USI_OVFaddr rjmp I2CdataRX ;----------------------------------------------------------; StartCondition: push AL in AL,SREG push AL cbi DDR_I2C,SDA outi Flag,0 sbic PIN_I2C,SCL ;Wait for SCL to go low to ensure the "Start Condition" has completed. rjmp PC-1 outi USICR,(1<