/* This function is used to Free the DMA channel when not use.  */
void tls_dma_free(unsigned char ch)
/* This function is used to Free the DMA channel when not use.  */
void tls_dma_free(unsigned char ch)
{
	if(ch < 8)
	{
		tls_dma_stop(ch);
		DMA_SRCADDR_REG(ch) = 0;
		DMA_DESTADDR_REG(ch) = 0;
		DMA_MODE_REG(ch) = 0;
		DMA_CTRL_REG(ch) = 0;
		DMA_INTSRC_REG |= 0x03<<(ch*2);
		channels.channels[ch] = 0x00;
		dma_used_bit &= ~(1<<ch);
		if (dma_used_bit == 0)
		{
			tls_close_peripheral_clock(TLS_PERIPHERAL_TYPE_DMA);
		}
	}
}