Skip to content

Commit 2248534

Browse files
committed
Fix warnings in Wire
1 parent 72b79a0 commit 2248534

File tree

5 files changed

+33
-34
lines changed

5 files changed

+33
-34
lines changed

cores/arduino/wiring.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,7 @@ void init()
327327

328328
/********************************* ADC ****************************************/
329329

330-
//#if defined(ADC0)
331-
332-
/************* Need to double check no other init required for ADC ***************/
330+
#if defined(ADC0)
333331

334332
/* ADC clock between 50-200KHz */
335333

@@ -380,4 +378,4 @@ void init()
380378
/*************************** ENABLE GLOBAL INTERRUPTS *************************/
381379

382380
sei();
383-
}
381+
}

libraries/Wire/src/Wire.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint32_t iaddres
105105
quantity = BUFFER_LENGTH;
106106
}
107107

108-
uint8_t bytes_read = TWI_MasterWriteRead(address,
109-
(uint8_t *) &iaddress,
110-
isize,
111-
quantity,
108+
uint8_t bytes_read = TWI_MasterWriteRead(address,
109+
(uint8_t *) &iaddress,
110+
isize,
111+
quantity,
112112
sendStop);
113113

114114
/* Copy read buffer from lower layer */
@@ -306,7 +306,7 @@ void TwoWire::flush(void)
306306
}
307307

308308
// behind the scenes function that is called when data is received
309-
void TwoWire::onReceiveService(uint8_t* inBytes, int numBytes)
309+
void TwoWire::onReceiveService(volatile uint8_t* inBytes, int numBytes)
310310
{
311311
// don't bother if user hasn't registered a callback
312312
if(!user_onReceive){

libraries/Wire/src/Wire.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class TwoWire : public HardwareI2C
4545
static void (*user_onRequest)(void);
4646
static void (*user_onReceive)(int);
4747
static void onRequestService(void);
48-
static void onReceiveService(uint8_t*, int);
48+
static void onReceiveService(volatile uint8_t*, int);
4949
public:
5050
TwoWire();
5151
void begin();

libraries/Wire/src/utility/twi.c

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ void TWI_MasterSetBaud(uint32_t frequency){
150150

151151
// Formula is: BAUD = ((F_CLKPER/frequency) - F_CLKPER*T_RISE - 10)/2;
152152
// Where T_RISE varies depending on operating frequency...
153-
// From 1617 DS: 1000ns @ 100kHz / 300ns @ 400kHz / 120ns @ 1MHz
154-
uint8_t t_rise;
153+
// From 1617 DS: 1000ns @ 100kHz / 300ns @ 400kHz / 120ns @ 1MHz
154+
155+
uint16_t t_rise;
155156

156157
if(frequency < 200000){
157158
frequency = 100000;
@@ -172,7 +173,7 @@ void TWI_MasterSetBaud(uint32_t frequency){
172173

173174
uint32_t baud = ((F_CPU_CORRECTED/frequency) - (((F_CPU_CORRECTED*t_rise)/1000)/1000)/1000 - 10)/2;
174175
TWI0.MBAUD = (uint8_t)baud;
175-
176+
176177
}
177178

178179
/*! \brief TWI write transaction.
@@ -694,24 +695,24 @@ void TWI_SlaveReadHandler(){
694695
}
695696
}
696697

697-
/*
698-
* Function twi_attachSlaveRxEvent
699-
* Desc sets function called before a slave read operation
700-
* Input function: callback function to use
701-
* Output none
702-
*/
703-
void TWI_attachSlaveRxEvent( void (*function)(uint8_t*, int) ){
704-
TWI_onSlaveReceive = function;
705-
}
706-
707-
/*
708-
* Function twi_attachSlaveTxEvent
709-
* Desc sets function called before a slave write operation
710-
* Input function: callback function to use
711-
* Output none
712-
*/
713-
void TWI_attachSlaveTxEvent( void (*function)(void) ){
714-
TWI_onSlaveTransmit = function;
698+
/*
699+
* Function twi_attachSlaveRxEvent
700+
* Desc sets function called before a slave read operation
701+
* Input function: callback function to use
702+
* Output none
703+
*/
704+
void TWI_attachSlaveRxEvent( void (*function)(volatile uint8_t*, int) ){
705+
TWI_onSlaveReceive = function;
706+
}
707+
708+
/*
709+
* Function twi_attachSlaveTxEvent
710+
* Desc sets function called before a slave write operation
711+
* Input function: callback function to use
712+
* Output none
713+
*/
714+
void TWI_attachSlaveTxEvent( void (*function)(void) ){
715+
TWI_onSlaveTransmit = function;
715716
}
716717

717718

libraries/Wire/src/utility/twi.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ register8_t master_trans_status; /*!< Status of transactio
8585
register8_t master_result; /*!< Result of transaction */
8686

8787
/* Slave variables */
88-
static void (*TWI_onSlaveTransmit)(void);
89-
static void (*TWI_onSlaveReceive)(uint8_t*, int);
88+
static void (*TWI_onSlaveTransmit)(void) __attribute__((unused));
89+
static void (*TWI_onSlaveReceive)(volatile uint8_t*, int) __attribute__((unused));
9090
register8_t slave_writeData[TWI_BUFFER_SIZE];
9191
register8_t slave_readData[TWI_BUFFER_SIZE];
9292
register8_t slave_bytesToWrite;
@@ -135,7 +135,7 @@ void TWI_SlaveStopHandler(void);
135135
void TWI_SlaveDataHandler(void);
136136
void TWI_SlaveWriteHandler(void);
137137
void TWI_SlaveReadHandler(void);
138-
void TWI_attachSlaveRxEvent( void (*function)(uint8_t*, int) );
138+
void TWI_attachSlaveRxEvent( void (*function)(volatile uint8_t*, int) );
139139
void TWI_attachSlaveTxEvent( void (*function)(void) );
140140
void TWI_SlaveTransactionFinished(uint8_t result);
141141
/*! TWI master interrupt service routine.

0 commit comments

Comments
 (0)