Microchip® Advanced Software Framework

qs_spi_dma_use.c File Reference

SAM Sercom SPI Driver with DMA Quick Start.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include <asf.h>
#include "conf_quick_start.h"

Macros

#define BUF_LENGTH   20
 [buf_length] More...
 
#define SLAVE_SELECT_PIN   CONF_MASTER_SS_PIN
 [spi_baudrate] More...
 
#define TEST_SPI_BAUDRATE   1000000UL
 [buf_length] More...
 

Functions

static void configure_dma_resource_rx (struct dma_resource *rx_resource)
 [config_dma_resource_tx] More...
 
static void configure_dma_resource_tx (struct dma_resource *tx_resource)
 [_transfer_rx_done] More...
 
static void configure_spi_master (void)
 [setup_dma_transfer_descriptor_rx] More...
 
static void configure_spi_slave (void)
 [configure_spi] More...
 
int main (void)
 [configure_spi_slave] [setup] More...
 
static void setup_transfer_descriptor_rx (DmacDescriptor *rx_descriptor)
 [setup_dma_transfer_descriptor] More...
 
static void setup_transfer_descriptor_tx (DmacDescriptor *tx_descriptor)
 [config_dma_resource_rx] More...
 
static void transfer_rx_done (struct dma_resource *const resource)
 [_transfer_tx_done] More...
 
static void transfer_tx_done (struct dma_resource *const resource)
 [dma_transfer_descriptor] More...
 

Variables

static uint8_t buffer_rx [BUF_LENGTH]
 
static const uint8_t buffer_tx [BUF_LENGTH]
 [slave_select_pin] More...
 
struct dma_resource example_resource_rx
 
struct dma_resource example_resource_tx
 [slave_dev_inst] More...
 
DmacDescriptor
example_descriptor_tx 
SECTION_DMAC_DESCRIPTOR
 [dma_transfer_done_flag] More...
 
struct spi_slave_inst slave
 [spi_module_inst] More...
 
struct spi_module spi_master_instance
 [spi_buffer] More...
 
struct spi_module spi_slave_instance
 
static volatile bool transfer_rx_is_done = false
 
static volatile bool transfer_tx_is_done = false
 [dma_resource] More...
 

#define BUF_LENGTH   20

[buf_length]

#define SLAVE_SELECT_PIN   CONF_MASTER_SS_PIN

[spi_baudrate]

[slave_select_pin]

Referenced by configure_spi_master().

#define TEST_SPI_BAUDRATE   1000000UL

[buf_length]

[spi_baudrate]

Referenced by configure_spi_master().

static void configure_dma_resource_rx ( struct dma_resource rx_resource)
static

[config_dma_resource_tx]

[config_dma_resource_rx]

[dma_rx_setup_1]

[dma_rx_setup_1]

[dma_rx_setup_2]

[dma_rx_setup_2]

[dma_rx_setup_3]

[dma_rx_setup_3]

[dma_rx_setup_4]

[dma_rx_setup_4]

References dma_allocate(), dma_get_config_defaults(), DMA_TRIGGER_ACTION_BEAT, dma_resource_config::peripheral_trigger, and dma_resource_config::trigger_action.

Referenced by main().

static void configure_dma_resource_tx ( struct dma_resource tx_resource)
static

[_transfer_rx_done]

[config_dma_resource_tx]

[dma_tx_setup_1]

[dma_tx_setup_1]

[dma_tx_setup_2]

[dma_tx_setup_2]

[dma_tx_setup_3]

[dma_tx_setup_3]

[dma_tx_setup_4]

[dma_tx_setup_4]

References dma_allocate(), dma_get_config_defaults(), DMA_TRIGGER_ACTION_BEAT, dma_resource_config::peripheral_trigger, and dma_resource_config::trigger_action.

Referenced by main().

static void configure_spi_master ( void  )
static

[setup_dma_transfer_descriptor_rx]

[configure_spi]

[spi_master_config]

[spi_master_config] [slave_config]

[slave_config]

[slave_conf_defaults]

[slave_conf_defaults] [ss_pin]

[ss_pin] [slave_init]

[slave_init]

[spi_master_conf_defaults]

[spi_master_conf_defaults]

[spi_master_mux_setting]

[spi_master_mux_setting]

[spi_master_init]

[spi_master_init]

[spi_master_enable]

[spi_master_enable]

References spi_master_config::baudrate, spi_config::master, spi_config::mode_specific, spi_config::mux_setting, spi_config::pinmux_pad0, spi_config::pinmux_pad1, spi_config::pinmux_pad2, spi_config::pinmux_pad3, slave, SLAVE_SELECT_PIN, spi_attach_slave(), spi_enable(), spi_get_config_defaults(), spi_init(), spi_master_instance, spi_slave_inst_get_config_defaults(), spi_slave_inst_config::ss_pin, and TEST_SPI_BAUDRATE.

static void configure_spi_slave ( void  )
static

[configure_spi]

[configure_spi_slave]

[spi_slave_config]

[spi_slave_config]

[spi_slave_conf_defaults]

