I’m trying to find a way to know if the usb port is plugged and is powering the board.
I’m currently trying to read the state of RXD0 as it have to be HIGH when idle (see serial specification https://learn.sparkfun.com/tutorials/serial-communication)
But i’m still unsuccessful as a digitalRead nor an analogRead seems to give any result.
I would gladly welcome any insight on that topic.
Unlike with the AVR based boards (such as the Mbili), on the SodaqONE (and Autonomo) the USB does not use the hardware UART labelled Serial. It uses the native USB support of the Samd21.
You could test the FSM state of the USB DEVICE register:
There are a few definitions which you can test against:
These reference specific bits in the FSMSTATE register.
See page 791 of the datasheet: http://www.atmel.com/Images/Atmel-42181-SAM-D21_Datasheet.pdf
Ok thank you for your quick answer !