/* Abort a DMA transfer. 
This function will abort a DMA transfer. The DMA channel used for the DMA resource will be disabled. The block transfer count will also be calculated and written to the DMA resource structure. */
void dma_abort_job(struct dma_resource *resource)
/* Abort a DMA transfer. 
This function will abort a DMA transfer. The DMA channel used for the DMA resource will be disabled. The block transfer count will also be calculated and written to the DMA resource structure. */
void dma_abort_job(struct dma_resource *resource)
{
	uint32_t write_size;
	uint32_t total_size;
	Assert(resource);
	Assert(resource->channel_id != DMA_INVALID_CHANNEL);
	system_interrupt_enter_critical_section();
	DMAC->CHID.reg = DMAC_CHID_ID(resource->channel_id);
	DMAC->CHCTRLA.reg = 0;
	system_interrupt_leave_critical_section();
	total_size = descriptor_section[resource->channel_id].BTCNT.reg;
	write_size = _write_back_section[resource->channel_id].BTCNT.reg;
	resource->transfered_size = total_size - write_size;
	resource->job_status = STATUS_ABORTED;
}