示例#1
0
/**
 * \brief Configure DMA AES DATA read trigger.
 */
static void configure_dma_aes_rd(void)
{

	struct dma_resource_config rx_config;

	dma_get_config_defaults(&rx_config);

	rx_config.peripheral_trigger = AES_DMAC_ID_RD;
	rx_config.trigger_action = DMA_TRIGGER_ACTON_BLOCK;

	/* Allocate DMA resource.*/
	dma_allocate(&example_resource_rx, &rx_config);

	struct dma_descriptor_config rx_descriptor_config;
	dma_descriptor_get_config_defaults(&rx_descriptor_config);

	rx_descriptor_config.beat_size = DMA_BEAT_SIZE_WORD;
	rx_descriptor_config.src_increment_enable = false;
	rx_descriptor_config.block_transfer_count = AES_EXAMPLE_REFBUF_SIZE;
	rx_descriptor_config.source_address = (uint32_t)&(AES->INDATA);
	rx_descriptor_config.destination_address =
		(uint32_t)output_data + sizeof(output_data);

	/* Create a DMA transfer descriptor.*/
	dma_descriptor_create(&example_descriptor_rx, &rx_descriptor_config);

	/* Add DMA transfer descriptor to DMA resource.*/
	dma_add_descriptor(&example_resource_rx, &example_descriptor_rx);
}
//! [config_dma_for_wave]
static void config_dma_for_wave(void)
{
	//! [config_dma_resource_for_wave]
	struct dma_resource_config config;
	dma_get_config_defaults(&config);
	config.trigger_action = DMA_TRIGGER_ACTON_BEAT;
	config.peripheral_trigger = CONF_COMPARE_TRIGGER;
	dma_allocate(&compare_dma_resource, &config);
	//! [config_dma_resource_for_wave]

	//! [config_dma_descriptor_for_wave]
	struct dma_descriptor_config descriptor_config;

	dma_descriptor_get_config_defaults(&descriptor_config);

	descriptor_config.block_transfer_count = 3;
	descriptor_config.beat_size = DMA_BEAT_SIZE_HWORD;
	descriptor_config.dst_increment_enable = false;
	descriptor_config.source_address =
			(uint32_t)compare_values + sizeof(compare_values);
	descriptor_config.destination_address =
			(uint32_t)&CONF_PWM_MODULE->CC[CONF_PWM_CHANNEL];

	dma_descriptor_create(&compare_dma_descriptor, &descriptor_config);
	//! [config_dma_descriptor_for_wave]

	//! [config_dma_job_for_wave]
	dma_add_descriptor(&compare_dma_resource, &compare_dma_descriptor);
	dma_add_descriptor(&compare_dma_resource, &compare_dma_descriptor);
	dma_start_transfer_job(&compare_dma_resource);
	//! [config_dma_job_for_wave]
}
示例#3
0
/**
 * \brief Configure DMA AES DATA write trigger.
 */
static void configure_dma_aes_wr(void)
{
	struct dma_resource_config tx_config;
	dma_get_config_defaults(&tx_config);

	tx_config.peripheral_trigger = AES_DMAC_ID_WR;
	tx_config.trigger_action = DMA_TRIGGER_ACTON_BLOCK;

	/* Allocate DMA resource.*/
	dma_allocate(&example_resource_tx, &tx_config);

	struct dma_descriptor_config tx_descriptor_config;

	dma_descriptor_get_config_defaults(&tx_descriptor_config);

	tx_descriptor_config.beat_size = DMA_BEAT_SIZE_WORD;
	tx_descriptor_config.dst_increment_enable = false;
	tx_descriptor_config.block_transfer_count = AES_EXAMPLE_REFBUF_SIZE;
	tx_descriptor_config.source_address = (uint32_t)ref_plain_text + sizeof(ref_plain_text);
	tx_descriptor_config.destination_address =(uint32_t) &(AES->INDATA);
	dma_descriptor_create(&example_descriptor_tx, &tx_descriptor_config);

	/*  Add DMA transfer descriptor to DMA resource.*/
	dma_add_descriptor(&example_resource_tx, &example_descriptor_tx);
}
示例#4
0
/**
 * \brief Configure each DMA channel
 * \param resource     Channel resource
 * \param channel_num  Channel number to be configured
 */
