1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-23 19:21:59 +03:00

Merge remote-tracking branch 'remotes/esp8266/master'

This commit is contained in:
Markus Sattler
2015-12-08 11:33:25 +01:00
7 changed files with 49 additions and 56 deletions

View File

@ -219,14 +219,12 @@ void loop(void);
void yield(void);
void optimistic_yield(uint32_t interval_us);
// Get the bit location within the hardware port of the given virtual pin.
// This comes from the pins_*.c file for the active board configuration.
#define digitalPinToPort(pin) (0)
#define digitalPinToBitMask(pin) (1UL << (pin))
#define digitalPinToTimer(pin) (0)
#define portOutputRegister(port) ((volatile uint32_t*) GPO)
#define portInputRegister(port) ((volatile uint32_t*) GPI)
#define portModeRegister(port) ((volatile uint32_t*) GPE)
#define portOutputRegister(port) ((volatile uint32_t*) &GPO)
#define portInputRegister(port) ((volatile uint32_t*) &GPI)
#define portModeRegister(port) ((volatile uint32_t*) &GPE)
#define NOT_A_PIN -1
#define NOT_A_PORT -1

View File

@ -617,18 +617,15 @@ size_t HardwareSerial::write(uint8_t c) {
size_t room = uart_get_tx_fifo_room(_uart);
if(room > 0 && _tx_buffer->empty()) {
uart_transmit_char(_uart, c);
if(room < 10) {
uart_arm_tx_interrupt(_uart);
}
return 1;
}
while(_tx_buffer->room() == 0) {
yield();
uart_arm_tx_interrupt(_uart);
}
_tx_buffer->write(c);
uart_arm_tx_interrupt(_uart);
return 1;
}

View File

@ -68,6 +68,10 @@ void __throw_length_error(char const*) {
void __throw_bad_alloc() {
panic();
}
void __throw_logic_error(const char* str) {
panic();
}
}
// TODO: rebuild windows toolchain to make this unnecessary:

View File

@ -42,9 +42,6 @@ class cbuf {
if(_end >= _begin) {
return _size - (_end - _begin) - 1;
}
if(_begin == _end) {
return _size;
}
return _begin - _end - 1;
}
@ -62,7 +59,7 @@ class cbuf {
if(getSize() == 0) return -1;
char result = *_begin;
if(++_begin == _bufend) _begin = _buf;
_begin = wrap_if_bufend(_begin + 1);
return static_cast<int>(result);
}
@ -78,8 +75,7 @@ class cbuf {
dst += top_size;
}
memcpy(dst, _begin, size_to_read);
_begin += size_to_read;
if(_begin == _bufend) _begin = _buf;
_begin = wrap_if_bufend(_begin + size_to_read);
return size_read;
}
@ -87,7 +83,7 @@ class cbuf {
if(room() == 0) return 0;
*_end = c;
if(++_end == _bufend) _end = _buf;
_end = wrap_if_bufend(_end + 1);
return 1;
}
@ -103,8 +99,7 @@ class cbuf {
src += top_size;
}
memcpy(_end, src, size_to_write);
_end += size_to_write;
if(_end == _bufend) _end = _buf;
_end = wrap_if_bufend(_end + size_to_write);
return size_written;
}
@ -114,6 +109,10 @@ class cbuf {
}
private:
inline char* wrap_if_bufend(char* ptr) {
return (ptr == _bufend) ? _buf : ptr;
}
size_t _size;
char* _buf;
char* _bufend;

View File

@ -78,7 +78,7 @@ int vsnprintf_P(char *str, size_t strSize, PGM_P formatP, va_list ap) __attribut
(__extension__({ \
PGM_P __local = (PGM_P)(addr); /* isolate varible for macro expansion */ \
ptrdiff_t __offset = ((uint32_t)__local & 0x00000003); /* byte aligned mask */ \
const uint32_t* __addr32 = reinterpret_cast<const uint32_t*>(reinterpret_cast<const uint8_t*>(__local)-__offset); \
const uint32_t* __addr32 = (const uint32_t*)((const uint8_t*)(__local)-__offset); \
uint8_t __result = ((*__addr32) >> (__offset * 8)); \
__result; \
}))
@ -87,7 +87,7 @@ int vsnprintf_P(char *str, size_t strSize, PGM_P formatP, va_list ap) __attribut
(__extension__({ \
PGM_P __local = (PGM_P)(addr); /* isolate varible for macro expansion */ \
ptrdiff_t __offset = ((uint32_t)__local & 0x00000002); /* word aligned mask */ \
const uint32_t* __addr32 = reinterpret_cast<const uint32_t*>(reinterpret_cast<const uint8_t*>(__local) - __offset); \
const uint32_t* __addr32 = (const uint32_t*)((const uint8_t*)(__local) - __offset); \
uint16_t __result = ((*__addr32) >> (__offset * 8)); \
__result; \
}))