Is it possible to identify at run time which SERCOM instance is used for a serial port on an Arduino zero or other board based on the SAMD21/51 devices.
I am trying to write a library that tweaks the SERCOM configuration when it is being used as a serial UART, and ideally I want the library to work seamlessly with any SAMD device and board configuration, but I can't see a way of identifying in code which SERCOM instance is being used for a serial port ...
i.e: when I put Serial1.begin() in the sketch - I want my code to be able to work out if, on the board in question, Serial1 is using SERCOM1, or SERCOM2 ...etc
but this are arduino pin numbers. so you would have to map them over pin description to port (and pin?) and then decide to which sercom is the port/pin assigned. maybe there is a simpler way, but I don't see it. For example Uart class doesn't have a getter for sercom instance.
Thanks - I'm already aware of how SERCOM's are assigned in the board definition files - my current solution is just to have lots of instructions for the user on how to find out which SERCOM is used, but that isn't exactly user friendly!
BillBigge:
Thanks - I'm already aware of how SERCOM's are assigned in the board definition files - my current solution is just to have lots of instructions for the user on how to find out which SERCOM is used, but that isn't exactly user friendly!
Yes - the problem then is that some pins can be muxed to two different sercoms, so there may be cases where you can only narrow it down to two possibilities...