void configure_dma_resource(struct dma_resource *resource, uint8_t channel_num)
{
	/* DMA config set up */
	struct dma_resource_config config;

	/* Get default DMA configuration */
	dma_get_config_defaults(&config);

	switch (channel_num){

	case DMAC_CHANNEL0_ID:
		/* Trigger is enabled for each beat transfer */
		config.trigger_action = DMA_TRIGGER_ACTON_BEAT;
		/* Peripheral trigger source is ADC result ready */
		config.peripheral_trigger = ADC_DMAC_ID_RESRDY;
		/* Generate event once DMA transfer is done */
		config.event_config.event_output_enable = true;
		break;

	default:
		Assert(false);
		break;
	}

	/* Configure the DMA channel */
	dma_allocate(resource, &config);
}
示例#5
0
//! [config_dma_for_tx]
static void _config_dma_for_tx(void)
{
	//! [config_dma_resource_for_tx]
	struct dma_resource_config config;
	dma_get_config_defaults(&config);
	config.trigger_action = DMA_TRIGGER_ACTON_BEAT;
	config.peripheral_trigger = CONF_TX_TRIGGER;
	dma_allocate(&tx_dma_resource, &config);
	//! [config_dma_resource_for_tx]

	//! [config_dma_descriptor_for_tx]
	struct dma_descriptor_config descriptor_config;

	dma_descriptor_get_config_defaults(&descriptor_config);

	descriptor_config.block_transfer_count = 4;
	descriptor_config.beat_size = DMA_BEAT_SIZE_HWORD;
	descriptor_config.dst_increment_enable = false;
	descriptor_config.source_address =
			(uint32_t)tx_values + sizeof(tx_values);
	descriptor_config.destination_address = (uint32_t)&CONF_I2S_MODULE->DATA[0];

	dma_descriptor_create(&tx_dma_descriptor, &descriptor_config);

	tx_dma_descriptor.DESCADDR.reg = (uint32_t)&tx_dma_descriptor;
	//! [config_dma_descriptor_for_tx]

	//! [config_dma_job_for_tx]
	dma_add_descriptor(&tx_dma_resource, &tx_dma_descriptor);
	dma_start_transfer_job(&tx_dma_resource);
	//! [config_dma_job_for_tx]
}
示例#6
0
//! [config_dma_for_rx]
static void _config_dma_for_rx(void)
{
	//! [config_dma_resource_for_rx]
	//! [dma_setup_1]
	struct dma_resource_config config;
	//! [dma_setup_1]

	//! [dma_setup_2]
	dma_get_config_defaults(&config);
	//! [dma_setup_2]

	//! [dma_setup_3]
	config.trigger_action = DMA_TRIGGER_ACTON_BEAT;
	config.peripheral_trigger = CONF_RX_TRIGGER;
	//! [dma_setup_3]

	//! [dma_setup_4]
	dma_allocate(&rx_dma_resource, &config);
	//! [dma_setup_4]
	//! [config_dma_resource_for_rx]

	//! [config_dma_descriptor_for_rx]
	//! [dma_setup_5]
	struct dma_descriptor_config descriptor_config;
	//! [dma_setup_5]

	//! [dma_setup_6]
	dma_descriptor_get_config_defaults(&descriptor_config);
	//! [dma_setup_6]

	//! [dma_setup_7]
	descriptor_config.block_transfer_count = 4;
	descriptor_config.beat_size = DMA_BEAT_SIZE_HWORD;
	descriptor_config.step_selection = DMA_STEPSEL_SRC;
	descriptor_config.src_increment_enable = false;
	descriptor_config.destination_address =
			(uint32_t)rx_values + sizeof(rx_values);
	descriptor_config.source_address = (uint32_t)&CONF_I2S_MODULE->DATA[1];
	//! [dma_setup_7]

	//! [dma_setup_8]
	dma_descriptor_create(&rx_dma_descriptor, &descriptor_config);
	//! [dma_setup_8]

	//! [dma_setup_9]
	rx_dma_descriptor.DESCADDR.reg = (uint32_t)&rx_dma_descriptor;
	//! [dma_setup_9]
	//! [config_dma_descriptor_for_rx]

	//! [config_dma_job_for_rx]
	//! [dma_setup_10]
	dma_add_descriptor(&rx_dma_resource, &rx_dma_descriptor);
	//! [dma_setup_10]
	//! [dma_setup_11]
	dma_start_transfer_job(&rx_dma_resource);
	//! [dma_setup_11]
	//! [config_dma_job_for_rx]
}
//! [config_dma_for_capture]
static void config_dma_for_capture(void)
{
	//! [config_dma_resource_for_capture]
	//! [dma_setup_1]
	struct dma_resource_config config;
	//! [dma_setup_1]

	//! [dma_setup_2]
	dma_get_config_defaults(&config);
	//! [dma_setup_2]

	//! [dma_setup_3]
	config.trigger_action = DMA_TRIGGER_ACTON_BEAT;
	config.peripheral_trigger = CONF_CAPTURE_TRIGGER;
	//! [dma_setup_3]

	//! [dma_setup_4]
	dma_allocate(&capture_dma_resource, &config);
	//! [dma_setup_4]
	//! [config_dma_resource_for_capture]

	//! [config_dma_descriptor_for_capture]
	//! [dma_setup_5]
	struct dma_descriptor_config descriptor_config;
	//! [dma_setup_5]

	//! [dma_setup_6]
	dma_descriptor_get_config_defaults(&descriptor_config);
	//! [dma_setup_6]

	//! [dma_setup_7]
	descriptor_config.block_transfer_count = 3;
	descriptor_config.beat_size = DMA_BEAT_SIZE_HWORD;
	descriptor_config.step_selection = DMA_STEPSEL_SRC;
	descriptor_config.src_increment_enable = false;
	descriptor_config.source_address =
			(uint32_t)&CONF_PWM_MODULE->CC[CONF_TCC_CAPTURE_CHANNEL];
	descriptor_config.destination_address =
			(uint32_t)capture_values + sizeof(capture_values);
	//! [dma_setup_7]

	//! [dma_setup_8]
	dma_descriptor_create(&capture_dma_descriptor, &descriptor_config);
	//! [dma_setup_8]
	//! [config_dma_descriptor_for_capture]

	//! [config_dma_job_for_capture]
	//! [dma_setup_10]
	dma_add_descriptor(&capture_dma_resource, &capture_dma_descriptor);
	dma_add_descriptor(&capture_dma_resource, &capture_dma_descriptor);
	//! [dma_setup_10]
	//! [dma_setup_11]
	dma_start_transfer_job(&capture_dma_resource);
	//! [dma_setup_11]
	//! [config_dma_job_for_capture]
}
示例#8
0
文件: main.c 项目: rmnsfx/DVA141
static void configure_dma_resource_rx(struct dma_resource *rx_resource)
{
	struct dma_resource_config rx_config;

	dma_get_config_defaults(&rx_config);

	rx_config.peripheral_trigger = CONF_PERIPHERAL_TRIGGER_RX;
	rx_config.trigger_action = DMA_TRIGGER_ACTION_BEAT;

	dma_allocate(rx_resource, &rx_config);
}
示例#9
0
//! [config_dma_resource]
static void configure_dma_resource(struct dma_resource *resource)
{
//! [setup_1]
	struct dma_resource_config config;
//! [setup_1]

//! [setup_2]
	dma_get_config_defaults(&config);
//! [setup_2]

//! [setup_3]
	dma_allocate(resource, &config);
//! [setup_3]
}
示例#10
0
文件: main.c 项目: thegeek82000/asf
/**
* \brief configure DMA resource.
*/
static void configure_dma_resource(struct dma_resource *resource)
{
    struct dma_resource_config config;
    /* Get the default configuration */
    dma_get_config_defaults(&config);

    if (true == is_scrolling) {
        /* Set the peripheral trigger source */
        config.peripheral_trigger = SLCD_DMAC_ID_ACMDRDY;
        /* Set the trigger action */
        config.trigger_action = DMA_TRIGGER_ACTON_BEAT;
    }

    if (true == is_bitmapping) {
        /* Set the peripheral trigger source */
        config.peripheral_trigger = SLCD_DMAC_ID_ABMDRDY;
        /* Set the trigger action */
        config.trigger_action = DMA_TRIGGER_ACTON_BEAT;
    }

    dma_allocate(resource, &config);
}