File tree 8 files changed +23
-24
lines changed
8 files changed +23
-24
lines changed Original file line number Diff line number Diff line change 179
179
*_ucsrb |= _udrie;
180
180
#else
181
181
if (!(LINENIR & _BV (LENTXOK))){
182
- // The buffer was previously empty, so enable TX Complete interrupt and load first byte.
183
- LINENIR = _BV (LENTXOK) | _BV (LENRXOK);
182
+ // The buffer was previously empty, so load the first byte, then enable
183
+ // the TX Complete interrupt
184
184
unsigned char c = _tx_buffer->buffer [_tx_buffer->tail ];
185
185
_tx_buffer->tail = (_tx_buffer->tail + 1 ) & (SERIAL_BUFFER_SIZE - 1 );
186
186
LINDAT = c;
187
+ LINENIR = _BV (LENTXOK) | _BV (LENRXOK);
187
188
}
188
189
#endif
189
190
Original file line number Diff line number Diff line change 37
37
if (LINSIR & _BV (LTXOK)) {
38
38
// PINA |= _BV(PINA5); //debug
39
39
if (tx_buffer.head == tx_buffer.tail ) {
40
- // Buffer empty, so disable interrupts
40
+ // Buffer empty, so disable the Transmit Performed Interrupt
41
41
LINENIR = LENRXOK; // unset LENTXOK
42
42
} else {
43
43
// There is more data in the output buffer. Send the next byte
Original file line number Diff line number Diff line change @@ -199,15 +199,14 @@ void i2c_delay_half(void)
199
199
__asm__ __volatile__ (" ret" );
200
200
// 7 cycles for call and return
201
201
#else
202
- uint8_t temp = 0 ;
203
202
__asm__ __volatile__
204
203
(
205
204
" ldi r25, %[DELAY] ; load delay constant ; 4C \n\t"
206
205
"_Lidelay: \n\t"
207
206
" dec r25 ; decrement counter ; 4C + xC \n\t"
208
207
" brne _Lidelay ; 5C+(x-1)2C + xC\n\t"
209
208
" ret ; 9C+(x-1)2C + xC = 7C + xC"
210
- : "+d" (( uint8_t ) temp ) : [DELAY ] "M" I2C_DELAY_COUNTER );
209
+ : : [DELAY ] "M" I2C_DELAY_COUNTER : "r25" );
211
210
// 7 cycles + 3 times x cycles
212
211
#endif
213
212
}
Original file line number Diff line number Diff line change @@ -113,11 +113,11 @@ class SoftWire : public Stream
113
113
beginTransmission (address);
114
114
// the maximum size of internal address is 3 bytes
115
115
if (isize > 3 ) {
116
- isize = 3 ;
116
+ isize = 3 ;
117
117
}
118
118
// write internal register address - most significant byte first
119
119
while (isize-- > 0 )
120
- write ((uint8_t )(iaddress >> (isize*8 )));
120
+ write ((uint8_t )(iaddress >> (isize*8 )));
121
121
endTransmission (false );
122
122
}
123
123
// clamp to buffer length
Original file line number Diff line number Diff line change 732
732
return value;
733
733
}
734
734
#else // Implementations for slave only mode
735
- void TwoWire::begin (int address) {
736
- begin ((uint8_t )address);
735
+ void TwoWire::begin (uint8_t address) {
736
+ TinyWireS. begin ((uint8_t )address, 0 );
737
737
}
738
-
739
738
// must be called in slave onRequest event callback
740
739
size_t TwoWire::write (uint8_t data) {
741
740
size_t numBytes = 0 ;
814
813
/* END MASTER ONLY METHODS */
815
814
816
815
/* BEGIN SLAVE ONLY METHODS */
817
- #if defined(SLAVE_MASTER_ONLY ) || defined(WIRE_BOTH)
816
+ #if defined(WIRE_SLAVE_ONLY ) || defined(WIRE_BOTH)
818
817
819
818
void TwoWire::onReceive ( void (*function)(size_t )) {
820
819
TinyWireS.onReceive (function);
821
820
}
822
821
void TwoWire::onReceive ( void (*function)(int )) {
823
822
// arduino api compatibility fixer:
824
823
// really hope size parameter will not exceed 2^31 :)
825
- static_assert (sizeof (int ) == sizeof (size_t ), " something is wrong in Arduino kingdom" );
824
+ static_assert (sizeof (int ) == sizeof (size_t ), " something is wrong in the Arduino kingdom" );
826
825
TinyWireS.onReceive (reinterpret_cast <void (*)(size_t )>(function));
827
826
}
828
827
// sets function called on slave read
Original file line number Diff line number Diff line change @@ -292,13 +292,13 @@ anyway) and instead just use TOCPMCOE bits to control whether PWM is output */
292
292
* a markedly inferior software TWI master implementation if that is requested.
293
293
*---------------------------------------------------------------------------*/
294
294
295
- /* Hardware I2C slave */
296
- #define SCL PIN_PA6
295
+ /* Used by hardware I2C slave and software I2C master */
296
+ #define SCL PIN_PA4
297
297
#define SCL_PORT (PORTA)
298
- #define SCL_PIN (6 )
299
- #define SDA PIN_PA4
298
+ #define SCL_PIN (4 )
299
+ #define SDA PIN_PA6
300
300
#define SDA_PORT (PORTA)
301
- #define SDA_PIN (4 )
301
+ #define SDA_PIN (6 )
302
302
303
303
/* Hardware SPI */
304
304
#if defined(SET_REMAP ) && SET_REMAP > 1
Original file line number Diff line number Diff line change @@ -293,13 +293,13 @@ anyway) and instead just use TOCPMCOE bits to control whether PWM is output */
293
293
* a markedly inferior software TWI master implementation if that is requested.
294
294
*---------------------------------------------------------------------------*/
295
295
296
- /* Hardware I2C slave */
297
- #define SCL PIN_PA6
296
+ /* Used by hardware I2C slave and software I2C master */
297
+ #define SCL PIN_PA4
298
298
#define SCL_PORT (PORTA)
299
- #define SCL_PIN (6 )
300
- #define SDA PIN_PA4
299
+ #define SCL_PIN (4 )
300
+ #define SDA PIN_PA6
301
301
#define SDA_PORT (PORTA)
302
- #define SDA_PIN (4 )
302
+ #define SDA_PIN (6 )
303
303
304
304
/* Hardware SPI */
305
305
#if defined(SET_REMAP ) && SET_REMAP > 1
Original file line number Diff line number Diff line change @@ -155,8 +155,8 @@ static const uint8_t A3 = ADC_CH(3);
155
155
#define INTERNAL INTERNAL1V1 /* deprecated */
156
156
/* Special Analog Channels */
157
157
#define ADC_TEMPERATURE ADC_CH(0x0F)
158
- #define ADC_INTERNAL1V1 ADC_CH(0x0D )
159
- #define ADC_GROUND ADC_CH(0x0C )
158
+ #define ADC_INTERNAL1V1 ADC_CH(0x0C )
159
+ #define ADC_GROUND ADC_CH(0x0D )
160
160
161
161
/* Differential Analog Channels */
162
162
#define DIFF_A2_A2_1X ADC_CH(0x04)
You can’t perform that action at this time.
0 commit comments