SpenceKonde / megaTinyCore

Arduino core for the tinyAVR 0/1/2-series - Ones's digit 2,4,5,7 (pincount, 8,14,20,24), tens digit 0, 1, or 2 (featureset), preceded by flash in kb. Library maintainers: porting help available!
Other
544 stars 141 forks source link

Add option to enable XDIR pin for RS485 mode #975

Closed xieliwei closed 1 year ago

xieliwei commented 1 year ago

I've added an option to enable RS485 mode 1 on the UART so that the XDIR pin can be used to control an external RS485 transceiver. Unlikely to be useful if you have more than one device on the network, but great for remotely flashing hard-to-access devices that you would otherwise need to physically get to.

With a suitable USB RS485 cable that automatically drives the bus without fancy RTS signaling, everything works (avrdude/Arduino upload) without any additional modification. You will of course need to figure out how to enter the bootloader remotely.

This change increases the bootloader size by an additional instruction to set the XDIR pin to output. For BIGBOOT, it also embeds the RS485 parameter.

SpenceKonde commented 1 year ago

Since the added feature is not available in prebuilt binaries (I certainly don't intend to pre-build them - I already prebuild hundreds of binaries....), and there are comparatively few people who would use it. so it doesn't have as high a bar as other changes.

Have you confirmed that normal tinyAVRs still build and generate binary identical output (if it's not identical, we need to understand why, and verify that it's not a problem.

SpenceKonde commented 1 year ago

confirmed generated binaries under normal circumstances are identical