1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

A modification of [New]SoftSerial to meet certain requests David

Mellis asked about in preparation for integration into core:
1. Remove notion of library version
2. Remove little used "enable_timer0" method.
3. Rename is_listening to isListening
i

:insert

:
:set showmode
This commit is contained in:
Mikal Hart
2011-02-17 23:55:38 -06:00
parent 38d4a34fec
commit 2832e8e0a8
4 changed files with 7 additions and 33 deletions

View File

@ -421,7 +421,7 @@ void SoftwareSerial::end()
// Read data from buffer
int SoftwareSerial::read()
{
if (!is_listening())
if (!isListening())
return -1;
// Empty buffer?
@ -436,7 +436,7 @@ int SoftwareSerial::read()
int SoftwareSerial::available()
{
if (!is_listening())
if (!isListening())
return 0;
return (_receive_buffer_tail + _SS_MAX_RX_BUFF - _receive_buffer_head) % _SS_MAX_RX_BUFF;
@ -488,30 +488,9 @@ void SoftwareSerial::write(uint8_t b)
tunedDelay(_tx_delay);
}
#if !defined(cbi)
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
void SoftwareSerial::enable_timer0(bool enable)
{
if (enable)
#if defined(__AVR_ATmega8__)
sbi(TIMSK, TOIE0);
#else
sbi(TIMSK0, TOIE0);
#endif
else
#if defined(__AVR_ATmega8__)
cbi(TIMSK, TOIE0);
#else
cbi(TIMSK0, TOIE0);
#endif
}
void SoftwareSerial::flush()
{
if (!is_listening())
if (!isListening())
return;
uint8_t oldSREG = SREG;
@ -522,7 +501,7 @@ void SoftwareSerial::flush()
int SoftwareSerial::peek()
{
if (!is_listening())
if (!isListening())
return -1;
// Empty buffer?