/* Main program entry point. This routine contains the overall program flow, including initial setup of all components and the main program loop.  */
int main(void)
/* Main program entry point. This routine contains the overall program flow, including initial setup of all components and the main program loop.  */
int main(void)
{
	SetupHardware();
	CDC_Device_CreateBlockingStream(&VirtualSerial_CDC_Interface, &USBSerialStream);
	GlobalInterruptEnable();
	for (;;)
	{
		uint8_t ColourUpdate = fgetc(&USBSerialStream);
		uint8_t Channel = (ColourUpdate & 0b11100000);
		uint8_t Duty    = (ColourUpdate & 0b00011111);
		if (Channel & (1 << 5))
		  SoftPWM_Channel1_Duty = Duty;
		if (Channel & (1 << 6))
		  SoftPWM_Channel2_Duty = Duty;
		if (Channel & (1 << 7))
		  SoftPWM_Channel3_Duty = Duty;
		fputc(ColourUpdate, &USBSerialStream);
		CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
		USB_USBTask();
	}
}