6,9 → 6,8 |
#include "servoboard.h" |
#include "twislave.h" |
|
unsigned char I2C_RXBuffer[32]; |
unsigned char Byte_Counter = 0; |
unsigned char I2C_Timeout = 0; |
uint8_t I2C_RXBuffer[32]; |
uint8_t Byte_Counter = 0; |
|
void InitIC2_Slave(uint8_t adr) |
{ |
27,21 → 26,17 |
|
ISR (TWI_vect) { |
|
#if 1 |
static char cnt=0; |
static char cnt = 0; |
if (pwm_neutral_programming_mode == 0 && cnt++ == 0) { |
if (PORTD&0x80) PORTD&=~0x80; else PORTD|=0x80; |
if (PORTD & 0x80) PORTD &= ~0x80; else PORTD |= 0x80; |
} |
#endif |
|
switch (TWSR & 0xF8) |
{ |
switch (TWSR & 0xF8) { |
case SR_SLA_ACK: |
TWCR |= (1<<TWINT); |
Byte_Counter = 0; |
return; |
case SR_PREV_ACK: |
I2C_Timeout = 250; |
if (Byte_Counter < 32) { |
I2C_RXBuffer[Byte_Counter++] = TWDR; |
} |
56,8 → 51,9 |
TWCR |=(1<<TWSTO) | (1<<TWINT); |
case TWI_BUS_ERR_1: |
TWCR |=(1<<TWSTO) | (1<<TWINT); |
} |
TWCR =(1<<TWEA) | (1<<TWINT) | (1<<TWEN) | (1<<TWIE); // TWI Reset |
} |
TWCR =(1<<TWEA) | (1<<TWINT) | (1<<TWEN) | (1<<TWIE); |
|
} |
|
|