circuitpython/supervisor
Jeff Epler 28043c94b5 supervisor: Improve serial connection detection
These changes remove the caveat from supervisor.runtime.serial_connected.

It appears that _tud_cdc_connected() only tracks explicit changes to the
"DTR" bit, which leads to disconnects not being registered.

Instead:
 * when line state is changed explicitly, track the dtr value in
   _serial_connected
 * when the USB bus is suspended, set _serial_connected to False

Testing performed (using sam e54 xplained):  Run a program to show
the state of `serial_connected` on the LED:
```
import digitalio
import supervisor
import board

led = digitalio.DigitalInOut(board.LED)
while True:
    led.switch_to_output(not supervisor.runtime.serial_connected)
```

Try all the following:
 * open, close serial terminal program
    - LED status tracks whether terminal is open
 * turn on/off data lines using the switchable charge-only cable
    - LED turns off when switch is in "charger" position
    - LED turns back on when switch is in Data position and terminal is
      opened (but doesn't turn back on just because switch position is
      changed)
2020-09-17 18:32:06 -05:00
..
messages Support internationalisation. 2018-08-07 14:58:57 -07:00
shared supervisor: Improve serial connection detection 2020-09-17 18:32:06 -05:00
stub Add license to some obvious files. 2020-07-06 19:16:25 +01:00
background_callback.h background_callback: Add gc collect callback 2020-07-17 08:36:26 -05:00
cpu.h Mark pointers in cpu registers as in use. 2018-07-03 05:45:50 -07:00
filesystem.h flush flash filesystem once a second 2019-03-20 12:21:36 -04:00
flash.h Add license to some obvious files. 2020-07-06 19:16:25 +01:00
flash_root_pointers.h Move atmel-samd to tinyusb and support nRF flash. 2018-11-08 17:25:30 -08:00
linker.h Linker file restructure, TCM and MPU additions 2020-04-03 16:33:18 -04:00
memory.h allow retrieving info about a supervisor allocation 2020-04-14 18:24:54 -05:00
port.h Scanning WIP. Need to sort out supervisor memory 2020-08-19 14:22:12 -07:00
serial.h supervisor: Improve serial connection detection 2020-09-17 18:32:06 -05:00
spi_flash_api.h Implement requested changes 2020-01-28 17:11:25 -05:00
supervisor.mk Merge remote-tracking branch 'adafruit/main' into ble_hci 2020-08-21 10:45:05 -04:00
usb.h Merge pull request #3223 from dhalbert/unmount-before-reset 2020-07-29 10:47:24 -07:00