Seems to me this is the same for baremetal and chibios, except that a different buffer is used.
So you could avoid the repetition by creating a local pointer to it and only ifdef that part.