/****************************************************/ /* The USI as Slave */ /* Author: Axel Gartner */ /****************************************************/ #include #include #include #define USI_DATA USIDR #define USI_STATUS USISR #define USI_CONTROL USICR #define USI_ADDRESS 0x20 #define NONE 0 #define ACK_PR_RX 1 #define BYTE_RX 2 #define ACK_PR_TX 3 #define PR_ACK_TX 4 #define BYTE_TX 5 // Device dependant defines #if defined(__at90tiny26__) | defined(__attiny26__) #define DDR_USI DDRB #define PORT_USI PORTB #define PIN_USI PINB #define PORT_USI_SDA PORTB0 #define PORT_USI_SCL PORTB2 #endif #if defined(__at90Tiny2313__) | defined(__attiny2313__) #define DDR_USI DDRB #define PORT_USI PORTB #define PIN_USI PINB #define PORT_USI_SDA PORTB5 #define PORT_USI_SCL PORTB7 #endif volatile uint8_t COMM_STATUS = NONE; void USI_init(void) { // 2-wire mode; Hold SCL on start and overflow; ext. clock USI_CONTROL |= (1<> 1) != USI_ADDRESS) { // if not receiving my address USI_CONTROL &= ~(1< no more bytes to send } else { /* Put next byte to transmit in buffer here! USI_DATA = ... */ PORT_USI |= (1<