Skip to content

Commit a22bd6b

Browse files
committed
[HWSerial] Replace assert() by Error_Handler()
Avoid to include "assert.h" which relies on printf(). This allow to save space: Example for SerialEvent sketch for BluePill: - with assert: Sketch uses 16692 bytes (25%) of program storage space. Maximum is 65536 bytes. Global variables use 1092 bytes (5%) of dynamic memory, leaving 19388 bytes for local variables. Maximum is 20480 bytes. - without assert: Sketch uses 12288 bytes (18%) of program storage space. Maximum is 65536 bytes. Global variables use 984 bytes (4%) of dynamic memory, leaving 19496 bytes for local variables. Maximum is 20480 bytes. Signed-off-by: Frederic.Pillon <[email protected]>
1 parent 01d9b09 commit a22bd6b

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

cores/arduino/HardwareSerial.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <stdio.h>
2727
#include <string.h>
2828
#include <inttypes.h>
29-
#include <assert.h>
3029
#include "Arduino.h"
3130
#include "HardwareSerial.h"
3231

@@ -385,10 +384,9 @@ void HardwareSerial::begin(unsigned long baud, byte config)
385384
break;
386385
default:
387386
case 0:
388-
databits = 0;
387+
Error_Handler();
389388
break;
390389
}
391-
assert(databits!=0);
392390

393391
uart_init(&_serial);
394392
uart_attach_rx_callback(&_serial, _rx_complete_irq);

0 commit comments

Comments
 (0)