Hardware Serial 9 bit for SAMD21
if anyone else interested to use/test/enhance:
https://github.com/PhiJu5/HWSerial9BitSamD21 (click ‘compare’ to view changes)
- By default Hardware Serial 9 is not active
- The change in board.txt is an example how to add the needed global compile
define (-D__HWSERIAL9BIT) by duplicate and modify an existing board.
Perhaps Aduino IDE will have a feature ‘add custom a global define’ per .ino file some day.
- Use write9bit(uint8_t data) for 9th bit set (use write(uint8_t data) for 9th bit not set).
This keeps exiting code with standard write(uint8_t data) compatible.
- set_tx_mode() set_rx_mode() experimental (half duplex)
- yes, rx/tx buffers memory footprint are doubled
Example attached (for “Arduino M0 HWSERIAL9BIT” Arduino IDE board entry).
Hw9w.ino (1.66 KB)