2019-07-07 01:59:39 +00:00
|
|
|
/********************************************************************************
|
|
|
|
|
|
|
|
Header file for the USI TWI Slave driver.
|
|
|
|
|
|
|
|
Created by Donald R. Blake
|
|
|
|
donblake at worldnet.att.net
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Created from Atmel source files for Application Note AVR312: Using the USI Module
|
|
|
|
as an I2C slave.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the
|
|
|
|
terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
|
|
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Change Activity:
|
|
|
|
|
|
|
|
Date Description
|
|
|
|
------ -------------
|
|
|
|
15 Mar 2007 Created.
|
|
|
|
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _USI_TWI_SLAVE_H_
|
|
|
|
#define _USI_TWI_SLAVE_H_
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-12-07 16:30:36 +00:00
|
|
|
|
2019-07-07 01:59:39 +00:00
|
|
|
/********************************************************************************
|
|
|
|
|
|
|
|
includes
|
|
|
|
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
|
|
|
|
prototypes
|
|
|
|
|
|
|
|
********************************************************************************/
|
|
|
|
|
2020-12-07 16:30:36 +00:00
|
|
|
|
2019-07-07 01:59:39 +00:00
|
|
|
void usiTwiSlaveInit( uint8_t );
|
|
|
|
void usiTwiTransmitByte( uint8_t );
|
|
|
|
uint8_t usiTwiReceiveByte( void );
|
|
|
|
bool usiTwiDataInReceiveBuffer( void );
|
2020-12-07 16:30:36 +00:00
|
|
|
//void (*_onTwiDataRequest)(void);
|
|
|
|
|
|
|
|
//extern request_func_t _onTwiDataRequest;
|
|
|
|
|
2019-07-07 01:59:39 +00:00
|
|
|
bool usiTwiDataInTransmitBuffer(void);
|
|
|
|
uint8_t usiTwiAmountDataInReceiveBuffer(void);
|
|
|
|
// on_XXX handler pointers
|
2020-12-07 16:30:36 +00:00
|
|
|
//void (*usi_onRequestPtr)(void);
|
|
|
|
//void (*usi_onReceiverPtr)(uint8_t);
|
|
|
|
|
|
|
|
typedef void (*request_func_t)(void);
|
|
|
|
typedef void (*receive_func_t)(uint8_t);
|
2019-07-07 01:59:39 +00:00
|
|
|
|
2020-12-07 16:30:36 +00:00
|
|
|
extern request_func_t usi_onRequestPtr;
|
|
|
|
extern receive_func_t usi_onReceiverPtr;
|
2019-07-07 01:59:39 +00:00
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
|
|
|
|
driver buffer definitions
|
|
|
|
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
// permitted RX buffer sizes: 1, 2, 4, 8, 16, 32, 64, 128 or 256
|
|
|
|
|
|
|
|
#ifndef TWI_RX_BUFFER_SIZE
|
|
|
|
#define TWI_RX_BUFFER_SIZE ( 16 )
|
|
|
|
#endif
|
|
|
|
#define TWI_RX_BUFFER_MASK ( TWI_RX_BUFFER_SIZE - 1 )
|
|
|
|
|
|
|
|
#if ( TWI_RX_BUFFER_SIZE & TWI_RX_BUFFER_MASK )
|
|
|
|
# error TWI RX buffer size is not a power of 2
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// permitted TX buffer sizes: 1, 2, 4, 8, 16, 32, 64, 128 or 256
|
|
|
|
|
|
|
|
#ifndef TWI_TX_BUFFER_SIZE
|
|
|
|
#define TWI_TX_BUFFER_SIZE ( 16 )
|
|
|
|
#endif
|
|
|
|
#define TWI_TX_BUFFER_MASK ( TWI_TX_BUFFER_SIZE - 1 )
|
|
|
|
|
|
|
|
#if ( TWI_TX_BUFFER_SIZE & TWI_TX_BUFFER_MASK )
|
|
|
|
# error TWI TX buffer size is not a power of 2
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // ifndef _USI_TWI_SLAVE_H_
|