/* Disables a Generic Clock that was previously enabled. 
Stops the clock generation of a Generic Clock that was previously started via a call to  */
void system_gclk_chan_disable(const uint8_t channel)
/* Disables a Generic Clock that was previously enabled. 
Stops the clock generation of a Generic Clock that was previously started via a call to  */
void system_gclk_chan_disable(const uint8_t channel)
{
	system_interrupt_enter_critical_section();
	*((uint8_t*)&GCLK->CLKCTRL.reg) = channel;
	Assert(!GCLK->CLKCTRL.bit.WRTLOCK);
	uint32_t prev_gen_id = GCLK->CLKCTRL.bit.GEN;
	GCLK->CLKCTRL.bit.GEN = 0;
	GCLK->CLKCTRL.reg &= ~GCLK_CLKCTRL_CLKEN;
	while (GCLK->CLKCTRL.reg & GCLK_CLKCTRL_CLKEN) {
	}
	GCLK->CLKCTRL.bit.GEN = prev_gen_id;
	system_interrupt_leave_critical_section();
}