Thanks to ideas from @shimarin for offering ideas to speed up the stopWaveform
calls which may help things like SoftwareSerial run better.
Optimize the stopWaveform routine to abort fast and early whenever possible.
Remove the stopWaveform call from digitalRead(). If you're running a waveform
on a pin and try to read it, that is a logic error and you'll end up reading the
waveform and not the outside world's view of the pin.
Setting a pin direction would cause a waveform generator attached to it to stop.
This could cause PWM to stop if pinMode() is called while running (as it was
called in __analogWrite()).
Remove the stopWaveform call from pinMode, the Tone, analogWrite, or Servo
that initiated the waveform has responsibility for stopping it (and it does)
when complete, irrespective of the pinMode.
Fixes#4905
* Compatibility and IRQ fixed for waveform/tone/pwm
Fix a compiler ambiguity introduced with a floating point frequency option
for tone(). Thanks to @Rob58329 for discovering this and proposing the
fix.
Match original analogWrite behavior by going from 0...1023 (PWMRANGE) and
not 0...1024, and also explicitly set the analogWrite pin to an OUTPUT.
Thanks to @jandrassy for finding this.
Fixes#4380 discovered by @cranphin where interrupts were disabled on a
stopWaveform(). Remove that completely and bracket the update of non-atomic
fields in the structure with disable/enable IRQs for safety.
* Fix tone(int,int,int) infinite loop
Explicitly cast the frequency, when passed in as an int, to an
unsigned int. Verified with snippet:
tone(D1, (int)1000, 500);
tone(D1, (unsigned int)1000, 500);
tone(D1, 1000.0, 500);
tone(D1, (int)1000);
tone(D1, (unsigned int)1000);
tone(D1, 1000.0);
* Scheduled Interrupt
* use capital letter for Schedule.h
* Prevent memory leak when attach is called multiple times without detach
* Add improved schedule_function
* WIP : Integrate FunctionalInterrupt & ScheduledInterrupt
* Fix travis error
Remove and rewrite all the parts of the core/libraries using TIMER1
and consolidate into a single, shared waveform generation interrupt
structure. Tone, analogWrite(), Servo all now just call into this
shared resource to perform their tasks so are all compatible
and can be used simultaneously.
This setup enables multiple tones, analogWrites, servos, and stepper
motors to be controlled with reasonable accuracy. It uses both TIMER1
and the internal ESP cycle counter to handle timing of waveform edges.
TIMER1 is used in non-reload mode and only edges cause interrupts. The
interrupt is started and stopped as required, minimizing overhead when
these features are not being used.
A generic "startWaveform(pin, high-US, low-US, runtime-US)" and
"stopWaveform(pin)" allow for further types of interfaces. Minimum
high or low period is ~1 us.
Add a tone(float) method, useful when working with lower frequencies.
Fixes#4321. Fixes 4349.
restrict usage of deprecated typedefs "prog_*", and cast "pgm_read_*"'s address parameters to "const void*" only when __PROG_TYPES_COMPAT__ is defined.
also add <avr/pgmspace.h> compatibility
Enables I2S stereo input via DMA using new API calls:
. i2s_rxtx_begin(bool rx, rool tx);
. i2s_read_sample(uint32_t *l, uint32_t *r);
Original API calls will only enable TX, so this is backwards compatible.
Add simple I2S input example code using Arduino serial plotter.
Add UDP transmit of I2S microphone data to a PC (remote microphone).
Clean up and reorganize code to share RX and TX logic as much as
possible. Fix a potential WDT error while in blocking sample read
and write.
* Fix for #4565 (rx fifo length), protect access to rx_buffer
* Fix typo
* reworked to separate safe from unsafe functions, factorized some code, constness
* additional rework for uart_rx_fifo_available()
* swapped unsafe function definition order
* Remove static for overrun string
* Some shorthand for perf and readability
* I2S driver fixes for IRQs, protocol, factoring
All redundant ICACHE_FLASH_ATTR decorators were removed, we already do
this by default for all routines, anyway,
The actual ISR and its called function moved to to IRAM. Used to be in flash
due to the decorator, which could lead to crashes. Use ets_memset to mute
buffers in ISR.
Fix the I2S on-the-wire protocol by enabling the transmit delay I2STMS because
I2S is supposed to send the MSB one clock after LRCLK toggles. This was
causing I2S to be twice as loud as intended in the best of cases, and causing
garbage/noise output when the MSB was set since data was effectively shifted.
Refactor the clock divider setting to be done in one function only, as there
is no reason to do the same complicated bit setting in two spots.
* Comment some add'l registers, use optimstic_yield
Comment the known and unknown I2S register settings for posterity, using
the ESP32 guide as a basis.
Use optimistic_yield() instead of esp_wdt_disable/enable when busy
waiting in blocking writes to ensure we don't hog the CPU completely.
Move the constant IO pins to #defines for easier understanding.
With this patch the set up clock rate survives a re-init that is done by many libraries several times.
This makes e.g. an accelerated OLED display possible with the adafruit libraries
* inefficient Print::write(data,len) shows message if used (only in debug mode)
* make HardwareSerial's write(data,len) efficient
* HardwareSerial: remove duplicate tests, move trivial code from .cpp to .h
Move all exception strings to IRAM and out of both PMEM (illegal) and add
output of any assert() failinf conditions.
The exception handler may be called while the SPI interface is in a bad
state. This means no PROGMEM reads are allowed, and all data and functions
used must be in system RAM or IRAM.
Add a new helper macro, ets_printf_P(), which places a constant string in
IRAM and copies it to the stack before calling the real ets_printf().
This makes the code simpler to read as no unwieldy combinations of
ets_putc/ets_printf/... are required to output anything.
The old handler also mistakenly used PSTR() strings in some places, so
fix those with this patch as well.
Gives back ~180 bytes of heap to every sketch built as the exception handler
is always included an application.
At runtime, whenever a realloc, malloc, calloc, or new call fails to
find enough memory, record the calling function and size requested.
Does not print anything or call any heavyweight functions on this, as it
is legal to return NULL to an alloc-type call.
If the main application handles this NULL properly, there should be no
panic and nothing different will happen.
If the main application panics() at any later point in time, this record
will be printed out as part of the crash log for processing with an
updated EspExceptionDecoder.java.
This adds 2-3 instructions overhead in the normal case, and around 10-12
instructions in the failing case, and requires an additional 8 bytes of
.BSS to function.
Only a single address is kept, the final failing malloc-type function call
before a panic, but it is trivial to extend to a fifo with little overhead
in the common, non-failing case.
The default Print::write(byte, count) method was continuing to send
bytes one-by-one even when a prior write returned 0. Because the buffer
pointer was incremented no matter success or fail, this leads to data
corruption as you'll not send some bytes in the middle and will then
send extra bytes past the end of the passed in buffer.
Because there's no concept of timeout, just stop on the first time
write(byte) fails and return the total bytes successfully written
and let the user worry about retrying or handling an error.
Found by @d-a-v and discussed on gitter.
Provides a simple interface to attach/detach pins to the sigma-delta generator, and get/set the 2 parameters prescaler & target. Working example that fades the onboard LED is provided. Code and sample by @stefaandesmet2003.
- Move GDB stub hooks into a separate file, provide header for it
- Use syscall instruction raise user mode exception
- Remove unused code in postmortem.c
fixup
fixup
* Flush the rx fifo when checking available bytes in fifo. This gives a more correct result rather than waiting until either the fifo is full or until a serial rx timeout occurs.
* When rx_avaiable is checked return rx_buffer plus rx_fifo. Then during rx_read and rx_peek functions copy over the data in the fifo as needed.
* Clean up early out case.
* Set the rx full fifo ISR to trigger a little sooner. This makes the uart rx isr more robust in cases where the ISR can't trigger very fast
* provide full version descriptor, displayed in debug mode
* unix: shows core version like under windows when git is unavailable
* store strings in progmem
* version string honours NDEBUG
* add ARDUINO_ESP8266_GIT_DESC
restore ARDUINO_ESP8266_GIT_VER
restore global variable "core_version"
don't print full version on setDebugOutput(true)
set platform.txt version to 2.4.1-pre
hide irrelevant boot version
fix typo
* lwip2: fix disconnection/reconnection issue
also:
improve version string
remove useless message
* lwip2: bump tag before 2.4.1
* lwip2: improve netif flags management on git side
* full-version string: remove useless NDEBUG in separate source file
* do not automatically enable sdk messages along with core messages
* automatically reenable sdk messages along with core messages *before* setup not after
* check serial port when showing version-string + move sdk messages enabler in hardware serial
* + license header
* updated and tested windows commands in platform.txt (without git)
* updated and tested windows commands in platform.txt (without git)
* update package builder accordingly
Calloc was calling memset(0) on NULL when its implicit malloc failed,
causing a crash in UMM. Instead, only do the memset if the memory
allocation succeeds.
Fixes issue #4207
* Added _setError function in the header file
_setError function wraps a few lines to eliminate repetitiveness when debugging for errors.
* Added _setError function
_setError function wraps a few lines to eliminate repetitiveness when debugging for errors.