130 |
pfowler |
1 |
/********************************************************************************
|
|
|
2 |
|
|
|
3 |
Header file for the USI TWI Slave driver.
|
|
|
4 |
|
|
|
5 |
Created by Donald R. Blake
|
|
|
6 |
donblake at worldnet.att.net
|
|
|
7 |
|
|
|
8 |
---------------------------------------------------------------------------------
|
|
|
9 |
|
|
|
10 |
Created from Atmel source files for Application Note AVR312: Using the USI Module
|
|
|
11 |
as an I2C slave.
|
|
|
12 |
|
|
|
13 |
This program is free software; you can redistribute it and/or modify it under the
|
|
|
14 |
terms of the GNU General Public License as published by the Free Software
|
|
|
15 |
Foundation; either version 2 of the License, or (at your option) any later
|
|
|
16 |
version.
|
|
|
17 |
|
|
|
18 |
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
19 |
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
|
20 |
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
21 |
|
|
|
22 |
---------------------------------------------------------------------------------
|
|
|
23 |
|
|
|
24 |
Change Activity:
|
|
|
25 |
|
|
|
26 |
Date Description
|
|
|
27 |
------ -------------
|
|
|
28 |
15 Mar 2007 Created.
|
|
|
29 |
|
|
|
30 |
********************************************************************************/
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
#ifndef _USI_TWI_SLAVE_H_
|
|
|
35 |
#define _USI_TWI_SLAVE_H_
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
/********************************************************************************
|
|
|
40 |
|
|
|
41 |
includes
|
|
|
42 |
|
|
|
43 |
********************************************************************************/
|
|
|
44 |
|
|
|
45 |
#include <stdbool.h>
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
/********************************************************************************
|
|
|
50 |
|
|
|
51 |
prototypes
|
|
|
52 |
|
|
|
53 |
********************************************************************************/
|
|
|
54 |
|
|
|
55 |
void usiTwiSlaveInit( uint8_t );
|
|
|
56 |
void usiTwiTransmitByte( uint8_t );
|
|
|
57 |
uint8_t usiTwiReceiveByte( void );
|
|
|
58 |
bool usiTwiDataInReceiveBuffer( void );
|
|
|
59 |
void (*_onTwiDataRequest)(void);
|
|
|
60 |
bool usiTwiDataInTransmitBuffer(void);
|
|
|
61 |
uint8_t usiTwiAmountDataInReceiveBuffer(void);
|
|
|
62 |
// on_XXX handler pointers
|
|
|
63 |
void (*usi_onRequestPtr)(void);
|
|
|
64 |
void (*usi_onReceiverPtr)(uint8_t);
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
/********************************************************************************
|
|
|
68 |
|
|
|
69 |
driver buffer definitions
|
|
|
70 |
|
|
|
71 |
********************************************************************************/
|
|
|
72 |
|
|
|
73 |
// permitted RX buffer sizes: 1, 2, 4, 8, 16, 32, 64, 128 or 256
|
|
|
74 |
|
|
|
75 |
#ifndef TWI_RX_BUFFER_SIZE
|
|
|
76 |
#define TWI_RX_BUFFER_SIZE ( 16 )
|
|
|
77 |
#endif
|
|
|
78 |
#define TWI_RX_BUFFER_MASK ( TWI_RX_BUFFER_SIZE - 1 )
|
|
|
79 |
|
|
|
80 |
#if ( TWI_RX_BUFFER_SIZE & TWI_RX_BUFFER_MASK )
|
|
|
81 |
# error TWI RX buffer size is not a power of 2
|
|
|
82 |
#endif
|
|
|
83 |
|
|
|
84 |
// permitted TX buffer sizes: 1, 2, 4, 8, 16, 32, 64, 128 or 256
|
|
|
85 |
|
|
|
86 |
#ifndef TWI_TX_BUFFER_SIZE
|
|
|
87 |
#define TWI_TX_BUFFER_SIZE ( 16 )
|
|
|
88 |
#endif
|
|
|
89 |
#define TWI_TX_BUFFER_MASK ( TWI_TX_BUFFER_SIZE - 1 )
|
|
|
90 |
|
|
|
91 |
#if ( TWI_TX_BUFFER_SIZE & TWI_TX_BUFFER_MASK )
|
|
|
92 |
# error TWI TX buffer size is not a power of 2
|
|
|
93 |
#endif
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
#endif // ifndef _USI_TWI_SLAVE_H_
|