File tree 3 files changed +7
-16
lines changed
3 files changed +7
-16
lines changed Original file line number Diff line number Diff line change @@ -28,12 +28,12 @@ extern "C" {
28
28
29
29
// Initialize Class Variables //////////////////////////////////////////////////
30
30
31
- uint8_t * TwoWire::rxBuffer = 0 ;
31
+ uint8_t TwoWire::rxBuffer[BUFFER_LENGTH] ;
32
32
uint8_t TwoWire::rxBufferIndex = 0 ;
33
33
uint8_t TwoWire::rxBufferLength = 0 ;
34
34
35
35
uint8_t TwoWire::txAddress = 0 ;
36
- uint8_t * TwoWire::txBuffer = 0 ;
36
+ uint8_t TwoWire::txBuffer[BUFFER_LENGTH] ;
37
37
uint8_t TwoWire::txBufferIndex = 0 ;
38
38
uint8_t TwoWire::txBufferLength = 0 ;
39
39
@@ -51,13 +51,9 @@ TwoWire::TwoWire()
51
51
52
52
void TwoWire::begin (void )
53
53
{
54
- // init buffer for reads
55
- rxBuffer = (uint8_t *) calloc (BUFFER_LENGTH, sizeof (uint8_t ));
56
54
rxBufferIndex = 0 ;
57
55
rxBufferLength = 0 ;
58
56
59
- // init buffer for writes
60
- txBuffer = (uint8_t *) calloc (BUFFER_LENGTH, sizeof (uint8_t ));
61
57
txBufferIndex = 0 ;
62
58
txBufferLength = 0 ;
63
59
Original file line number Diff line number Diff line change 27
27
class TwoWire
28
28
{
29
29
private:
30
- static uint8_t * rxBuffer;
30
+ static uint8_t rxBuffer[] ;
31
31
static uint8_t rxBufferIndex;
32
32
static uint8_t rxBufferLength;
33
33
34
34
static uint8_t txAddress;
35
- static uint8_t * txBuffer;
35
+ static uint8_t txBuffer[] ;
36
36
static uint8_t txBufferIndex;
37
37
static uint8_t txBufferLength;
38
38
Original file line number Diff line number Diff line change @@ -40,15 +40,15 @@ static uint8_t twi_slarw;
40
40
static void (* twi_onSlaveTransmit )(void );
41
41
static void (* twi_onSlaveReceive )(uint8_t * , int );
42
42
43
- static uint8_t * twi_masterBuffer ;
43
+ static uint8_t twi_masterBuffer [ TWI_BUFFER_LENGTH ] ;
44
44
static volatile uint8_t twi_masterBufferIndex ;
45
45
static uint8_t twi_masterBufferLength ;
46
46
47
- static uint8_t * twi_txBuffer ;
47
+ static uint8_t twi_txBuffer [ TWI_BUFFER_LENGTH ] ;
48
48
static volatile uint8_t twi_txBufferIndex ;
49
49
static volatile uint8_t twi_txBufferLength ;
50
50
51
- static uint8_t * twi_rxBuffer ;
51
+ static uint8_t twi_rxBuffer [ TWI_BUFFER_LENGTH ] ;
52
52
static volatile uint8_t twi_rxBufferIndex ;
53
53
54
54
static volatile uint8_t twi_error ;
@@ -88,11 +88,6 @@ void twi_init(void)
88
88
89
89
// enable twi module, acks, and twi interrupt
90
90
TWCR = _BV (TWEN ) | _BV (TWIE ) | _BV (TWEA );
91
-
92
- // allocate buffers
93
- twi_masterBuffer = (uint8_t * ) calloc (TWI_BUFFER_LENGTH , sizeof (uint8_t ));
94
- twi_txBuffer = (uint8_t * ) calloc (TWI_BUFFER_LENGTH , sizeof (uint8_t ));
95
- twi_rxBuffer = (uint8_t * ) calloc (TWI_BUFFER_LENGTH , sizeof (uint8_t ));
96
91
}
97
92
98
93
/*
You can’t perform that action at this time.
0 commit comments