[spi_slave_conf_defaults] [conf_spi_slave_instance]

[conf_spi_slave_instance] [conf_preload]

[conf_preload] [conf_format]

[conf_format] [spi_slave_mux_setting]

[spi_slave_mux_setting]

[spi_slave_init]

[spi_slave_init]

[spi_slave_enable]

[spi_slave_enable]

References spi_slave_config::frame_format, spi_config::mode, spi_config::mode_specific, spi_config::mux_setting, spi_config::pinmux_pad0, spi_config::pinmux_pad1, spi_config::pinmux_pad2, spi_config::pinmux_pad3, spi_slave_config::preload_enable, spi_config::slave, spi_enable(), SPI_FRAME_FORMAT_SPI_FRAME, spi_get_config_defaults(), spi_init(), SPI_MODE_SLAVE, and spi_slave_instance.

int main ( void  )

[configure_spi_slave] [setup]

[setup_init] [setup_spi]

[setup_spi]

[setup_dma_resource]

[setup_dma_resource]

[setup_transfer_descriptor]

[setup_transfer_descriptor]

[dma_resource_add_descriptor]

[dma_resource_add_descriptor]

[setup_callback_register]

[setup_callback_register]

[setup_enable_callback]

[setup_enable_callback] [setup_init]

[main]

[select_slave]

[select_slave]

[main_1]

[main_1]

[main_2]

[main_2]

[deselect_slave]

[deselect_slave]

[endless_loop]

[endless_loop]

[main]

References configure_dma_resource_rx(), configure_dma_resource_tx(), configure_spi_master(), configure_spi_slave(), dma_add_descriptor(), DMA_CALLBACK_TRANSFER_DONE, dma_enable_callback(), dma_register_callback(), dma_start_transfer_job(), example_resource_rx, example_resource_tx, setup_transfer_descriptor_rx(), setup_transfer_descriptor_tx(), slave, spi_master_instance, spi_select_slave(), system_init(), transfer_rx_done(), transfer_rx_is_done, and transfer_tx_done().

static void setup_transfer_descriptor_rx ( DmacDescriptor *  rx_descriptor)
static

[setup_dma_transfer_descriptor]

[setup_dma_transfer_descriptor_rx]

[dma_rx_setup_5]

[dma_rx_setup_5]

[dma_rx_setup_6]

[dma_rx_setup_6]

[dma_rx_setup_7]

[dma_rx_setup_7]

[dma_rx_setup_8]

[dma_rx_setup_8]

References dma_descriptor_config::beat_size, dma_descriptor_config::block_transfer_count, buffer_rx, dma_descriptor_config::destination_address, DMA_BEAT_SIZE_BYTE, dma_descriptor_create(), dma_descriptor_get_config_defaults(), dma_descriptor_config::source_address, spi_slave_instance, and dma_descriptor_config::src_increment_enable.

Referenced by main().

static void setup_transfer_descriptor_tx ( DmacDescriptor *  tx_descriptor)
static

[config_dma_resource_rx]

[setup_dma_transfer_descriptor]

[dma_tx_setup_5]

[dma_tx_setup_5]

[dma_tx_setup_6]

[dma_tx_setup_6]

[dma_tx_setup_7]

[dma_tx_setup_7]

[dma_tx_setup_8]

[dma_tx_setup_8]

References dma_descriptor_config::beat_size, dma_descriptor_config::block_transfer_count, buffer_tx, dma_descriptor_config::destination_address, DMA_BEAT_SIZE_BYTE, dma_descriptor_create(), dma_descriptor_get_config_defaults(), dma_descriptor_config::dst_increment_enable, dma_descriptor_config::source_address, and spi_master_instance.

Referenced by main().

static void transfer_rx_done ( struct dma_resource *const  resource)
static

[_transfer_tx_done]

[_transfer_rx_done]

References transfer_rx_is_done.

Referenced by main().

static void transfer_tx_done ( struct dma_resource *const  resource)
static

[dma_transfer_descriptor]

[setup] [_transfer_tx_done]

References transfer_tx_is_done.

Referenced by main().

uint8_t buffer_rx[BUF_LENGTH]
static
const uint8_t buffer_tx[BUF_LENGTH]
static
Initial value:
= {
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14,
}

[slave_select_pin]

[spi_buffer]

Referenced by setup_transfer_descriptor_tx().

struct dma_resource example_resource_rx

Referenced by main().

struct dma_resource example_resource_tx

[slave_dev_inst]

[dma_resource]

Referenced by main().

DmacDescriptor example_descriptor_rx SECTION_DMAC_DESCRIPTOR

[dma_transfer_done_flag]

[dma_transfer_descriptor]

struct spi_slave_inst slave

[spi_module_inst]

[slave_dev_inst]

struct spi_module spi_master_instance

[spi_buffer]

[spi_module_inst]

struct spi_module spi_slave_instance
volatile bool transfer_rx_is_done = false
static

Referenced by main(), and transfer_rx_done().

volatile bool transfer_tx_is_done = false
static

[dma_resource]

[dma_transfer_done_flag]

Referenced by transfer_tx_done().