I'm putting together a link where the physical layer is SPDIF transmitters and receivers. I control both sides of the link (ie it doesn't have to interoperate with any other equipment). I would like to send data from a microcontroller, essentially treating this as a UART. The problem: if the output stays low or stays high too long (not sending data on the UART), the SPDIF receiver output becomes unpredictable, and it takes a fair amount of time with regular transitions for it to recover. SPDIF normally uses Bi-phase Mark Code (BMC) to deal with this problem (the clock is always running so there are always low-high transitions).
What is the easiest way to encode and decode data which ensures the link is always transitioning between states? I'd like to use the least amount of hardware to implement, and relatively simple software; ideally no hardware, and just using the peripherals on the microcontroller. It doesn't have to be BMC; 8/10 for example would be perfectly ok.