Skip to content

Commit 77ae92a

Browse files
committed
Merge branch 'v2.0.0-devThis-is-the-head-submit-PRs-against-this' of https://github.com/SpenceKonde/ATTinyCore into v2.0.0-devThis-is-the-head-submit-PRs-against-this
2 parents e61f040 + dc8bad6 commit 77ae92a

File tree

8 files changed

+23
-24
lines changed

8 files changed

+23
-24
lines changed

avr/cores/tiny/HardwareSerial.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,12 @@
179179
*_ucsrb |= _udrie;
180180
#else
181181
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
184184
unsigned char c = _tx_buffer->buffer[_tx_buffer->tail];
185185
_tx_buffer->tail = (_tx_buffer->tail + 1) & (SERIAL_BUFFER_SIZE - 1);
186186
LINDAT = c;
187+
LINENIR = _BV(LENTXOK) | _BV(LENRXOK);
187188
}
188189
#endif
189190

avr/cores/tiny/Serial0.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
if(LINSIR & _BV(LTXOK)) {
3838
//PINA |= _BV(PINA5); //debug
3939
if (tx_buffer.head == tx_buffer.tail) {
40-
// Buffer empty, so disable interrupts
40+
// Buffer empty, so disable the Transmit Performed Interrupt
4141
LINENIR = LENRXOK; //unset LENTXOK
4242
} else {
4343
// There is more data in the output buffer. Send the next byte

avr/libraries/Wire/src/SoftI2CMaster.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,14 @@ void i2c_delay_half(void)
199199
__asm__ __volatile__ (" ret");
200200
// 7 cycles for call and return
201201
#else
202-
uint8_t temp = 0;
203202
__asm__ __volatile__
204203
(
205204
" ldi r25, %[DELAY] ; load delay constant ; 4C \n\t"
206205
"_Lidelay: \n\t"
207206
" dec r25 ; decrement counter ; 4C + xC \n\t"
208207
" brne _Lidelay ; 5C+(x-1)2C + xC\n\t"
209208
" 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");
211210
// 7 cycles + 3 times x cycles
212211
#endif
213212
}

avr/libraries/Wire/src/SoftWire.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ class SoftWire : public Stream
113113
beginTransmission(address);
114114
// the maximum size of internal address is 3 bytes
115115
if (isize > 3) {
116-
isize = 3;
116+
isize = 3;
117117
}
118118
// write internal register address - most significant byte first
119119
while (isize-- > 0)
120-
write((uint8_t)(iaddress >> (isize*8)));
120+
write((uint8_t)(iaddress >> (isize*8)));
121121
endTransmission(false);
122122
}
123123
// clamp to buffer length

avr/libraries/Wire/src/Wire.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -732,10 +732,9 @@
732732
return value;
733733
}
734734
#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);
737737
}
738-
739738
// must be called in slave onRequest event callback
740739
size_t TwoWire::write(uint8_t data) {
741740
size_t numBytes = 0;
@@ -814,15 +813,15 @@
814813
/* END MASTER ONLY METHODS */
815814

816815
/* BEGIN SLAVE ONLY METHODS */
817-
#if defined(SLAVE_MASTER_ONLY) || defined(WIRE_BOTH)
816+
#if defined(WIRE_SLAVE_ONLY) || defined(WIRE_BOTH)
818817

819818
void TwoWire::onReceive( void (*function)(size_t)) {
820819
TinyWireS.onReceive(function);
821820
}
822821
void TwoWire::onReceive( void (*function)(int)) {
823822
// arduino api compatibility fixer:
824823
// 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");
826825
TinyWireS.onReceive(reinterpret_cast<void(*)(size_t)>(function));
827826
}
828827
// sets function called on slave read

avr/variants/tinyx41_cw/pins_arduino.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,13 @@ anyway) and instead just use TOCPMCOE bits to control whether PWM is output */
292292
* a markedly inferior software TWI master implementation if that is requested.
293293
*---------------------------------------------------------------------------*/
294294

295-
/* Hardware I2C slave */
296-
#define SCL PIN_PA6
295+
/* Used by hardware I2C slave and software I2C master */
296+
#define SCL PIN_PA4
297297
#define SCL_PORT (PORTA)
298-
#define SCL_PIN (6)
299-
#define SDA PIN_PA4
298+
#define SCL_PIN (4)
299+
#define SDA PIN_PA6
300300
#define SDA_PORT (PORTA)
301-
#define SDA_PIN (4)
301+
#define SDA_PIN (6)
302302

303303
/* Hardware SPI */
304304
#if defined(SET_REMAP) && SET_REMAP > 1

avr/variants/tinyx41_legacy/pins_arduino.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,13 @@ anyway) and instead just use TOCPMCOE bits to control whether PWM is output */
293293
* a markedly inferior software TWI master implementation if that is requested.
294294
*---------------------------------------------------------------------------*/
295295

296-
/* Hardware I2C slave */
297-
#define SCL PIN_PA6
296+
/* Used by hardware I2C slave and software I2C master */
297+
#define SCL PIN_PA4
298298
#define SCL_PORT (PORTA)
299-
#define SCL_PIN (6)
300-
#define SDA PIN_PA4
299+
#define SCL_PIN (4)
300+
#define SDA PIN_PA6
301301
#define SDA_PORT (PORTA)
302-
#define SDA_PIN (4)
302+
#define SDA_PIN (6)
303303

304304
/* Hardware SPI */
305305
#if defined(SET_REMAP) && SET_REMAP > 1

avr/variants/tinyx5/pins_arduino.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ static const uint8_t A3 = ADC_CH(3);
155155
#define INTERNAL INTERNAL1V1 /* deprecated */
156156
/* Special Analog Channels */
157157
#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)
160160

161161
/* Differential Analog Channels */
162162
#define DIFF_A2_A2_1X ADC_CH(0x04)

0 commit comments

Comments
 (0)