Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- /home/uaa/ArduinoCore-avr/libraries/SoftwareSerial/src/SoftwareSerial.cpp Sun Jul 19 07:27:55 2020
- +++ SoftwareSerial.cpp Sat Jul 18 05:17:07 2020
- @@ -42,8 +42,29 @@ http://arduiniana.org.
- #include <avr/pgmspace.h>
- #include <Arduino.h>
- #include <SoftwareSerial.h>
- -#include <util/delay_basic.h>
- +// #include <util/delay_basic.h>
- +// replace modified _delay_loop_2() for LGT8F328P
- +/*
- + Delay loop using a 16-bit counter \c __count, so up to 65536
- + iterations are possible. (The value 65536 would have to be
- + passed as 0.) The loop executes four CPU cycles per iteration,
- + not including the overhead the compiler requires to setup the
- + counter register pair.
- + Thus, at a CPU speed of 1 MHz, delays of up to about 262.1
- + milliseconds can be achieved.
- + */
- +static void SoftwareSerial::_delay_loop_2(uint16_t __count)
- +{
- + __asm__ volatile (
- + "1: sbiw %0,1" "\n\t"
- + "nop" "\n\t" // LGT8F328P's SBIW takes 1 clock, adjust
- + "brne 1b"
- + : "=w" (__count)
- + : "0" (__count)
- + );
- +}
- +
- //
- // Statics
- //
- @@ -301,6 +322,31 @@ uint16_t SoftwareSerial::subtract_cap(uint16_t num, ui
- // Public methods
- //
- +void SoftwareSerial::begin(uint16_t rxcenter, uint16_t rxintra, uint16_t rxstop, uint16_t tx)
- +{
- + _rx_delay_centering = _rx_delay_intrabit = _rx_delay_stopbit = 0;
- + _tx_delay = tx;
- +
- + // Only setup rx when we have a valid PCINT for this pin
- + if (digitalPinToPCICR((int8_t)_receivePin)) {
- + _rx_delay_centering = rxcenter;
- + _rx_delay_intrabit = rxintra;
- + _rx_delay_stopbit = rxstop;
- +
- + *digitalPinToPCICR((int8_t)_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));
- + _pcint_maskreg = digitalPinToPCMSK(_receivePin);
- + _pcint_maskvalue = _BV(digitalPinToPCMSKbit(_receivePin));
- +
- + tunedDelay(_tx_delay); // if we were low this establishes the end
- + }
- +
- +#if _DEBUG
- + pinMode(_DEBUG_PIN1, OUTPUT);
- + pinMode(_DEBUG_PIN2, OUTPUT);
- +#endif
- +
- + listen();
- +}
- void SoftwareSerial::begin(long speed)
- {
- _rx_delay_centering = _rx_delay_intrabit = _rx_delay_stopbit = _tx_delay = 0;
Add Comment
Please, Sign In to add comment