Example #1
0
int main(void)
{
	//! [sample_resource]
	struct dma_resource example_resource;
	//! [sample_resource]

	system_init();

	//! [setup_init]
	//! [setup_dma_resource]
	configure_dma_resource(&example_resource);
	//! [setup_dma_resource]

	//! [setup_transfer_descriptor]
	setup_transfer_descriptor(&example_descriptor);
	//! [setup_transfer_descriptor]

	//! [add_descriptor_to_dma_resource]
	dma_add_descriptor(&example_resource, &example_descriptor);
	//! [add_descriptor_to_dma_resource]

	//! [setup_callback_register]
	dma_register_callback(&example_resource, transfer_done,
			DMA_CALLBACK_TRANSFER_DONE);
	//! [setup_callback_register]

	//! [setup_enable_callback]
	dma_enable_callback(&example_resource, DMA_CALLBACK_TRANSFER_DONE);
	//! [setup_enable_callback]

	//! [setup_source_memory_content]
	for (uint32_t i = 0; i < DATA_LENGTH; i++) {
		source_memory[i] = i;
	}
	//! [setup_source_memory_content]

	//! [setup_init]

	//! [main]
	//! [main_1]
	dma_start_transfer_job(&example_resource);
	//! [main_1]

	//! [main_1_1]
	dma_trigger_transfer(&example_resource);
	//! [main_1_1]

	//! [main_2]
	while (!transfer_is_done) {
		/* Wait for transfer done */
	}
	//! [main_2]

	while (true) {
		/* Nothing to do */
	}

	//! [main]
}
Example #2
0
/**
 * \brief The main function.
 */
int main(void)
{
//! [setup_init]

	/* Initialize the system and console*/
	system_init();
	configure_usart();

//! [setup_dma]
	/* Configure AES DMA and enable callback */
	configure_dma_aes_wr();
	configure_dma_aes_rd();

	dma_register_callback(&example_resource_tx, transfer_tx_rx_done,
			DMA_CALLBACK_TRANSFER_DONE);
	dma_enable_callback(&example_resource_tx, DMA_CALLBACK_TRANSFER_DONE);

	dma_register_callback(&example_resource_rx, transfer_tx_rx_done,
			DMA_CALLBACK_TRANSFER_DONE);
	dma_enable_callback(&example_resource_rx, DMA_CALLBACK_TRANSFER_DONE);
//! [setup_dma]

//! [setup_config]
	aes_get_config_defaults(&g_aes_cfg);
//! [setup_config]
//! [setup_config_defaults]
	aes_init(&aes_instance,AES, &g_aes_cfg);
//! [setup_config_defaults]

//! [module_enable]
	aes_enable(&aes_instance);
//! [module_enable]

//! [setup_init]

//! [encryption_decryption]
	/* ECB mode encryption test with DMA */
	ecb_mode_test_dma();
//! [encryption_decryption]

	while(1) ;

}
Example #3
0
/**
* \brief Config DMA to make peripheral-to-memory transfer scrolling string to
* SLCD memory.
*/
static void configure_dma(void)
{
    configure_dma_resource(&example_resource);
    setup_transfer_descriptor(&example_descriptor);

    if (STATUS_OK != dma_add_descriptor(&example_resource,
                                        &example_descriptor)) {
        printf("Descriptor status error\n\n\r");
    }

    dma_register_callback(&example_resource, dma_callback,
                          DMA_CALLBACK_TRANSFER_DONE);
    dma_enable_callback(&example_resource, DMA_CALLBACK_TRANSFER_DONE);
}
Example #4
0
/**
 * \brief configure and enable DMA multiple channel (in this case it is 3)
 */
void configure_dma(void)
{
	/* Configure DMA channel 0 */
	configure_dma_resource(&dmac_adc_channel0, DMAC_CHANNEL0_ID);

	/* Configure descriptor for channel 1 */
	setup_transfer_descriptor(&dmac_adc_descriptor1, DMAC_DESCRIPTOR1_ID);

	/* Assign descriptor 1 to DMA channel 0 */
	dma_add_descriptor(&dmac_adc_channel0, &dmac_adc_descriptor1);
	/*
	 * Register call back for DMA channel 0 transfer complete interrupt
	 * which will get triggered for every block transfer (I.e. 1024 beats 
	 * in this case 
	 */
	dma_register_callback(&dmac_adc_channel0, dmac_calback_channel0,
		DMA_CALLBACK_TRANSFER_DONE);
	/* Enable Call back for channel 0 */
	dma_enable_callback(&dmac_adc_channel0, DMA_CALLBACK_TRANSFER_DONE);
	/* Enable DMA channel 0 and its interrupt */
	dma_start_transfer_job(&dmac_adc_channel0);

}