/************************************************** *****/
uint8_t TWIS_ResonseRequired (uint8_t *TWI_ResonseType)
{
*TWI_ResonseType = TWSR;
return TWCR & (1<<TWINT);
}
************************************************** *****/
uint8_t TWIS_Init (uint8_t Address, uint32_t Bitrate)
{
/*
** Set the TWI bitrate
** If TWBR is less 11, then error
*/
TWBR = ((F_CPU/Bitrate)-16)/2;
if (TWBR < 11) return FALSE;
/*
** Set the TWI slave address
*/
TWAR = (Address << 1);
/*
** Activate TWI interface
*/
TWCR = (1<<TWEN)|(1<<TWEA);
return TRUE;
}
//
main()
{
...
TWIS_Init (0x15, 50000); // Set as Slave with Address 0x15 using 50kBus
...
...
/*
** Check whether something is to do for the TWI slave interface
*/
if (TWIS_ResonseRequired (&TWIS_ResonseType))
{
TWI_Handler( TWIS_ResonseType ); <---- hier kommt nie das Programm an.
}
}
Lesezeichen